xref: /reactos/dll/directx/d3d9/d3d9_callbacks.c (revision 50cf16b3)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS ReactX
4  * FILE:            dll/directx/d3d9/d3d9_callbacks.c
5  * PURPOSE:         Direct3D9's callback functions
6  * PROGRAMERS:      Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
7  */
8 #include "d3d9_common.h"
9 #include "d3d9_callbacks.h"
10 #include <d3d9.h>
11 #include <dll/directx/d3d8thk.h>
12 #include "d3d9_private.h"
13 #include "ddrawi.h"
14 
15 DWORD WINAPI D3d9GetAvailDriverMemory(LPD3D9_GETAVAILDRIVERMEMORYDATA pData)
16 {
17     DWORD Ret = FALSE;
18     DDHAL_GETAVAILDRIVERMEMORYDATA Data;
19     ZeroMemory(&Data, sizeof(Data));
20 
21     if (D3D9_GETAVAILDRIVERMEMORY_TYPE_ALL == pData->dwMemoryType)
22     {
23         Data.DDSCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
24     }
25     else if (D3D9_GETAVAILDRIVERMEMORY_TYPE_LOCAL == pData->dwMemoryType)
26     {
27         Data.DDSCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
28     }
29     else if (D3D9_GETAVAILDRIVERMEMORY_TYPE_NONLOCAL == pData->dwMemoryType)
30     {
31         Data.DDSCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM;
32     }
33 
34     if (Data.DDSCaps.dwCaps != 0)
35     {
36         if (0 == pData->dwTextureType)
37             Data.DDSCaps.dwCaps |= DDSCAPS_TEXTURE;
38 
39         if (pData->dwTextureType & D3D9_TEXTURETYPE_HALSURFACE)
40             Data.DDSCaps.dwCaps |= DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE;
41 
42         if (pData->dwTextureType & D3D9_TEXTURETYPE_BACKBUFFER)
43             Data.DDSCaps.dwCaps |= DDSCAPS_ZBUFFER;
44 
45         Ret = OsThunkDdGetAvailDriverMemory(pData->pUnknown6BC->hDirectDrawLocal, (DD_GETAVAILDRIVERMEMORYDATA*)&Data);
46         pData->dwFree = Data.dwFree;
47     }
48 
49     return Ret;
50 }
51