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 ??
1 Pixel more needs +98% CPU
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: 1 Pixel more needs +98% CPU
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.
-
- Prole
- Posts: 4
- Joined: Sun Jun 26, 2011 7:32 pm
Re: 1 Pixel more needs +98% CPU
Likewise is 1024x512, but this also gives 99% CPU. Definitely not a normal behaviour, and I'm just using the examples.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: 1 Pixel more needs +98% CPU
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.TheCaptain wrote:Likewise is 1024x512, but this also gives 99% CPU. Definitely not a normal behaviour, and I'm just using the examples.
Help us help you: attach a .love.
Re: 1 Pixel more needs +98% CPU
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.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- 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
Shouldn't it be the case the 512x256 pixel image also uses 99%? That is, unless you are doing vsync or framerate management.
-
- Prole
- Posts: 4
- Joined: Sun Jun 26, 2011 7:32 pm
Re: 1 Pixel more needs +98% CPU
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.
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.
- 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
Can you show us the code you are using? Maybe there's more than meets the eye.
When I write def I mean function.
-
- Prole
- Posts: 4
- Joined: Sun Jun 26, 2011 7:32 pm
Re: 1 Pixel more needs +98% CPU
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
- 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
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.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.
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests