Sign in to follow this  
karwosts

Terrible frame hiccups, 200ms for 0 triangles!

Recommended Posts

As I've been playing with my program lately I've been noticing a weird problem. The game runs really smoothly (<2ms whole frame time) as measured with Hi-Res timers, although every so often get a really bad framerate hiccup that's very noticible during gameplay. I profiled it to the renderer, then to swapbuffers, and started removing pieces of the rendering pipeline until I could see what was causing it. Unfortunately I'm to the point where I've removed Everything from the rendering pipeline, and its still happening. This is now the entirety of my program, I call SwapBuffers in a loop and do nothing else. No glClear, no updates, nothing.

	while (!exiting)
	{
		if(initialized) { //Ignore very first startup frames
			
			timer.startTimer();
			SwapBuffers(hDC);
			timer.stopTimer();
			rendertimes[i] = timer.getElapsedTime();
			timer.clearTimer();
		}
		i++;
		if(i==1000){
			i=0;
			if(initialized==true){
				int stop = 1;//Breakpoint here
			}
			initialized=true;
		}

while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage (&msg, NULL, 0, 0))
			{
				exiting = true;
				break;
			}

			TranslateMessage (&msg);
			DispatchMessage (&msg);
		}


I break after going through the second thousand frames and scroll through the rendertimes in the debugger. Scrolling down the list most are 0.1ms which is ok, but then every so often I'll see one enormous frame, sometimes several in a short time. I could see something like this: 0.0001 0.0001 0.0001 0.2014 0.0001 0.0001 0.0941 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0380 0.0001 0.0001 0.0001 Game is freezing for 200ms to perform a single frame! Any thoughts what I can do to stop this? Edit: OS is Windows Vista, GPU is 8800GTS [Edited by - karwosts on April 29, 2010 11:51:32 AM]

Share this post


Link to post
Share on other sites
I can try that later when I get back, although my message loop is outside the timer so I'm not sure if that will help much.

I'm pretty sure vsync is off, like I said typically the loop time is ~0.1ms

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this