Page 1 of 1

Is LOVE limited to how much hardware it can use?

Posted: Tue Apr 11, 2023 1:20 am
by Pratix
I'm using LOVE to create a very hardware intensive application. It should be using I'd assume over 10% of my CPU (Intel Core i7 12700K) and much more than 30% of my GPU (GeForce RTX 3060) but it seems that isn't the case. Due to the lack of intense usage of my hardware LOVE drops my game's performance down to 7 FPS! Could anyone explain if there is a workaround to this or why this is happening?

Re: Is LOVE limited to how much hardware it can use?

Posted: Tue Apr 11, 2023 3:56 am
by BrotSagtMist
Without seeing any code, no. This question is too generic.

Re: Is LOVE limited to how much hardware it can use?

Posted: Tue Apr 11, 2023 11:01 am
by zorg
Considering the CPU you're talking about is a 6+4 core one with 20 threads in total, Löve by default being a single-thread application, it can only use one thread out of the 20, so that's around 5% of cpu usage at most (may be more due to the cpu in question having both performance and economy cores that might factor differently into percentages, idk).

If you use love.thread stuff in your code, only then could more cpu be potentially used.

As for GPU, a lot of bottlenecks can crop up depending on what you're doing, so it may very well be your own code's fault, and not anything löve can do about it.

Also, yes, do show code.

Re: Is LOVE limited to how much hardware it can use?

Posted: Tue Apr 11, 2023 12:47 pm
by Sasha264
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 :o: 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.

Re: Is LOVE limited to how much hardware it can use?

Posted: Sat Apr 22, 2023 12:29 pm
by tourgen
Start using an OpenGL profiler and debugger like https://renderdoc.org/

Start using Love2D's threading functionality. You can offload pretty much anything but the actual Love2D draw functions.

There are many, many advanced features of OpenGL and your gfx hardware you don't even have access to because there is no Love2D functions for them (bindless textures, compute shaders, various shader buffers).

Re: Is LOVE limited to how much hardware it can use?

Posted: Sat Apr 22, 2023 3:51 pm
by Andlac028
Actually some great features are being developed in love 12.0, like compute shaders. Take a look at love repo at github, if you are interested in testing it. (However development version may contain bugs and change features / functions / …, so use at your own risk)