While attempting to implement Poisson Disk Sampling - I decided to try to visualize what was going on, and hacked a few draw calls in, as well as calling graphics.present() at set intervals. The below code is it's simplest form.
This worked fine (if not a little slower) as long as the modulus was fairly small (<10) but with a modulus greater than ~100 it began slowing down, and with a modulus of ~1000, my computer threw itself out the window.
My first assumption was that draw calls to the "main screen" outside of the draw loop were buffered/queued in some way, leading to massive memory consumption. So I turned to a canvas, thinking draw calls to an offscreen canvas would happen immediately - but that doesn't seem to be the case either as the results were virtually identical.
I *think* the problem lies in how many draw calls are made without a corresponding call to present() - small modulus means a small ratio between draw calls and present() where a large modulus means a very large ratio between calls and present() and catastrophic failure.
To be clear, I'm looking to understand the 'why', not a specific fix for the code below, what is happening behind the scenes, is it buffered/queued? or is there some other mechanic happening?
I realize this specific case of possibly 10's of millions of draw calls prior to calling present() is not a likely or common scenario - but there is a wall there and I'd like to know what it's made of... so to speak.
Code: Select all
for i=1,10000 do
for _, pos in pairs(points) do -- #points==8000
love.graphics.circle("fill", pos.x, pos.y, settings.radius / 2)
end
if i % 10 ==1 then
love.graphics.present()
end
end