Reactos

[WIN32SS][NTDDRAW] Don't startup DirectX graphics each time on DirectDraw object creation (#5329)

CORE-17561, CORE-17932, CORE-18221

Do it at each system startup instead: Remove old DirectX initialization code.
It's now outdated and not needed anymore.

Previously, the corresponding hackish intEnableReactXDriver() function
did two things: load dxg.sys and enable DirectDraw.
Now loading DirectX graphics is done during WINSRV initialization, and
enabling DirectDraw is called during each (and also first) display mode
switch, as in Windows. As debug analysis proves, there are no any other
calls in NtGdiDdCreateDirectDrawObject, besides the corresponding DXG
function.

authored by

Oleg Dubinskiy and committed by
GitHub
e7ccb36b e034377b

-90
-89
win32ss/reactx/ntddraw/ddraw.c
··· 27 27 #define DXDBG 1 28 28 29 29 /************************************************************************/ 30 - /* DirectX graphic/video driver enable start here */ 31 - /************************************************************************/ 32 - BOOL 33 - intEnableReactXDriver(HDC hdc) 34 - { 35 - NTSTATUS Status; 36 - PEPROCESS Proc = NULL; 37 - PDC pDC = NULL; 38 - PPDEVOBJ pDev = NULL; 39 - PGD_DXDDENABLEDIRECTDRAW pfnDdEnableDirectDraw = NULL; 40 - BOOL success = FALSE; 41 - 42 - /* FIXME: Get the process data */ 43 - 44 - /* Do not try load dxg.sys when it have already been load once */ 45 - if (gpfnStartupDxGraphics == NULL) 46 - { 47 - Status = DxDdStartupDxGraphics(0,NULL,0,NULL,NULL, Proc); 48 - if (!NT_SUCCESS(Status)) 49 - { 50 - DPRINT1("Warning: Failed to create the directx interface\n"); 51 - return FALSE; 52 - } 53 - } 54 - 55 - pDC = DC_LockDc(hdc); 56 - if (pDC == NULL) 57 - { 58 - DPRINT1("Warning: Failed to lock hdc\n"); 59 - return FALSE; 60 - } 61 - 62 - pDev = pDC->ppdev; 63 - 64 - /* Test and see if drv got a DX interface or not */ 65 - if ( ( pDev->DriverFunctions.DisableDirectDraw == NULL) || 66 - ( pDev->DriverFunctions.EnableDirectDraw == NULL)) 67 - { 68 - DPRINT1("Warning : DisableDirectDraw and EnableDirectDraw are NULL, no dx driver \n"); 69 - } 70 - else 71 - { 72 - 73 - /* Check and see if DX has been enabled or not */ 74 - if ( pDev->pEDDgpl->pvmList == NULL) 75 - { 76 - pDev->pEDDgpl->ddCallbacks.dwSize = sizeof(DD_CALLBACKS); 77 - pDev->pEDDgpl->ddSurfaceCallbacks.dwSize = sizeof(DD_SURFACECALLBACKS); 78 - pDev->pEDDgpl->ddPaletteCallbacks.dwSize = sizeof(DD_PALETTECALLBACKS); 79 - 80 - pfnDdEnableDirectDraw = (PGD_DXDDENABLEDIRECTDRAW)gpDxFuncs[DXG_INDEX_DxDdEnableDirectDraw].pfn; 81 - if (pfnDdEnableDirectDraw == NULL) 82 - { 83 - DPRINT1("Warning: no pfnDdEnableDirectDraw\n"); 84 - } 85 - else 86 - { 87 - DPRINT1(" call to pfnDdEnableDirectDraw \n "); 88 - 89 - /* Note: it is the hdev struct it wants, not the drv hPDev aka pdc->PDev */ 90 - success = pfnDdEnableDirectDraw(pDC->ppdev, TRUE); 91 - } 92 - } 93 - else 94 - { 95 - DPRINT1(" The dxg.sys and graphic card driver interface is enabled \n "); 96 - success = TRUE; 97 - } 98 - } 99 - 100 - 101 - DPRINT1("Return value : 0x%08x\n",success); 102 - DC_UnlockDc(pDC); 103 - DPRINT1(" end call to pfnDdEnableDirectDraw \n "); 104 - return success; 105 - } 106 - 107 - /************************************************************************/ 108 - /* DirectX graphic/video driver enable ends here */ 109 - /************************************************************************/ 110 - 111 - /************************************************************************/ 112 30 /* DirectX graphic/video driver loading and cleanup starts here */ 113 31 /************************************************************************/ 114 32 NTSTATUS ··· 217 135 { 218 136 DPRINT1("Warning: hdc is NULL\n"); 219 137 return 0; 220 - } 221 - 222 - /* FIXME: This should be alloc for each drv and use it from each drv, not global for whole win32k */ 223 - if (intEnableReactXDriver(hdc) == FALSE) 224 - { 225 - DPRINT1("Warning: Failed to start the DirectX interface from the graphic driver\n"); 226 - return DDHAL_DRIVER_NOTHANDLED; 227 138 } 228 139 229 140 /* Get the pfnDdCreateDirectDrawObject after we load the drv */
-1
win32ss/reactx/ntddraw/intddraw.h
··· 8 8 #include <reactos/drivers/directx/dxeng.h> 9 9 10 10 /* From ddraw.c */ 11 - BOOL intEnableReactXDriver(HDC); 12 11 NTSTATUS APIENTRY DxDdStartupDxGraphics(ULONG, PDRVENABLEDATA, ULONG, PDRVENABLEDATA, PULONG, PEPROCESS); 13 12 extern DRVFN gpDxFuncs[]; 14 13