Pratix wrote: ↑Tue Apr 11, 2023 1:20 am
10% of my CPU (Intel Core i7 12700K)
Well... It's not the Love "feature", it's actually quite common for most of the games I've played on Steam. Way more than 50% behaving similarly in my case, which is hundreds of games
The reason is that they are all single-threaded applications. Or use just a fixed number of threads: for instance, one thread for drawing, another for background loading, and two more for calculating secondary tasks. Therefore, they cannot use all 10+ cores of modern CPUs. And generally, they shouldn't, because good-written game should be GPU-bound, not CPU-bound.
To fix this, developers could use multi-threading seriously, but most don't because it's challenging, or they don't know how to do it, or it is just not needed for their simple games. Besides, most game engines do not provide convenient functionality for multi-threading. Love2d has some support through the
love.thread, but it's rather limited because between-thread communication is difficult to manage. Besides, it still can't use multiple threads for the primary task of drawing.
This second limitation is not specific to Love but to OpenGL. To overcome it, developers could use Vulkan or DirectX12 and tinker with a LOT more complicated stuff than just single-threaded rendering engines.
Regarding your issue with only 7 fps, several factors could cause it, but the most likely one is that you have too many draw calls. You can check this by adding
Code: Select all
print(love.graphics.getStats().drawcalls)
at the end of your love.draw() and checking the number. Generally, if it's more than 1000, you have a problem.
If it's the case, you could use
love.graphics.drawInstanced or
SpriteBatch to draw your things. With these personally I've managed to draw literally millions of things in one frame without issues in Love. That should reduce CPU usage and fill up GPU usage up to ~100%
with all internal and external frame limiters such as vsync disabled for that test of course. That would be an indication that your Love lua code's performance is optimal.