--- /dev/null
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = d3d9.dll
+IMPORTLIB = libd3d9.$(IMPLIBEXT)
+IMPORTS = wined3d user32 gdi32 kernel32
+EXTRALIBS = -ldxguid -luuid
+
+C_SRCS = \
+ basetexture.c \
+ cubetexture.c \
+ d3d9_main.c \
+ device.c \
+ directx.c \
+ indexbuffer.c \
+ pixelshader.c \
+ query.c \
+ resource.c \
+ stateblock.c \
+ surface.c \
+ swapchain.c \
+ texture.c \
+ vertexbuffer.c \
+ vertexdeclaration.c \
+ vertexshader.c \
+ volume.c \
+ volumetexture.c
+
+RC_SRCS = version.rc
+
+@MAKE_DLL_RULES@
+
+@DEPENDENCIES@ # everything below this line is overwritten by make depend
--- /dev/null
+/*
+ * IDirect3DBaseTexture9 implementation
+ *
+ * Copyright 2002-2004 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DBaseTexture9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_QueryInterface(LPDIRECT3DBASETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DBaseTexture9Impl_AddRef(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DBaseTexture9Impl_Release(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DBaseTexture9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetDevice(LPDIRECT3DBASETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+}
+
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
+}
+
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
+}
+
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_FreePrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
+}
+
+static DWORD WINAPI IDirect3DBaseTexture9Impl_SetPriority(LPDIRECT3DBASETEXTURE9 iface, DWORD PriorityNew) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
+}
+
+static DWORD WINAPI IDirect3DBaseTexture9Impl_GetPriority(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
+}
+
+static void WINAPI IDirect3DBaseTexture9Impl_PreLoad(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
+ return ;
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DBaseTexture9Impl_GetType(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
+}
+
+/* IDirect3DBaseTexture9 Interface follow: */
+static DWORD WINAPI IDirect3DBaseTexture9Impl_SetLOD(LPDIRECT3DBASETEXTURE9 iface, DWORD LODNew) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
+}
+
+DWORD WINAPI IDirect3DBaseTexture9Impl_GetLOD(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
+}
+
+static DWORD WINAPI IDirect3DBaseTexture9Impl_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
+}
+
+static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return IWineD3DBaseTexture_SetAutoGenFilterType(This->wineD3DBaseTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
+}
+
+static D3DTEXTUREFILTERTYPE WINAPI IDirect3DBaseTexture9Impl_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ return (D3DTEXTUREFILTERTYPE) IWineD3DBaseTexture_GetAutoGenFilterType(This->wineD3DBaseTexture);
+}
+
+static void WINAPI IDirect3DBaseTexture9Impl_GenerateMipSubLevels(LPDIRECT3DBASETEXTURE9 iface) {
+ IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+ IWineD3DBaseTexture_GenerateMipSubLevels(This->wineD3DBaseTexture);
+}
+
+const IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl =
+{
+ IDirect3DBaseTexture9Impl_QueryInterface,
+ IDirect3DBaseTexture9Impl_AddRef,
+ IDirect3DBaseTexture9Impl_Release,
+ IDirect3DBaseTexture9Impl_GetDevice,
+ IDirect3DBaseTexture9Impl_SetPrivateData,
+ IDirect3DBaseTexture9Impl_GetPrivateData,
+ IDirect3DBaseTexture9Impl_FreePrivateData,
+ IDirect3DBaseTexture9Impl_SetPriority,
+ IDirect3DBaseTexture9Impl_GetPriority,
+ IDirect3DBaseTexture9Impl_PreLoad,
+ IDirect3DBaseTexture9Impl_GetType,
+ IDirect3DBaseTexture9Impl_SetLOD,
+ IDirect3DBaseTexture9Impl_GetLOD,
+ IDirect3DBaseTexture9Impl_GetLevelCount,
+ IDirect3DBaseTexture9Impl_SetAutoGenFilterType,
+ IDirect3DBaseTexture9Impl_GetAutoGenFilterType,
+ IDirect3DBaseTexture9Impl_GenerateMipSubLevels
+};
--- /dev/null
+/*
+ * IDirect3DCubeTexture9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Copyright 2002-2005 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+
+/* IDirect3DCubeTexture9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
+ || IsEqualGUID(riid, &IID_IDirect3DCubeTexture9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D9CB_DestroySurface);
+ IUnknown_Release(This->parentDevice);
+ LeaveCriticalSection(&d3d9_cs);
+
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ D3DRESOURCETYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
+static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ D3DTEXTUREFILTERTYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+/* IDirect3DCubeTexture9 Interface follow: */
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ WINED3DSURFACE_DESC wined3ddesc;
+ UINT tmpInt = -1;
+ HRESULT hr;
+
+ TRACE("(%p) Relay\n", This);
+
+ /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
+ wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
+ wined3ddesc.Type = (WINED3DRESOURCETYPE *) &pDesc->Type;
+ wined3ddesc.Usage = &pDesc->Usage;
+ wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
+ wined3ddesc.Size = &tmpInt;
+ wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
+ wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
+ wined3ddesc.Width = &pDesc->Width;
+ wined3ddesc.Height = &pDesc->Height;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DSurface *mySurface = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
+ if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
+ IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
+ IWineD3DCubeTexture_Release(mySurface);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
+ IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DCubeTexture9Impl_QueryInterface,
+ IDirect3DCubeTexture9Impl_AddRef,
+ IDirect3DCubeTexture9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DCubeTexture9Impl_GetDevice,
+ IDirect3DCubeTexture9Impl_SetPrivateData,
+ IDirect3DCubeTexture9Impl_GetPrivateData,
+ IDirect3DCubeTexture9Impl_FreePrivateData,
+ IDirect3DCubeTexture9Impl_SetPriority,
+ IDirect3DCubeTexture9Impl_GetPriority,
+ IDirect3DCubeTexture9Impl_PreLoad,
+ IDirect3DCubeTexture9Impl_GetType,
+ /* IDirect3DBaseTexture9 */
+ IDirect3DCubeTexture9Impl_SetLOD,
+ IDirect3DCubeTexture9Impl_GetLOD,
+ IDirect3DCubeTexture9Impl_GetLevelCount,
+ IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
+ IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
+ IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
+ IDirect3DCubeTexture9Impl_GetLevelDesc,
+ IDirect3DCubeTexture9Impl_GetCubeMapSurface,
+ IDirect3DCubeTexture9Impl_LockRect,
+ IDirect3DCubeTexture9Impl_UnlockRect,
+ IDirect3DCubeTexture9Impl_AddDirtyRect
+};
+
+
+
+
+/* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface,
+ UINT EdgeLength, UINT Levels, DWORD Usage,
+ D3DFORMAT Format, D3DPOOL Pool,
+ IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
+
+ IDirect3DCubeTexture9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This, EdgeLength, Levels, Usage, Format, Pool, pSharedHandle);
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+
+ if (NULL == object) {
+ FIXME("(%p) allocation of CubeTexture failed\n", This);
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+ object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
+ object->ref = 1;
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
+ (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object,
+ D3D9CB_CreateSurface);
+ LeaveCriticalSection(&d3d9_cs);
+
+ if (hr != D3D_OK){
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
+ TRACE("(%p) : Created cube texture %p\n", This, object);
+ }
+
+ TRACE("(%p) returning %p\n",This, *ppCubeTexture);
+ return hr;
+}
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
+<module name="d3d9" type="win32dll" installbase="system32" installname="d3d9.dll" allowwarnings ="true">
+ <importlibrary definition="d3d9.spec.def" />
+ <include base="d3d9">.</include>
+ <include base="ReactOS">include/reactos/wine</include>
+ <define name="UNICODE" />
+ <define name="_UNICODE" />
+ <define name="_WIN32_IE">0x600</define>
+ <define name="_WIN32_WINNT">0x501</define>
+ <define name="WINVER">0x501</define>
+ <define name="__WINESRC__" />
+ <define name="USE_WIN32_OPENGL" />
+
+ <library>uuid</library>
+ <library>wine</library>
+ <library>user32</library>
+ <library>opengl32</library>
+ <library>gdi32</library>
+ <library>advapi32</library>
+ <library>kernel32</library>
+ <library>wined3d</library>
+
+ <file>basetexture.c</file>
+ <file>cubetexture.c</file>
+ <file>d3d9_main.c</file>
+ <file>device.c</file>
+ <file>directx.c</file>
+ <file>indexbuffer.c</file>
+ <file>pixelshader.c</file>
+ <file>query.c</file>
+ <file>resource.c</file>
+ <file>stateblock.c</file>
+ <file>surface.c</file>
+ <file>swapchain.c</file>
+ <file>texture.c</file>
+ <file>vertexbuffer.c</file>
+ <file>vertexdeclaration.c</file>
+ <file>vertexshader.c</file>
+ <file>volume.c</file>
+ <file>volumetexture.c</file>
+ <file>version.rc</file>
+ <file>d3d9.spec</file>
+</module>
--- /dev/null
+@ stdcall D3D9GetSWInfo()
+@ stdcall DebugSetMute()
+@ stdcall Direct3DCreate9(long)
+@ stdcall D3DPERF_BeginEvent(long wstr)
+@ stdcall D3DPERF_EndEvent()
+@ stdcall D3DPERF_GetStatus()
+@ stdcall D3DPERF_SetOptions(long)
+@ stdcall D3DPERF_QueryRepeatFrame()
+@ stdcall D3DPERF_SetMarker(long wstr)
+@ stdcall D3DPERF_SetRegion(long wstr)
--- /dev/null
+/*
+ * Direct3D 9
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "initguid.h"
+#include "d3d9_private.h"
+
+static CRITICAL_SECTION_DEBUG d3d9_cs_debug =
+{
+ 0, 0, &d3d9_cs,
+ { &d3d9_cs_debug.ProcessLocksList,
+ &d3d9_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": d3d9_cs") }
+};
+CRITICAL_SECTION d3d9_cs = { &d3d9_cs_debug, -1, 0, 0, 0, 0 };
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+static int D3DPERF_event_level = 0;
+
+HRESULT WINAPI D3D9GetSWInfo(void) {
+ FIXME("(void): stub\n");
+ return 0;
+}
+
+void WINAPI DebugSetMute(void) {
+ /* nothing to do */
+}
+
+IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
+ IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
+
+ object->lpVtbl = &Direct3D9_Vtbl;
+ object->ref = 1;
+ EnterCriticalSection(&d3d9_cs);
+ object->WineD3D = WineDirect3DCreate(SDKVersion, 9, (IUnknown *)object);
+ LeaveCriticalSection(&d3d9_cs);
+
+ TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
+
+ return (IDirect3D9*) object;
+}
+
+/* At process attach */
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
+{
+ TRACE("fdwReason=%d\n", fdwReason);
+ if (fdwReason == DLL_PROCESS_ATTACH)
+ DisableThreadLibraryCalls(hInstDLL);
+
+ return TRUE;
+}
+
+/***********************************************************************
+ * D3DPERF_BeginEvent (D3D9.@)
+ */
+int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, LPCWSTR name) {
+ FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+
+ return D3DPERF_event_level++;
+}
+
+/***********************************************************************
+ * D3DPERF_EndEvent (D3D9.@)
+ */
+int WINAPI D3DPERF_EndEvent(void) {
+ FIXME("(void) : stub\n");
+
+ return --D3DPERF_event_level;
+}
+
+/***********************************************************************
+ * D3DPERF_GetStatus (D3D9.@)
+ */
+DWORD WINAPI D3DPERF_GetStatus(void) {
+ FIXME("(void) : stub\n");
+
+ return 0;
+}
+
+/***********************************************************************
+ * D3DPERF_SetOptions (D3D9.@)
+ *
+ */
+void WINAPI D3DPERF_SetOptions(DWORD options)
+{
+ FIXME("(%#x) : stub\n", options);
+}
+
+/***********************************************************************
+ * D3DPERF_QueryRepeatFrame (D3D9.@)
+ */
+BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
+ FIXME("(void) : stub\n");
+
+ return FALSE;
+}
+
+/***********************************************************************
+ * D3DPERF_SetMarker (D3D9.@)
+ */
+void WINAPI D3DPERF_SetMarker(D3DCOLOR color, LPCWSTR name) {
+ FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+}
+
+/***********************************************************************
+ * D3DPERF_SetRegion (D3D9.@)
+ */
+void WINAPI D3DPERF_SetRegion(D3DCOLOR color, LPCWSTR name) {
+ FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
+}
--- /dev/null
+/*
+ * Direct3D 9 private include file
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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
+ */
+
+#ifndef __WINE_D3D9_PRIVATE_H
+#define __WINE_D3D9_PRIVATE_H
+
+#include <stdarg.h>
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#define COBJMACROS
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+#include "d3d9.h"
+#include "wine/wined3d_interface.h"
+
+/* ===========================================================================
+ Internal use
+ =========================================================================== */
+extern HRESULT vdecl_convert_fvf(
+ DWORD FVF,
+ D3DVERTEXELEMENT9** ppVertexElements);
+extern CRITICAL_SECTION d3d9_cs;
+
+/* ===========================================================================
+ Macros
+ =========================================================================== */
+/* Not nice, but it lets wined3d support different versions of directx */
+#define D3D9CAPSTOWINECAPS(_pD3D9Caps, _pWineCaps) \
+ _pWineCaps->DeviceType = (WINED3DDEVTYPE *) &_pD3D9Caps->DeviceType; \
+ _pWineCaps->AdapterOrdinal = &_pD3D9Caps->AdapterOrdinal; \
+ _pWineCaps->Caps = &_pD3D9Caps->Caps; \
+ _pWineCaps->Caps2 = &_pD3D9Caps->Caps2; \
+ _pWineCaps->Caps3 = &_pD3D9Caps->Caps3; \
+ _pWineCaps->PresentationIntervals = &_pD3D9Caps->PresentationIntervals; \
+ _pWineCaps->CursorCaps = &_pD3D9Caps->CursorCaps; \
+ _pWineCaps->DevCaps = &_pD3D9Caps->DevCaps; \
+ _pWineCaps->PrimitiveMiscCaps = &_pD3D9Caps->PrimitiveMiscCaps; \
+ _pWineCaps->RasterCaps = &_pD3D9Caps->RasterCaps; \
+ _pWineCaps->ZCmpCaps = &_pD3D9Caps->ZCmpCaps; \
+ _pWineCaps->SrcBlendCaps = &_pD3D9Caps->SrcBlendCaps; \
+ _pWineCaps->DestBlendCaps = &_pD3D9Caps->DestBlendCaps; \
+ _pWineCaps->AlphaCmpCaps = &_pD3D9Caps->AlphaCmpCaps; \
+ _pWineCaps->ShadeCaps = &_pD3D9Caps->ShadeCaps; \
+ _pWineCaps->TextureCaps = &_pD3D9Caps->TextureCaps; \
+ _pWineCaps->TextureFilterCaps = &_pD3D9Caps->TextureFilterCaps; \
+ _pWineCaps->CubeTextureFilterCaps = &_pD3D9Caps->CubeTextureFilterCaps; \
+ _pWineCaps->VolumeTextureFilterCaps = &_pD3D9Caps->VolumeTextureFilterCaps; \
+ _pWineCaps->TextureAddressCaps = &_pD3D9Caps->TextureAddressCaps; \
+ _pWineCaps->VolumeTextureAddressCaps = &_pD3D9Caps->VolumeTextureAddressCaps; \
+ _pWineCaps->LineCaps = &_pD3D9Caps->LineCaps; \
+ _pWineCaps->MaxTextureWidth = &_pD3D9Caps->MaxTextureWidth; \
+ _pWineCaps->MaxTextureHeight = &_pD3D9Caps->MaxTextureHeight; \
+ _pWineCaps->MaxVolumeExtent = &_pD3D9Caps->MaxVolumeExtent; \
+ _pWineCaps->MaxTextureRepeat = &_pD3D9Caps->MaxTextureRepeat; \
+ _pWineCaps->MaxTextureAspectRatio = &_pD3D9Caps->MaxTextureAspectRatio; \
+ _pWineCaps->MaxAnisotropy = &_pD3D9Caps->MaxAnisotropy; \
+ _pWineCaps->MaxVertexW = &_pD3D9Caps->MaxVertexW; \
+ _pWineCaps->GuardBandLeft = &_pD3D9Caps->GuardBandLeft; \
+ _pWineCaps->GuardBandTop = &_pD3D9Caps->GuardBandTop; \
+ _pWineCaps->GuardBandRight = &_pD3D9Caps->GuardBandRight; \
+ _pWineCaps->GuardBandBottom = &_pD3D9Caps->GuardBandBottom; \
+ _pWineCaps->ExtentsAdjust = &_pD3D9Caps->ExtentsAdjust; \
+ _pWineCaps->StencilCaps = &_pD3D9Caps->StencilCaps; \
+ _pWineCaps->FVFCaps = &_pD3D9Caps->FVFCaps; \
+ _pWineCaps->TextureOpCaps = &_pD3D9Caps->TextureOpCaps; \
+ _pWineCaps->MaxTextureBlendStages = &_pD3D9Caps->MaxTextureBlendStages; \
+ _pWineCaps->MaxSimultaneousTextures = &_pD3D9Caps->MaxSimultaneousTextures; \
+ _pWineCaps->VertexProcessingCaps = &_pD3D9Caps->VertexProcessingCaps; \
+ _pWineCaps->MaxActiveLights = &_pD3D9Caps->MaxActiveLights; \
+ _pWineCaps->MaxUserClipPlanes = &_pD3D9Caps->MaxUserClipPlanes; \
+ _pWineCaps->MaxVertexBlendMatrices = &_pD3D9Caps->MaxVertexBlendMatrices; \
+ _pWineCaps->MaxVertexBlendMatrixIndex = &_pD3D9Caps->MaxVertexBlendMatrixIndex; \
+ _pWineCaps->MaxPointSize = &_pD3D9Caps->MaxPointSize; \
+ _pWineCaps->MaxPrimitiveCount = &_pD3D9Caps->MaxPrimitiveCount; \
+ _pWineCaps->MaxVertexIndex = &_pD3D9Caps->MaxVertexIndex; \
+ _pWineCaps->MaxStreams = &_pD3D9Caps->MaxStreams; \
+ _pWineCaps->MaxStreamStride = &_pD3D9Caps->MaxStreamStride; \
+ _pWineCaps->VertexShaderVersion = &_pD3D9Caps->VertexShaderVersion; \
+ _pWineCaps->MaxVertexShaderConst = &_pD3D9Caps->MaxVertexShaderConst; \
+ _pWineCaps->PixelShaderVersion = &_pD3D9Caps->PixelShaderVersion; \
+ _pWineCaps->PixelShader1xMaxValue = &_pD3D9Caps->PixelShader1xMaxValue; \
+ _pWineCaps->DevCaps2 = &_pD3D9Caps->DevCaps2; \
+ _pWineCaps->MaxNpatchTessellationLevel = &_pD3D9Caps->MaxNpatchTessellationLevel; \
+ _pWineCaps->MasterAdapterOrdinal = &_pD3D9Caps->MasterAdapterOrdinal; \
+ _pWineCaps->AdapterOrdinalInGroup = &_pD3D9Caps->AdapterOrdinalInGroup; \
+ _pWineCaps->NumberOfAdaptersInGroup = &_pD3D9Caps->NumberOfAdaptersInGroup; \
+ _pWineCaps->DeclTypes = &_pD3D9Caps->DeclTypes; \
+ _pWineCaps->NumSimultaneousRTs = &_pD3D9Caps->NumSimultaneousRTs; \
+ _pWineCaps->StretchRectFilterCaps = &_pD3D9Caps->StretchRectFilterCaps; \
+ _pWineCaps->VS20Caps.Caps = &_pD3D9Caps->VS20Caps.Caps; \
+ _pWineCaps->VS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->VS20Caps.DynamicFlowControlDepth; \
+ _pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \
+ _pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \
+ _pWineCaps->VS20Caps.StaticFlowControlDepth = &_pD3D9Caps->VS20Caps.StaticFlowControlDepth; \
+ _pWineCaps->PS20Caps.Caps = &_pD3D9Caps->PS20Caps.Caps; \
+ _pWineCaps->PS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->PS20Caps.DynamicFlowControlDepth; \
+ _pWineCaps->PS20Caps.NumTemps = &_pD3D9Caps->PS20Caps.NumTemps; \
+ _pWineCaps->PS20Caps.StaticFlowControlDepth = &_pD3D9Caps->PS20Caps.StaticFlowControlDepth; \
+ _pWineCaps->PS20Caps.NumInstructionSlots = &_pD3D9Caps->PS20Caps.NumInstructionSlots; \
+ _pWineCaps->VertexTextureFilterCaps = &_pD3D9Caps->VertexTextureFilterCaps; \
+ _pWineCaps->MaxVShaderInstructionsExecuted = &_pD3D9Caps->MaxVShaderInstructionsExecuted; \
+ _pWineCaps->MaxPShaderInstructionsExecuted = &_pD3D9Caps->MaxPShaderInstructionsExecuted; \
+ _pWineCaps->MaxVertexShader30InstructionSlots = &_pD3D9Caps->MaxVertexShader30InstructionSlots; \
+ _pWineCaps->MaxPixelShader30InstructionSlots = &_pD3D9Caps->MaxPixelShader30InstructionSlots;
+
+/* ===========================================================================
+ D3D9 interfactes
+ =========================================================================== */
+
+/* ---------- */
+/* IDirect3D9 */
+/* ---------- */
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern const IDirect3D9Vtbl Direct3D9_Vtbl;
+
+/*****************************************************************************
+ * IDirect3D implementation structure
+ */
+typedef struct IDirect3D9Impl
+{
+ /* IUnknown fields */
+ const IDirect3D9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* The WineD3D device */
+ IWineD3D *WineD3D;
+
+} IDirect3D9Impl;
+
+void filter_caps(D3DCAPS9* pCaps);
+
+/* ---------------- */
+/* IDirect3DDevice9 */
+/* ---------------- */
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl;
+
+/*****************************************************************************
+ * IDirect3DDevice9 implementation structure
+ */
+typedef struct IDirect3DDevice9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DDevice9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DDevice9 fields */
+ IWineD3DDevice *WineD3DDevice;
+
+ /* Avoids recursion with nested ReleaseRef to 0 */
+ BOOL inDestruction;
+
+ IDirect3DVertexDeclaration9 **convertedDecls;
+ unsigned int numConvertedDecls, declArraySize;
+
+} IDirect3DDevice9Impl;
+
+
+/* IDirect3DDevice9: */
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
+extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB);
+extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface);
+extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9 iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, float* pConstantData, UINT Vector4fCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, float* pConstantData, UINT Vector4fCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
+extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
+
+
+/* ---------------- */
+/* IDirect3DVolume9 */
+/* ---------------- */
+
+/*****************************************************************************
+ * IDirect3DVolume9 implementation structure
+ */
+typedef struct IDirect3DVolume9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DVolume9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DVolume9 fields */
+ IWineD3DVolume *wineD3DVolume;
+
+ /* The volume container */
+ IUnknown *container;
+
+ /* If set forward refcounting to this object */
+ IUnknown *forwardReference;
+} IDirect3DVolume9Impl;
+
+/* ------------------- */
+/* IDirect3DSwapChain9 */
+/* ------------------- */
+
+/*****************************************************************************
+ * IDirect3DSwapChain9 implementation structure
+ */
+typedef struct IDirect3DSwapChain9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DSwapChain9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DSwapChain9 fields */
+ IWineD3DSwapChain *wineD3DSwapChain;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+
+ /* Flags an implicit swap chain */
+ BOOL isImplicit;
+} IDirect3DSwapChain9Impl;
+
+/* ------------------ */
+/* IDirect3DResource9 */
+/* ------------------ */
+
+/*****************************************************************************
+ * IDirect3DResource9 implementation structure
+ */
+typedef struct IDirect3DResource9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DResource9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DResource *wineD3DResource;
+} IDirect3DResource9Impl;
+
+extern HRESULT WINAPI IDirect3DResource9Impl_GetDevice(LPDIRECT3DRESOURCE9 iface, IDirect3DDevice9** ppDevice);
+
+
+/* ----------------- */
+/* IDirect3DSurface9 */
+/* ----------------- */
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl;
+
+/*****************************************************************************
+ * IDirect3DSurface9 implementation structure
+ */
+typedef struct IDirect3DSurface9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DSurface9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DSurface *wineD3DSurface;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+
+ /* The surface container */
+ IUnknown *container;
+
+ /* If set forward refcounting to this object */
+ IUnknown *forwardReference;
+
+ /* Flags an implicit surface */
+ BOOL isImplicit;
+} IDirect3DSurface9Impl;
+
+/* ---------------------- */
+/* IDirect3DVertexBuffer9 */
+/* ---------------------- */
+
+/*****************************************************************************
+ * IDirect3DVertexBuffer9 implementation structure
+ */
+typedef struct IDirect3DVertexBuffer9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DVertexBuffer9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DVertexBuffer *wineD3DVertexBuffer;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DVertexBuffer9Impl;
+
+/* --------------------- */
+/* IDirect3DIndexBuffer9 */
+/* --------------------- */
+
+/*****************************************************************************
+ * IDirect3DIndexBuffer9 implementation structure
+ */
+typedef struct IDirect3DIndexBuffer9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DIndexBuffer9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DIndexBuffer *wineD3DIndexBuffer;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DIndexBuffer9Impl;
+
+/* --------------------- */
+/* IDirect3DBaseTexture9 */
+/* --------------------- */
+
+/*****************************************************************************
+ * IDirect3DBaseTexture9 implementation structure
+ */
+typedef struct IDirect3DBaseTexture9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DBaseTexture9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DBaseTexture *wineD3DBaseTexture;
+
+} IDirect3DBaseTexture9Impl;
+
+extern DWORD WINAPI IDirect3DBaseTexture9Impl_GetLOD(LPDIRECT3DBASETEXTURE9 iface);
+
+/* --------------------- */
+/* IDirect3DCubeTexture9 */
+/* --------------------- */
+
+/*****************************************************************************
+ * IDirect3DCubeTexture9 implementation structure
+ */
+typedef struct IDirect3DCubeTexture9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DCubeTexture9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DCubeTexture *wineD3DCubeTexture;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DCubeTexture9Impl;
+
+
+/* ----------------- */
+/* IDirect3DTexture9 */
+/* ----------------- */
+
+/*****************************************************************************
+ * IDirect3DTexture9 implementation structure
+ */
+typedef struct IDirect3DTexture9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DTexture9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DTexture *wineD3DTexture;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DTexture9Impl;
+
+/* ----------------------- */
+/* IDirect3DVolumeTexture9 */
+/* ----------------------- */
+
+/*****************************************************************************
+ * IDirect3DVolumeTexture9 implementation structure
+ */
+typedef struct IDirect3DVolumeTexture9Impl
+{
+ /* IUnknown fields */
+ const IDirect3DVolumeTexture9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DResource9 fields */
+ IWineD3DVolumeTexture *wineD3DVolumeTexture;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DVolumeTexture9Impl;
+
+/* ----------------------- */
+/* IDirect3DStateBlock9 */
+/* ----------------------- */
+
+/*****************************************************************************
+ * IDirect3DStateBlock9 implementation structure
+ */
+typedef struct IDirect3DStateBlock9Impl {
+ /* IUnknown fields */
+ const IDirect3DStateBlock9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DStateBlock9 fields */
+ IWineD3DStateBlock *wineD3DStateBlock;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DStateBlock9Impl;
+
+
+/* --------------------------- */
+/* IDirect3DVertexDeclaration9 */
+/* --------------------------- */
+
+/*****************************************************************************
+ * IDirect3DVertexDeclaration implementation structure
+ */
+typedef struct IDirect3DVertexDeclaration9Impl {
+ /* IUnknown fields */
+ const IDirect3DVertexDeclaration9Vtbl *lpVtbl;
+ LONG ref;
+
+ D3DVERTEXELEMENT9 *elements;
+ size_t element_count;
+
+ /* IDirect3DVertexDeclaration9 fields */
+ IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
+ DWORD convFVF;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DVertexDeclaration9Impl;
+
+void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface);
+
+/* ---------------------- */
+/* IDirect3DVertexShader9 */
+/* ---------------------- */
+
+/*****************************************************************************
+ * IDirect3DVertexShader implementation structure
+ */
+typedef struct IDirect3DVertexShader9Impl {
+ /* IUnknown fields */
+ const IDirect3DVertexShader9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DVertexShader9 fields */
+ IWineD3DVertexShader *wineD3DVertexShader;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DVertexShader9Impl;
+
+/* --------------------- */
+/* IDirect3DPixelShader9 */
+/* --------------------- */
+
+/*****************************************************************************
+ * IDirect3DPixelShader implementation structure
+ */
+typedef struct IDirect3DPixelShader9Impl {
+ /* IUnknown fields */
+ const IDirect3DPixelShader9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DPixelShader9 fields */
+ IWineD3DPixelShader *wineD3DPixelShader;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DPixelShader9Impl;
+
+/* --------------- */
+/* IDirect3DQuery9 */
+/* --------------- */
+
+/*****************************************************************************
+ * IDirect3DPixelShader implementation structure
+ */
+typedef struct IDirect3DQuery9Impl {
+ /* IUnknown fields */
+ const IDirect3DQuery9Vtbl *lpVtbl;
+ LONG ref;
+
+ /* IDirect3DQuery9 fields */
+ IWineD3DQuery *wineD3DQuery;
+
+ /* Parent reference */
+ LPDIRECT3DDEVICE9 parentDevice;
+} IDirect3DQuery9Impl;
+
+
+/* Callbacks */
+extern HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
+ WINED3DCUBEMAP_FACES Face, IWineD3DSurface** ppSurface,
+ HANDLE* pSharedHandle);
+
+extern HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
+ WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
+ IWineD3DVolume **ppVolume,
+ HANDLE * pSharedHandle);
+
+extern HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Discard,
+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
+
+extern HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Lockable,
+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
+
+extern ULONG WINAPI D3D9CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain);
+
+extern ULONG WINAPI D3D9CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface);
+
+extern ULONG WINAPI D3D9CB_DestroyRenderTarget (IWineD3DSurface *pSurface);
+
+extern ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface);
+
+extern ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume);
+
+#endif /* __WINE_D3D9_PRIVATE_H */
--- /dev/null
+/*
+ * IDirect3DDevice9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Copyright 2002-2005 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+
+/* IDirect3D IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DDevice9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ ULONG ref;
+
+ if (This->inDestruction) return 0;
+ ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ int i;
+ This->inDestruction = TRUE;
+
+ EnterCriticalSection(&d3d9_cs);
+ for(i = 0; i < This->numConvertedDecls; i++) {
+ /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
+ * device
+ */
+ IDirect3DVertexDeclaration9Impl_Destroy(This->convertedDecls[i]);
+ }
+ HeapFree(GetProcessHeap(), 0, This->convertedDecls);
+
+ IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroyDepthStencilSurface, D3D9CB_DestroySwapChain);
+ IWineD3DDevice_Release(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DDevice Interface follow: */
+static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr = D3D_OK;
+ IWineD3D* pWineD3D;
+
+ TRACE("(%p) Relay\n", This);
+
+ if (NULL == ppD3D9) {
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
+ if (hr == D3D_OK && pWineD3D != NULL)
+ {
+ IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D9);
+ IWineD3D_Release(pWineD3D);
+ } else {
+ FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
+ *ppD3D9 = NULL;
+ }
+ TRACE("(%p) returning %p\n", This, *ppD3D9);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ WINED3DCAPS *pWineCaps;
+
+ TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
+ if(NULL == pCaps){
+ return D3DERR_INVALIDCALL;
+ }
+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
+ if(pWineCaps == NULL){
+ return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
+ }
+
+ memset(pCaps, 0, sizeof(*pCaps));
+ D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, pWineCaps);
+
+ /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
+ pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
+
+ filter_caps(pCaps);
+
+ TRACE("Returning %p %p\n", This, pCaps);
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
+ HRESULT hr;
+
+ TRACE("(%p) Relay\n", This);
+ if(!pCursorBitmap) {
+ WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, (IWineD3DSurface*)pSurface->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ BOOL ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ WINED3DPRESENT_PARAMETERS localParameters;
+ HRESULT hr;
+
+ TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
+
+ localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
+ localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
+ localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
+ localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
+ localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
+ localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
+ localParameters.SwapEffect = pPresentationParameters->SwapEffect;
+ localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
+ localParameters.Windowed = pPresentationParameters->Windowed;
+ localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
+ localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
+ localParameters.Flags = pPresentationParameters->Flags;
+ localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
+ localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
+ LeaveCriticalSection(&d3d9_cs);
+
+ pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
+ pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
+ pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
+ pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
+ pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
+ pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
+ pPresentationParameters->SwapEffect = localParameters.SwapEffect;
+ pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
+ pPresentationParameters->Windowed = localParameters.Windowed;
+ pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
+ pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
+ pPresentationParameters->Flags = localParameters.Flags;
+ pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
+ pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
+ pDirtyRegion) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+ }
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DSurface *retSurface = NULL;
+ HRESULT rc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, (IWineD3DSurface **)&retSurface);
+ if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
+ IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
+ IWineD3DSurface_Release(retSurface);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return rc;
+}
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
+
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
+ IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
+ IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) {
+ HRESULT hrc;
+ IDirect3DSurface9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ if(MultisampleQuality < 0) {
+ FIXME("MultisampleQuality out of range %d, substituting 0\n", MultisampleQuality);
+ /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
+ MultisampleQuality=0;
+ }
+
+ if(MultisampleQuality > 0){
+ FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
+ /*
+ MultisampleQuality
+ [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.
+ */
+
+ MultisampleQuality=0;
+ }
+ /*FIXME: Check MAX bounds of MultisampleQuality*/
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DSurface9_Vtbl;
+ object->ref = 1;
+
+ TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
+
+ hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL) Pool,MultiSample,MultisampleQuality,pSharedHandle,SURFACE_OPENGL,(IUnknown *)object);
+
+ if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ TRACE("(%p) : Created surface %p\n", This, object);
+ *ppSurface = (LPDIRECT3DSURFACE9) object;
+ }
+ return hrc;
+}
+
+
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Lockable,
+ IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
+ HRESULT hr;
+ TRACE("Relay\n");
+
+ /* Is this correct? */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,Lockable,FALSE/*Discard*/, 0/*Level*/, ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_RENDERTARGET,D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Discard,
+ IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
+ HRESULT hr;
+ TRACE("Relay\n");
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/* Lockable */,Discard, 0/* Level */
+ ,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,
+ D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+/* This isn't in MSDN!
+static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ FIXME("(%p) : stub\n", This);
+ return D3D_OK;
+}
+*/
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
+ IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
+ HRESULT hr;
+ TRACE("(%p)->(%p,%p)\n" , This, renderTarget, destSurface);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_BltFast(destSurface->wineD3DSurface, 0, 0, renderTarget->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *src = (IDirect3DSurface9Impl *) pSourceSurface;
+ IDirect3DSurface9Impl *dst = (IDirect3DSurface9Impl *) pDestSurface;
+ HRESULT hr;
+
+ TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This, src, pSourceRect, dst, pDestRect, Filter);
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_Blt(dst->wineD3DSurface, (RECT *) pDestRect, src->wineD3DSurface, (RECT *) pSourceRect, 0, NULL, Filter);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DRECT is compatible with WINED3DRECT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
+ HRESULT hr;
+ TRACE("Relay\n");
+ if(Pool == D3DPOOL_MANAGED ){
+ FIXME("Attempting to create a managed offscreen plain surface\n");
+ return D3DERR_INVALIDCALL;
+ }
+ /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
+
+ 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
+ but then...
+ D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
+ Why, their always lockable?
+ should I change the usage to dynamic?
+ */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/*Loackable*/,FALSE/*Discard*/,0/*Level*/ , ppSurface,D3DRTYPE_SURFACE, 0/*Usage (undefined/none)*/,(WINED3DPOOL) Pool,D3DMULTISAMPLE_NONE,0/*MultisampleQuality*/,pSharedHandle);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+/* TODO: move to wineD3D */
+static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? (IWineD3DSurface*)pSurface->wineD3DSurface : NULL);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr = D3D_OK;
+ IWineD3DSurface *pRenderTarget;
+
+ TRACE("(%p) Relay\n" , This);
+
+ if (ppRenderTarget == NULL) {
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
+
+ if (hr == D3D_OK && pRenderTarget != NULL) {
+ IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
+ IWineD3DSurface_Release(pRenderTarget);
+ } else {
+ FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
+ *ppRenderTarget = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSurface9Impl *pSurface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL==pSurface ? NULL : pSurface->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr = D3D_OK;
+ IWineD3DSurface *pZStencilSurface;
+
+ TRACE("(%p) Relay\n" , This);
+ if(ppZStencilSurface == NULL){
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
+ if(hr == D3D_OK) {
+ if(pZStencilSurface != NULL){
+ IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
+ IWineD3DSurface_Release(pZStencilSurface);
+ } else {
+ *ppZStencilSurface = NULL;
+ }
+ } else {
+ WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed\n");
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DRECT is compatible with WINED3DRECT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
+ return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL Enable) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL* pEnable) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST float* pPlane) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, float* pPlane) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DBaseTexture *retTexture = NULL;
+ HRESULT rc = D3D_OK;
+
+ TRACE("(%p) Relay\n" , This);
+
+ if(ppTexture == NULL){
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture);
+ if (rc == D3D_OK && NULL != retTexture) {
+ IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
+ IWineD3DBaseTexture_Release(retTexture);
+ }else{
+ FIXME("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
+ *ppTexture = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+
+ return rc;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
+ pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface, DWORD* pNumPasses) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT* PaletteNumber) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface, CONST RECT* pRect) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface, RECT* pRect) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface, BOOL bSoftware) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface, float nSegments) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType,
+ INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
+ hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
+ UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
+ D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
+ pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DVertexDeclaration9Impl *Decl = (IDirect3DVertexDeclaration9Impl *) pVertexDecl;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer9Impl *)pDestBuffer)->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) {
+ HRESULT hr;
+ D3DVERTEXELEMENT9* elements = NULL;
+ IDirect3DVertexDeclaration9* pDecl = NULL;
+ int p, low, high; /* deliberately signed */
+ IDirect3DVertexDeclaration9 **convertedDecls = This->convertedDecls;
+
+ TRACE("Searching for declaration for fvf %08x... ", fvf);
+
+ low = 0;
+ high = This->numConvertedDecls - 1;
+ while(low <= high) {
+ p = (low + high) >> 1;
+ TRACE("%d ", p);
+ if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF == fvf) {
+ TRACE("found %p\n", convertedDecls[p]);
+ return convertedDecls[p];
+ } else if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF < fvf) {
+ low = p + 1;
+ } else {
+ high = p - 1;
+ }
+ }
+ TRACE("not found. Creating and inserting at position %d.\n", low);
+
+ hr = vdecl_convert_fvf(fvf, &elements);
+ if (hr != S_OK) return NULL;
+
+ hr = IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9 *) This, elements, &pDecl);
+ if (hr != S_OK) return NULL;
+
+ if(This->declArraySize == This->numConvertedDecls) {
+ int grow = max(This->declArraySize / 2, 8);
+ convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
+ sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
+ if(!convertedDecls) {
+ /* This will destroy it */
+ IDirect3DVertexDeclaration9_Release(pDecl);
+ return NULL;
+ }
+ This->convertedDecls = convertedDecls;
+ This->declArraySize += grow;
+ }
+
+ memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(IDirect3DVertexDeclaration9Impl *) * (This->numConvertedDecls - low));
+ convertedDecls[low] = pDecl;
+ This->numConvertedDecls++;
+
+ /* Will prevent the decl from being destroyed */
+ ((IDirect3DVertexDeclaration9Impl *) pDecl)->convFVF = fvf;
+ IDirect3DVertexDeclaration9_Release(pDecl); /* Does not destroy now */
+
+ TRACE("Returning %p. %d decls in array\n", pDecl, This->numConvertedDecls);
+ return pDecl;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ if (0 != FVF) {
+ HRESULT hr;
+ IDirect3DVertexDeclaration9* pDecl = getConvertedDecl(This, FVF);
+
+ if(!pDecl) {
+ /* Any situation when this should happen, except out of memory? */
+ ERR("Failed to create a converted vertex declaration\n");
+ LeaveCriticalSection(&d3d9_cs);
+ return D3DERR_DRIVERINTERNALERROR;
+ }
+
+ hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
+ if (hr != S_OK) {
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+ }
+ }
+ hr = IWineD3DDevice_SetFVF(This->WineD3DDevice, FVF);
+ LeaveCriticalSection(&d3d9_cs);
+
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetFVF(This->WineD3DDevice, pFVF);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
+ pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
+ OffsetInBytes, Stride);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DVertexBuffer *retStream = NULL;
+ HRESULT rc = D3D_OK;
+
+ TRACE("(%p) Relay\n" , This);
+
+ if(pStream == NULL){
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride);
+ if (rc == D3D_OK && NULL != retStream) {
+ IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
+ IWineD3DVertexBuffer_Release(retStream);
+ }else{
+ if (rc != D3D_OK){
+ FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
+ }
+ *pStream = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+
+ return rc;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT* Divider) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n" , This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
+ pIndexData ? ((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9 **ppIndexData) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DIndexBuffer *retIndexData = NULL;
+ HRESULT rc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ if(ppIndexData == NULL){
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData);
+ if (SUCCEEDED(rc) && retIndexData) {
+ IWineD3DIndexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
+ IWineD3DIndexBuffer_Release(retIndexData);
+ } else {
+ if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
+ *ppIndexData = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return rc;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+/*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface, UINT Handle) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DDevice9Impl_QueryInterface,
+ IDirect3DDevice9Impl_AddRef,
+ IDirect3DDevice9Impl_Release,
+ /* IDirect3DDevice9 */
+ IDirect3DDevice9Impl_TestCooperativeLevel,
+ IDirect3DDevice9Impl_GetAvailableTextureMem,
+ IDirect3DDevice9Impl_EvictManagedResources,
+ IDirect3DDevice9Impl_GetDirect3D,
+ IDirect3DDevice9Impl_GetDeviceCaps,
+ IDirect3DDevice9Impl_GetDisplayMode,
+ IDirect3DDevice9Impl_GetCreationParameters,
+ IDirect3DDevice9Impl_SetCursorProperties,
+ IDirect3DDevice9Impl_SetCursorPosition,
+ IDirect3DDevice9Impl_ShowCursor,
+ IDirect3DDevice9Impl_CreateAdditionalSwapChain,
+ IDirect3DDevice9Impl_GetSwapChain,
+ IDirect3DDevice9Impl_GetNumberOfSwapChains,
+ IDirect3DDevice9Impl_Reset,
+ IDirect3DDevice9Impl_Present,
+ IDirect3DDevice9Impl_GetBackBuffer,
+ IDirect3DDevice9Impl_GetRasterStatus,
+ IDirect3DDevice9Impl_SetDialogBoxMode,
+ IDirect3DDevice9Impl_SetGammaRamp,
+ IDirect3DDevice9Impl_GetGammaRamp,
+ IDirect3DDevice9Impl_CreateTexture,
+ IDirect3DDevice9Impl_CreateVolumeTexture,
+ IDirect3DDevice9Impl_CreateCubeTexture,
+ IDirect3DDevice9Impl_CreateVertexBuffer,
+ IDirect3DDevice9Impl_CreateIndexBuffer,
+ IDirect3DDevice9Impl_CreateRenderTarget,
+ IDirect3DDevice9Impl_CreateDepthStencilSurface,
+ IDirect3DDevice9Impl_UpdateSurface,
+ IDirect3DDevice9Impl_UpdateTexture,
+ IDirect3DDevice9Impl_GetRenderTargetData,
+ IDirect3DDevice9Impl_GetFrontBufferData,
+ IDirect3DDevice9Impl_StretchRect,
+ IDirect3DDevice9Impl_ColorFill,
+ IDirect3DDevice9Impl_CreateOffscreenPlainSurface,
+ IDirect3DDevice9Impl_SetRenderTarget,
+ IDirect3DDevice9Impl_GetRenderTarget,
+ IDirect3DDevice9Impl_SetDepthStencilSurface,
+ IDirect3DDevice9Impl_GetDepthStencilSurface,
+ IDirect3DDevice9Impl_BeginScene,
+ IDirect3DDevice9Impl_EndScene,
+ IDirect3DDevice9Impl_Clear,
+ IDirect3DDevice9Impl_SetTransform,
+ IDirect3DDevice9Impl_GetTransform,
+ IDirect3DDevice9Impl_MultiplyTransform,
+ IDirect3DDevice9Impl_SetViewport,
+ IDirect3DDevice9Impl_GetViewport,
+ IDirect3DDevice9Impl_SetMaterial,
+ IDirect3DDevice9Impl_GetMaterial,
+ IDirect3DDevice9Impl_SetLight,
+ IDirect3DDevice9Impl_GetLight,
+ IDirect3DDevice9Impl_LightEnable,
+ IDirect3DDevice9Impl_GetLightEnable,
+ IDirect3DDevice9Impl_SetClipPlane,
+ IDirect3DDevice9Impl_GetClipPlane,
+ IDirect3DDevice9Impl_SetRenderState,
+ IDirect3DDevice9Impl_GetRenderState,
+ IDirect3DDevice9Impl_CreateStateBlock,
+ IDirect3DDevice9Impl_BeginStateBlock,
+ IDirect3DDevice9Impl_EndStateBlock,
+ IDirect3DDevice9Impl_SetClipStatus,
+ IDirect3DDevice9Impl_GetClipStatus,
+ IDirect3DDevice9Impl_GetTexture,
+ IDirect3DDevice9Impl_SetTexture,
+ IDirect3DDevice9Impl_GetTextureStageState,
+ IDirect3DDevice9Impl_SetTextureStageState,
+ IDirect3DDevice9Impl_GetSamplerState,
+ IDirect3DDevice9Impl_SetSamplerState,
+ IDirect3DDevice9Impl_ValidateDevice,
+ IDirect3DDevice9Impl_SetPaletteEntries,
+ IDirect3DDevice9Impl_GetPaletteEntries,
+ IDirect3DDevice9Impl_SetCurrentTexturePalette,
+ IDirect3DDevice9Impl_GetCurrentTexturePalette,
+ IDirect3DDevice9Impl_SetScissorRect,
+ IDirect3DDevice9Impl_GetScissorRect,
+ IDirect3DDevice9Impl_SetSoftwareVertexProcessing,
+ IDirect3DDevice9Impl_GetSoftwareVertexProcessing,
+ IDirect3DDevice9Impl_SetNPatchMode,
+ IDirect3DDevice9Impl_GetNPatchMode,
+ IDirect3DDevice9Impl_DrawPrimitive,
+ IDirect3DDevice9Impl_DrawIndexedPrimitive,
+ IDirect3DDevice9Impl_DrawPrimitiveUP,
+ IDirect3DDevice9Impl_DrawIndexedPrimitiveUP,
+ IDirect3DDevice9Impl_ProcessVertices,
+ IDirect3DDevice9Impl_CreateVertexDeclaration,
+ IDirect3DDevice9Impl_SetVertexDeclaration,
+ IDirect3DDevice9Impl_GetVertexDeclaration,
+ IDirect3DDevice9Impl_SetFVF,
+ IDirect3DDevice9Impl_GetFVF,
+ IDirect3DDevice9Impl_CreateVertexShader,
+ IDirect3DDevice9Impl_SetVertexShader,
+ IDirect3DDevice9Impl_GetVertexShader,
+ IDirect3DDevice9Impl_SetVertexShaderConstantF,
+ IDirect3DDevice9Impl_GetVertexShaderConstantF,
+ IDirect3DDevice9Impl_SetVertexShaderConstantI,
+ IDirect3DDevice9Impl_GetVertexShaderConstantI,
+ IDirect3DDevice9Impl_SetVertexShaderConstantB,
+ IDirect3DDevice9Impl_GetVertexShaderConstantB,
+ IDirect3DDevice9Impl_SetStreamSource,
+ IDirect3DDevice9Impl_GetStreamSource,
+ IDirect3DDevice9Impl_SetStreamSourceFreq,
+ IDirect3DDevice9Impl_GetStreamSourceFreq,
+ IDirect3DDevice9Impl_SetIndices,
+ IDirect3DDevice9Impl_GetIndices,
+ IDirect3DDevice9Impl_CreatePixelShader,
+ IDirect3DDevice9Impl_SetPixelShader,
+ IDirect3DDevice9Impl_GetPixelShader,
+ IDirect3DDevice9Impl_SetPixelShaderConstantF,
+ IDirect3DDevice9Impl_GetPixelShaderConstantF,
+ IDirect3DDevice9Impl_SetPixelShaderConstantI,
+ IDirect3DDevice9Impl_GetPixelShaderConstantI,
+ IDirect3DDevice9Impl_SetPixelShaderConstantB,
+ IDirect3DDevice9Impl_GetPixelShaderConstantB,
+ IDirect3DDevice9Impl_DrawRectPatch,
+ IDirect3DDevice9Impl_DrawTriPatch,
+ IDirect3DDevice9Impl_DeletePatch,
+ IDirect3DDevice9Impl_CreateQuery
+};
+
+
+/* Internal function called back during the CreateDevice to create a render target */
+HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
+ WINED3DCUBEMAP_FACES Face,IWineD3DSurface** ppSurface,
+ HANDLE* pSharedHandle) {
+
+ HRESULT res = D3D_OK;
+ IDirect3DSurface9Impl *d3dSurface = NULL;
+ BOOL Lockable = TRUE;
+
+ if((Pool == D3DPOOL_DEFAULT && Usage != D3DUSAGE_DYNAMIC))
+ Lockable = FALSE;
+
+ TRACE("relay\n");
+ res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, (D3DFORMAT)Format,
+ Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE,
+ Usage, (D3DPOOL) Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
+
+ if (SUCCEEDED(res)) {
+ *ppSurface = d3dSurface->wineD3DSurface;
+ d3dSurface->container = pSuperior;
+ IUnknown_Release(d3dSurface->parentDevice);
+ d3dSurface->parentDevice = NULL;
+ d3dSurface->forwardReference = pSuperior;
+ } else {
+ FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device);
+ }
+ return res;
+}
+
+ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) {
+ IDirect3DSurface9Impl* surfaceParent;
+ TRACE("(%p) call back\n", pSurface);
+
+ IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
+ /* GetParent's AddRef was forwarded to an object in destruction.
+ * Releasing it here again would cause an endless recursion. */
+ surfaceParent->forwardReference = NULL;
+ return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
+}
--- /dev/null
+/*
+ * IDirect3D9 implementation
+ *
+ * Copyright 2002 Jason Edmeades
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3D9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppobj)
+{
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3D9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3D_Release(This->WineD3D);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
+}
+
+/* IDirect3D9 Interface follow: */
+static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* pInitializeFunction) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%p)\n", This, pInitializeFunction);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_GetAdapterCount(This->WineD3D);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ WINED3DADAPTER_IDENTIFIER adapter_id;
+ HRESULT hr;
+
+ /* dx8 and dx9 have different structures to be filled in, with incompatible
+ layouts so pass in pointers to the places to be filled via an internal
+ structure */
+ adapter_id.Driver = pIdentifier->Driver;
+ adapter_id.Description = pIdentifier->Description;
+ adapter_id.DeviceName = pIdentifier->DeviceName;
+ adapter_id.DriverVersion = &pIdentifier->DriverVersion;
+ adapter_id.VendorId = &pIdentifier->VendorId;
+ adapter_id.DeviceId = &pIdentifier->DeviceId;
+ adapter_id.SubSysId = &pIdentifier->SubSysId;
+ adapter_id.Revision = &pIdentifier->Revision;
+ adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
+ adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%d, %d\n", This, Adapter, Format);
+
+ /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
+ if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
+ return 0;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%d, %d, %d, %p)\n", This, Adapter, Format, Mode, pMode);
+ /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
+ It's supposed to fail anyway, so no harm returning failure. */
+ if(Format != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
+ return D3DERR_INVALIDCALL;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface,
+ UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
+ D3DFORMAT BackBufferFormat, BOOL Windowed) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%d, %d, %d, %d, %s\n", This, Adapter, CheckType, DisplayFormat,
+ BackBufferFormat, Windowed ? "true" : "false");
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
+ BackBufferFormat, Windowed);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
+ DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
+ Usage, RType, CheckFormat);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
+ BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
+ Windowed, MultiSampleType, pQualityLevels);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
+ D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
+ RenderTargetFormat, DepthStencilFormat);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hr;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType, SourceFormat,
+ TargetFormat);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+void filter_caps(D3DCAPS9* pCaps)
+{
+
+ DWORD textureFilterCaps =
+ D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
+ D3DPTFILTERCAPS_MINFPYRAMIDALQUAD | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
+ D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
+ D3DPTFILTERCAPS_MAGFLINEAR |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
+ D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
+ pCaps->TextureFilterCaps &= textureFilterCaps;
+ pCaps->CubeTextureFilterCaps &= textureFilterCaps;
+ pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
+
+ pCaps->DevCaps &=
+ D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
+ D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY |
+ D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
+ D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
+ D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL |
+ D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_PUREDEVICE | D3DDEVCAPS_QUINTICRTPATCHES |
+ D3DDEVCAPS_RTPATCHES | D3DDEVCAPS_RTPATCHHANDLEZERO | D3DDEVCAPS_NPATCHES;
+
+ pCaps->ShadeCaps &=
+ D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_SPECULARGOURAUDRGB |
+ D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
+
+ pCaps->RasterCaps &=
+ D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_FOGVERTEX |
+ D3DPRASTERCAPS_FOGTABLE | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBUFFERLESSHSR |
+ D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY | D3DPRASTERCAPS_WBUFFER |
+ D3DPRASTERCAPS_WFOG | D3DPRASTERCAPS_ZFOG | D3DPRASTERCAPS_COLORPERSPECTIVE |
+ D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
+ D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
+
+ pCaps->DevCaps2 &=
+ D3DDEVCAPS2_STREAMOFFSET | D3DDEVCAPS2_DMAPNPATCH | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
+ D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES |
+ D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
+
+ pCaps->Caps2 &=
+ D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED |
+ D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP;
+
+ pCaps->VertexProcessingCaps &=
+ D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_DIRECTIONALLIGHTS |
+ D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER | D3DVTXPCAPS_TWEENING |
+ D3DVTXPCAPS_TEXGEN_SPHEREMAP | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
+
+ pCaps->TextureCaps &=
+ D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
+ D3DPTEXTURECAPS_SQUAREONLY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |
+ D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
+ D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_VOLUMEMAP |
+ D3DPTEXTURECAPS_MIPMAP | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP |
+ D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
+}
+
+static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ WINED3DCAPS *pWineCaps;
+
+ TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
+
+ if(NULL == pCaps){
+ return D3DERR_INVALIDCALL;
+ }
+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
+ if(pWineCaps == NULL){
+ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
+ }
+ memset(pCaps, 0, sizeof(*pCaps));
+ D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, pWineCaps);
+
+ /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
+ pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
+
+ filter_caps(pCaps);
+
+ TRACE("(%p) returning %p\n", This, pCaps);
+ return hrc;
+}
+
+static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ HMONITOR ret;
+ TRACE("%p\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* Internal function called back during the CreateDevice to create a render target */
+HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Lockable,
+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
+ HRESULT res = D3D_OK;
+ IDirect3DSurface9Impl *d3dSurface = NULL;
+ TRACE("(%p) call back\n", device);
+ res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height,
+ (D3DFORMAT)Format, MultiSample, MultisampleQuality, Lockable,
+ (IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
+
+ if (SUCCEEDED(res)) {
+ *ppSurface = d3dSurface->wineD3DSurface;
+ d3dSurface->container = pSuperior;
+ d3dSurface->isImplicit = TRUE;
+ /* Implicit surfaces are created with an refcount of 0 */
+ IUnknown_Release((IUnknown *)d3dSurface);
+ } else {
+ *ppSurface = NULL;
+ }
+ return res;
+}
+
+ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
+ IDirect3DSurface9Impl* surfaceParent;
+ TRACE("(%p) call back\n", pSurface);
+
+ IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
+ surfaceParent->isImplicit = FALSE;
+ /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
+ return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
+}
+
+static HRESULT WINAPI D3D9CB_CreateAdditionalSwapChain(IUnknown *device,
+ WINED3DPRESENT_PARAMETERS* pPresentationParameters,
+ IWineD3DSwapChain ** ppSwapChain) {
+ HRESULT res = D3D_OK;
+ IDirect3DSwapChain9Impl *d3dSwapChain = NULL;
+ D3DPRESENT_PARAMETERS localParameters;
+ TRACE("(%p) call back\n", device);
+
+ /* Copy the presentation parameters */
+ localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
+ localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
+ localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
+ localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
+ localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
+ localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
+ localParameters.SwapEffect = pPresentationParameters->SwapEffect;
+ localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
+ localParameters.Windowed = pPresentationParameters->Windowed;
+ localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
+ localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
+ localParameters.Flags = pPresentationParameters->Flags;
+ localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
+ localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
+
+ res = IDirect3DDevice9_CreateAdditionalSwapChain((IDirect3DDevice9 *)device, &localParameters, (IDirect3DSwapChain9 **)&d3dSwapChain);
+
+ if (SUCCEEDED(res)) {
+ *ppSwapChain = d3dSwapChain->wineD3DSwapChain;
+ d3dSwapChain->isImplicit = TRUE;
+ /* Implicit swap chains are created with an refcount of 0 */
+ IUnknown_Release((IUnknown *)d3dSwapChain);
+ } else {
+ *ppSwapChain = NULL;
+ }
+
+ /* Copy back the presentation parameters */
+ pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
+ pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
+ pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
+ pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
+ pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
+ pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
+ pPresentationParameters->SwapEffect = localParameters.SwapEffect;
+ pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
+ pPresentationParameters->Windowed = localParameters.Windowed;
+ pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
+ pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
+ pPresentationParameters->Flags = localParameters.Flags;
+ pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
+ pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
+
+ return res;
+}
+
+ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
+ IDirect3DSwapChain9Impl* swapChainParent;
+ TRACE("(%p) call back\n", pSwapChain);
+
+ IWineD3DSwapChain_GetParent(pSwapChain,(IUnknown **) &swapChainParent);
+ swapChainParent->isImplicit = FALSE;
+ /* Swap chain had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
+ return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent);
+}
+
+/* Internal function called back during the CreateDevice to create a render target */
+HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
+ WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Discard,
+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
+ HRESULT res = D3D_OK;
+ IDirect3DSurface9Impl *d3dSurface = NULL;
+ TRACE("(%p) call back\n", device);
+
+ res = IDirect3DDevice9_CreateDepthStencilSurface((IDirect3DDevice9 *)device, Width, Height,
+ (D3DFORMAT)Format, MultiSample, MultisampleQuality, Discard,
+ (IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
+ if (SUCCEEDED(res)) {
+ *ppSurface = d3dSurface->wineD3DSurface;
+ d3dSurface->container = device;
+ d3dSurface->isImplicit = TRUE;
+ /* Implicit surfaces are created with an refcount of 0 */
+ IUnknown_Release((IUnknown *)d3dSurface);
+ }
+ return res;
+}
+
+ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
+ IDirect3DSurface9Impl* surfaceParent;
+ TRACE("(%p) call back\n", pSurface);
+
+ IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
+ surfaceParent->isImplicit = FALSE;
+ /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
+ return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
+}
+
+static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType,
+ HWND hFocusWindow, DWORD BehaviourFlags,
+ D3DPRESENT_PARAMETERS* pPresentationParameters,
+ IDirect3DDevice9** ppReturnedDeviceInterface) {
+
+ IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
+ IDirect3DDevice9Impl *object = NULL;
+ WINED3DPRESENT_PARAMETERS localParameters;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ /* Check the validity range of the adapter parameter */
+ if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
+ *ppReturnedDeviceInterface = NULL;
+ return D3DERR_INVALIDCALL;
+ }
+
+ /* Allocate the storage for the device object */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed\n");
+ *ppReturnedDeviceInterface = NULL;
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DDevice9_Vtbl;
+ object->ref = 1;
+ *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
+
+ /* Allocate an associated WineD3DDevice object */
+ EnterCriticalSection(&d3d9_cs);
+ hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object);
+
+ if (hr != D3D_OK) {
+ HeapFree(GetProcessHeap(), 0, object);
+ *ppReturnedDeviceInterface = NULL;
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+ }
+
+ TRACE("(%p) : Created Device %p\n", This, object);
+
+ localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
+ localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
+ localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
+ localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
+ localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
+ localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
+ localParameters.SwapEffect = pPresentationParameters->SwapEffect;
+ localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
+ localParameters.Windowed = pPresentationParameters->Windowed;
+ localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
+ localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
+ localParameters.Flags = pPresentationParameters->Flags;
+ localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
+ localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
+
+ if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
+ IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
+ }
+
+ hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D9CB_CreateAdditionalSwapChain);
+
+ pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
+ pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
+ pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
+ pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
+ pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
+ pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
+ pPresentationParameters->SwapEffect = localParameters.SwapEffect;
+ pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
+ pPresentationParameters->Windowed = localParameters.Windowed;
+ pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
+ pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
+ pPresentationParameters->Flags = localParameters.Flags;
+ pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
+ pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
+
+ if (hr != D3D_OK) {
+ FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
+ HeapFree(GetProcessHeap(), 0, object);
+ *ppReturnedDeviceInterface = NULL;
+ }
+
+ /* Initialize the converted declaration array. This creates a valid pointer and when adding decls HeapReAlloc
+ * can be used without further checking
+ */
+ object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
+ LeaveCriticalSection(&d3d9_cs);
+
+ return hr;
+}
+
+
+
+const IDirect3D9Vtbl Direct3D9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3D9Impl_QueryInterface,
+ IDirect3D9Impl_AddRef,
+ IDirect3D9Impl_Release,
+ /* IDirect3D9 */
+ IDirect3D9Impl_RegisterSoftwareDevice,
+ IDirect3D9Impl_GetAdapterCount,
+ IDirect3D9Impl_GetAdapterIdentifier,
+ IDirect3D9Impl_GetAdapterModeCount,
+ IDirect3D9Impl_EnumAdapterModes,
+ IDirect3D9Impl_GetAdapterDisplayMode,
+ IDirect3D9Impl_CheckDeviceType,
+ IDirect3D9Impl_CheckDeviceFormat,
+ IDirect3D9Impl_CheckDeviceMultiSampleType,
+ IDirect3D9Impl_CheckDepthStencilMatch,
+ IDirect3D9Impl_CheckDeviceFormatConversion,
+ IDirect3D9Impl_GetDeviceCaps,
+ IDirect3D9Impl_GetAdapterMonitor,
+ IDirect3D9Impl_CreateDevice
+};
--- /dev/null
+/*
+ * IDirect3DIndexBuffer9 implementation
+ *
+ * Copyright 2002-2004 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DIndexBuffer9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ D3DRESOURCETYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* IDirect3DIndexBuffer9 Interface follow: */
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) {
+ IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DIndexBuffer9Impl_QueryInterface,
+ IDirect3DIndexBuffer9Impl_AddRef,
+ IDirect3DIndexBuffer9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DIndexBuffer9Impl_GetDevice,
+ IDirect3DIndexBuffer9Impl_SetPrivateData,
+ IDirect3DIndexBuffer9Impl_GetPrivateData,
+ IDirect3DIndexBuffer9Impl_FreePrivateData,
+ IDirect3DIndexBuffer9Impl_SetPriority,
+ IDirect3DIndexBuffer9Impl_GetPriority,
+ IDirect3DIndexBuffer9Impl_PreLoad,
+ IDirect3DIndexBuffer9Impl_GetType,
+ /* IDirect3DIndexBuffer9 */
+ IDirect3DIndexBuffer9Impl_Lock,
+ IDirect3DIndexBuffer9Impl_Unlock,
+ IDirect3DIndexBuffer9Impl_GetDesc
+};
+
+
+/* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface,
+ UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
+ IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
+
+ IDirect3DIndexBuffer9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
+ object->ref = 1;
+ TRACE("Calling wined3d create index buffer\n");
+ hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, pSharedHandle, (IUnknown *)object);
+ if (hrc != D3D_OK) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object;
+ TRACE("(%p) : Created index buffer %p\n", This, object);
+ }
+ return hrc;
+}
--- /dev/null
+/*
+ * IDirect3DPixelShader9 implementation
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DPixelShader9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
+ IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
+ IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DPixelShader_Release(This->wineD3DPixelShader);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DPixelShader9 Interface follow: */
+static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
+ IWineD3DDevice *myDevice = NULL;
+
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
+ IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(myDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ TRACE("(%p) returning (%p)\n", This, *ppDevice);
+ return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
+ IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DPixelShader9Impl_QueryInterface,
+ IDirect3DPixelShader9Impl_AddRef,
+ IDirect3DPixelShader9Impl_Release,
+ /* IDirect3DPixelShader9 */
+ IDirect3DPixelShader9Impl_GetDevice,
+ IDirect3DPixelShader9Impl_GetFunction
+};
+
+
+/* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DPixelShader9Impl *object;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ if (ppShader == NULL) {
+ TRACE("(%p) Invalid call\n", This);
+ return D3DERR_INVALIDCALL;
+ }
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return E_OUTOFMEMORY;
+ }
+
+ object->ref = 1;
+ object->lpVtbl = &Direct3DPixelShader9_Vtbl;
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
+ LeaveCriticalSection(&d3d9_cs);
+ if (hrc != D3D_OK) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
+ HeapFree(GetProcessHeap(), 0 , object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppShader = (IDirect3DPixelShader9*) object;
+ TRACE("(%p) : Created pixel shader %p\n", This, object);
+ }
+
+ TRACE("(%p) : returning %p\n", This, *ppShader);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
+ LeaveCriticalSection(&d3d9_cs);
+ return D3D_OK;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DPixelShader *object;
+
+ HRESULT hrc = D3D_OK;
+ TRACE("(%p) Relay\n", This);
+ if (ppShader == NULL) {
+ TRACE("(%p) Invalid call\n", This);
+ return D3DERR_INVALIDCALL;
+ }
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
+ if (hrc == D3D_OK && object != NULL) {
+ hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
+ IWineD3DPixelShader_Release(object);
+ } else {
+ *ppShader = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+
+ TRACE("(%p) : returning %p\n", This, *ppShader);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
--- /dev/null
+/*
+ * IDirect3DQuery9 implementation
+ *
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DQuery9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DQuery9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DQuery_Release(This->wineD3DQuery);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DQuery9 Interface follow: */
+static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ IWineD3DDevice* pDevice;
+ HRESULT hr;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
+ if(hr != D3D_OK){
+ *ppDevice = NULL;
+ }else{
+ hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(pDevice);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DQuery_GetType(This->wineD3DQuery);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
+ IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
+{
+ IDirect3DQuery9Impl_QueryInterface,
+ IDirect3DQuery9Impl_AddRef,
+ IDirect3DQuery9Impl_Release,
+ IDirect3DQuery9Impl_GetDevice,
+ IDirect3DQuery9Impl_GetType,
+ IDirect3DQuery9Impl_GetDataSize,
+ IDirect3DQuery9Impl_Issue,
+ IDirect3DQuery9Impl_GetData
+};
+
+
+/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DQuery9Impl *object = NULL;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ if (!ppQuery)
+ {
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+ }
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DQuery9_Vtbl;
+ object->ref = 1;
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
+ LeaveCriticalSection(&d3d9_cs);
+
+ if (FAILED(hr)) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppQuery = (LPDIRECT3DQUERY9) object;
+ TRACE("(%p) : Created query %p\n", This , object);
+ }
+ TRACE("(%p) : returning %x\n", This, hr);
+ return hr;
+}
--- /dev/null
+/*
+ * IDirect3DResource9 implementation
+ *
+ * Copyright 2002-2004 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DResource9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DResource9Impl_QueryInterface(LPDIRECT3DRESOURCE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DResource9Impl_AddRef(LPDIRECT3DRESOURCE9 iface) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DResource9Impl_Release(LPDIRECT3DRESOURCE9 iface) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ IWineD3DResource_Release(This->wineD3DResource);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DResource9 Interface follow: */
+HRESULT WINAPI IDirect3DResource9Impl_GetDevice(LPDIRECT3DRESOURCE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ IWineD3DDevice *myDevice = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
+ IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(myDevice);
+ return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DResource9Impl_SetPrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_SetPrivateData(This->wineD3DResource, refguid, pData, SizeOfData, Flags);
+}
+
+static HRESULT WINAPI IDirect3DResource9Impl_GetPrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_GetPrivateData(This->wineD3DResource, refguid, pData, pSizeOfData);
+}
+
+static HRESULT WINAPI IDirect3DResource9Impl_FreePrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_FreePrivateData(This->wineD3DResource, refguid);
+}
+
+static DWORD WINAPI IDirect3DResource9Impl_SetPriority(LPDIRECT3DRESOURCE9 iface, DWORD PriorityNew) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_SetPriority(This->wineD3DResource, PriorityNew);
+}
+
+static DWORD WINAPI IDirect3DResource9Impl_GetPriority(LPDIRECT3DRESOURCE9 iface) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_GetPriority(This->wineD3DResource);
+}
+
+static void WINAPI IDirect3DResource9Impl_PreLoad(LPDIRECT3DRESOURCE9 iface) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ IWineD3DResource_PreLoad(This->wineD3DResource);
+ return;
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DResource9Impl_GetType(LPDIRECT3DRESOURCE9 iface) {
+ IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DResource_GetType(This->wineD3DResource);
+}
+
+
+const IDirect3DResource9Vtbl Direct3DResource9_Vtbl =
+{
+ IDirect3DResource9Impl_QueryInterface,
+ IDirect3DResource9Impl_AddRef,
+ IDirect3DResource9Impl_Release,
+ IDirect3DResource9Impl_GetDevice,
+ IDirect3DResource9Impl_SetPrivateData,
+ IDirect3DResource9Impl_GetPrivateData,
+ IDirect3DResource9Impl_FreePrivateData,
+ IDirect3DResource9Impl_SetPriority,
+ IDirect3DResource9Impl_GetPriority,
+ IDirect3DResource9Impl_PreLoad,
+ IDirect3DResource9Impl_GetType
+};
--- /dev/null
+/*
+ * IDirect3DStateBlock9 implementation
+ *
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DStateBlock9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DStateBlock9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DStateBlock_Release(This->wineD3DStateBlock);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DStateBlock9 Interface follow: */
+static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface) {
+ IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DStateBlock9Impl_QueryInterface,
+ IDirect3DStateBlock9Impl_AddRef,
+ IDirect3DStateBlock9Impl_Release,
+ /* IDirect3DStateBlock9 */
+ IDirect3DStateBlock9Impl_GetDevice,
+ IDirect3DStateBlock9Impl_Capture,
+ IDirect3DStateBlock9Impl_Apply
+};
+
+
+/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DStateBlock9Impl* object;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ if(Type != D3DSBT_ALL && Type != D3DSBT_PIXELSTATE &&
+ Type != D3DSBT_VERTEXSTATE ) {
+ WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
+ return D3DERR_INVALIDCALL;
+ }
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
+ if (NULL == object) return E_OUTOFMEMORY;
+ object->lpVtbl = &Direct3DStateBlock9_Vtbl;
+ object->ref = 1;
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object);
+ LeaveCriticalSection(&d3d9_cs);
+ if(hrc != D3D_OK){
+ FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppStateBlock = (IDirect3DStateBlock9*)object;
+ TRACE("(%p) : Created stateblock %p\n", This, object);
+ }
+ TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ IWineD3DStateBlock* wineD3DStateBlock;
+ IDirect3DStateBlock9Impl* object;
+
+ TRACE("(%p) Relay\n", This);
+
+ /* Tell wineD3D to endstatablock before anything else (in case we run out
+ * of memory later and cause locking problems)
+ */
+ EnterCriticalSection(&d3d9_cs);
+ hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
+ LeaveCriticalSection(&d3d9_cs);
+ if(hr!= D3D_OK){
+ FIXME("IWineD3DDevice_EndStateBlock returned an error\n");
+ return hr;
+ }
+ /* allocate a new IDirectD3DStateBlock */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock9Impl));
+ if (!object) return E_OUTOFMEMORY;
+ object->ref = 1;
+ object->lpVtbl = &Direct3DStateBlock9_Vtbl;
+ object->wineD3DStateBlock = wineD3DStateBlock;
+
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppSB=(IDirect3DStateBlock9*)object;
+ TRACE("(%p)Returning %p %p\n", This, *ppSB, wineD3DStateBlock);
+ return D3D_OK;
+}
--- /dev/null
+/*
+ * IDirect3DSurface9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DSurface9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(LPDIRECT3DSURFACE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DSurface9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+
+ TRACE("(%p)\n", This);
+
+ if (This->forwardReference) {
+ /* Forward refcounting */
+ TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
+ return IUnknown_AddRef(This->forwardReference);
+ } else {
+ /* No container, handle our own refcounting */
+ ULONG ref = InterlockedIncrement(&This->ref);
+ if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+ }
+
+}
+
+static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+
+ TRACE("(%p)\n", This);
+
+ if (This->forwardReference) {
+ /* Forward to the containerParent */
+ TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
+ return IUnknown_Release(This->forwardReference);
+ } else {
+ /* No container, handle our own refcounting */
+ ULONG ref = InterlockedDecrement(&This->ref);
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ if (This->parentDevice) IUnknown_Release(This->parentDevice);
+ if (!This->isImplicit) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DSurface_Release(This->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ }
+
+ return ref;
+ }
+}
+
+/* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p)->(%p)\n", This, ppDevice);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_GetPriority(This->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DSurface_PreLoad(This->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return ;
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ D3DRESOURCETYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DSurface_GetType(This->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* IDirect3DSurface9 Interface follow: */
+static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT res;
+
+ TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
+
+ if (!This->container) return E_NOINTERFACE;
+
+ if (!ppContainer) {
+ ERR("Called without a valid ppContainer\n");
+ }
+
+ res = IUnknown_QueryInterface(This->container, riid, ppContainer);
+
+ TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
+
+ return res;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ WINED3DSURFACE_DESC wined3ddesc;
+ UINT tmpInt = -1;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
+ wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
+ wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
+ wined3ddesc.Usage = &pDesc->Usage;
+ wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
+ wined3ddesc.Size = &tmpInt;
+ wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
+ wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
+ wined3ddesc.Width = &pDesc->Width;
+ wined3ddesc.Height = &pDesc->Height;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
+ hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
+ IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DSurface9Impl_QueryInterface,
+ IDirect3DSurface9Impl_AddRef,
+ IDirect3DSurface9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DSurface9Impl_GetDevice,
+ IDirect3DSurface9Impl_SetPrivateData,
+ IDirect3DSurface9Impl_GetPrivateData,
+ IDirect3DSurface9Impl_FreePrivateData,
+ IDirect3DSurface9Impl_SetPriority,
+ IDirect3DSurface9Impl_GetPriority,
+ IDirect3DSurface9Impl_PreLoad,
+ IDirect3DSurface9Impl_GetType,
+ /* IDirect3DSurface9 */
+ IDirect3DSurface9Impl_GetContainer,
+ IDirect3DSurface9Impl_GetDesc,
+ IDirect3DSurface9Impl_LockRect,
+ IDirect3DSurface9Impl_UnlockRect,
+ IDirect3DSurface9Impl_GetDC,
+ IDirect3DSurface9Impl_ReleaseDC
+};
--- /dev/null
+/*
+ * IDirect3DSwapChain9 implementation
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DSwapChain IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, LPVOID* ppobj)
+{
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DSwapChain9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ if (This->parentDevice) IUnknown_Release(This->parentDevice);
+ if (!This->isImplicit) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D9CB_DestroyRenderTarget);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ }
+ return ref;
+}
+
+/* IDirect3DSwapChain9 parts follow: */
+static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DSurface *mySurface = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &mySurface);
+ if (hrc == D3D_OK && NULL != mySurface) {
+ IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
+ IWineD3DSurface_Release(mySurface);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ /* Do not touch the **ppBackBuffer pointer otherwise! (see device test) */
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DDevice *device = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
+ if (hrc == D3D_OK && NULL != device) {
+ IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(device);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
+ IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
+ WINED3DPRESENT_PARAMETERS winePresentParameters;
+ HRESULT hr;
+
+ TRACE("(%p)->(%p): Relay\n", This, pPresentationParameters);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
+ LeaveCriticalSection(&d3d9_cs);
+
+ pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
+ pPresentationParameters->BackBufferHeight = winePresentParameters.BackBufferHeight;
+ pPresentationParameters->BackBufferFormat = winePresentParameters.BackBufferFormat;
+ pPresentationParameters->BackBufferCount = winePresentParameters.BackBufferCount;
+ pPresentationParameters->MultiSampleType = winePresentParameters.MultiSampleType;
+ pPresentationParameters->MultiSampleQuality = winePresentParameters.MultiSampleQuality;
+ pPresentationParameters->SwapEffect = winePresentParameters.SwapEffect;
+ pPresentationParameters->hDeviceWindow = winePresentParameters.hDeviceWindow;
+ pPresentationParameters->Windowed = winePresentParameters.Windowed;
+ pPresentationParameters->EnableAutoDepthStencil = winePresentParameters.EnableAutoDepthStencil;
+ pPresentationParameters->Flags = winePresentParameters.Flags;
+ pPresentationParameters->FullScreen_RefreshRateInHz = winePresentParameters.FullScreen_RefreshRateInHz;
+ pPresentationParameters->PresentationInterval = winePresentParameters.PresentationInterval;
+
+ return hr;
+}
+
+
+static const IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl =
+{
+ IDirect3DSwapChain9Impl_QueryInterface,
+ IDirect3DSwapChain9Impl_AddRef,
+ IDirect3DSwapChain9Impl_Release,
+ IDirect3DSwapChain9Impl_Present,
+ IDirect3DSwapChain9Impl_GetFrontBufferData,
+ IDirect3DSwapChain9Impl_GetBackBuffer,
+ IDirect3DSwapChain9Impl_GetRasterStatus,
+ IDirect3DSwapChain9Impl_GetDisplayMode,
+ IDirect3DSwapChain9Impl_GetDevice,
+ IDirect3DSwapChain9Impl_GetPresentParameters
+};
+
+
+/* IDirect3DDevice9 IDirect3DSwapChain9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DSwapChain9Impl* object;
+ HRESULT hrc = D3D_OK;
+ WINED3DPRESENT_PARAMETERS localParameters;
+
+ TRACE("(%p) Relay\n", This);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+ object->ref = 1;
+ object->lpVtbl = &Direct3DSwapChain9_Vtbl;
+
+ /* The back buffer count is set to one if it's 0 */
+ if(pPresentationParameters->BackBufferCount == 0) {
+ pPresentationParameters->BackBufferCount = 1;
+ }
+
+ /* Allocate an associated WineD3DDevice object */
+ localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
+ localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
+ localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
+ localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
+ localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
+ localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
+ localParameters.SwapEffect = pPresentationParameters->SwapEffect;
+ localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
+ localParameters.Windowed = pPresentationParameters->Windowed;
+ localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
+ localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
+ localParameters.Flags = pPresentationParameters->Flags;
+ localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
+ localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface);
+ LeaveCriticalSection(&d3d9_cs);
+
+ pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
+ pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
+ pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
+ pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
+ pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
+ pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
+ pPresentationParameters->SwapEffect = localParameters.SwapEffect;
+ pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
+ pPresentationParameters->Windowed = localParameters.Windowed;
+ pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
+ pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
+ pPresentationParameters->Flags = localParameters.Flags;
+ pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
+ pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
+
+ if (hrc != D3D_OK) {
+ FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
+ HeapFree(GetProcessHeap(), 0 , object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *pSwapChain = (IDirect3DSwapChain9 *)object;
+ TRACE("(%p) : Created swapchain %p\n", This, *pSwapChain);
+ }
+ TRACE("(%p) returning %p\n", This, *pSwapChain);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DSwapChain *swapchain = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
+ if (hrc == D3D_OK && NULL != swapchain) {
+ IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
+ IWineD3DSwapChain_Release(swapchain);
+ } else {
+ *pSwapChain = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hrc;
+}
+
+UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ UINT ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
--- /dev/null
+/*
+ * IDirect3DTexture9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Copyright 2002-2005 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DTexture9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
+ || IsEqualGUID(riid, &IID_IDirect3DTexture9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DTexture_Destroy(This->wineD3DTexture, D3D9CB_DestroySurface);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DTexture9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DTexture_PreLoad(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_GetType(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* IDirect3DTexture9 IDirect3DBaseTexture9 Interface follow: */
+static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ DWORD ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ D3DTEXTUREFILTERTYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = (D3DTEXTUREFILTERTYPE) IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture);
+ LeaveCriticalSection(&d3d9_cs);
+}
+
+/* IDirect3DTexture9 Interface follow: */
+static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+
+ WINED3DSURFACE_DESC wined3ddesc;
+ UINT tmpInt = -1;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
+ wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
+ wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
+ wined3ddesc.Usage = &pDesc->Usage;
+ wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
+ wined3ddesc.Size = &tmpInt; /* required for d3d8 */
+ wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
+ wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
+ wined3ddesc.Width = &pDesc->Width;
+ wined3ddesc.Height = &pDesc->Height;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DSurface *mySurface = NULL;
+
+ TRACE("(%p) Relay\n", This);
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
+ if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
+ IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
+ IWineD3DSurface_Release(mySurface);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) {
+ IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static const IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DTexture9Impl_QueryInterface,
+ IDirect3DTexture9Impl_AddRef,
+ IDirect3DTexture9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DTexture9Impl_GetDevice,
+ IDirect3DTexture9Impl_SetPrivateData,
+ IDirect3DTexture9Impl_GetPrivateData,
+ IDirect3DTexture9Impl_FreePrivateData,
+ IDirect3DTexture9Impl_SetPriority,
+ IDirect3DTexture9Impl_GetPriority,
+ IDirect3DTexture9Impl_PreLoad,
+ IDirect3DTexture9Impl_GetType,
+ /* IDirect3dBaseTexture9 */
+ IDirect3DTexture9Impl_SetLOD,
+ IDirect3DTexture9Impl_GetLOD,
+ IDirect3DTexture9Impl_GetLevelCount,
+ IDirect3DTexture9Impl_SetAutoGenFilterType,
+ IDirect3DTexture9Impl_GetAutoGenFilterType,
+ IDirect3DTexture9Impl_GenerateMipSubLevels,
+ /* IDirect3DTexture9 */
+ IDirect3DTexture9Impl_GetLevelDesc,
+ IDirect3DTexture9Impl_GetSurfaceLevel,
+ IDirect3DTexture9Impl_LockRect,
+ IDirect3DTexture9Impl_UnlockRect,
+ IDirect3DTexture9Impl_AddDirtyRect
+};
+
+
+/* IDirect3DDevice9 IDirect3DTexture9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
+ D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
+ IDirect3DTexture9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%#x), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl));
+
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DTexture9_Vtbl;
+ object->ref = 1;
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
+ (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface);
+ LeaveCriticalSection(&d3d9_cs);
+
+ if (FAILED(hrc)) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppTexture= (LPDIRECT3DTEXTURE9) object;
+ TRACE("(%p) Created Texture %p, %p\n", This, object, object->wineD3DTexture);
+ }
+
+ return hrc;
+}
--- /dev/null
+/*
+ * Copyright 2001 Ove Kaaven
+ *
+ * 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
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine Direct3D"
+#define WINE_FILENAME_STR "d3d9.dll"
+#define WINE_FILEVERSION 5,3,1,904
+#define WINE_FILEVERSION_STR "5.3.1.904"
+#define WINE_PRODUCTVERSION 5,3,1,904
+#define WINE_PRODUCTVERSION_STR "5.3.1.904"
+
+#include "wine/wine_common_ver.rc"
--- /dev/null
+/*
+ * IDirect3DVertexBuffer9 implementation
+ *
+ * Copyright 2002-2004 Jason Edmeades
+ * Copyright 2002-2004 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DVertexBuffer9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
+}
+
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return ;
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ D3DRESOURCETYPE ret;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ ret = IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return ret;
+}
+
+/* IDirect3DVertexBuffer9 Interface follow: */
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
+ IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DVertexBuffer9Impl_QueryInterface,
+ IDirect3DVertexBuffer9Impl_AddRef,
+ IDirect3DVertexBuffer9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DVertexBuffer9Impl_GetDevice,
+ IDirect3DVertexBuffer9Impl_SetPrivateData,
+ IDirect3DVertexBuffer9Impl_GetPrivateData,
+ IDirect3DVertexBuffer9Impl_FreePrivateData,
+ IDirect3DVertexBuffer9Impl_SetPriority,
+ IDirect3DVertexBuffer9Impl_GetPriority,
+ IDirect3DVertexBuffer9Impl_PreLoad,
+ IDirect3DVertexBuffer9Impl_GetType,
+ /* IDirect3DVertexBuffer9 */
+ IDirect3DVertexBuffer9Impl_Lock,
+ IDirect3DVertexBuffer9Impl_Unlock,
+ IDirect3DVertexBuffer9Impl_GetDesc
+};
+
+
+/* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
+ UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
+ IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
+
+ IDirect3DVertexBuffer9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
+ object->ref = 1;
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
+ LeaveCriticalSection(&d3d9_cs);
+
+ if (hrc != D3D_OK) {
+
+ /* free up object */
+ WARN("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ TRACE("(%p) : Created vertex buffer %p\n", This, object);
+ *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
+ }
+ return hrc;
+}
--- /dev/null
+/*
+ * IDirect3DVertexDeclaration9 implementation
+ *
+ * Copyright 2002-2003 Raphael Junqueira
+ * Jason Edmeades
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+typedef struct _D3DDECLTYPE_INFO {
+ D3DDECLTYPE d3dType;
+ int size;
+ int typesize;
+} D3DDECLTYPE_INFO;
+
+static D3DDECLTYPE_INFO const d3d_dtype_lookup[D3DDECLTYPE_UNUSED] = {
+ {D3DDECLTYPE_FLOAT1, 1, sizeof(float)},
+ {D3DDECLTYPE_FLOAT2, 2, sizeof(float)},
+ {D3DDECLTYPE_FLOAT3, 3, sizeof(float)},
+ {D3DDECLTYPE_FLOAT4, 4, sizeof(float)},
+ {D3DDECLTYPE_D3DCOLOR, 4, sizeof(BYTE)},
+ {D3DDECLTYPE_UBYTE4, 4, sizeof(BYTE)},
+ {D3DDECLTYPE_SHORT2, 2, sizeof(short int)},
+ {D3DDECLTYPE_SHORT4, 4, sizeof(short int)},
+ {D3DDECLTYPE_UBYTE4N, 4, sizeof(BYTE)},
+ {D3DDECLTYPE_SHORT2N, 2, sizeof(short int)},
+ {D3DDECLTYPE_SHORT4N, 4, sizeof(short int)},
+ {D3DDECLTYPE_USHORT2N, 2, sizeof(short int)},
+ {D3DDECLTYPE_USHORT4N, 4, sizeof(short int)},
+ {D3DDECLTYPE_UDEC3, 3, sizeof(short int)},
+ {D3DDECLTYPE_DEC3N, 3, sizeof(short int)},
+ {D3DDECLTYPE_FLOAT16_2, 2, sizeof(short int)},
+ {D3DDECLTYPE_FLOAT16_4, 4, sizeof(short int)}};
+
+#define D3D_DECL_SIZE(type) d3d_dtype_lookup[type].size
+#define D3D_DECL_TYPESIZE(type) d3d_dtype_lookup[type].typesize
+
+HRESULT vdecl_convert_fvf(
+ DWORD fvf,
+ D3DVERTEXELEMENT9** ppVertexElements) {
+
+ unsigned int idx, idx2;
+ unsigned int offset;
+ BOOL has_pos = (fvf & D3DFVF_POSITION_MASK) != 0;
+ BOOL has_blend = (fvf & D3DFVF_XYZB5) > D3DFVF_XYZRHW;
+ BOOL has_blend_idx = has_blend &&
+ (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB5) ||
+ (fvf & D3DFVF_LASTBETA_D3DCOLOR) ||
+ (fvf & D3DFVF_LASTBETA_UBYTE4));
+ BOOL has_normal = (fvf & D3DFVF_NORMAL) != 0;
+ BOOL has_psize = (fvf & D3DFVF_PSIZE) != 0;
+
+ BOOL has_diffuse = (fvf & D3DFVF_DIFFUSE) != 0;
+ BOOL has_specular = (fvf & D3DFVF_SPECULAR) !=0;
+
+ DWORD num_textures = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
+ DWORD texcoords = (fvf & 0x00FF0000) >> 16;
+
+ D3DVERTEXELEMENT9 end_element = D3DDECL_END();
+ D3DVERTEXELEMENT9 *elements = NULL;
+
+ unsigned int size;
+ DWORD num_blends = 1 + (((fvf & D3DFVF_XYZB5) - D3DFVF_XYZB1) >> 1);
+ if (has_blend_idx) num_blends--;
+
+ /* Compute declaration size */
+ size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
+ has_psize + has_diffuse + has_specular + num_textures + 1;
+
+ /* convert the declaration */
+ elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9));
+ if (!elements)
+ return D3DERR_OUTOFVIDEOMEMORY;
+
+ memcpy(&elements[size-1], &end_element, sizeof(D3DVERTEXELEMENT9));
+ idx = 0;
+ if (has_pos) {
+ if (!has_blend && (fvf & D3DFVF_XYZRHW)) {
+ elements[idx].Type = D3DDECLTYPE_FLOAT4;
+ elements[idx].Usage = D3DDECLUSAGE_POSITIONT;
+ }
+ else {
+ elements[idx].Type = D3DDECLTYPE_FLOAT3;
+ elements[idx].Usage = D3DDECLUSAGE_POSITION;
+ }
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_blend && (num_blends > 0)) {
+ if (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR))
+ elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
+ else
+ elements[idx].Type = D3DDECLTYPE_FLOAT1 + num_blends - 1;
+ elements[idx].Usage = D3DDECLUSAGE_BLENDWEIGHT;
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_blend_idx) {
+ if (fvf & D3DFVF_LASTBETA_UBYTE4 ||
+ (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR)))
+ elements[idx].Type = D3DDECLTYPE_UBYTE4;
+ else if (fvf & D3DFVF_LASTBETA_D3DCOLOR)
+ elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
+ else
+ elements[idx].Type = D3DDECLTYPE_FLOAT1;
+ elements[idx].Usage = D3DDECLUSAGE_BLENDINDICES;
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_normal) {
+ elements[idx].Type = D3DDECLTYPE_FLOAT3;
+ elements[idx].Usage = D3DDECLUSAGE_NORMAL;
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_psize) {
+ elements[idx].Type = D3DDECLTYPE_FLOAT1;
+ elements[idx].Usage = D3DDECLUSAGE_PSIZE;
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_diffuse) {
+ elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
+ elements[idx].Usage = D3DDECLUSAGE_COLOR;
+ elements[idx].UsageIndex = 0;
+ idx++;
+ }
+ if (has_specular) {
+ elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
+ elements[idx].Usage = D3DDECLUSAGE_COLOR;
+ elements[idx].UsageIndex = 1;
+ idx++;
+ }
+ for (idx2 = 0; idx2 < num_textures; idx2++) {
+ unsigned int numcoords = (texcoords >> (idx2*2)) & 0x03;
+ switch (numcoords) {
+ case D3DFVF_TEXTUREFORMAT1:
+ elements[idx].Type = D3DDECLTYPE_FLOAT1;
+ break;
+ case D3DFVF_TEXTUREFORMAT2:
+ elements[idx].Type = D3DDECLTYPE_FLOAT2;
+ break;
+ case D3DFVF_TEXTUREFORMAT3:
+ elements[idx].Type = D3DDECLTYPE_FLOAT3;
+ break;
+ case D3DFVF_TEXTUREFORMAT4:
+ elements[idx].Type = D3DDECLTYPE_FLOAT4;
+ break;
+ }
+ elements[idx].Usage = D3DDECLUSAGE_TEXCOORD;
+ elements[idx].UsageIndex = idx2;
+ idx++;
+ }
+
+ /* Now compute offsets, and initialize the rest of the fields */
+ for (idx = 0, offset = 0; idx < size-1; idx++) {
+ elements[idx].Stream = 0;
+ elements[idx].Method = D3DDECLMETHOD_DEFAULT;
+ elements[idx].Offset = offset;
+ offset += D3D_DECL_SIZE(elements[idx].Type) * D3D_DECL_TYPESIZE(elements[idx].Type);
+ }
+
+ *ppVertexElements = elements;
+ return D3D_OK;
+}
+
+/* IDirect3DVertexDeclaration9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLARATION9 iface) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ if(ref == 1) {
+ IUnknown_AddRef(This->parentDevice);
+ }
+
+ return ref;
+}
+
+void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+
+ if(This->ref != 0) {
+ /* Should not happen unless wine has a bug or the application releases references it does not own */
+ ERR("Destroying vdecl with ref != 0\n");
+ }
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
+ LeaveCriticalSection(&d3d9_cs);
+ HeapFree(GetProcessHeap(), 0, This->elements);
+ HeapFree(GetProcessHeap(), 0, This);
+}
+
+static ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECLARATION9 iface) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ IDirect3DDevice9 *parentDevice = This->parentDevice;
+
+ if(!This->convFVF) {
+ IDirect3DVertexDeclaration9Impl_Release(iface);
+ }
+ IUnknown_Release(parentDevice);
+ }
+ return ref;
+}
+
+/* IDirect3DVertexDeclaration9 Interface follow: */
+static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+ IWineD3DDevice *myDevice = NULL;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) : Relay\n", iface);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
+ if (hr == D3D_OK && myDevice != NULL) {
+ hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(myDevice);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements) {
+ IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
+
+ TRACE("(%p) : pDecl %p, pNumElements %p)\n", This, pDecl, pNumElements);
+
+ *pNumElements = This->element_count;
+
+ /* Passing a NULL pDecl is used to just retrieve the number of elements */
+ if (!pDecl) {
+ TRACE("NULL pDecl passed. Returning D3D_OK.\n");
+ return D3D_OK;
+ }
+
+ TRACE("Copying %p to %p\n", This->elements, pDecl);
+ CopyMemory(pDecl, This->elements, This->element_count * sizeof(D3DVERTEXELEMENT9));
+
+ return D3D_OK;
+}
+
+static const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DVertexDeclaration9Impl_QueryInterface,
+ IDirect3DVertexDeclaration9Impl_AddRef,
+ IDirect3DVertexDeclaration9Impl_Release,
+ /* IDirect3DVertexDeclaration9 */
+ IDirect3DVertexDeclaration9Impl_GetDevice,
+ IDirect3DVertexDeclaration9Impl_GetDeclaration
+};
+
+static size_t convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elements, WINED3DVERTEXELEMENT **wined3d_elements) {
+ const D3DVERTEXELEMENT9* element;
+ size_t element_count = 1;
+ size_t i;
+
+ TRACE("d3d9_elements %p, wined3d_elements %p\n", d3d9_elements, wined3d_elements);
+
+ element = d3d9_elements;
+ while (element++->Stream != 0xff && element_count++ < 128);
+
+ if (element_count == 128) {
+ return 0;
+ }
+
+ *wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(WINED3DVERTEXELEMENT));
+ if (!*wined3d_elements) {
+ FIXME("Memory allocation failed\n");
+ return 0;
+ }
+
+ for (i = 0; i < element_count; ++i) {
+ CopyMemory(*wined3d_elements + i, d3d9_elements + i, sizeof(D3DVERTEXELEMENT9));
+ (*wined3d_elements)[i].Reg = -1;
+ }
+
+ return element_count;
+}
+
+/* IDirect3DDevice9 IDirect3DVertexDeclaration9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9 iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) {
+
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DVertexDeclaration9Impl *object = NULL;
+ WINED3DVERTEXELEMENT* wined3d_elements;
+ size_t element_count;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) : Relay\n", iface);
+ if (NULL == ppDecl) {
+ WARN("(%p) : Caller passed NULL As ppDecl, returning D3DERR_INVALIDCALL\n",This);
+ return D3DERR_INVALIDCALL;
+ }
+
+ element_count = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements);
+ if (!element_count) {
+ FIXME("(%p) : Error parsing vertex declaration\n", This);
+ return D3DERR_INVALIDCALL;
+ }
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexDeclaration9Impl));
+ if (NULL == object) {
+ HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DVertexDeclaration9_Vtbl;
+ object->ref = 0;
+
+ object->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(D3DVERTEXELEMENT9));
+ if (!object->elements) {
+ HeapFree(GetProcessHeap(), 0, wined3d_elements);
+ HeapFree(GetProcessHeap(), 0, object);
+ ERR("Memory allocation failed\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+ CopyMemory(object->elements, pVertexElements, element_count * sizeof(D3DVERTEXELEMENT9));
+ object->element_count = element_count;
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration, (IUnknown *)object, wined3d_elements, element_count);
+ LeaveCriticalSection(&d3d9_cs);
+
+ HeapFree(GetProcessHeap(), 0, wined3d_elements);
+
+ if (FAILED(hr)) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateVertexDeclaration failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object->elements);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ object->parentDevice = iface;
+ *ppDecl = (LPDIRECT3DVERTEXDECLARATION9) object;
+ IUnknown_AddRef(*ppDecl);
+ TRACE("(%p) : Created vertex declaration %p\n", This, object);
+ }
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) : Relay\n", iface);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl) {
+ IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface;
+ IWineD3DVertexDeclaration* pTest = NULL;
+ HRESULT hr = D3D_OK;
+
+ TRACE("(%p) : Relay+\n", iface);
+
+ if (NULL == ppDecl) {
+ return D3DERR_INVALIDCALL;
+ }
+
+ *ppDecl = NULL;
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
+ if (hr == D3D_OK && NULL != pTest) {
+ IWineD3DVertexDeclaration_GetParent(pTest, (IUnknown **)ppDecl);
+ IWineD3DVertexDeclaration_Release(pTest);
+ } else {
+ *ppDecl = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ TRACE("(%p) : returning %p\n", This, *ppDecl);
+ return hr;
+}
--- /dev/null
+/*
+ * IDirect3DVertexShader9 implementation
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DVertexShader9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
+ IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
+ IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ EnterCriticalSection(&d3d9_cs);
+ IWineD3DVertexShader_Release(This->wineD3DVertexShader);
+ LeaveCriticalSection(&d3d9_cs);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DVertexShader9 Interface follow: */
+static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
+ IWineD3DDevice *myDevice = NULL;
+ HRESULT hr = D3D_OK;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ if (D3D_OK == (hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice) && myDevice != NULL)) {
+ hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(myDevice);
+ } else {
+ *ppDevice = NULL;
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ TRACE("(%p) returning (%p)\n", This, *ppDevice);
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
+ IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+
+static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DVertexShader9Impl_QueryInterface,
+ IDirect3DVertexShader9Impl_AddRef,
+ IDirect3DVertexShader9Impl_Release,
+ /* IDirect3DVertexShader9 */
+ IDirect3DVertexShader9Impl_GetDevice,
+ IDirect3DVertexShader9Impl_GetFunction
+};
+
+
+/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IDirect3DVertexShader9Impl *object;
+
+ /* Setup a stub object for now */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
+ if (NULL == object) {
+ FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->ref = 1;
+ object->lpVtbl = &Direct3DVertexShader9_Vtbl;
+ EnterCriticalSection(&d3d9_cs);
+ hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
+ LeaveCriticalSection(&d3d9_cs);
+
+ if (FAILED(hrc)) {
+
+ /* free up object */
+ FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
+ HeapFree(GetProcessHeap(), 0, object);
+ }else{
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppShader = (IDirect3DVertexShader9 *)object;
+ TRACE("(%p) : Created vertex shader %p\n", This, object);
+ }
+
+ TRACE("(%p) : returning %p\n", This, *ppShader);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) : Relay\n", This);
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
+ LeaveCriticalSection(&d3d9_cs);
+
+ TRACE("(%p) : returning hr(%u)\n", This, hrc);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IWineD3DVertexShader *pShader;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
+ EnterCriticalSection(&d3d9_cs);
+ hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
+ if(hrc == D3D_OK && pShader != NULL){
+ hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
+ IWineD3DVertexShader_Release(pShader);
+ } else {
+ WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
+ }
+ LeaveCriticalSection(&d3d9_cs);
+ TRACE("(%p) : returning %p\n", This, *ppShader);
+ return hrc;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+
+ TRACE("(%p) : Relay\n", This);
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
+
+HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hr;
+ TRACE("(%p) : Relay\n", This);
+
+ EnterCriticalSection(&d3d9_cs);
+ hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
+ LeaveCriticalSection(&d3d9_cs);
+ return hr;
+}
--- /dev/null
+/*
+ * IDirect3DVolume9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DVolume9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DVolume9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+
+ TRACE("(%p)\n", This);
+
+ if (This->forwardReference) {
+ /* Forward refcounting */
+ TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
+ return IUnknown_AddRef(This->forwardReference);
+ } else {
+ /* No container, handle our own refcounting */
+ ULONG ref = InterlockedIncrement(&This->ref);
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+ return ref;
+ }
+}
+
+static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+
+ TRACE("(%p)\n", This);
+
+ if (This->forwardReference) {
+ /* Forward refcounting */
+ TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
+ return IUnknown_Release(This->forwardReference);
+ } else {
+ /* No container, handle our own refcounting */
+ ULONG ref = InterlockedDecrement(&This->ref);
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ IWineD3DVolume_Release(This->wineD3DVolume);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
+ }
+}
+
+/* IDirect3DVolume9 Interface follow: */
+static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ IWineD3DDevice *myDevice = NULL;
+
+ IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
+ IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
+ IWineD3DDevice_Release(myDevice);
+ return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ HRESULT res;
+
+ TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
+
+ if (!This->container) return E_NOINTERFACE;
+
+ if (!ppContainer) {
+ ERR("Called without a valid ppContainer.\n");
+ }
+
+ res = IUnknown_QueryInterface(This->container, riid, ppContainer);
+
+ TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
+
+ return res;
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ WINED3DVOLUME_DESC wined3ddesc;
+ UINT tmpInt = -1;
+
+ TRACE("(%p) Relay\n", This);
+
+ /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
+ wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
+ wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
+ wined3ddesc.Usage = &pDesc->Usage;
+ wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
+ wined3ddesc.Size = &tmpInt;
+ wined3ddesc.Width = &pDesc->Width;
+ wined3ddesc.Height = &pDesc->Height;
+ wined3ddesc.Depth = &pDesc->Depth;
+
+ return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
+ return IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume, (CONST WINED3DBOX *)pBox, Flags);
+}
+
+static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
+ IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
+ TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
+ return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
+}
+
+static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DVolume9Impl_QueryInterface,
+ IDirect3DVolume9Impl_AddRef,
+ IDirect3DVolume9Impl_Release,
+ /* IDirect3DVolume9 */
+ IDirect3DVolume9Impl_GetDevice,
+ IDirect3DVolume9Impl_SetPrivateData,
+ IDirect3DVolume9Impl_GetPrivateData,
+ IDirect3DVolume9Impl_FreePrivateData,
+ IDirect3DVolume9Impl_GetContainer,
+ IDirect3DVolume9Impl_GetDesc,
+ IDirect3DVolume9Impl_LockBox,
+ IDirect3DVolume9Impl_UnlockBox
+};
+
+
+/* Internal function called back during the CreateVolumeTexture */
+HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
+ WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
+ IWineD3DVolume **ppVolume,
+ HANDLE * pSharedHandle) {
+ IDirect3DVolume9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)pDevice;
+ HRESULT hrc = D3D_OK;
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume9Impl));
+ if (NULL == object) {
+ FIXME("Allocation of memory failed\n");
+ *ppVolume = NULL;
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DVolume9_Vtbl;
+ object->ref = 1;
+ hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage & WINED3DUSAGE_MASK, Format,
+ Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
+ if (hrc != D3D_OK) {
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ *ppVolume = NULL;
+ } else {
+ *ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
+ object->container = pSuperior;
+ object->forwardReference = pSuperior;
+ }
+ TRACE("(%p) Created volume %p\n", This, *ppVolume);
+ return hrc;
+}
+
+ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) {
+ IDirect3DVolume9Impl* volumeParent;
+
+ IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
+ /* GetParent's AddRef was forwarded to an object in destruction.
+ * Releasing it here again would cause an endless recursion. */
+ volumeParent->forwardReference = NULL;
+ return IDirect3DVolume9_Release((IDirect3DVolume9*) volumeParent);
+}
--- /dev/null
+/*
+ * IDirect3DVolumeTexture9 implementation
+ *
+ * Copyright 2002-2005 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+/* IDirect3DVolumeTexture9 IUnknown parts follow: */
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+
+ if (IsEqualGUID(riid, &IID_IUnknown)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
+ || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
+ IUnknown_AddRef(iface);
+ *ppobj = This;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+ *ppobj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) : AddRef from %d\n", This, ref - 1);
+
+ return ref;
+}
+
+static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) : ReleaseRef to %d\n", This, ref);
+
+ if (ref == 0) {
+ IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D9CB_DestroyVolume);
+ IUnknown_Release(This->parentDevice);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
+}
+
+static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
+}
+
+static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
+}
+
+static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
+}
+
+static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
+}
+
+/* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
+static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
+}
+
+static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
+}
+
+static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
+}
+
+static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return (D3DTEXTUREFILTERTYPE) IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
+}
+
+static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
+}
+
+/* IDirect3DVolumeTexture9 Interface follow: */
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ WINED3DVOLUME_DESC wined3ddesc;
+ UINT tmpInt = -1;
+
+ TRACE("(%p) Relay\n", This);
+
+ /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
+ wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
+ wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
+ wined3ddesc.Usage = &pDesc->Usage;
+ wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
+ wined3ddesc.Size = &tmpInt;
+ wined3ddesc.Width = &pDesc->Width;
+ wined3ddesc.Height = &pDesc->Height;
+ wined3ddesc.Depth = &pDesc->Depth;
+
+ return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+ IWineD3DVolume *myVolume = NULL;
+
+ TRACE("(%p) Relay\n", This);
+
+ hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
+ if (hrc == D3D_OK && NULL != ppVolumeLevel) {
+ IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
+ IWineD3DVolumeTexture_Release(myVolume);
+ }
+ return hrc;
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
+ return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume, (CONST WINED3DBOX *)pBox, Flags);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
+ return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
+}
+
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
+ IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+ TRACE("(%p) Relay\n", This);
+ return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
+}
+
+
+static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
+{
+ /* IUnknown */
+ IDirect3DVolumeTexture9Impl_QueryInterface,
+ IDirect3DVolumeTexture9Impl_AddRef,
+ IDirect3DVolumeTexture9Impl_Release,
+ /* IDirect3DResource9 */
+ IDirect3DVolumeTexture9Impl_GetDevice,
+ IDirect3DVolumeTexture9Impl_SetPrivateData,
+ IDirect3DVolumeTexture9Impl_GetPrivateData,
+ IDirect3DVolumeTexture9Impl_FreePrivateData,
+ IDirect3DVolumeTexture9Impl_SetPriority,
+ IDirect3DVolumeTexture9Impl_GetPriority,
+ IDirect3DVolumeTexture9Impl_PreLoad,
+ IDirect3DVolumeTexture9Impl_GetType,
+ /* IDirect3DBaseTexture9 */
+ IDirect3DVolumeTexture9Impl_SetLOD,
+ IDirect3DVolumeTexture9Impl_GetLOD,
+ IDirect3DVolumeTexture9Impl_GetLevelCount,
+ IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
+ IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
+ IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
+ /* IDirect3DVolumeTexture9 */
+ IDirect3DVolumeTexture9Impl_GetLevelDesc,
+ IDirect3DVolumeTexture9Impl_GetVolumeLevel,
+ IDirect3DVolumeTexture9Impl_LockBox,
+ IDirect3DVolumeTexture9Impl_UnlockBox,
+ IDirect3DVolumeTexture9Impl_AddDirtyBox
+};
+
+
+/* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
+HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface,
+ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
+ D3DFORMAT Format, D3DPOOL Pool,
+ IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
+
+ IDirect3DVolumeTexture9Impl *object;
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ HRESULT hrc = D3D_OK;
+
+ TRACE("(%p) Relay\n", This);
+
+ /* Allocate the storage for the device */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
+ if (NULL == object) {
+ FIXME("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This);
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
+ object->ref = 1;
+ hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage & WINED3DUSAGE_MASK,
+ (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, pSharedHandle,
+ (IUnknown *)object, D3D9CB_CreateVolume);
+
+
+ if (hrc != D3D_OK) {
+
+ /* free up object */
+ FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
+ HeapFree(GetProcessHeap(), 0, object);
+ } else {
+ IUnknown_AddRef(iface);
+ object->parentDevice = iface;
+ *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object;
+ TRACE("(%p) : Created volume texture %p\n", This, object);
+ }
+ TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
+ return hrc;
+}
<directory name="d3d8">
<xi:include href="d3d8/d3d8.rbuild" />
</directory>
+ <directory name="d3d9">
+ <xi:include href="d3d9/d3d9.rbuild" />
+ </directory>
</group>