[WIN32SS][ENG][NTDDRAW] Manage DirectDraw instances when switching display mode (#4519)

CORE-17932

[ENG] Implement DirectDraw management in switch display mode functions
(e.g. resolution change, color depth, display frequency etc.):

- Switch DirectDraw instances between the two PDEVs (the current one and
  the new one allocated by ourselves) by calling dxg!DxDdDynamicModeChange
  function.

- Suspend them before and resume after the display mode switch, by calling
  dxg!DxDdsuspendDirectDraw and dxg!DxDdResumeDirectDraw appropriately.

We currently don't have these functions implemented, but MS DXG has, so
it allows to properly manage DirectDraw PDEVs using this driver, similarly
to Windows.
My analysis confirms that these functions are always called in XP/2k3 on
display mode switch, even when there is no any DirectX app running at the
moment. Analyzing their prototypes show that my guesses are correct.

- Initialize hDev and dhpdev members for EDD_DIRECTDRAW_GLOBAL for newly
  created surfaces, switch them during mode change and re-initialize after
  it also. They are commonly used by DirectDraw stack.
  In addition, enable DirectDraw for old and new PDEVs, by calling
  dxg!DxDdEnableDirectDraw function.


[NTDDRAW] Additionally, fix usage of DirectDraw lock count in the PDEVOBJ
structure.

- Enable cDirectDrawDisableLocks member for storing its value, instead of
  DxDd_nCount, which is marked as ROS-specific.

- Use it in win32k!DxEngGet/SetHdevData for getting/setting DirectDraw
  count appropriately.

My analysis also shows that in Windows, the PDEVOBJ::cDirectDrawDisableLocks
method calls DxEngGetHdevData with type 8, which corresponds to our DxDd_nCount.
So there are no doubts that this member is used there.

- Rename DxEngGetHdevData_dd_count alias of type 8 to DxEngGetHdevData_dd_locks,
  to match more accurately an actual member name. Update the enumeration
  and fix all code parts appropriately.

All these changes allow to properly change display mode during executing
DirectDraw applications, when they try to switch in full-screen mode.
At least a bugcheck that happened before my changes, does no longer appear.

There are still some games that don't run correctly, as if there is no
3D acceleration (which actually exists). This requires further investigations.
This commit is contained in:
Oleg Dubinskiy 2023-06-21 18:00:24 +02:00 committed by GitHub
parent 3fa613b9da
commit e034377b51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 16 deletions

View file

@ -324,9 +324,9 @@ DxEngGetHdevData(HDEV hDev,
DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_eddg\n");
retVal = (DWORD_PTR) PDev->pEDDgpl;
break;
case DxEGShDevData_dd_nCount:
DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dd_nCount\n");
retVal = (DWORD_PTR) PDev->DxDd_nCount;
case DxEGShDevData_dd_locks:
DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dd_locks\n");
retVal = (DWORD_PTR) PDev->cDirectDrawDisableLocks;
break;
case DxEGShDevData_dd_flags:
DPRINT1("requested DXEGSHDEVDATA DxEGShDevData_dd_flags\n");
@ -413,9 +413,10 @@ DxEngSetHdevData(HDEV hDev,
DPRINT1("ReactX Calling : DxEngSetHdevData DXEGSHDEVDATA : %ld\n", Type);
if ( Type == DxEGShDevData_dd_nCount )
if (Type == DxEGShDevData_dd_locks)
{
((PPDEVOBJ)hDev)->DxDd_nCount = Data;
DPRINT1("Assigning value %d\n", Data);
((PPDEVOBJ)hDev)->cDirectDrawDisableLocks = Data;
retVal = TRUE; // Set
}
return retVal;

View file

@ -108,6 +108,11 @@ typedef VOID (APIENTRY *PGD_ENGFREEPRIVATEUSERMEM)(PDD_SURFACE_LOCAL, PVOID);
typedef PDD_SURFACE_LOCAL (APIENTRY *PGD_ENGLOCKDIRECTDRAWSURFACE)(HANDLE);
typedef BOOL (APIENTRY *PGD_ENGUNLOCKDIRECTDRAWSURFACE)(PDD_SURFACE_LOCAL);
/* Other internal functions */
typedef VOID (APIENTRY *PGD_DXDDDYNAMICMODECHANGE)(HDEV, HDEV, ULONG_PTR);
typedef VOID (APIENTRY *PGD_DXDDRESUMEDIRECTDRAW)(HDEV, ULONG_PTR);
typedef VOID (APIENTRY *PGD_DXDDSUSPENDDIRECTDRAW)(HDEV, ULONG_PTR);
/* Gammaramp internal prototype */
BOOL FASTCALL IntGetDeviceGammaRamp(HDEV hPDev, PGAMMARAMP Ramp);
BOOL FASTCALL IntSetDeviceGammaRamp(HDEV hPDev, PGAMMARAMP Ramp, BOOL);