Skip to content

Commit

Permalink
[WIN32SS] Introduce the NATIVE_REACTX define and disable some Dx calls
Browse files Browse the repository at this point in the history
The code itself isn't wrong but we're entirely missing the logic needed
to make it work. This leads to spontaneous crashes with video drivers and
various unity games.
  • Loading branch information
DarkFire01 committed Nov 21, 2023
1 parent edaeef9 commit 47c8e0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions win32ss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set(USE_DIBLIB FALSE)
# Give WIN32 subsystem its own project.
PROJECT(WIN32SS)

if (NATIVE_REACTX)
add_definitions(-DNATIVE_REACTX)
endif()

add_subdirectory(drivers)

if(USE_DIBLIB)
Expand Down
21 changes: 16 additions & 5 deletions win32ss/gdi/eng/pdevobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ PDEVOBJ_pSurface(
return ppdev->pSurface;
}

#ifdef NATIVE_REACTX
BOOL
PDEVOBJ_bEnableDirectDraw(
_Inout_ PPDEVOBJ ppdev)
Expand Down Expand Up @@ -385,6 +386,7 @@ PDEVOBJ_vSwitchDirectDraw(
TRACE("DxDdDynamicModeChange(ppdev %p, ppdev2 %p)\n", ppdev, ppdev2);
pfnDdDynamicModeChange((HDEV)ppdev, (HDEV)ppdev2, 0);
}
#endif

VOID
PDEVOBJ_vEnableDisplay(
Expand Down Expand Up @@ -415,7 +417,9 @@ PDEVOBJ_bDisableDisplay(
if (ppdev->flFlags & PDEV_DISABLED)
return TRUE;

#ifdef NATIVE_REACTX
PDEVOBJ_vSuspendDirectDraw(ppdev);
#endif

TRACE("DrvAssertMode(dhpdev %p, FALSE)\n", ppdev->dhpdev);
assertVal = ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE);
Expand Down Expand Up @@ -600,6 +604,7 @@ PDEVOBJ_Create(
return NULL;
}

#ifdef NATIVE_REACTX
/* Enable DirectDraw */
if (!PDEVOBJ_bEnableDirectDraw(ppdev))
{
Expand All @@ -608,6 +613,7 @@ PDEVOBJ_Create(
EngUnloadImage(pldev);
return NULL;
}
#endif

/* Remove some acceleration capabilities from driver */
PDEVOBJ_vFilterDriverHooks(ppdev);
Expand Down Expand Up @@ -692,8 +698,10 @@ PDEVOBJ_bDynamicModeChange(
ppdev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
ppdev2->pfn.CompletePDEV(ppdev2->dhpdev, (HDEV)ppdev2);

#ifdef NATIVE_REACTX
/* Switch DirectDraw mode */
PDEVOBJ_vSwitchDirectDraw(ppdev, ppdev2);
#endif

return TRUE;
}
Expand Down Expand Up @@ -724,8 +732,10 @@ PDEVOBJ_bSwitchMode(
if (!PDEVOBJ_bDisableDisplay(ppdev))
{
DPRINT1("PDEVOBJ_bDisableDisplay() failed\n");
#ifdef NATIVE_REACTX
/* Resume DirectDraw in case of failure */
PDEVOBJ_vResumeDirectDraw(ppdev);
#endif
goto leave;
}

Expand All @@ -745,11 +755,11 @@ PDEVOBJ_bSwitchMode(
PDEVOBJ_vRelease(ppdevTmp);
goto leave2;
}

#ifdef NATIVE_REACTX
/* 4. Temporarily suspend DirectDraw for mode change */
PDEVOBJ_vSuspendDirectDraw(ppdev);
PDEVOBJ_vSuspendDirectDraw(ppdevTmp);

#endif
/* 5. Switch the PDEVs */
if (!PDEVOBJ_bDynamicModeChange(ppdev, ppdevTmp))
{
Expand All @@ -758,17 +768,18 @@ PDEVOBJ_bSwitchMode(
goto leave2;
}

#ifdef NATIVE_REACTX
/* 6. Resume DirectDraw */
PDEVOBJ_vResumeDirectDraw(ppdev);
PDEVOBJ_vResumeDirectDraw(ppdevTmp);

#endif
/* Release temp PDEV */
PDEVOBJ_vRelease(ppdevTmp);

#ifdef NATIVE_REACTX
/* Re-initialize DirectDraw data */
ppdev->pEDDgpl->hDev = (HDEV)ppdev;
ppdev->pEDDgpl->dhpdev = ppdev->dhpdev;

#endif
/* Update primary display capabilities */
if (ppdev == gpmdev->ppdevGlobal)
{
Expand Down

0 comments on commit 47c8e0b

Please sign in to comment.