[WIN32SS] Handle Graphics acceleration level (registry key Acceleration.Level)

- store the acceleration level in PDEVOBJ
- when searching a pdev, search a pdev with required acceleration level
- disable some functions when not at full acceleration level
  (levels 3 and 5 are not implemented)
This commit is contained in:
Hervé Poussineau 2022-03-20 18:03:43 +01:00 committed by hpoussin
parent 494de7c2df
commit c89ac107ce
3 changed files with 69 additions and 3 deletions

View file

@ -64,6 +64,7 @@ MDEVOBJ_Create(
DEVMODEW dmDefault;
PDEVMODEW localPdm;
ULONG iDevNum = 0;
ULONG dwAccelerationLevel = 0;
TRACE("MDEVOBJ_Create('%wZ' '%dx%dx%d (%d Hz)')\n",
pustrDeviceName,
@ -152,13 +153,14 @@ MDEVOBJ_Create(
READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput", DM_DISPLAYFIXEDOUTPUT);
READ(dmPosition.x, "Attach.RelativeX", DM_POSITION);
READ(dmPosition.y, "Attach.RelativeY", DM_POSITION);
RegReadDWORD(hKey, L"Acceleration.Level", &dwAccelerationLevel);
ZwClose(hKey);
}
/* Get or create a PDEV for these settings */
if (LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, pdm ? pdm : &dmDefault, &localPdm, !pdm))
{
ppdev = PDEVOBJ_Create(pGraphicsDevice, localPdm, LDEV_DEVICE_DISPLAY);
ppdev = PDEVOBJ_Create(pGraphicsDevice, localPdm, dwAccelerationLevel, LDEV_DEVICE_DISPLAY);
}
else
{

View file

@ -243,6 +243,62 @@ PDEVOBJ_vCompletePDEV(
ppdev->pldev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
}
static
VOID
PDEVOBJ_vFilterDriverHooks(
_In_ PPDEVOBJ ppdev)
{
PLDEVOBJ pldev = ppdev->pldev;
ULONG dwAccelerationLevel = ppdev->dwAccelerationLevel;
if (!pldev->pGdiDriverInfo)
return;
if (pldev->ldevtype != LDEV_DEVICE_DISPLAY)
return;
if (dwAccelerationLevel >= 1)
{
ppdev->apfn[INDEX_DrvSetPointerShape] = NULL;
ppdev->apfn[INDEX_DrvCreateDeviceBitmap] = NULL;
}
if (dwAccelerationLevel >= 2)
{
/* Remove sophisticated display accelerations */
ppdev->pSurface->flags &= ~(HOOK_STRETCHBLT |
HOOK_FILLPATH |
HOOK_GRADIENTFILL |
HOOK_LINETO |
HOOK_ALPHABLEND |
HOOK_TRANSPARENTBLT);
}
if (dwAccelerationLevel >= 3)
{
/* Disable DirectDraw and Direct3D accelerations */
/* FIXME: need to call DxDdSetAccelLevel */
UNIMPLEMENTED;
}
if (dwAccelerationLevel >= 4)
{
/* Remove almost all display accelerations */
ppdev->pSurface->flags &= ~HOOK_FLAGS |
HOOK_BITBLT |
HOOK_COPYBITS |
HOOK_TEXTOUT |
HOOK_STROKEPATH |
HOOK_SYNCHRONIZE;
}
if (dwAccelerationLevel >= 5)
{
/* Disable all display accelerations */
UNIMPLEMENTED;
}
}
PSURFACE
NTAPI
PDEVOBJ_pSurface(
@ -354,6 +410,7 @@ PPDEVOBJ
PDEVOBJ_Create(
_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice,
_In_opt_ PDEVMODEW pdm,
_In_ ULONG dwAccelerationLevel,
_In_ ULONG ldevtype)
{
PPDEVOBJ ppdev, ppdevMatch = NULL;
@ -375,7 +432,8 @@ PDEVOBJ_Create(
{
PDEVOBJ_vReference(ppdev);
if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)))
if (RtlEqualMemory(pdm, ppdev->pdmwDev, sizeof(DEVMODEW)) &&
ppdev->dwAccelerationLevel == dwAccelerationLevel)
{
PDEVOBJ_vReference(ppdev);
ppdevMatch = ppdev;
@ -441,6 +499,7 @@ PDEVOBJ_Create(
/* Initialize PDEV */
ppdev->pldev = pldev;
ppdev->dwAccelerationLevel = dwAccelerationLevel;
/* Call the driver to enable the PDEV */
if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
@ -467,6 +526,9 @@ PDEVOBJ_Create(
return NULL;
}
/* Remove some acceleration capabilities from driver */
PDEVOBJ_vFilterDriverHooks(ppdev);
/* Set MovePointer function */
ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
if (!ppdev->pfnMovePointer)
@ -580,7 +642,7 @@ PDEVOBJ_bSwitchMode(
}
/* 2. Create new PDEV */
ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, LDEV_DEVICE_DISPLAY);
ppdevTmp = PDEVOBJ_Create(ppdev->pGraphicsDevice, pdm, 0, LDEV_DEVICE_DISPLAY);
if (!ppdevTmp)
{
DPRINT1("Failed to create a new PDEV\n");

View file

@ -128,6 +128,7 @@ typedef struct _PDEVOBJ
PDEVMODEW pdmwDev; /* Ptr->DEVMODEW.dmSize + dmDriverExtra == alloc size. */
// DWORD Unknown3;
FLONG DxDd_Flags; /* DxDD active status flags. */
DWORD dwAccelerationLevel;
// LONG devAttr;
// PVOID WatchDogContext;
// ULONG WatchDogs;
@ -224,6 +225,7 @@ PPDEVOBJ
PDEVOBJ_Create(
_In_opt_ PGRAPHICS_DEVICE pGraphicsDevice,
_In_opt_ PDEVMODEW pdm,
_In_ ULONG dwAccelerationLevel,
_In_ ULONG ldevtype);
/* Change display settings: