|
|
|
date: Thu, 26 Jun 2008 10:05:36 -0700 (PDT),
group: microsoft.public.win32.programmer.directx.graphics
back
VSYNC makes CPU high in fullscreen ?!
Hi,
I have a simple renderloop, which just clears the screen to black and
draws FPS in the top left corner. If I switch to fullscreen with VSYNC
on, my application starts eating 20-30% CPU for just calling a Clear
and Present. If I switch off the VSYNC, it works fine, causing 0-1%
most of the time. I'm using DXUT library, I've tried searching in the
code for anything suspicious...I couldn't find anything.
As not that experienced DirectX programmer, I ask, is there anything
other than turning on the VSYNC in the PresentParameters I should do
when using vsync, should I do any checks ?
Thanks,
George
date: Thu, 26 Jun 2008 10:05:36 -0700 (PDT)
author: Pencheff
Re: VSYNC makes CPU high in fullscreen ?!
On Jun 27, 6:44 pm, Clint Eastwood wrote:
> I highly recommend actually running a CPU benchmark with wait for
> vsync on and off and compare the results. Don't trust the numbers you
> get from Task Manager or perfmon, as the CPU utilization can be
> misleading. I think when the CPU goes into a wait in the kernel-mode
> driver the CPU utilizaiton shows as 100%, but it can still be
> interrupted by other processes.
I'm actually running a 1080p video inside using VMR9, it starts to
freeze frames when CPU usage goes above 40%, so I guess that's my
benchmark...after adding that sleep before calling present, everything
seems normal.
So, right now my renderloop (which is a separate thread from VMR9)
looks like this:
void RenderThreadProc()
{
while( !quit )
{
Move();
Render();
if (fullscreen & vsync_on)
sleep( calculated interval );
Present();
}
}
The calculated interval is being calculated when device is calculated,
the value depends on the monitor refresh rate, but commonly it's
something between 5 and 10 (which will vary on different CPUs).
Any better idea ? Is there a command to wait for vertical sync in
Direct3D (something like WaitForVerticalBlank() in DirectDraw) ?
date: Fri, 27 Jun 2008 09:22:07 -0700 (PDT)
author: Pencheff
|
|