Page 1 of 1

Optimize image loading / displaying

Posted: Fri Feb 24, 2017 7:46 am
by Mirk
Hi !

I recently start on LÖVE (my sweet LÖVE !) and I try to done a citybuilder with isometric tile.
The display of the map is dynamic (autosize with the size of the windows).
For a fullscreen on 1920x1080, I display ~2300 images (one tile : 60x30) with 60 FPS. But with dual screen (3840x1080) I fall at 40 FPS and the main thread is overloaded.

I use love.graphics.newImage() and love.graphics.draw()
Is there a more optimized way to display images ?
You can find in attached my .love file

Thanks (sorry for mistakes, I'm French :S)

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 10:12 am
by raidho36
Most of the workload here is GPU draw calls. Use spite batch to reduce number of draw calls. You can try using autobatch library with no code modification, be aware however that switching to a different sprite, switching shader, switching color etc. breaks the batch and starts a new one, and you'll need a draw call per each batch.

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 10:45 am
by darkmetalic
Since you are organizing numerically, enjoy it

Code: Select all

Test = {}
for i=1, 58 do
Test[i] = love.graphics.newImage("Terrain/Land1a_00"..(121+i)..".png")
end

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 2:00 pm
by Zireael
Is there a way to batch lines written using love.graphics.print?

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 2:09 pm
by Mirk
raidho36 wrote: Fri Feb 24, 2017 10:12 am Most of the workload here is GPU draw calls. Use spite batch to reduce number of draw calls. You can try using autobatch library with no code modification, be aware however that switching to a different sprite, switching shader, switching color etc. breaks the batch and starts a new one, and you'll need a draw call per each batch.
I tried but no change, because I have too many different images on my screen.
darkmetalic wrote: Fri Feb 24, 2017 10:45 am Since you are organizing numerically, enjoy it

Code: Select all

Test = {}
for i=1, 58 do
Test[i] = love.graphics.newImage("Terrain/Land1a_00"..(121+i)..".png")
end
Yes ^^ (It's just a quick test)

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 2:14 pm
by raidho36
If you use an image atlas you can definitely leverage batching more easily, since they're all on the same texture and if it never has to switch the batch is never broken.

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 7:39 pm
by Mirk
raidho36 ! I want to say you one thing : I löve you !
I already knew this way but not his name (thanks for the information) and I never used it.
You can find in attached the new .love file with a texture atlas.

Many thanks for this help !

PS : like many of my questions on english forums, it's more a lack of keywords than a real problem ^^ sorry for that :S

Re: Optimize image loading / displaying

Posted: Fri Feb 24, 2017 10:50 pm
by Positive07
If you are using a texture atlas then you should be using an SpriteBatch!