Module: wine Branch: master Commit: 5ad6766c85d4978ad535e5ec4c066f6bec5d7e9e URL: http://source.winehq.org/git/wine.git/?a=commit;h=5ad6766c85d4978ad535e5ec4c...
Author: H. Verbeet hverbeet@gmail.com Date: Tue Feb 13 23:12:24 2007 +0100
d3d8: Store the d3d8 vertex declaration in the d3d8 vertex shader.
---
dlls/d3d8/d3d8_private.h | 1 + dlls/d3d8/device.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/d3d8/vertexshader.c | 1 + 3 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 0af3c56..d35f351 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -586,6 +586,7 @@ struct IDirect3DVertexShader8Impl { LONG ref;
shader_handle *handle; + IDirect3DVertexDeclaration8 *vertex_declaration; IWineD3DVertexShader *wineD3DVertexShader; };
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 18b79ce..d82919c 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1162,6 +1162,35 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 ifa return IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer8Impl *)pDestBuffer)->wineD3DVertexBuffer, NULL, Flags); }
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexDeclaration(IDirect3DDevice8 *iface, CONST DWORD *declaration, IDirect3DVertexDeclaration8 **decl_ptr) { + IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; + IDirect3DVertexDeclaration8Impl *object; + HRESULT hr = D3D_OK; + + TRACE("(%p) : declaration %p\n", This, declaration); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) { + ERR("Memory allocation failed\n"); + *decl_ptr = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + + object->ref_count = 1; + object->lpVtbl = &Direct3DVertexDeclaration8_Vtbl; + + hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, declaration, &object->wined3d_vertex_declaration, (IUnknown *)object); + if (FAILED(hr)) { + ERR("(%p) : IWineD3DDevice_CreateVertexDeclaration call failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + } else { + *decl_ptr = (IDirect3DVertexDeclaration8 *)object; + TRACE("(%p) : Created vertex declaration %p\n", This, object); + } + + return hr; +} + static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* ppShader, DWORD Usage) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; HRESULT hrc = D3D_OK; @@ -1178,6 +1207,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8
object->ref = 1; object->lpVtbl = &Direct3DVertexShader8_Vtbl; + + hrc = IDirect3DDevice8Impl_CreateVertexDeclaration(iface, pDeclaration, &object->vertex_declaration); + if (FAILED(hrc)) { + ERR("(%p) : IDirect3DDeviceImpl_CreateVertexDeclaration call failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppShader = 0; + return D3DERR_INVALIDCALL; + } + /* Usage is missing ..*/ hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pDeclaration, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
diff --git a/dlls/d3d8/vertexshader.c b/dlls/d3d8/vertexshader.c index 2f22e31..89555bd 100644 --- a/dlls/d3d8/vertexshader.c +++ b/dlls/d3d8/vertexshader.c @@ -56,6 +56,7 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) { + IDirect3DVertexDeclaration8_Release(This->vertex_declaration); IWineD3DVertexShader_Release(This->wineD3DVertexShader); HeapFree(GetProcessHeap(), 0, This); }