"line" draw mode results in insane FPS drops.

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
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

"line" draw mode results in insane FPS drops.

Post by severedskullz »

Hello everyone, new to the forums here... Hope I am doing this right.

I am making a nice little space game to draw planets and such.
With the following code:

Code: Select all

	--Draw all of our planets
	love.graphics.push() -- Save Original
	love.graphics.translate(cX-camX*zoomScale, cY+camY*zoomScale)
	for k, v in pairs(univ.planets) do
		local radScale = clamp(v.radius * zoomScale, 8, 180)
		love.graphics.setColor( 198, 241, 255, 255 )
		love.graphics.circle("fill",  v.x * zoomScale,  v.y * zoomScale, v.radius * zoomScale, radScale)
		love.graphics.setColor( 255, 0, 0, 255 )
		love.graphics.setLineWidth( 1 )
		love.graphics.rectangle( "line", (v.x-v.radius)*zoomScale, (v.y-v.radius)*zoomScale, (v.radius*2)*zoomScale, (v.radius*2)*zoomScale )
		--love.graphics.circle("line", v.x * zoomScale ,  v.y * zoomScale, math.max(3, (v.radius+10) * zoomScale),radScale)
	end
	love.graphics.pop() -- reload original
I am going from 200 FPS to 91 with the rectangle draw line. If I comment it out, I get a 120 FPS gain with only 100 boxes being drawn. I can't imagine drawing those 100 circles above a few lines being less expensive than drawing a simple box! Attempting to draw the circle (line below rectangle) instead results in a similar FPS drop amount... If I switch the mode to Fill I am at 142 FPS! What is going on?!
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: "line" draw mode results in insane FPS drops.

Post by Boolsheet »

The default line style "smooth" (love.graphics.setLineStyle) does some calculations on the CPU to get an anti-aliased line. It can have quite the impact if you draw many lines, though 100 rectangles don't seem like that much.
Shallow indentations.
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

Re: "line" draw mode results in insane FPS drops.

Post by severedskullz »

Boolsheet wrote:The default line style "smooth" (love.graphics.setLineStyle) does some calculations on the CPU to get an anti-aliased line. It can have quite the impact if you draw many lines, though 100 rectangles don't seem like that much.
Noted. Anything else I should be aware of? I still don't understand why filling is less computationally expensive than drawing a line... even after setting it to "rough" ( I'm just doing UI Debug stuff so I could care less about "prettiness")
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: "line" draw mode results in insane FPS drops.

Post by Jasoco »

Can we see the whole .love project? I'm just curious if it's something else in the program.

I threw this testing thing together for some reason so you can see how your computer performs. Spent way too much time on it (An hour and a half at 6 in the morning) because I'm a perfectionist and it never felt polished enough even though it's only for testing out framerate, but I digress. If you get really bad framerates with this then it might be your machine which is weird. But let us know some results. Should be self-explanatory. All the keys you can press are in the message. Should be no problem to figure out. Test out all the modes and combinations.
Sample.love
(49.34 KiB) Downloaded 236 times
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

Re: "line" draw mode results in insane FPS drops.

Post by severedskullz »

Jasoco wrote:Can we see the whole .love project? I'm just curious if it's something else in the program.

I threw this testing thing together for some reason so you can see how your computer performs. Spent way too much time on it (An hour and a half at 6 in the morning) because I'm a perfectionist and it never felt polished enough even though it's only for testing out framerate, but I digress. If you get really bad framerates with this then it might be your machine which is weird. But let us know some results. Should be self-explanatory. All the keys you can press are in the message. Should be no problem to figure out. Test out all the modes and combinations.
Sample.love
Very nice! Just tested it and Ill be looking through the code after breakfast to see what I am and am not doing right on my end. I had very little problems running images and rectangles under the one thousand mark at a solid 500 FPS ranging for all polys 100 - 1000 (Does Love go any higher?) Here's the results:

Code: Select all

--Circle Fill vs Line: 53 / 25
Poly:5000
Detail: 13
Type: Circle
Fill: Fill
Style: Smooth (Rough was the same FPS)
FPS 53

Poly:5000
Detail: 13
Type: Circle
Fill: Line
Style: Smooth (Rough = 38 FPS)
FPS 25

