From bc1d4f7c8cac778e3b0272cac86e5f2af6964263 Mon Sep 17 00:00:00 2001 From: Gregor Brunmar Date: Mon, 5 May 2008 16:49:13 +0000 Subject: [PATCH] Implemented IDirect3DDevice9::GetAvailableTextureMem() svn path=/trunk/; revision=33299 --- reactos/dll/directx/d3d9/d3d9_device.c | 36 +++++++++++++++++++++++-- reactos/dll/directx/d3d9/d3d9_private.h | 3 ++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/reactos/dll/directx/d3d9/d3d9_device.c b/reactos/dll/directx/d3d9/d3d9_device.c index 599be8099b4..57ed64224c0 100644 --- a/reactos/dll/directx/d3d9/d3d9_device.c +++ b/reactos/dll/directx/d3d9/d3d9_device.c @@ -70,11 +70,43 @@ static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE return D3D_OK; } +/*++ +* @name IDirect3DDevice9::GetAvailableTextureMem +* @implemented +* +* The function IDirect3DDevice9Impl_GetAvailableTextureMem returns a pointer to the IDirect3D9 object +* that created this device. +* +* @param LPDIRECT3D iface +* Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice() +* +* @return UINT +* The method returns an estimated the currently available texture memory in bytes rounded +* to the nearest MB. Applications should NOT use this as an exact number. +* +*/ static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface) { - UNIMPLEMENTED + UINT AvailableTextureMemory = 0; + DD_GETAVAILDRIVERMEMORYDATA ddGetAvailDriverMemoryData; - return D3D_OK; + LPDIRECT3DDEVICE9_INT This = impl_from_IDirect3DDevice9(iface); + LOCK_D3DDEVICE9(); + + memset(&ddGetAvailDriverMemoryData, 0, sizeof(ddGetAvailDriverMemoryData)); + ddGetAvailDriverMemoryData.lpDD = (PDD_DIRECTDRAW_GLOBAL)&This->DeviceData[0].pUnknown6BC->hDD; + + if (DDHAL_DRIVER_HANDLED == (*This->DeviceData[0].D3D9Callbacks.DdGetAvailDriverMemory)(&ddGetAvailDriverMemoryData)) + { + if (DD_OK == ddGetAvailDriverMemoryData.ddRVal) + { + /* Round it up to the nearest MB */ + AvailableTextureMemory = (ddGetAvailDriverMemoryData.dwFree + 0x80000) & 0xFFF00000; + } + } + + UNLOCK_D3DDEVICE9(); + return AvailableTextureMemory; } static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface) diff --git a/reactos/dll/directx/d3d9/d3d9_private.h b/reactos/dll/directx/d3d9/d3d9_private.h index 5c5699d7835..3d98d6c9d6f 100644 --- a/reactos/dll/directx/d3d9/d3d9_private.h +++ b/reactos/dll/directx/d3d9/d3d9_private.h @@ -10,6 +10,7 @@ #include #include +#include #define D3D9_INT_MAX_NUM_ADAPTERS 12 @@ -107,7 +108,7 @@ typedef struct _tagD3D9_CALLBACKS /* 0x0044 */ DWORD DdFlip; /* 0x0048 */ DWORD DdGetBltStatus; /* 0x004c */ DWORD DdGetFlipStatus; -/* 0x0050 */ DWORD DdGetAvailDriverMemory; +/* 0x0050 */ PDD_GETAVAILDRIVERMEMORY DdGetAvailDriverMemory; /* 0x0054 */ DWORD unknown0115; /* 0x0058 */ DWORD DdSetMode; /* 0x005c */ DWORD DdSetExclusiveMode;