* Added stubs for IDirect3DTexture9 methods
* Implemented IDirect3DTexture9::GetDevice()
* Moved device locking to the D3D9BaseObject instead of in each child object

svn path=/trunk/; revision=36370
This commit is contained in:
Gregor Brunmar 2008-09-21 12:25:38 +00:00
parent a63c53bdac
commit 82d36803fa
8 changed files with 329 additions and 26 deletions

View file

@ -66,7 +66,7 @@ HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9**
{
if (pBaseObject->pUnknown)
{
return pBaseObject->pUnknown->lpVtbl->QueryInterface((IUnknown*) &pBaseObject->pUnknown->lpVtbl, &IID_IDirect3DDevice9, (void**)ppDevice);
return IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)ppDevice);
}
return E_NOINTERFACE;
@ -74,10 +74,15 @@ HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9**
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, DIRECT3DDEVICE9_INT** ppDevice)
{
if (NULL == ppDevice)
return D3DERR_INVALIDCALL;
*ppDevice = NULL;
if (pBaseObject->pUnknown)
{
LPDIRECT3DDEVICE9 pDevice;
if (FAILED(pBaseObject->pUnknown->lpVtbl->QueryInterface((IUnknown*) &pBaseObject->pUnknown->lpVtbl, &IID_IDirect3DDevice9, (void**)&pDevice)))
if (FAILED(IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)&pDevice)))
return E_NOINTERFACE;
*ppDevice = IDirect3DDevice9ToImpl(pDevice);
@ -86,3 +91,23 @@ HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, DIRECT3DDEVICE9
return E_NOINTERFACE;
}
VOID D3D9BaseObject_LockDevice(D3D9BaseObject* pBaseObject)
{
DIRECT3DDEVICE9_INT* pDevice;
if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice)))
return;
if (pDevice->bLockDevice)
EnterCriticalSection(&pDevice->CriticalSection);
}
VOID D3D9BaseObject_UnlockDevice(D3D9BaseObject* pBaseObject)
{
DIRECT3DDEVICE9_INT* pDevice;
if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice)))
return;
if (pDevice->bLockDevice)
LeaveCriticalSection(&pDevice->CriticalSection);
}

View file

@ -44,5 +44,7 @@ ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject);
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject);
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9** ppDevice);
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, struct _Direct3DDevice9_INT** ppDevice);
VOID D3D9BaseObject_LockDevice(D3D9BaseObject* pBaseObject);
VOID D3D9BaseObject_UnlockDevice(D3D9BaseObject* pBaseObject);
#endif // _D3D9_BASEOBJECT_H_

View file

@ -15,7 +15,7 @@
#define LOCK_D3DDEVICE9() if (This->bLockDevice) EnterCriticalSection(&This->CriticalSection);
#define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
/* Convert a IDirect3D9 pointer safely to the internal implementation struct */
/* Convert a IDirect3DDevice9 pointer safely to the internal implementation struct */
LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
{
if (NULL == iface)

View file

@ -8,10 +8,252 @@
#include "d3d9_mipmap.h"
#include "debug.h"
#include "d3d9_device.h"
#include "d3d9_helpers.h"
#include <d3d9.h>
HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT* pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture)
#define LOCK_D3DDEVICE9() D3D9BaseObject_LockDevice(&This->BaseTexture.BaseResource.BaseObject)
#define UNLOCK_D3DDEVICE9() D3D9BaseObject_UnlockDevice(&This->BaseTexture.BaseResource.BaseObject)
/* Convert a IDirect3DTexture9 pointer safely to the internal implementation struct */
LPD3D9MIPMAP IDirect3DTexture9ToImpl(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED;
if (NULL == iface)
return NULL;
return (LPD3D9MIPMAP)((ULONG_PTR)iface - FIELD_OFFSET(D3D9MipMap, lpVtbl));
}
/* IUnknown */
static HRESULT WINAPI D3D9MipMap_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, void** ppvObject)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDirect3DTexture9) ||
IsEqualGUID(riid, &IID_IDirect3DBaseTexture9) ||
IsEqualGUID(riid, &IID_IDirect3DResource9))
{
IUnknown_AddRef(iface);
*ppvObject = &This->lpVtbl;
return D3D_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
ULONG WINAPI D3D9MipMap_AddRef(LPDIRECT3DTEXTURE9 iface)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
return D3D9BaseObject_AddRef(&This->BaseTexture.BaseResource.BaseObject);
}
ULONG WINAPI D3D9MipMap_Release(LPDIRECT3DTEXTURE9 iface)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
return D3D9BaseObject_Release(&This->BaseTexture.BaseResource.BaseObject);
}
/* IDirect3DBaseTexture9 */
/*++
* @name IDirect3DTexture9::GetDevice
* @implemented
*
* The function D3D9MipMap_GetDevice sets the ppDevice argument
* to the device connected to create the swap chain.
*
* @param LPDIRECT3DTEXTURE9 iface
* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture()
*
* @param IDirect3DDevice9** ppDevice
* Pointer to a IDirect3DDevice9* structure to be set to the device object.
*
* @return HRESULT
* If the method successfully sets the ppDevice value, the return value is D3D_OK.
* If ppDevice is a bad pointer the return value will be D3DERR_INVALIDCALL.
* If the texture didn't contain any device, the return value will be D3DERR_INVALIDDEVICE.
*
*/HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
if (NULL == ppDevice)
{
DPRINT1("Invalid ppDevice parameter specified");
UNLOCK_D3DDEVICE9();
return D3DERR_INVALIDCALL;
}
if (FAILED(D3D9BaseObject_GetDevice(&This->BaseTexture.BaseResource.BaseObject, ppDevice)))
{
DPRINT1("Invalid This parameter speficied");
UNLOCK_D3DDEVICE9();
return D3DERR_INVALIDDEVICE;
}
UNLOCK_D3DDEVICE9();
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid)
{
UNIMPLEMENTED
return D3D_OK;
}
DWORD WINAPI D3D9MipMap_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew)
{
UNIMPLEMENTED
return 0;
}
DWORD WINAPI D3D9MipMap_GetPriority(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return 0;
}
void WINAPI D3D9MipMap_PreLoad(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
}
D3DRESOURCETYPE WINAPI D3D9MipMap_GetType(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return D3DRTYPE_TEXTURE;
}
DWORD WINAPI D3D9MipMap_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew)
{
UNIMPLEMENTED
return 0;
}
DWORD WINAPI D3D9MipMap_GetLOD(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return 0;
}
DWORD WINAPI D3D9MipMap_GetLevelCount(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return 0;
}
HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType)
{
UNIMPLEMENTED
return D3D_OK;
}
D3DTEXTUREFILTERTYPE WINAPI D3D9MipMap_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return D3DRTYPE_TEXTURE;
}
void WINAPI D3D9MipMap_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
}
/* IDirect3DTexture9 */
HRESULT WINAPI D3D9MipMap_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level)
{
UNIMPLEMENTED
return D3D_OK;
}
HRESULT WINAPI D3D9MipMap_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect)
{
UNIMPLEMENTED
return D3D_OK;
}
#if !defined(__cplusplus) || defined(CINTERFACE)
static IDirect3DTexture9Vtbl D3D9MipMap_Vtbl =
{
/* IUnknown methods */
D3D9MipMap_QueryInterface,
D3D9MipMap_AddRef,
D3D9MipMap_Release,
/* IDirect3DBaseTexture9 methods */
D3D9MipMap_GetDevice,
D3D9MipMap_SetPrivateData,
D3D9MipMap_GetPrivateData,
D3D9MipMap_FreePrivateData,
D3D9MipMap_SetPriority,
D3D9MipMap_GetPriority,
D3D9MipMap_PreLoad,
D3D9MipMap_GetType,
D3D9MipMap_SetLOD,
D3D9MipMap_GetLOD,
D3D9MipMap_GetLevelCount,
D3D9MipMap_SetAutoGenFilterType,
D3D9MipMap_GetAutoGenFilterType,
D3D9MipMap_GenerateMipSubLevels,
/* IDirect3DTexture9 methods */
D3D9MipMap_GetLevelDesc,
D3D9MipMap_GetSurfaceLevel,
D3D9MipMap_LockRect,
D3D9MipMap_UnlockRect,
D3D9MipMap_AddDirtyRect,
};
#endif // !defined(__cplusplus) || defined(CINTERFACE)
HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT* pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture)
{
LPD3D9MIPMAP pThisTexture;
if (FAILED(AlignedAlloc((LPVOID*)&pThisTexture, sizeof(D3D9MipMap))))
{
DPRINT1("Could not create D3D9MipMap");
return E_OUTOFMEMORY;
}
pThisTexture->lpVtbl = &D3D9MipMap_Vtbl;
pThisTexture->dwWidth = Width;
pThisTexture->dwHeight = Height;
pThisTexture->Format = Format;
*ppTexture = (IDirect3DTexture9*)pThisTexture->lpVtbl;
UNIMPLEMENTED;
return D3D_OK;
}

View file

