Help, I've optimized too much!

Started by
14 comments, last by user0 11 years, 3 months ago
So If I limit my frames to 60 per second, should I only be limiting my Render function (that renders the scene) or both update and render functions. Update functions handles all game updates, moving objects, AI, etc...... I'm also single threaded. This is a small game really. I'm just kinda asking what the best advice is when limiting FPS.

Well since you can run at 200 FPS that means you are not CPU bound. And for simplicity sake why not just keep it like you have it.

Lock to vsync. This will lock you state updates, input, and rendering. If you start wanting to run at lower than 60 that is when it might become a concern for your input timings. But you'll create more input woes if you want to start threading anyway, so why not keep it as simple as possible until you need something more.

Yes thanks, I've learned a bit with this thread. I'll keep things the way it is, and try to reduce the fps to 60. I'm at work at the moment, so I'll have to give it a go tonight.

Advertisement
http://blogs.msdn.com/b/oldnewthing/archive/2010/12/03/10097861.aspx

I was asking about the Loud fan on my laptop. i'm guessing it's more GPU related then CPU. The thing spins up and gets REALLY REALLY loud. Only when I've got lots of visual apps going on at the same time.

Youtube, face time, and maybe a game. But no where as loud as when my game launches. I'm sure it has has to do with me trying to flip the backbuffer as many times as I can with each cycle.

So my game was running around 50 FPS, but then I reworked my terrain by implimenting GeoMipMapping, and sending my entity draw calls to a frustrum check instead of just rendering all entities.

I'm now pushing 170 fps, and my laptops fan ramps up and gets loud. I'm assuming this will cook the GPU after a while.

Is there a way to figure out how much to sleep given the FPS? I want to get it back down to 60ish fps (or some lower value).

Really? they didn't buzz before. I mean before rework... The CPU usage would be the same with or without optimization with your description so strange...

I'm not sure why you would assume his CPU load would be the same when he runs at 50 FPS vs 170 FPS, but it is not relevant. He asked how to limit his FPS.

I assumed his program without leash (no VSync, sleep etc...) had 50FPS before optimization and 170 after optimization.

The CPU usage is same in this case, therefore his fan screaming is result of something other.

i merely misunderstood.

Regarding topic:

I have no experience in OpenGL delay mechanism, there fore i am unable to help.

Going down to 60 fps:

Is there a way to figure out how much to sleep given the FPS? I want to get it back down to 60ish fps (or some lower value).

[/quote]

1000 / 60 = 1.66... per loop

second / FPS = amount time for one loop

This_Loop_Time = (how much time did program take to execute this loop); Max_Loop_Time = 1000/60;// (second / FPS) if(This_Loop_Time < Max_Loop_Time) Delay(Max_Loop_Time - This_Loop_Time)

For sleep, i suggest Google for "c++ Sleep" and find what suits your needs

So my game was running around 50 FPS, but then I reworked my terrain by implimenting GeoMipMapping, and sending my entity draw calls to a frustrum check instead of just rendering all entities.

I'm now pushing 170 fps, and my laptops fan ramps up and gets loud. I'm assuming this will cook the GPU after a while.

Is there a way to figure out how much to sleep given the FPS? I want to get it back down to 60ish fps (or some lower value).

I think I need to put something to rest right now that no one else has mentioned. You will NOT cook your GPU because the fan goes up! You would only cook the GPU if the fan dies. Modern GPUs (and CPUs for that matter) have built in heat profiles that adjust fan speed based on core temperature. There is a cut off point that varies by manufacturer and once the temperature passes this point, the hardware will shut down to prevent damage.

Your hardware is doing what it is supposed to and there is nothing wrong. You are wanting to limit performance based on lack of knowledge. Focus your energy on other tasks and be grateful that you can push 170 FPS on a laptop.

So my game was running around 50 FPS, but then I reworked my terrain by implimenting GeoMipMapping, and sending my entity draw calls to a frustrum check instead of just rendering all entities.

I'm now pushing 170 fps, and my laptops fan ramps up and gets loud. I'm assuming this will cook the GPU after a while.

Is there a way to figure out how much to sleep given the FPS? I want to get it back down to 60ish fps (or some lower value).

So you were running at 50fps, then implemented rendering-related optimizations, and now run much faster. So, it sounds like you were (or still are) GPU-bound, which means that previously your CPU was sitting around waiting for the GPU to finish. Now that the GPU does less work, the CPU waits less, and so it does more work. More work means it gets hotter, so the fan ramps up.

Options:

1. wait for vsync, which should automatically limit it to 60fps

2. put in code at the beginning of each frame to determine the frametime, and sleep until it reaches your target max framerate.

3. dont do anything and let it run as fast as it can.

Running the CPU as fast as possible should not be an issue. If it is then you need to look at options like underclocking, or maybe open it up and make sure the heatsync isnt clogged with dust, or stuff like that.

BTW for mobile games, limiting the framerate of your game might be a good idea in order to save battery life. You could even make it an option that the user can select. Just something to think about.

Just a little post on OpenGL and VSync topic - look at OpenGL wiki http://www.opengl.org/wiki/Swap_Interval - VSync how-to for more platforms and description (along with Adaptive VSync implementation - which seems like the thing you're looking for).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Set vsync for opengl windows

void System_Set_VSync(bool sync){

typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(sync);
}

This topic is closed to new replies.

Advertisement