mirror of
https://github.com/reactos/reactos.git
synced 2025-06-27 21:59:42 +00:00
D3D9:
* Fixed incomplete HAL device * Fixed IDirect3DSwapChain9 and D3D9BaseObject ref counting svn path=/trunk/; revision=35592
This commit is contained in:
parent
72d7445528
commit
57fad8bdc4
4 changed files with 36 additions and 16 deletions
|
@ -9,9 +9,14 @@
|
||||||
#include "d3d9_device.h"
|
#include "d3d9_device.h"
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include "d3d9_helpers.h"
|
||||||
|
|
||||||
VOID D3D9BaseObject_Destroy()
|
VOID D3D9BaseObject_Destroy(D3D9BaseObject* pBaseObject, BOOL bFreeThis)
|
||||||
{
|
{
|
||||||
|
if (bFreeThis)
|
||||||
|
{
|
||||||
|
AlignedFree((LPVOID*) pBaseObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D9BaseObjectVtbl D3D9BaseObject_Vtbl =
|
ID3D9BaseObjectVtbl D3D9BaseObject_Vtbl =
|
||||||
|
@ -22,7 +27,6 @@ ID3D9BaseObjectVtbl D3D9BaseObject_Vtbl =
|
||||||
|
|
||||||
VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice)
|
VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice)
|
||||||
{
|
{
|
||||||
// TODO: Add dtor to vtbl
|
|
||||||
pBaseObject->lpVtbl = &D3D9BaseObject_Vtbl;
|
pBaseObject->lpVtbl = &D3D9BaseObject_Vtbl;
|
||||||
pBaseObject->RefType = RefType;
|
pBaseObject->RefType = RefType;
|
||||||
pBaseObject->pBaseDevice = pBaseDevice;
|
pBaseObject->pBaseDevice = pBaseDevice;
|
||||||
|
@ -30,14 +34,30 @@ VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, stru
|
||||||
|
|
||||||
ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject)
|
ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject)
|
||||||
{
|
{
|
||||||
// TODO: Implement ref counting
|
if (pBaseObject->pBaseDevice)
|
||||||
UNIMPLEMENTED
|
{
|
||||||
return 1;
|
pBaseObject->pBaseDevice->lpVtbl->AddRef((IDirect3DDevice9*)&pBaseObject->pBaseDevice->lpVtbl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return InterlockedIncrement(&pBaseObject->lRefCnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject)
|
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject)
|
||||||
{
|
{
|
||||||
// TODO: Implement ref counting
|
ULONG Ref = 0;
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
if (pBaseObject)
|
||||||
|
{
|
||||||
|
Ref = InterlockedDecrement(&pBaseObject->lRefCnt);
|
||||||
|
|
||||||
|
if (Ref == 0)
|
||||||
|
{
|
||||||
|
if (pBaseObject->pBaseDevice)
|
||||||
|
{
|
||||||
|
pBaseObject->pBaseDevice->lpVtbl->Release((IDirect3DDevice9*)&pBaseObject->pBaseDevice->lpVtbl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ref;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@ enum REF_TYPE
|
||||||
|
|
||||||
typedef struct _D3D9BaseObjectVtbl
|
typedef struct _D3D9BaseObjectVtbl
|
||||||
{
|
{
|
||||||
VOID (*Destroy)();
|
VOID (*Destroy)(struct _D3D9BaseObject* pBaseObject, BOOL bFreeThis);
|
||||||
} ID3D9BaseObjectVtbl;
|
} ID3D9BaseObjectVtbl;
|
||||||
|
|
||||||
typedef struct _D3D9BaseObject
|
typedef struct _D3D9BaseObject
|
||||||
{
|
{
|
||||||
/* 0x0000 */ ID3D9BaseObjectVtbl* lpVtbl;
|
/* 0x0000 */ ID3D9BaseObjectVtbl* lpVtbl;
|
||||||
/* 0x0004 */ DWORD dwUnknown0004;
|
/* 0x0004 */ LONG lRefCnt;
|
||||||
/* 0x0008 */ DWORD dwUnknown0008;
|
/* 0x0008 */ DWORD dwNumUsed;
|
||||||
/* 0x000c */ struct _Direct3DDevice9_INT* pBaseDevice;
|
/* 0x000c */ struct _Direct3DDevice9_INT* pBaseDevice;
|
||||||
/* 0x0010 */ DWORD dwUnknown0010; // Index? Unique id?
|
/* 0x0010 */ DWORD dwUnknown0010; // Index? Unique id?
|
||||||
/* 0x0014 */ HANDLE hKernelHandle;
|
/* 0x0014 */ HANDLE hKernelHandle;
|
||||||
|
|
|
@ -41,15 +41,13 @@ static HRESULT WINAPI Direct3DSwapChain9_QueryInterface(LPDIRECT3DSWAPCHAIN9 ifa
|
||||||
static ULONG WINAPI Direct3DSwapChain9_AddRef(LPDIRECT3DSWAPCHAIN9 iface)
|
static ULONG WINAPI Direct3DSwapChain9_AddRef(LPDIRECT3DSWAPCHAIN9 iface)
|
||||||
{
|
{
|
||||||
LPDIRECT3DSWAPCHAIN9_INT This = IDirect3DSwapChain9ToImpl(iface);
|
LPDIRECT3DSWAPCHAIN9_INT This = IDirect3DSwapChain9ToImpl(iface);
|
||||||
D3D9BaseObject* BaseObject = (D3D9BaseObject*)((ULONG_PTR)This - FIELD_OFFSET(Direct3DSwapChain9_INT, lpVtbl) - FIELD_OFFSET(Direct3DSwapChain9_INT, BaseObject));
|
return D3D9BaseObject_AddRef((D3D9BaseObject*) &This->BaseObject.lpVtbl);
|
||||||
return D3D9BaseObject_AddRef(BaseObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI Direct3DSwapChain9_Release(LPDIRECT3DSWAPCHAIN9 iface)
|
static ULONG WINAPI Direct3DSwapChain9_Release(LPDIRECT3DSWAPCHAIN9 iface)
|
||||||
{
|
{
|
||||||
LPDIRECT3DSWAPCHAIN9_INT This = IDirect3DSwapChain9ToImpl(iface);
|
LPDIRECT3DSWAPCHAIN9_INT This = IDirect3DSwapChain9ToImpl(iface);
|
||||||
D3D9BaseObject* BaseObject = (D3D9BaseObject*)((ULONG_PTR)This - FIELD_OFFSET(Direct3DSwapChain9_INT, lpVtbl) - FIELD_OFFSET(Direct3DSwapChain9_INT, BaseObject));
|
return D3D9BaseObject_Release((D3D9BaseObject*) &This->BaseObject.lpVtbl);
|
||||||
return D3D9BaseObject_Release(BaseObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IDirect3DSwapChain9 interface */
|
/* IDirect3DSwapChain9 interface */
|
||||||
|
@ -121,7 +119,7 @@ Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitD3D9BaseObject(&pThisSwapChain->BaseObject, RefType, pBaseDevice);
|
InitD3D9BaseObject((D3D9BaseObject*) &pThisSwapChain->BaseObject.lpVtbl, RefType, pBaseDevice);
|
||||||
|
|
||||||
pThisSwapChain->lpVtbl = &Direct3DSwapChain9_Vtbl;
|
pThisSwapChain->lpVtbl = &Direct3DSwapChain9_Vtbl;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ HRESULT InitD3D9BaseDevice(LPDIRECT3DDEVICE9_INT pThisBaseDevice, LPDIRECT3D9_IN
|
||||||
|
|
||||||
pThisBaseDevice->pResourceManager = pResourceManager;
|
pThisBaseDevice->pResourceManager = pResourceManager;
|
||||||
|
|
||||||
|
pThisBaseDevice->lpVtbl = &Direct3DDevice9_Vtbl;
|
||||||
|
pThisBaseDevice->lRefCnt = 1;
|
||||||
pThisBaseDevice->pDirect3D9 = pDirect3D9;
|
pThisBaseDevice->pDirect3D9 = pDirect3D9;
|
||||||
pThisBaseDevice->DeviceType = DeviceType;
|
pThisBaseDevice->DeviceType = DeviceType;
|
||||||
pThisBaseDevice->hWnd = hFocusWindow;
|
pThisBaseDevice->hWnd = hFocusWindow;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue