Author: gbrunmar
Date: Sun Aug 24 04:34:16 2008
New Revision: 35592
URL:
http://svn.reactos.org/svn/reactos?rev=35592&view=rev
Log:
D3D9:
* Fixed incomplete HAL device
* Fixed IDirect3DSwapChain9 and D3D9BaseObject ref counting
Modified:
trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c
trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h
trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c
trunk/reactos/dll/directx/d3d9/device.c
Modified: trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_base…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c [iso-8859-1] Sun Aug 24 04:34:16
2008
@@ -9,9 +9,14 @@
#include "d3d9_device.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 =
@@ -22,7 +27,6 @@
VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, struct
_Direct3DDevice9_INT* pBaseDevice)
{
- // TODO: Add dtor to vtbl
pBaseObject->lpVtbl = &D3D9BaseObject_Vtbl;
pBaseObject->RefType = RefType;
pBaseObject->pBaseDevice = pBaseDevice;
@@ -30,14 +34,30 @@
ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject)
{
- // TODO: Implement ref counting
- UNIMPLEMENTED
- return 1;
+ if (pBaseObject->pBaseDevice)
+ {
+
pBaseObject->pBaseDevice->lpVtbl->AddRef((IDirect3DDevice9*)&pBaseObject->pBaseDevice->lpVtbl);
+ }
+
+ return InterlockedIncrement(&pBaseObject->lRefCnt);
}
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject)
{
- // TODO: Implement ref counting
- UNIMPLEMENTED
- return 0;
+ ULONG Ref = 0;
+
+ if (pBaseObject)
+ {
+ Ref = InterlockedDecrement(&pBaseObject->lRefCnt);
+
+ if (Ref == 0)
+ {
+ if (pBaseObject->pBaseDevice)
+ {
+
pBaseObject->pBaseDevice->lpVtbl->Release((IDirect3DDevice9*)&pBaseObject->pBaseDevice->lpVtbl);
+ }
+ }
+ }
+
+ return Ref;
}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_base…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h [iso-8859-1] Sun Aug 24 04:34:16
2008
@@ -19,14 +19,14 @@
typedef struct _D3D9BaseObjectVtbl
{
- VOID (*Destroy)();
+ VOID (*Destroy)(struct _D3D9BaseObject* pBaseObject, BOOL bFreeThis);
} ID3D9BaseObjectVtbl;
typedef struct _D3D9BaseObject
{
/* 0x0000 */ ID3D9BaseObjectVtbl* lpVtbl;
-/* 0x0004 */ DWORD dwUnknown0004;
-/* 0x0008 */ DWORD dwUnknown0008;
+/* 0x0004 */ LONG lRefCnt;
+/* 0x0008 */ DWORD dwNumUsed;
/* 0x000c */ struct _Direct3DDevice9_INT* pBaseDevice;
/* 0x0010 */ DWORD dwUnknown0010; // Index? Unique id?
/* 0x0014 */ HANDLE hKernelHandle;
Modified: trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_swap…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c [iso-8859-1] Sun Aug 24 04:34:16 2008
@@ -41,15 +41,13 @@
static ULONG WINAPI Direct3DSwapChain9_AddRef(LPDIRECT3DSWAPCHAIN9 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(BaseObject);
+ return D3D9BaseObject_AddRef((D3D9BaseObject*) &This->BaseObject.lpVtbl);
}
static ULONG WINAPI Direct3DSwapChain9_Release(LPDIRECT3DSWAPCHAIN9 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(BaseObject);
+ return D3D9BaseObject_Release((D3D9BaseObject*) &This->BaseObject.lpVtbl);
}
/* IDirect3DSwapChain9 interface */
@@ -121,7 +119,7 @@
return NULL;
}
- InitD3D9BaseObject(&pThisSwapChain->BaseObject, RefType, pBaseDevice);
+ InitD3D9BaseObject((D3D9BaseObject*) &pThisSwapChain->BaseObject.lpVtbl,
RefType, pBaseDevice);
pThisSwapChain->lpVtbl = &Direct3DSwapChain9_Vtbl;
Modified: trunk/reactos/dll/directx/d3d9/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/device.c?…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/device.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/device.c [iso-8859-1] Sun Aug 24 04:34:16 2008
@@ -49,6 +49,8 @@
pThisBaseDevice->pResourceManager = pResourceManager;
+ pThisBaseDevice->lpVtbl = &Direct3DDevice9_Vtbl;
+ pThisBaseDevice->lRefCnt = 1;
pThisBaseDevice->pDirect3D9 = pDirect3D9;
pThisBaseDevice->DeviceType = DeviceType;
pThisBaseDevice->hWnd = hFocusWindow;