From 368e5651fccea3dcc4f36cc26c379da705e007eb Mon Sep 17 00:00:00 2001 From: aquanull Date: Mon, 28 Nov 2011 13:11:18 +0000 Subject: [PATCH] win32: fixed graphic-tearing WITH vertical sync enabled in windowed mode. It used to wait for V-Blank too early so that the V-Blank would end too soon before the blitting could be finished. --- src/drivers/win/video.cpp | 17 ++++- vc/vc10_fceux.vcxproj | 24 ------- vc/vc10_fceux.vcxproj.filters | 117 ++++++++++++++++++++-------------- 3 files changed, 83 insertions(+), 75 deletions(-) diff --git a/src/drivers/win/video.cpp b/src/drivers/win/video.cpp index 4b6a272e..820ea060 100644 --- a/src/drivers/win/video.cpp +++ b/src/drivers/win/video.cpp @@ -432,10 +432,9 @@ bool FCEUD_ShouldDrawInputAids() static void BlitScreenWindow(uint8 *XBuf); static void BlitScreenFull(uint8 *XBuf); -//static uint8 *XBSave; -void FCEUD_BlitScreen(uint8 *XBuf) + +static void FCEUD_VerticalSync() { - xbsave = XBuf; if(!NoWaiting) { int ws; @@ -453,6 +452,12 @@ void FCEUD_BlitScreen(uint8 *XBuf) Sleep(0); } } +} + +//static uint8 *XBSave; +void FCEUD_BlitScreen(uint8 *XBuf) +{ + xbsave = XBuf; if(fullscreen) { @@ -518,6 +523,9 @@ static void BlitScreenWindow(unsigned char *XBuf) IDirectDrawSurface7_Unlock(lpDDSBack, NULL); + //aquanull 2011-11-28 fix tearing + FCEUD_VerticalSync(); + if(IDirectDrawSurface7_Blt(lpDDSPrimary, &drect,lpDDSBack,&srect,DDBLT_ASYNC,0)!=DD_OK) { ddrval=IDirectDrawSurface7_Blt(lpDDSPrimary, &drect,lpDDSBack,&srect,DDBLT_WAIT,0); @@ -586,6 +594,9 @@ static void BlitScreenFull(uint8 *XBuf) PaletteChanged=0; } + //aquanull 2011-11-28 fix tearing + FCEUD_VerticalSync(); + if(vmodes[vmod].flags&VMDF_DXBLT) { ddrval=IDirectDrawSurface7_Lock(lpDDSBack,NULL,&ddsdback, 0, NULL); diff --git a/vc/vc10_fceux.vcxproj b/vc/vc10_fceux.vcxproj index c143362e..f35a2596 100644 --- a/vc/vc10_fceux.vcxproj +++ b/vc/vc10_fceux.vcxproj @@ -857,9 +857,7 @@ - - @@ -899,28 +897,6 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/vc/vc10_fceux.vcxproj.filters b/vc/vc10_fceux.vcxproj.filters index 5fc795b6..e5490616 100644 --- a/vc/vc10_fceux.vcxproj.filters +++ b/vc/vc10_fceux.vcxproj.filters @@ -49,6 +49,9 @@ {b826cbb1-8f65-48a4-89ca-a1b691426971} + + {19ba9ddc-37b7-4962-a3d7-9eb69929a8dc} + @@ -1427,56 +1430,74 @@ drivers\win\res - - drivers\win\res - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix + + + pix +