From ba6d711d3a918e37481d2584532aa36147cc4d24 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 4 Feb 2020 14:55:01 +0000 Subject: [PATCH] Tick cute_spritebatch once per frame ...As opposed to once per draw call. This change was made because multiple draw calls can be made per frame, or a only a handful of draw calls may be made per minute. Since draw calls are an inconsistent metric, I just switched to frames instead. --- src/Backends/Rendering/OpenGL3.cpp | 4 ++-- src/Backends/Rendering/SDLTexture.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index 5039a300..c7e3f609 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -635,7 +635,6 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful config.atlas_width_in_pixels = 256; config.atlas_height_in_pixels = 256; config.lonely_buffer_count_till_flush = 4; // Start making atlases immediately - config.ticks_to_decay_texture = 100; // If a glyph hasn't been used for the past 100 draws, destroy it config.batch_callback = GlyphBatch_Draw; config.get_pixels_callback = GlyphBatch_GetPixels; config.generate_texture_callback = GlyphBatch_CreateTexture; @@ -718,6 +717,8 @@ void Backend_Deinit(void) void Backend_DrawScreen(void) { + spritebatch_tick(&glyph_batcher); + FlushVertexBuffer(); last_render_mode = MODE_BLANK; last_source_texture = 0; @@ -1064,7 +1065,6 @@ void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y) void Backend_FlushGlyphs(void) { - spritebatch_tick(&glyph_batcher); spritebatch_defrag(&glyph_batcher); spritebatch_flush(&glyph_batcher); } diff --git a/src/Backends/Rendering/SDLTexture.cpp b/src/Backends/Rendering/SDLTexture.cpp index 6bb94e02..59f1fd8d 100644 --- a/src/Backends/Rendering/SDLTexture.cpp +++ b/src/Backends/Rendering/SDLTexture.cpp @@ -170,7 +170,6 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful config.atlas_width_in_pixels = 256; config.atlas_height_in_pixels = 256; config.lonely_buffer_count_till_flush = 4; // Start making atlases immediately - config.ticks_to_decay_texture = 100; // If a glyph hasn't been used for the past 100 draws, destroy it config.batch_callback = GlyphBatch_Draw; config.get_pixels_callback = GlyphBatch_GetPixels; config.generate_texture_callback = GlyphBatch_CreateTexture; @@ -212,6 +211,8 @@ void Backend_Deinit(void) void Backend_DrawScreen(void) { + spritebatch_tick(&glyph_batcher); + SDL_SetRenderTarget(renderer, NULL); SDL_RenderCopy(renderer, framebuffer.texture, NULL, NULL); SDL_RenderPresent(renderer); @@ -419,7 +420,6 @@ void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y) void Backend_FlushGlyphs(void) { - spritebatch_tick(&glyph_batcher); spritebatch_defrag(&glyph_batcher); spritebatch_flush(&glyph_batcher); }