1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Removed dependency on hardware color fill support

On some systems, a newly created DirectDraw video memory surface will initially
have a different surface memory address (obtainable with Lock) than the address
returned after the first Blt operation.

Previously a color fill Blt was used on newly created surfaces to make the
returned address consistent (which GDI interworking currently relies on, as well
as some games, e.g. Nox). But this may not work correctly on some low-end systems
that don't support hardware accelerated color fills.

Now a simple 1x1 Blt is used instead with a temporary (cached) surface as source.
A separate source surface is used because I have concerns (based on some MSDN
articles about WDDM) that same-surface Blts may not be handled the same way on
all drivers.
This commit is contained in:
narzoul 2016-01-01 23:25:56 +01:00
parent e5fd3a9e16
commit 2e8d7e47ab

View File

@ -39,17 +39,26 @@ namespace
return dd;
}
void fixSurfacePtr(IDirectDrawSurface7& surface, DDSURFACEDESC2& desc)
void fixSurfacePtr(IDirectDrawSurface7& surface, const DDSURFACEDESC2& desc)
{
if ((desc.dwFlags & DDSD_CAPS) && (desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY))
{
return;
}
DDBLTFX fx = {};
fx.dwSize = sizeof(fx);
DDSURFACEDESC2 tempSurfaceDesc = desc;
tempSurfaceDesc.dwWidth = 1;
tempSurfaceDesc.dwHeight = 1;
SimilarSurface tempSurface = getSimilarSurface(desc);
if (!tempSurface.front)
{
LOG_ONCE("Failed to fix a surface memory pointer");
return;
}
RECT r = { 0, 0, 1, 1 };
CompatDirectDrawSurface<IDirectDrawSurface7>::s_origVtable.Blt(
&surface, nullptr, nullptr, nullptr, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
&surface, &r, tempSurface.front, &r, DDBLT_WAIT, nullptr);
}
HRESULT WINAPI enumSurfacesCallback(
@ -208,7 +217,7 @@ namespace
g_mirrorDirectDraw, &similarDesc, &similarSurface.front, nullptr);
if (FAILED(result))
{
LOG_ONCE("Failed to create a front surface for mirroring");
LOG_ONCE("Failed to create a similar front surface");
similarSurface.front = nullptr;
return similarSurface;
}
@ -217,7 +226,7 @@ namespace
g_mirrorDirectDraw, &similarDesc, &similarSurface.back, nullptr);
if (FAILED(result))
{
LOG_ONCE("Failed to create a back surface for mirroring");
LOG_ONCE("Failed to create a similar back surface");
origVtable.Release(similarSurface.front);
similarSurface.front = nullptr;
return similarSurface;