shithub: cstory

Download patch

ref: ba6d711d3a918e37481d2584532aa36147cc4d24
parent: 2e5e1994c25a66c5c840c99656190bbd8f8c1f42
author: Clownacy <[email protected]>
date: Tue Feb 4 09:55:01 EST 2020

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.

--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -635,7 +635,6 @@
 							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_DrawScreen(void)
 {
+	spritebatch_tick(&glyph_batcher);
+
 	FlushVertexBuffer();
 	last_render_mode = MODE_BLANK;
 	last_source_texture = 0;
@@ -1064,7 +1065,6 @@
 
 void Backend_FlushGlyphs(void)
 {
-	spritebatch_tick(&glyph_batcher);
 	spritebatch_defrag(&glyph_batcher);
 	spritebatch_flush(&glyph_batcher);
 }
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -170,7 +170,6 @@
 				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_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_FlushGlyphs(void)
 {
-	spritebatch_tick(&glyph_batcher);
 	spritebatch_defrag(&glyph_batcher);
 	spritebatch_flush(&glyph_batcher);
 }