-- Circle Test 2 Line vs Fill
Poly: 200
Detail: 13
Type: Circle
Fill: Line
Style: Smooth (Rough is same)
FPS 333

Poly: 200
Detail: 13
Type: Circle
Fill: Fill
Style: Smooth (Rough is same)
FPS 500

--Odd note: Going from 200 - 300 polys on either fill or line drops FPS to ~300, but does not lose further significant (aka +- 20) FPS till about 600 which goes to 250 FPS

-- Image
Poly:5000
Type: Image
Fill: Line
Style: Smooth
FPS 25


--Rectangle
Poly:5000
Type: Rectangle
Fill: Fill
Style: Smooth (Rough is same)
FPS 71

Poly:5000
Type: Rectangle
Fill: Line
Style: Smooth (Rough = 55 FPS)
FPS 36
Using GPUz on the first test for circles resulted in 87% GPU utilization with and average of 28% CPU Utilization at 53 FPS

Code: Select all

GPU Core Clock [MHz] 940.6
GPU Memory Clock [MHz] 1350.0
GPU Temperature [°C] 58.0
Fan Speed (%) 23
Memory Used [MB] 245
GPU Load [%] 85
Memory Controller Load [%] 49
Video Engine Load [%] 0
VDDC [V] 1.0620

Sorry... I'm a CSCI Major with a concentration in Game Dev so I love all the little numbers and facts. :awesome:
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

Re: "line" draw mode results in insane FPS drops.

Post by severedskullz »

Been doing some more testing... Interesting fact: with my code for my game, my GPU usage never goes above 25% utilization (Even when I am below 20 FPS), but with your sample benchmark it will go all the way up to 95%.

I looked at your code and didn't anything significantly different in the way I was drawing my objects so I don't understand why it is going so slow. Earlier this morning I was at ~330, but now I am at ~250 with virtually no change to the code itself. Just cleaning it up, removing obsolete commented code, etc. and now it runs slower. Not a clue whats up.

It still isn't all that playable, but here is the love file.

Offtopic:
Whats the deal with me requiring a Mod to verify my posts? I can't see them or edit them until they are posted. Resulting in this possible double post...
Attachments
Terrae.love
WASD to move camera, scroll wheel to zoom out.
Click a planet to select it, right click to send units to attack the planet (Does not work yet. Entities persist once they get there)
F5 reloads the game for whatever reason. Easy to refresh code.
(132.21 KiB) Downloaded 188 times
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: "line" draw mode results in insane FPS drops.

Post by vrld »

Just as a side note: FPS are not a very useful measure for this kind of benchmark, since it distorts the actual time differences. For example, the difference of 330FPS to 250FPS is a whooping 80 FPS, but only 1s/250 - 1s/330 = 0.004s - 0.003030...s = 0.001s = 1ms.
On the other hand, the difference between 60FPS and 30FPS is only 30FPS, but the time difference is 1s/60 - 1s/30 = 0.016s = 16ms.

1ms difference is well within the "measurement noise" of your computer, and could be caused by processes your computer wasn't running this morning or even some weird other effects (e.g. temperature).
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
severedskullz
Prole
Posts: 36
Joined: Thu May 30, 2013 1:55 am

Re: "line" draw mode results in insane FPS drops.

Post by severedskullz »

vrld wrote:Just as a side note: FPS are not a very useful measure for this kind of benchmark, since it distorts the actual time differences. For example, the difference of 330FPS to 250FPS is a whooping 80 FPS, but only 1s/250 - 1s/330 = 0.004s - 0.003030...s = 0.001s = 1ms.
On the other hand, the difference between 60FPS and 30FPS is only 30FPS, but the time difference is 1s/60 - 1s/30 = 0.016s = 16ms.

1ms difference is well within the "measurement noise" of your computer, and could be caused by processes your computer wasn't running this morning or even some weird other effects (e.g. temperature).
Didn't even think to check other processes. That link was a very interesting read. Its rather funny actually that this material was not included in my courses when we were doing Integrated Circuits design... Very nice.

Never knew 1ms made that much of a difference. Any ideas in regards to my code only using less than 25% of the GPU, whereas others use all available?
Post Reply

Who is online

Users browsing this forum: No registered users and 78 guests