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.
This commit is contained in:
aquanull 2011-11-28 13:11:18 +00:00
parent c9f276761e
commit 368e5651fc
3 changed files with 83 additions and 75 deletions

View File

@ -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);

View File

@ -857,9 +857,7 @@
<ResourceCompile Include="..\src\drivers\win\res.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\src\drivers\win\res\bitmap1.bmp" />
<None Include="..\src\drivers\win\res\branch_spritesheet.bmp" />
<None Include="..\src\drivers\win\res\branch_spritesheet.png" />
<None Include="..\src\drivers\win\res\ICON_1.ico" />
<None Include="..\src\drivers\win\res\ICON_2.ico" />
<None Include="..\src\drivers\win\res\te_0.bmp" />
@ -899,28 +897,6 @@
</CustomBuild>
<None Include="..\src\pputile.inc" />
<None Include="ClassDiagram1.cd" />
<None Include="res\branch_spritesheet.bmp" />
<None Include="res\branch_spritesheet.png" />
<None Include="res\te_0.bmp" />
<None Include="res\te_1.bmp" />
<None Include="res\te_10.bmp" />
<None Include="res\te_11.bmp" />
<None Include="res\te_12.bmp" />
<None Include="res\te_13.bmp" />
<None Include="res\te_14.bmp" />
<None Include="res\te_15.bmp" />
<None Include="res\te_16.bmp" />
<None Include="res\te_17.bmp" />
<None Include="res\te_18.bmp" />
<None Include="res\te_19.bmp" />
<None Include="res\te_2.bmp" />
<None Include="res\te_3.bmp" />
<None Include="res\te_4.bmp" />
<None Include="res\te_5.bmp" />
<None Include="res\te_6.bmp" />
<None Include="res\te_7.bmp" />
<None Include="res\te_8.bmp" />
<None Include="res\te_9.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -49,6 +49,9 @@
<Filter Include="utils">
<UniqueIdentifier>{b826cbb1-8f65-48a4-89ca-a1b691426971}</UniqueIdentifier>
</Filter>
<Filter Include="pix">
<UniqueIdentifier>{19ba9ddc-37b7-4962-a3d7-9eb69929a8dc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\asm.cpp" />
@ -1427,56 +1430,74 @@
<None Include="..\src\drivers\win\res\ICON_2.ico">
<Filter>drivers\win\res</Filter>
</None>
<None Include="..\src\drivers\win\res\te_arrow.bmp">
<Filter>drivers\win\res</Filter>
</None>
<None Include="..\src\pputile.inc" />
<None Include="ClassDiagram1.cd" />
<None Include="..\src\drivers\win\res\bitmap1.bmp" />
<None Include="res\te_0.bmp" />
<None Include="res\te_1.bmp" />
<None Include="res\te_2.bmp" />
<None Include="res\te_3.bmp" />
<None Include="res\te_4.bmp" />
<None Include="res\te_5.bmp" />
<None Include="res\te_6.bmp" />
<None Include="res\te_7.bmp" />
<None Include="res\te_8.bmp" />
<None Include="res\te_9.bmp" />
<None Include="..\src\drivers\win\res\te_0.bmp" />
<None Include="..\src\drivers\win\res\te_1.bmp" />
<None Include="..\src\drivers\win\res\te_2.bmp" />
<None Include="..\src\drivers\win\res\te_3.bmp" />
<None Include="..\src\drivers\win\res\te_4.bmp" />
<None Include="..\src\drivers\win\res\te_5.bmp" />
<None Include="..\src\drivers\win\res\te_6.bmp" />
<None Include="..\src\drivers\win\res\te_7.bmp" />
<None Include="..\src\drivers\win\res\te_8.bmp" />
<None Include="..\src\drivers\win\res\te_9.bmp" />
<None Include="res\te_10.bmp" />
<None Include="res\te_11.bmp" />
<None Include="res\te_12.bmp" />
<None Include="res\te_13.bmp" />
<None Include="res\te_14.bmp" />
<None Include="res\te_15.bmp" />
<None Include="res\te_16.bmp" />
<None Include="res\te_17.bmp" />
<None Include="res\te_18.bmp" />
<None Include="res\te_19.bmp" />
<None Include="..\src\drivers\win\res\te_10.bmp" />
<None Include="..\src\drivers\win\res\te_11.bmp" />
<None Include="..\src\drivers\win\res\te_12.bmp" />
<None Include="..\src\drivers\win\res\te_13.bmp" />
<None Include="..\src\drivers\win\res\te_14.bmp" />
<None Include="..\src\drivers\win\res\te_15.bmp" />
<None Include="..\src\drivers\win\res\te_16.bmp" />
<None Include="..\src\drivers\win\res\te_17.bmp" />
<None Include="..\src\drivers\win\res\te_18.bmp" />
<None Include="..\src\drivers\win\res\te_19.bmp" />
<None Include="res\branch_spritesheet.png" />
<None Include="..\src\drivers\win\res\branch_spritesheet.png" />
<None Include="res\branch_spritesheet.bmp" />
<None Include="..\src\drivers\win\res\branch_spritesheet.bmp" />
<None Include="..\src\drivers\win\res\branch_spritesheet.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_0.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_1.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_2.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_3.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_4.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_5.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_6.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_7.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_8.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_9.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_10.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_11.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_12.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_13.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_14.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_15.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_16.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_17.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_18.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_19.bmp">
<Filter>pix</Filter>
</None>
<None Include="..\src\drivers\win\res\te_arrow.bmp">
<Filter>pix</Filter>
</None>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\src\auxlib.lua" />