Accelerate 2D by tracking state client-side
Created by: lawnjelly
GLES2 only first.
Godot 2D performance is usually bottlenecked by the methods used with OpenGL, there are currently drawcalls per quad.
In this PR basic state tracking is added to rasterizer_canvas_gles2::_canvas_item_render_commands().
This gives a 'free' performance increase of around 40% frames per second in a test scene, while requiring minimal changes to the overall mechanism.
Notes
-
I have been using the test project in this issue #27230 with the tilemap selected as the one under test.
-
The actual speed increase will scale with the number of Rects being drawn. There is also likely to be more benefit on some hardware / platform combinations than others, all should receive some benefit.
-
The best solution to this problem is batching, which will give far greater performance increases. But this might help as a simpler interim solution.
Mentioning @ClayJohn as we discussed this yesterday.