Hi, lövly folks
I am quite new to löve and started coding in löve 2 weeks ago. This forum is a great help and a source of tips and inspirations.
I created a 2d worldmap with tiles and draw it in love.draw().
With vsync=true i reached 60fps and 5%cpu. - FINE!
I wrote more and more (uneffective) code into love.update(dt)
With vsync=true i reached 15fps and 99%cpu. - BAD!
I optimized my code and went back to 60fps and lower cpu load. - OK!
I tried to find out how fast my code runs and set vsync=false. The fps went up to 300fps and heavy cpu load.
I optimized more and the cpu load dropped down below 10% BUT the fps still sticks at 300fps.
Now my question:
Is there some fps-hard-limit implemented? Can i disable this hardlimit for testing purposes? Or i am thinking in a wrong direction?
Thanks in advance.
Fuzzlix.
[solved] fps, vsync related question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[solved] fps, vsync related question
Last edited by Fuzzlix on Sat Oct 15, 2016 1:09 pm, edited 1 time in total.
- RaycatRakittra
- Prole
- Posts: 22
- Joined: Fri Sep 30, 2016 12:40 am
- Location: Chicago, IL
- Contact:
Re: fps, vsync related question
'FPS', by default, is unlimited. It's the number of times the game is updating. I'm unsure of whatever code you wrote but if you think it's ineffective, it probably is. For all the other issues: https://github.com/bjornbytes/tick
Sometimes, I can code things.
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: fps, vsync related question
If vsync is off, then yes, the speed of your löve program is only limited by the speed of one core on your CPU. If vsync is on, since löve uses the main thread for graphics as well, the frame limiting will effectively throttle your processing speed as well, not just the rendering speed.
Still, try vsync on with your latest code, if your cpu consumption is still high with it, then you could attach a .love file so we can see what any errors might be.
Also, vsync using 99% cpu even without too much processing can also mean that your OS is doing something stupid, i think, but i'm not sure.
Still, try vsync on with your latest code, if your cpu consumption is still high with it, then you could attach a .love file so we can see what any errors might be.
Also, vsync using 99% cpu even without too much processing can also mean that your OS is doing something stupid, i think, but i'm not sure.
Me and my stuff True 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.
[solved]: fps, vsync related question
Thanks for the tip. ... I found the bottleneck: It is the Intel-GPU inside my Celeron. I hit 100% GPU load by drawing a 230x200 canvas scaled up to a 1600x900 window.RaycatRakittra wrote:'FPS', by default, is unlimited. It's the number of times the game is updating. I'm unsure of whatever code you wrote but if you think it's ineffective, it probably is. For all the other issues: https://github.com/bjornbytes/tick
Question answered.
Re: [solved] fps, vsync related question
If you're using the default love.run function, I'm pretty sure it limits the FPS you can get.
Check this out: https://love2d.org/wiki/love.run
I'm pretty sure this line near the bottom is to prevent the application from using too much of the CPU and therefore limiting the FPS.
Please correct me if I'm wrong though.
Check this out: https://love2d.org/wiki/love.run
I'm pretty sure this line near the bottom is to prevent the application from using too much of the CPU and therefore limiting the FPS.
Code: Select all
if love.timer then love.timer.sleep(0.001) end
Computer science student and part time game dev! Currently working on Depths of Limbo!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Re: [solved] fps, vsync related question
You point in the right direction. I did some experiments with love.run() today and wrote a modified version for my game. I expirienced the actual fps is 1 more than the requested. I assume some rounding errors in the floating point math. (e.g. 30fps gives me 31fps, 60fps->61fps,...). The loop time looks very stable, if i set vsync=false. (vsync=true results in some aditional sleep(), i dont want in this situation.) And 20..30fps are good enouth for my MasterOfMagic/Civilisation like game. I added 3 lines of debug-print, that allows me to judge the speed of different versions of my code. May be, in the final version i go back to the builtin love.run() and vsync=true.evgiz wrote:If you're using the default love.run function, I'm pretty sure it limits the FPS you can get.
Check this out: https://love2d.org/wiki/love.run
I'm pretty sure this line near the bottom is to prevent the application from using too much of the CPU and therefore limiting the FPS.
Please correct me if I'm wrong though.Code: Select all
if love.timer then love.timer.sleep(0.001) end
Code: Select all
function love.run()
local fps = 20;
local getTime = love.timer.getTime
local sleepTime = 1 / fps;
if love.math then love.math.setRandomSeed(os.time()) end;
if love.load then love.load(arg) end;
-- We don't want the first frame's dt to include time taken by love.load.
if love.timer then love.timer.step() end
local dt = 0
local time = getTime()
-- Main loop time.
while true do
-- Process events.
if love.event then
love.event.pump()
for name, a,b,c,d,e,f in love.event.poll() do
if name == "quit" and (not love.quit or not love.quit()) then return a; end;
love.handlers[name](a,b,c,d,e,f);
end
end
local deltaTime;
if love.timer then
local newTime = getTime()
deltaTime = getTime() - time;
love.timer.sleep(max(sleepTime-(deltaTime), 0.001));
time = getTime()
-- Update dt, as we'll be passing it to update
love.timer.step()
dt = love.timer.getDelta()
end
-- Call update and draw
if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
if love.graphics and love.graphics.isActive() then
love.graphics.clear(love.graphics.getBackgroundColor());
love.graphics.origin();
if love.draw then love.draw() end;
if __DEBUG then
love.graphics.print(("dt: %04d ms"):format(dt*1000), 10, 10);
love.graphics.print(("fps: %02d"):format(love.timer.getFPS()), 10, 30);
love.graphics.print(("lua load: %02d %%"):format(deltaTime/dt*100), 10, 50);
end;
love.graphics.present();
end;
--
end;
end;
Who is online
Users browsing this forum: No registered users and 2 guests