Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
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 ?!   
I just did a search on that problem in this group, it seems that it's
a DirectX issue, so I find my workaround with putting a pre-calculated
sleep before calling Present, which doesn't guarantee that Present
will always keep up with the refreshrate, but it's still better to
drop few frames than to have excessive CPU usage.
date: Thu, 26 Jun 2008 13:43:29 -0700 (PDT)   author:   Pencheff

Re: VSYNC makes CPU high in fullscreen ?!   
On Jun 26, 1:43 pm, Pencheff  wrote:
> I just did a search on that problem in this group, it seems that it's
> a DirectX issue, so I find my workaround with putting a pre-calculated
> sleep before calling Present, which doesn't guarantee that Present
> will always keep up with the refreshrate, but it's still better to
> drop few frames than to have excessive CPU usage.

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.

--Matt
date: Fri, 27 Jun 2008 08:44:06 -0700 (PDT)   author:   Clint Eastwood

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

Re: VSYNC makes CPU high in fullscreen ?!   
> Any better idea ? Is there a command to wait for vertical sync in
> Direct3D (something like WaitForVerticalBlank() in DirectDraw) ?

Nothing explicit that I could find.  However, you can loop over
IDirect3DDevice9::GetRasterStatus() until the status indicates
that you are in the vertical blank.  This is a clunky way of doing
WaitForVerticalBlank().

kodecharlie
date: Mon, 7 Jul 2008 11:46:53 -0700 (PDT)   author:   kodecharlie

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us