Remove those annoying renderer sanity checks

Duplicate junk. If they're that important, they can go in the game,
not the backends.
This commit is contained in:
Clownacy 2020-09-14 23:55:39 +01:00
parent 27b3980a56
commit 611afe7417
5 changed files with 16 additions and 79 deletions

View file

@ -671,9 +671,6 @@ RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height,
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
{
if (surface == NULL)
return;
// Flush the vertex buffer if we're about to destroy its texture
if (surface->texture_id == last_source_texture)
{
@ -720,9 +717,6 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{
if (source_surface == NULL || destination_surface == NULL)
return;
const RenderMode render_mode = (colour_key ? MODE_DRAW_SURFACE_WITH_TRANSPARENCY : MODE_DRAW_SURFACE);
// Flush vertex data if a context-change is needed
@ -800,9 +794,6 @@ void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBacken
static unsigned char last_green;
static unsigned char last_blue;
if (surface == NULL)
return;
// Flush vertex data if a context-change is needed
if (last_render_mode != MODE_COLOUR_FILL || last_destination_texture != surface->texture_id || last_red != red || last_green != green || last_blue != blue)
{
@ -918,9 +909,6 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa
static unsigned char last_green;
static unsigned char last_blue;
if (destination_surface == NULL)
return;
glyph_destination_surface = destination_surface;
// Flush vertex data if a context-change is needed
@ -953,9 +941,6 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa
void RenderBackend_DrawGlyph(RenderBackend_GlyphAtlas *atlas, long x, long y, size_t glyph_x, size_t glyph_y, size_t glyph_width, size_t glyph_height)
{
if (glyph_destination_surface == NULL)
return;
// Add data to the vertex queue
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);

View file

@ -122,9 +122,6 @@ RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height,
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
{
if (surface == NULL)
return;
SDL_FreeSurface(surface->sdlsurface);
free(surface);
}
@ -154,9 +151,6 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{
if (source_surface == NULL || destination_surface == NULL)
return;
SDL_Rect source_rect;
RectToSDLRect(rect, &source_rect);
@ -176,9 +170,6 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBacke
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{
if (surface == NULL)
return;
SDL_Rect destination_rect;
RectToSDLRect(rect, &destination_rect);
@ -239,9 +230,6 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
if (destination_surface == NULL)
return;
glyph_destination_sdlsurface = destination_surface->sdlsurface;
if (SDL_SetSurfaceColorMod(atlas->sdlsurface, red, green, blue) < 0)

View file

@ -201,9 +201,6 @@ RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height,
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
{
if (surface == NULL)
return;
// Remove from linked list
if (surface->next != NULL)
surface->next->prev = surface->prev;
@ -269,9 +266,6 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{
if (source_surface == NULL || destination_surface == NULL)
return;
SDL_Rect source_rect;
RectToSDLRect(rect, &source_rect);
@ -290,9 +284,6 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBacke
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{
if (surface == NULL)
return;
SDL_Rect sdl_rect;
RectToSDLRect(rect, &sdl_rect);
@ -382,9 +373,6 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa
{
(void)atlas;
if (destination_surface == NULL)
return;
if (SDL_SetRenderTarget(renderer, destination_surface->texture) < 0)
Backend_PrintError("Couldn't set texture as current rendering target: %s", SDL_GetError());

View file

@ -88,9 +88,6 @@ RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height,
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
{
if (surface == NULL)
return;
free(surface->pixels);
free(surface);
}
@ -115,9 +112,6 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{
if (source_surface == NULL || source_surface->pixels == NULL || destination_surface == NULL || destination_surface->pixels == NULL)
return;
RenderBackend_Rect rect_clamped;
rect_clamped.left = rect->left;
@ -197,9 +191,6 @@ ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, con
ATTRIBUTE_HOT void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{
if (surface == NULL || surface->pixels == NULL)
return;
RenderBackend_Rect rect_clamped;
rect_clamped.left = rect->left;
@ -283,9 +274,6 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa
{
(void)atlas;
if (destination_surface == NULL)
return;
glyph_destination_surface = destination_surface;
glyph_colour_channels[0] = red;

View file

@ -515,27 +515,24 @@ RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height,
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
{
if (surface != NULL)
// Flush the vertex buffer if we're about to destroy its texture
if (&surface->texture == last_source_texture)
{
// Flush the vertex buffer if we're about to destroy its texture
if (&surface->texture == last_source_texture)
{
FlushVertexBuffer();
last_source_texture = NULL;
}
if (&surface->texture == last_destination_texture)
{
FlushVertexBuffer();
last_destination_texture = NULL;
}
if (surface->render_target)
GX2RDestroySurfaceEx(&surface->colour_buffer.surface, (GX2RResourceFlags)0);
GX2RDestroySurfaceEx(&surface->texture.surface, (GX2RResourceFlags)0);
free(surface);
FlushVertexBuffer();
last_source_texture = NULL;
}
if (&surface->texture == last_destination_texture)
{
FlushVertexBuffer();
last_destination_texture = NULL;
}
if (surface->render_target)
GX2RDestroySurfaceEx(&surface->colour_buffer.surface, (GX2RResourceFlags)0);
GX2RDestroySurfaceEx(&surface->texture.surface, (GX2RResourceFlags)0);
free(surface);
}
bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
@ -582,9 +579,6 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{
if (source_surface == NULL || destination_surface == NULL)
return;
const RenderMode render_mode = (colour_key ? MODE_DRAW_SURFACE_WITH_TRANSPARENCY : MODE_DRAW_SURFACE);
// Flush vertex data if a context-change is needed
@ -661,9 +655,6 @@ void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBacken
static unsigned char last_green;
static unsigned char last_blue;
if (surface == NULL)
return;
// Flush vertex data if a context-change is needed
if (last_render_mode != MODE_COLOUR_FILL || last_destination_texture != &surface->texture || last_red != red || last_green != green || last_blue != blue)
{
@ -789,9 +780,6 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa
static unsigned char last_green;
static unsigned char last_blue;
if (destination_surface == NULL)
return;
glyph_destination_surface = destination_surface;
// Flush vertex data if a context-change is needed