diff --git a/reactos/subsystems/win32/win32k/include/intddraw.h b/reactos/subsystems/win32/win32k/include/intddraw.h index 6467700ceee..a2752d66cbb 100644 --- a/reactos/subsystems/win32/win32k/include/intddraw.h +++ b/reactos/subsystems/win32/win32k/include/intddraw.h @@ -98,6 +98,9 @@ typedef DWORD (NTAPI *PGD_DXDDGETFLIPSTATUS)(HANDLE, PDD_GETFLIPSTATUSDATA); typedef DWORD (NTAPI *PGD_DXDDUPDATEOVERLAY)(HANDLE, HANDLE, PDD_UPDATEOVERLAYDATA); typedef DWORD (NTAPI *PGD_DXDDSETOVERLAYPOSITION)(HANDLE, HANDLE, PDD_SETOVERLAYPOSITIONDATA); +/* From eng.c */ +typedef FLATPTR (NTAPI *PGD_HEAPVIDMEMALLOCALIGNED)(LPVIDMEM, DWORD, DWORD, LPSURFACEALIGNMENT, LPLONG); +typedef VOID (NTAPI *PGD_VIDMEMFREE)(LPVMEMHEAP, FLATPTR); /* Standard macro */ #define DXG_GET_INDEX_FUNCTION(INDEX, FUNCTION) \ diff --git a/reactos/subsystems/win32/win32k/ntddraw/d3d.c b/reactos/subsystems/win32/win32k/ntddraw/d3d.c index 6b3d6d8b46d..06b924c5b07 100644 --- a/reactos/subsystems/win32/win32k/ntddraw/d3d.c +++ b/reactos/subsystems/win32/win32k/ntddraw/d3d.c @@ -16,19 +16,45 @@ #include #include -/************************************************************************/ -/* NtGdiDdCanCreateD3DBuffer */ -/************************************************************************/ + +/*++ +* @name NtGdiDdCanCreateD3DBuffer +* @implemented +* +* The function NtGdiDdCanCreateD3DBuffer checks if you can create a +* surface for DirectX. It is redirected to dxg.sys. +* +* @param HANDLE hDirectDraw +* The handle we got from NtGdiDdCreateDirectDrawObject +* +* @param PDD_CANCREATESURFACEDATA puCanCreateSurfaceData +* This contains information to check if the driver can create the buffers, +* surfaces, textures and vertexes, and how many of each the driver can create. + +* +* @return +* Depending on if the driver supports this API or not, DDHAL_DRIVER_HANDLED +* or DDHAL_DRIVER_NOTHANDLED is returned. +* To check if the function has been successful, do a full check. +* A full check is done by checking if the return value is DDHAL_DRIVER_HANDLED +* and puCanCreateSurfaceData->ddRVal is set to DD_OK. +* +* @remarks. +* dxg.sys NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface call are redirect to dxg.sys +* inside the dxg.sys they ar redirect to same functions. examine the driver list functions +* table, the memory address you will see they are pointed to same memory address. +* +* Before call to this api please set the puCanCreateSurfaceData->ddRVal to a error value example DDERR_NOTUSPORTED. +* for the ddRVal will other wise be unchange if some error happen inside the driver. +* +*--*/ + DWORD STDCALL NtGdiDdCanCreateD3DBuffer(HANDLE hDirectDraw, - PDD_CANCREATESURFACEDATA puCanCreateSurfaceData -) + PDD_CANCREATESURFACEDATA puCanCreateSurfaceData) { - PGD_DDCANCREATED3DBUFFER pfnDdCanCreateD3DBuffer = NULL; - INT i; - - DXG_GET_INDEX_FUNCTION(DXG_INDEX_DxDdCanCreateD3DBuffer, pfnDdCanCreateD3DBuffer); + PGD_DXDDDESTROYD3DBUFFER pfnDdCanCreateD3DBuffer = gpDxFuncs[DXG_INDEX_DxDdCanCreateD3DBuffer].pfn; if (pfnDdCanCreateD3DBuffer == NULL) { @@ -40,9 +66,40 @@ NtGdiDdCanCreateD3DBuffer(HANDLE hDirectDraw, return pfnDdCanCreateD3DBuffer(hDirectDraw,puCanCreateSurfaceData); } -/************************************************************************/ -/* NtGdiD3dContextCreate */ -/************************************************************************/ +/*++ +* @name NtGdiD3dContextCreate +* @implemented +* +* The Function NtGdiDdCanCreateD3DBuffer check if you can create a +* surface for directx it redirect the call to dxg.sys. +* +* @param HANDLE hDirectDrawLocal +* The handle we got from NtGdiDdCreateDirectDrawObject +* +* @param HANDLE hSurfColor +* Handle to DD_SURFACE_LOCAL to be use as target rendring +* +* @param HANDLE hSurfZ +* Handle to a DD_SURFACE_LOCAL it is the Z deep buffer, accdoing MSDN if it set to NULL nothing should happen. +* +* @param D3DNTHAL_CONTEXTCREATEDATA* hSurfZ +* the buffer to create the context data +* +* @return +* DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED if the driver support this api. +* Todo full check if we sussess is to check the return value DDHAL_DRIVER_HANDLED +* puCanCreateSurfaceData->ddRVal are set to DD_OK. +* +* +* @remarks. +* dxg.sys NtGdiD3dContextCreate and NtGdiD3dContextCreate call are redirect to +* same functions in the dxg.sys. So they are working exacly same. everthing else is lying if they +* are diffent. +* +* Before call to this api please set the hSurfZ->ddRVal to a error value example DDERR_NOTUSPORTED. +* for the ddRVal will other wise be unchange if some error happen inside the driver. +* +*--*/ BOOL STDCALL NtGdiD3dContextCreate(HANDLE hDirectDrawLocal, @@ -50,15 +107,12 @@ NtGdiD3dContextCreate(HANDLE hDirectDrawLocal, HANDLE hSurfZ, D3DNTHAL_CONTEXTCREATEDATA* pdcci) { - PGD_D3DCONTEXTCREATE pfnD3dContextCreate = NULL; - INT i; - - DXG_GET_INDEX_FUNCTION(DXG_INDEX_DxD3dContextCreate, pfnD3dContextCreate); + PGD_DDCANCREATED3DBUFFER pfnD3dContextCreate = gpDxFuncs[DXG_INDEX_DxD3dContextCreate].pfn; if (pfnD3dContextCreate == NULL) { DPRINT1("Warring no pfnD3dContextCreate"); - return DDHAL_DRIVER_NOTHANDLED; + return FALSE; } DPRINT1("Calling on dxg.sys D3dContextCreate"); diff --git a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c index 7c97d49e687..ca1e436787f 100644 --- a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c +++ b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c @@ -26,16 +26,16 @@ ULONG gcEngFuncs; NTSTATUS STDCALL DxDdStartupDxGraphics( ULONG ulc1, - PDRVENABLEDATA pDrved1, + PDRVENABLEDATA DxEngDrvOld, ULONG ulc2, - PDRVENABLEDATA pDrved2, - PULONG DDContext, + PDRVENABLEDATA DxgDrvOld, + PULONG DirectDrawContext, PEPROCESS Proc) { - DRVENABLEDATA EngDrv; - DRVENABLEDATA DXG_API; + DRVENABLEDATA DxEngDrv; + DRVENABLEDATA DxgDrv; - NTSTATUS Status = STATUS_DLL_NOT_FOUND; + NTSTATUS Status = STATUS_PROCEDURE_NOT_FOUND; /* FIXME setup of gaEngFuncs driver export list * but not in this api, we can add it here tempary until we figout where @@ -51,45 +51,57 @@ DxDdStartupDxGraphics( ULONG ulc1, if (!ghDxGraphics) { DPRINT1("Warring no dxg.sys in ReactOS"); - return Status; - } - - /* import DxDdStartupDxGraphics and DxDdCleanupDxGraphics */ - gpfnStartupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdStartupDxGraphics"); - gpfnCleanupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdCleanupDxGraphics"); - - if ((gpfnStartupDxGraphics) && - (gpfnCleanupDxGraphics)) - { - /* Setup driver data for activate the dx interface */ - EngDrv.iDriverVersion = DDI_DRIVER_VERSION_NT5_01; - EngDrv.pdrvfn = &gaEngFuncs; - EngDrv.c = gcEngFuncs; - - Status = gpfnStartupDxGraphics ( sizeof(DRVENABLEDATA), - &EngDrv, - sizeof(DRVENABLEDATA), - &DXG_API, - &gdwDirectDrawContext, - Proc ); - } - - /* check if we manger loading the data and execute the dxStartupDxGraphics and it susscess */ - if (!NT_SUCCESS(Status)) - { - gpfnStartupDxGraphics = NULL; - gpfnCleanupDxGraphics = NULL; - EngUnloadImage( ghDxGraphics); - ghDxGraphics = NULL; - DPRINT1("Warring no init of DirectX graphic interface"); + Status = STATUS_DLL_NOT_FOUND; } else { - gpDxFuncs = DXG_API.pdrvfn; - DPRINT1("DirectX interface is Activated"); + /* import DxDdStartupDxGraphics and DxDdCleanupDxGraphics */ + gpfnStartupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdStartupDxGraphics"); + gpfnCleanupDxGraphics = EngFindImageProcAddress(ghDxGraphics,"DxDdCleanupDxGraphics"); + + if ((gpfnStartupDxGraphics) && + (gpfnCleanupDxGraphics)) + { + /* Setup driver data for activate the dx interface */ + DxEngDrv.iDriverVersion = DDI_DRIVER_VERSION_NT5_01; + DxEngDrv.pdrvfn = &gaEngFuncs; + DxEngDrv.c = gcEngFuncs; + + Status = gpfnStartupDxGraphics ( sizeof(DRVENABLEDATA), + &DxEngDrv, + sizeof(DRVENABLEDATA), + &DxgDrv, + &gdwDirectDrawContext, + Proc ); + } + + /* check if we manger loading the data and execute the dxStartupDxGraphics and it susscess */ + if (!NT_SUCCESS(Status)) + { + gpfnStartupDxGraphics = NULL; + gpfnCleanupDxGraphics = NULL; + EngUnloadImage( ghDxGraphics); + ghDxGraphics = NULL; + DPRINT1("Warring no init of DirectX graphic interface"); + } + else + { + /* Sort the drv functions list in index order, this allown us doing, smaller optimze + * in api that are redirect to dx.sys + */ + + PDRVFN lstDrvFN = DxgDrv.pdrvfn; + INT t; + for (t=0;t<=DXG_INDEX_DxDdIoctl;t++) + { + gpDxFuncs[lstDrvFN[t].iFunc].iFunc =lstDrvFN[t].iFunc; + gpDxFuncs[lstDrvFN[t].iFunc].pfn =lstDrvFN[t].pfn; + } + DPRINT1("DirectX interface is Activated"); + } + /* return the status */ } - /* return the status */ return Status; } diff --git a/reactos/subsystems/win32/win32k/ntddraw/eng.c b/reactos/subsystems/win32/win32k/ntddraw/eng.c index 613ec90d8a6..d2b8cd3b060 100644 --- a/reactos/subsystems/win32/win32k/ntddraw/eng.c +++ b/reactos/subsystems/win32/win32k/ntddraw/eng.c @@ -33,7 +33,7 @@ HeapVidMemAllocAligned(LPVIDMEM lpVidMem, if (pfnHeapVidMemAllocAligned == NULL) { DPRINT1("Warring no pfnHeapVidMemAllocAligned"); - return DDHAL_DRIVER_NOTHANDLED; + return NULL; } DPRINT1("Calling on dxg.sys pfnHeapVidMemAllocAligned"); @@ -56,11 +56,12 @@ VidMemFree(LPVMEMHEAP pvmh, if (pfnVidMemFree == NULL) { DPRINT1("Warring no pfnVidMemFree"); - return DDHAL_DRIVER_NOTHANDLED; } - - DPRINT1("Calling on dxg.sys pfnVidMemFree"); - return pfnVidMemFree(pvmh, ptr); + else + { + DPRINT1("Calling on dxg.sys pfnVidMemFree"); + pfnVidMemFree(pvmh, ptr); + } } /************************************************************************/