Is there an effective way to cut down lag?

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.
milon
Party member
Posts: 123
Joined: Thu Jan 18, 2018 9:14 pm

Re: Is there an effective way to cut down lag?

Post by milon »

pgimeno wrote: Tue Apr 10, 2018 4:54 pm Drawing a quad has no advantage over drawing an image. However, drawing multiple quads in a single spritebatch has a big performance advantage, as the cost is comparable to that of drawing a single image, even when you have hundreds of quads in the batch.
I'm pretty new to Love myself, and haven't (yet!) needed to worry about spritebatches. But then 11.0 came out, and I thought I read that it automatically batches draw calls into a spritebatch. So I still haven't looked into that because I thought it was already happening. Did I misunderstand something?
User avatar
pgimeno
Party member
Posts: 2599
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is there an effective way to cut down lag?

Post by pgimeno »

milon wrote: Wed Apr 11, 2018 1:28 pm I'm pretty new to Love myself, and haven't (yet!) needed to worry about spritebatches. But then 11.0 came out, and I thought I read that it automatically batches draw calls into a spritebatch. So I still haven't looked into that because I thought it was already happening. Did I misunderstand something?
You're right, I forgot about the new 11.0 auto-batching feature (still not related to quads).

I haven't found any docs on how that's controlled, if it is controllable at all. The similar performance with 0.10 and 11.0 in the example I posted suggests that either auto-batching is inactive by default, or that the bottleneck is something else (e.g. total amount of pixels changed/rewritten).
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Is there an effective way to cut down lag?

Post by bartbes »

pgimeno wrote: Wed Apr 11, 2018 4:04 pm I haven't found any docs on how that's controlled, if it is controllable at all.
It isn't, it's always on.
pgimeno wrote: Wed Apr 11, 2018 4:04 pm The similar performance with 0.10 and 11.0 in the example I posted suggests that either auto-batching is inactive by default, or that the bottleneck is something else (e.g. total amount of pixels changed/rewritten).
I just took a peek at the included resources. I suspect you're drawing lots of different images. Automatic batching is limited to (mostly) the same things as manual batching, so whenever you do some major graphics setting change (which includes a texture change), the batch ends and a new one begins. If you switch to a single ball image you'll probably see autobatching kick in. Note that this is why it's advisable to still batch manually wherever possible, so you can be sure it happens.

Can I also suggest looking at love.graphics.getStats, and in particular at the number of draw calls?
User avatar
pgimeno
Party member
Posts: 2599
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is there an effective way to cut down lag?

Post by pgimeno »

bartbes wrote: Wed Apr 11, 2018 5:11 pm
pgimeno wrote: Wed Apr 11, 2018 4:04 pm The similar performance with 0.10 and 11.0 in the example I posted suggests that either auto-batching is inactive by default, or that the bottleneck is something else (e.g. total amount of pixels changed/rewritten).
I just took a peek at the included resources. I suspect you're drawing lots of different images. Automatic batching is limited to (mostly) the same things as manual batching, so whenever you do some major graphics setting change (which includes a texture change), the batch ends and a new one begins.
To clarify, I'm not the OP and I didn't write the game that was posted in the thread. I just posted this example:
pgimeno wrote: Tue Apr 10, 2018 4:54 pm With this example program, I get ~320 FPS at 800x600 and ~123 FPS when maximized (approx. 1280x1024):

Code: Select all

love.window.setMode(800, 600, {vsync=false, resizable=true})
local MAX = love._version_major > 0 and 1 or 255

function love.draw()
  love.graphics.clear()
  love.graphics.setColor(0,0,MAX)
  local w, h = love.graphics.getDimensions()
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.rectangle("fill", 0, 0, w, h)
  love.graphics.setColor(MAX,MAX,MAX)
  love.graphics.print(love.timer.getFPS())
end

function love.keypressed(k)
  if k == "escape" then love.event.quit() end
  if k == "f" then
    love.window.maximize()
  elseif k == "n" then
    love.window.restore()
  end
end
I get the same FPS in 0.10 and 11.0.
From my reading of the release notes, "shapes" includes rectangles:
11.0 release notes wrote: Improved performance when drawing Textures, shapes, lines, and points by automatically batching their draw calls together when possible.
milon
Party member
Posts: 123
Joined: Thu Jan 18, 2018 9:14 pm

Re: Is there an effective way to cut down lag?

Post by milon »

bartbes wrote: Wed Apr 11, 2018 5:11 pm ...Automatic batching is limited to (mostly) the same things as manual batching, so whenever you do some major graphics setting change (which includes a texture change), the batch ends and a new one begins. If you switch to a single ball image you'll probably see autobatching kick in. Note that this is why it's advisable to still batch manually wherever possible, so you can be sure it happens.
Am I correct that this means (generally speaking) that when I draw a bunch of sprite quads from a single image file, Love will attempt to batch them all together? And thanks for the tip about manual batching - I'll put that back on my to do list. :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Is there an effective way to cut down lag?

Post by bartbes »

pgimeno wrote: Wed Apr 11, 2018 11:34 pm To clarify, I'm not the OP and I didn't write the game that was posted in the thread. I just posted this example:
I know, I was replying to your post though.
milon wrote: Thu Apr 12, 2018 12:01 pm Am I correct that this means (generally speaking) that when I draw a bunch of sprite quads from a single image file, Love will attempt to batch them all together?
That's the idea.
User avatar
pgimeno
Party member
Posts: 2599
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is there an effective way to cut down lag?

Post by pgimeno »

bartbes wrote: Thu Apr 12, 2018 3:46 pm
pgimeno wrote: Wed Apr 11, 2018 11:34 pm To clarify, I'm not the OP and I didn't write the game that was posted in the thread. I just posted this example:
I know, I was replying to your post though.
Oh, then I don't understand what you mean here:
bartbes wrote: Wed Apr 11, 2018 5:11 pm I just took a peek at the included resources. I suspect you're drawing lots of different images. [...]
The test I posted includes no resources and it only draws rectangles, all the same size. The results I got refer to that text. What included resources do you mean? Where am I drawing lots of different images?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 26 guests