Is LOVE limited to how much hardware it can use?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Pratix
Prole
Posts: 5
Joined: Sat Feb 04, 2023 11:46 pm

Is LOVE limited to how much hardware it can use?

Post 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?
User avatar
BrotSagtMist
Party member
Posts: 655
Joined: Fri Aug 06, 2021 10:30 pm

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

Post by BrotSagtMist »

Without seeing any code, no. This question is too generic.
obey
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

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

Post 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.
tourgen
Citizen
Posts: 53
Joined: Sat Mar 18, 2023 12:45 am

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

Post 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).
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

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

Post 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)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests