Why does _drawing many circles tank the fps even without QueueRedraw()

Godot Version

4.6

Question

Hi! I’m drawing a grid of many points by using the _draw function of a ColorRect.

I’m drawing a ton of tiny circles like so:
for (int i = 0; i < 300; i++)
{
for (int j = 0; j < 300; j++)
{
DrawCircle(new(20 + i * 6, j * 6), 3, Color.Color8(0,0,0,30));

}
}

Now, after these shapes have been drawn, I never call QueueRedraw() again. My assumption is that the drawing should be cached, and not have an effect on the performance. But even without redrawing, displaying these circles permanently drops the fps from ~200 to ~16.

I know there’s lots of workarounds here (I could convert the drawing to a texture for example), but I’d like to know why this affects performance so much first. What am I not understanding about _draw?

Look at the number of draw calls in Debugger/Monitors.

Try using draw_texture() or draw_texture_rect() instead. It may batch the draw calls.

Probably it’s the drawing commands that are being cached, not the resulting raster. Besides, you not calling the QueueRedraw doesn’t prevent it from being called elsewhere.