[7/7] Add ID3D10Device interface and implement it's IUnknown methods
Kovács András
andras at csevego.net
Tue Jun 12 17:17:16 CDT 2007
[7/7] Add ID3D10Device interface and implement it's IUnknown methods
--
----------------------------
Kovács András (andras)
NetClub Vezető Rendszergazda
Lamarr
csevego.net
andras at csevego.net
----------------------------
-------------- next part --------------
From 704d04b8e6dd805be49b12e169fa37a9b3d4b5c3 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A1s_Kov=C3=A1cs?= <andras at debian.sth.sze.hu>
Date: Wed, 13 Jun 2007 00:08:49 +0200
Subject: [PATCH] Add ID3D10Device interface and implement its IUnknown methods
---
dlls/d3d10/Makefile.in | 1 +
dlls/d3d10/d3d10.spec | 2 +-
dlls/d3d10/d3d10_main.c | 25 ++++++++++++++
dlls/d3d10/d3d10_private.h | 12 +++++++
dlls/d3d10/device.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
include/d3d10_misc.h | 2 +
6 files changed, 117 insertions(+), 1 deletions(-)
diff --git a/dlls/d3d10/Makefile.in b/dlls/d3d10/Makefile.in
index 30f2b7a..824e1c6 100644
--- a/dlls/d3d10/Makefile.in
+++ b/dlls/d3d10/Makefile.in
@@ -8,6 +8,7 @@ IMPORTS = wined3d user32 gdi32 kernel32
EXTRALIBS = -ldxguid -luuid
C_SRCS = \
+ device.c \
d3d10_main.c
RC_SRCS = version.rc
diff --git a/dlls/d3d10/d3d10.spec b/dlls/d3d10/d3d10.spec
index 221d19f..1412a49 100644
--- a/dlls/d3d10/d3d10.spec
+++ b/dlls/d3d10/d3d10.spec
@@ -1,5 +1,5 @@
@ stub D3D10CreateBlob
-@ stub D3D10CreateDevice
+@ stdcall D3D10CreateDevice(ptr long long long long ptr)
@ stub D3D10CreateDeviceAndSwapChain
@ stub D3D10CompileShader
diff --git a/dlls/d3d10/d3d10_main.c b/dlls/d3d10/d3d10_main.c
index a38070a..6485758 100644
--- a/dlls/d3d10/d3d10_main.c
+++ b/dlls/d3d10/d3d10_main.c
@@ -20,11 +20,36 @@
*/
#include "config.h"
+#include "initguid.h"
#include "d3d10_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
+/* FIXME: Define the interface for the Adapter parameter */
+HRESULT WINAPI D3D10CreateDevice(void *Adapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, UINT SDKVersion, ID3D10Device **Device)
+{
+ ID3D10DeviceImpl *object;
+ TRACE("Adapter %p, Driver Type %d, Software Module handle %p, Flags %08x, SDKVersion %d, Device %p\n",
+ Adapter, DriverType, Software, Flags, SDKVersion, Device);
+
+ FIXME("ID3D10Device interface is not binary compatible to windows yet\n");
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if(!object)
+ {
+ ERR("Out of memory when allocating a D3D10 Device implementation structure\n");
+ *Device = NULL;
+ return E_OUTOFMEMORY;
+ }
+ object->lpVtbl = &D3D10Device_Vtbl;
+ object->ref = 0;
+
+ *Device = (ID3D10Device *) object;
+ TRACE("Created device at %p\n", object);
+
+ return S_OK;
+}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h
index 4338acb..8e9d8ce 100644
--- a/dlls/d3d10/d3d10_private.h
+++ b/dlls/d3d10/d3d10_private.h
@@ -39,4 +39,16 @@
#include "wine/wined3d_interface.h"
+/**************************************************************************
+* ID3D10Device implementation structure
+*/
+typedef struct ID3D10DeviceImpl
+{
+ /* IUnknown fields */
+ const ID3D10DeviceVtbl *lpVtbl;
+ LONG ref;
+} ID3D10DeviceImpl;
+
+extern const ID3D10DeviceVtbl D3D10Device_Vtbl;
+
#endif /* __WINE_D3D10_PRIVATE_H */
diff --git a/dlls/d3d10/device.c b/dlls/d3d10/device.c
new file mode 100644
index 0000000..f2b5a3c
--- /dev/null
+++ b/dlls/d3d10/device.c
@@ -0,0 +1,76 @@
+/*
+ * Direct3D 10
+ *
+ * Copyright 2007 Andras Kovacs
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "config.h"
+
+#include "d3d10_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
+
+static HRESULT WINAPI ID3D10DeviceImpl_QueryInterface(ID3D10Device *iface, REFIID riid, void **obj)
+{
+ ID3D10DeviceImpl *This = (ID3D10DeviceImpl *)iface;
+
+ TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
+ if(IsEqualGUID(riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_ID3D10Device))
+ {
+ IUnknown_AddRef(iface);
+ *obj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), obj);
+ *obj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI ID3D10DeviceImpl_AddRef(ID3D10Device *iface)
+{
+ ID3D10DeviceImpl *This = (ID3D10DeviceImpl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+ return ref;
+}
+
+static ULONG WINAPI ID3D10DeviceImpl_Release(ID3D10Device *iface)
+{
+ ID3D10DeviceImpl *This = (ID3D10DeviceImpl *)iface;
+ ULONG ref;
+
+ ref = InterlockedDecrement(&This->ref);
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
+}
+
+const ID3D10DeviceVtbl D3D10Device_Vtbl =
+{
+ ID3D10DeviceImpl_QueryInterface,
+ ID3D10DeviceImpl_AddRef,
+ ID3D10DeviceImpl_Release
+};
diff --git a/include/d3d10_misc.h b/include/d3d10_misc.h
index 9eceaae..c22c603 100644
--- a/include/d3d10_misc.h
+++ b/include/d3d10_misc.h
@@ -27,5 +27,7 @@ typedef enum D3D10_DRIVER_TYPE
D3D10_DRIVER_TYPE_SOFTWARE = 3,
} D3D10_DRIVER_TYPE;
+/* FIXME: Define the interface for the Adapter parameter */
+HRESULT WINAPI D3D10CreateDevice(void *Adapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, UINT SDKVersion, ID3D10Device **Device);
#endif
--
1.4.4.4
More information about the wine-patches
mailing list