@ -14,12 +14,46 @@ struct _Direct3DDevice9_INT;
typedef struct _D3D9MipMap
{
/* 0x0000 */ D3D9Texture BaseTexture;
/* 0x0068 */ DWORD dwUnknown68;
/* 0x0000 */ Direct3DBaseTexture9_INT BaseTexture;
/* 0x0060 */ struct IDirect3DTexture9Vtbl* lpVtbl;
/* 0x0064 */ LPDWORD dwUnknown64;
/* 0x0068 */ D3DFORMAT Format;
/* 0x006c */ DWORD dwUnknown6c;
/* 0x0070 */ DWORD dwUnknown70;
/* 0x0074 */ DWORD dwUnknown74;
} D3D9MipMap;
/* 0x0078 */ DWORD dwUnknown78;
/* 0x007c */ DWORD dwUnknown7c;
/* 0x0080 */ DWORD dwWidth;
/* 0x0084 */ DWORD dwHeight;
/* 0x0088 */ DWORD dwUnknown88;
/* 0x008c */ DWORD dwUnknown8c;
/* 0x0090 */ DWORD dwUnknown90;
/* 0x0094 */ DWORD dwUnknown94;
/* 0x0098 */ DWORD dwUnknown98;
/* 0x009c */ DWORD dwUnknown9c;
/* 0x00a0 */ DWORD dwUnknowna0;
/* 0x00a4 */ DWORD dwUnknowna4;
/* 0x00a8 */ DWORD dwUnknowna8;
/* 0x00ac */ DWORD dwUnknownac;
/* 0x00b0 */ DWORD dwUnknownb0;
/* 0x00b4 */ DWORD dwUnknownb4;
/* 0x00b8 */ DWORD dwUnknownb8;
/* 0x00bc */ DWORD dwUnknownbc;
/* 0x00c0 */ DWORD dwUnknownc0;
/* 0x00c4 */ DWORD dwUnknownc4;
/* 0x00c8 */ DWORD dwUnknownc8;
/* 0x00cc */ DWORD dwUnknowncc;
/* 0x00d0 */ DWORD dwUnknownd0;
/* 0x00d4 */ DWORD dwUnknownd4;
/* 0x00d8 */ DWORD dwUnknownd8;
/* 0x00dc */ DWORD dwUnknowndc;
/* 0x00e0 */ DWORD dwUnknowne0;
/* 0x00e4 */ DWORD dwUnknowne4;
/* 0x00e8 */ DWORD dwUnknowne8;
/* 0x00ec */ DWORD dwUnknownec;
/* 0x00f0 */ DWORD dwUnknownf0;
/* 0x00f4 */ DWORD dwUnknownf4;
} D3D9MipMap, FAR* LPD3D9MIPMAP;
HRESULT CreateD3D9MipMap(struct _Direct3DDevice9_INT* pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture);

View file

@ -10,7 +10,7 @@
#include "d3d9_baseobject.h"
typedef struct _D3D9Resource
typedef struct _Direct3DResource9_INT
{
/* 0x0000 */ D3D9BaseObject BaseObject;
/* 0x0020 */ DWORD dwUnknown20;
@ -19,9 +19,11 @@ typedef struct _D3D9Resource
/* 0x002c */ DWORD dwUnknown2c;
/* 0x0030 */ DWORD dwUnknown30;
/* 0x0034 */ DWORD dwUnknown34;
/* 0x0038 */ DWORD dwUnknown38;
/* 0x0038 */ D3DPOOL Pool;
/* 0x003c */ DWORD dwUnknown3c;
/* 0x0040 */ DWORD dwUnknown40;
} D3D9Resource;
/* 0x0040 */ LPDWORD dwUnknown40;
} Direct3DResource9_INT;
#endif // _D3D9_RESOURCE_H_

View file

@ -14,10 +14,8 @@
#include "d3d9_device.h"
#include "d3d9_cursor.h"
#define LOCK_D3DDEVICE9() if (This->BaseObject.pUnknown && ((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->bLockDevice) \
EnterCriticalSection(&((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->CriticalSection);
#define UNLOCK_D3DDEVICE9() if (This->BaseObject.pUnknown && ((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->bLockDevice) \
LeaveCriticalSection(&((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->CriticalSection);
#define LOCK_D3DDEVICE9() D3D9BaseObject_LockDevice(&This->BaseObject)
#define UNLOCK_D3DDEVICE9() D3D9BaseObject_UnlockDevice(&This->BaseObject)
/* Convert a IDirect3DSwapChain9 pointer safely to the internal implementation struct */
static LPDIRECT3DSWAPCHAIN9_INT IDirect3DSwapChain9ToImpl(LPDIRECT3DSWAPCHAIN9 iface)

View file

@ -10,18 +10,18 @@
#include "d3d9_resource.h"
typedef struct _D3D9Texture
typedef struct _Direct3DBaseTexture9_INT
{
/* 0x0000 */ D3D9Resource BaseResource;
/* 0x0044 */ DWORD dwUnknown44;
/* 0x0048 */ DWORD dwUnknown48;
/* 0x0000 */ struct IDirect3DBaseTexture9Vtbl* lpVtbl;
/* 0x0004 */ DWORD dwUnknown04;
/* 0x0008 */ Direct3DResource9_INT BaseResource;
/* 0x004c */ DWORD dwUnknown4c;
/* 0x0050 */ DWORD dwUnknown50;
/* 0x0054 */ DWORD dwUnknown54;
/* 0x0058 */ DWORD dwUnknown58;
/* 0x005c */ DWORD dwUnknown5c;
/* 0x0060 */ DWORD dwUnknown60;
/* 0x0064 */ DWORD dwUnknown64;
} D3D9Texture;
/* 0x0054 */ DWORD Usage;
/* 0x0058 */ WORD MipMapLevels;
/* 0x005a */ WORD dUnknown5a;
/* 0x005c */ WORD MipMapLevels2;
/* 0x005e */ WORD dUnknown5e;
} Direct3DBaseTexture9_INT;
#endif // _D3D9_TEXTURE_H_