1 Pixel more needs +98% CPU

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.
TheCaptain
Prole
Posts: 4
Joined: Sun Jun 26, 2011 7:32 pm

1 Pixel more needs +98% CPU

Post by TheCaptain »

Hi,

first of all, very impressive engine. Some HowTos more would be nice, i struggled finding out theres an animation framework for löve. BTW don't google for "AnAL Löve", it won't give you any useful results :)

My Problem is that a background-image with 512x256px is using about 0-1% of CPU, but 513x256px is using 99%.

WTF ??
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: 1 Pixel more needs +98% CPU

Post by Robin »

Simply put: it's likely because 512 is a power of two, which is what computer are optimized for.
Help us help you: attach a .love.
TheCaptain
Prole
Posts: 4
Joined: Sun Jun 26, 2011 7:32 pm

Re: 1 Pixel more needs +98% CPU

Post by TheCaptain »

Likewise is 1024x512, but this also gives 99% CPU. Definitely not a normal behaviour, and I'm just using the examples.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: 1 Pixel more needs +98% CPU

Post by Robin »

TheCaptain wrote:Likewise is 1024x512, but this also gives 99% CPU. Definitely not a normal behaviour, and I'm just using the examples.
I think I have an idea: your computer can comfortably handle 512x256, but 513x256 is "rounded up" to 1024x256, giving similar performance. This is called "padding", and we actually use it in our games, because some computers simply can't handle non-PO2 images at all, displaying white rectangles instead.
Help us help you: attach a .love.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: 1 Pixel more needs +98% CPU

Post by T-Bone »

Still, rendering a 1024*256 image shouldn't be all that hard, it shouldn't use all the cpu, even on a crappy computer, if it's just rendering a single image.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: 1 Pixel more needs +98% CPU

Post by TechnoCat »

Shouldn't it be the case the 512x256 pixel image also uses 99%? That is, unless you are doing vsync or framerate management.
TheCaptain
Prole
Posts: 4
Joined: Sun Jun 26, 2011 7:32 pm

Re: 1 Pixel more needs +98% CPU

Post by TheCaptain »

Yeah, i read something about the PO2_Syndrome, but graphic card is not that old.

I found the problem. Seems that cutting off background images to the size of the screen is extremely inefficient. If the image extends screen.width or screen.height set in conf.lua, then CPU goes crazy. The 513px image probably was padded to 1024px like you say, which was more than the 600 or so pixel that I've set as width in configuration. If I use 1024x512px image on 1024x512px viewport, everything works fine.

Still I would think cutting a too big image to the viewport size doesn't make your CPU sweat. Thanks anyway.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: 1 Pixel more needs +98% CPU

Post by kikito »

Can you show us the code you are using? Maybe there's more than meets the eye.
When I write def I mean function.
TheCaptain
Prole
Posts: 4
Joined: Sun Jun 26, 2011 7:32 pm

Re: 1 Pixel more needs +98% CPU

Post by TheCaptain »

Sure. Just plain simple though. With 513x256px image for 1a.jpg, its getting hot in here.

Code: Select all

require("lua/AnAL.lua")

function love.load()
	image = love.graphics.newImage("images/bg/1a.jpg")
	player = love.graphics.newImage("images/run/c2.jpg")
	anim = newAnimation(player, 45, 113, 0.1, 0)
	anim:setMode("bounce")
end

function love.draw()	
	love.graphics.draw(image, imgx, imgy)	
	anim:draw(400, 300)
end

function love.update(dt)
	anim:update(dt)
end

Code: Select all

function love.conf(t)
    t.screen.width = 557
    t.screen.height = 441
end
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: 1 Pixel more needs +98% CPU

Post by Taehl »

T-Bone wrote:Still, rendering a 1024*256 image shouldn't be all that hard, it shouldn't use all the cpu, even on a crappy computer, if it's just rendering a single image.
Don't make assumptions. Ensayia was making a screensaver for someone at some point, and after a lot of frustration, discovered that the target computer choked when handed anything bigger than 256x256. The solution is simply to cut your huge image into smaller pieces.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 7 guests