Low power mode?

Discussion in 'Game Design' started by Phil Steinmeyer, Oct 5, 2006.

  1. Phil Steinmeyer

    Original Member

    Joined:
    Mar 1, 2005
    Messages:
    757
    Likes Received:
    0
    I just had a bit of feedback from one of my beta testers, complaining a bit that my game drains the battery on his laptop really fast.

    This makes sense - it's a software engine that for the most part runs flat out - it'll generally consume close to 100% of CPU time (and presumably, full power), if it's the foreground app.

    I believe that clamping frame rate would reduce power dramatically. I don't want to make this a default (because high frame rate looks good), but for a laptop user, dropping to 20 FPS and halving the power demands might be useful.

    One thing I could possibly do is detect if I'm running on battery power, and take some steps automatically in that case (say, clamp to 30 FPS). Is there an API call to determine this?

    Or, I could add an checkbox to my options menu for 'low power mode' or something, and get a little more sever (20 FPS) if they check that.

    I'm assuming here that it'll actually make a difference - that if, on a given machine, the game can run 'natively' at, say 40 FPS (i.e. 25 milliseconds/frame), that clamping it to half that (20 FPS - render a frame in 25 ms, then sleep for 25 ms), would have a roughly linear effect on power. But possibly, cycling from 100% of CPU to 0% every 25 ms would in fact not be very efficient. Anybody got insight into this?

    Is an options menu checkbox for this overkill? (I'm trying to keep my options minimal to avoid confusing users)
     
    #1 Phil Steinmeyer, Oct 5, 2006
    Last edited: Oct 5, 2006
  2. James C. Smith

    Moderator Original Member

    Joined:
    Aug 21, 2004
    Messages:
    1,768
    Likes Received:
    0
    You can't please them all. Keep it simple. Don't do anything.

    Just my opinion.
     
  3. Tom Cain

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    284
    Likes Received:
    0
    I agree with James. Battery drain is part of running realtime games on laptops or handhelds. It's unfortunate to have to be the company that explains that to a user, though.

    If the game is turn-based, I've found on Palm that you can save power if you use the standard OS event queue/message pump for input. That way you aren't consuming any more power than a standard app between turns, it's just idle. When I needed to update small areas of the screen while waiting for input, I used a standard OS timer to fire off screen update events that use dirty rects to only change what's necessary.

    That's the lowest power consumption method I've come up with, but it only works for turn-based games.
     
  4. george

    Original Member

    Joined:
    Aug 8, 2004
    Messages:
    343
    Likes Received:
    0
    i don't see anything wrong with adding a "laptop friendly" option, as long as it doesn't take too much time to implement... if a lot of your customers use the product on battery powered laptops, then I think it is a wise decision to invest in satisfying your customers (as long as the solution is practical), not to mention its great customer service!

    but as the previous posters said, there is nothing wrong, and definitely don't go adding special unpractical features to your product for just a handful of people, especially if it is time consuming and impractical.

    but there is something to this idea, i say research a little further before brushing it off, you never know it may even get you more customers.
     
  5. Sharpfish

    Original Member

    Joined:
    Feb 25, 2005
    Messages:
    1,309
    Likes Received:
    0
    No, my initial thought was: If you can't make the app consume less CPU% for *EVERYONE* they don't make special conditions for laptops.

    Sure it sounds nice on paper to add it in but if you think about it, if your game is going to suffer (get stuttery) because an option is checked then it's probably going to cause more problems than it's worth.

    Also the implementation could be a bit of a pain and i'm sure you would be better looking to reduce the overall usage of your app rather than just on laptops. If you can't then as was said "Keep it simple".
     
  6. Phil Steinmeyer

    Original Member

    Joined:
    Mar 1, 2005
    Messages:
    757
    Likes Received:
    0
    Do any of you guys (especially those with softwarer renderers) clamp your frame rate? If so, what do you clamp it to?

    And is there any way in windows to automatically detect if you're running in battery mode?
     
  7. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    My Flash-based game is clamped at 30FPS and consumes between 25% and 50% CPU on my P4 2.66GHz. Clamped at 60FPS it uses between 50% and 85% CPU. That said, even at its native framerate of 30FPS, it causes some laptops to die pretty quickly.
     
  8. Sharpfish

    Original Member

    Joined:
    Feb 25, 2005
    Messages:
    1,309
    Likes Received:
    0
    Though mine is hardware rendered the cpu logic is still able to run away (100% usage). I have a framecap option in my game (which I know is a bit advanced for casual users) however I found a flaw on desktops using windows blinds without frame capping that caused frame rate drops and other quirks.

    Anyway with framecap on (typically 800x600 in game runs ~ 60fps though it's a percentage of available frames rather than a strict FPS rate) and uses between 30-40% of the CPU power. This is set on as default.
     
  9. Pogacha

    Original Member

    Joined:
    Jan 21, 2005
    Messages:
    605
    Likes Received:
    0
    If you can set a " low consume [ ] (will drop down the quality)" option then

    Code:
    while( bNotTheEndOfGame )
    {
       if( bLowConsume ) Sleep(10);
       Game.NextFrame();
    }
     
  10. oNyx

    Original Member

    Joined:
    Jul 26, 2004
    Messages:
    1,211
    Likes Received:
    0
    >But possibly, cycling from 100% of CPU to 0% every 25 ms would in fact not
    >be very efficient. Anybody got insight into this?

    50% usage means 100% usage for half of the time. The cpu is either used or not (HLT-ed or a deeper sleep mode). If its HLT-ed parts of the CPU are switched off, which means less power consumption.

    The HLT-ing itself is done by some low priority thread spawned by the OS. Win9x doesnt have such a thread therefore power consumption is pretty much the same regardless what you do. You can, however, make a CPU take more energy than usual by running special asm code, which was 100% optimized for this cpu (see cpuburn).
     
  11. Phil Steinmeyer

    Original Member

    Joined:
    Mar 1, 2005
    Messages:
    757
    Likes Received:
    0
    BTW, I found a Windows API function to detect 'Running on Battery'

    GetSystemPowerStatus
     
  12. PaulModz

    Original Member

    Joined:
    Apr 7, 2006
    Messages:
    53
    Likes Received:
    0
    Running flat-out makes your game a "bad neighbor". There's nothing more annoying than a game that hogs resources when it doesn't have too. Even mediocre hardware can do 2D at 60 fps without using too much CPU (depending on what else you're doing, of course).

    It can hurt the game, too. If you don't leave any cycles for other apps, the system bogs when Outlook, AIM or a background service needs to take care of business, since the scheduler will be forced to interrupt the game if it doesn't leave any openings. This can get really bad if you don't scale the animation speed with the elapsed time between frames.

    In general, its better to sleep in lots of small increments instead of a few large ones. This is part of the timing code in my current game:

    mainLoopTicks = HiPerfTimer.Ticks;
    diff = HiPerfTimer.Seconds(mainLoopLastTicks, mainLoopTicks);

    if (diff < minFrameDiff){
    System.Threading.Thread.Sleep(1);

    continue;
    }

    The loop might run 1000 times a second, but that's nothing since the the 'continue' short circuits the main game loop.

    Think about how much your game adds to the overall entropy of the Universe for no good reason. ;)
     
  13. badjim

    Original Member

    Joined:
    Jan 8, 2005
    Messages:
    17
    Likes Received:
    0
    Buffer flipping is what is ridiculously wasteful. It seems to involve 100% CPU usage until the flip occurs.


    If you can get the current scanline you can sleep until the last millisecond and flip just in time. Note that for some cards the buffer flip itself is instantaneous but the next drawing operation will take time if it is called just after the flip. Something to think about while you work out the timing code.

    Triple buffering might work.

    Double buffering with vwait off also works quite nicely on a lot of machines(it shouldn't but it does). For those that don't, there is another technique:
    1) sleep until the scanline comes down halfway
    2) Blit the top half of the back buffer onto the front buffer
    3) sleep until the scanline goes back to the top of the screen
    4) Blit the second half.
    Unfortunately I have found it not always perfect visually.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer