Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IDirect3DVertexShader9 implementation |
| 3 | * |
| 4 | * Copyright 2002-2003 Jason Edmeades |
| 5 | * Raphael Junqueira |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "config.h" |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 23 | #include "d3d9_private.h" |
| 24 | |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 25 | WINE_DEFAULT_DEBUG_CHANNEL(d3d9); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 26 | |
| 27 | /* IDirect3DVertexShader9 IUnknown parts follow: */ |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 28 | static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 29 | IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 30 | |
| 31 | if (IsEqualGUID(riid, &IID_IUnknown) |
| 32 | || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 33 | IUnknown_AddRef(iface); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 34 | *ppobj = This; |
H. Verbeet | 34e2e2b | 2006-06-07 15:13:29 +0200 | [diff] [blame] | 35 | return S_OK; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); |
H. Verbeet | 34e2e2b | 2006-06-07 15:13:29 +0200 | [diff] [blame] | 39 | *ppobj = NULL; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 40 | return E_NOINTERFACE; |
| 41 | } |
| 42 | |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 43 | static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 44 | IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface; |
Paul Vriens | 7a49e82 | 2005-01-24 11:31:45 +0000 | [diff] [blame] | 45 | ULONG ref = InterlockedIncrement(&This->ref); |
| 46 | |
| 47 | TRACE("(%p) : AddRef from %ld\n", This, ref - 1); |
| 48 | |
| 49 | return ref; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 52 | static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 53 | IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface; |
Paul Vriens | 7a49e82 | 2005-01-24 11:31:45 +0000 | [diff] [blame] | 54 | ULONG ref = InterlockedDecrement(&This->ref); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 55 | |
Paul Vriens | 7a49e82 | 2005-01-24 11:31:45 +0000 | [diff] [blame] | 56 | TRACE("(%p) : ReleaseRef to %ld\n", This, ref); |
| 57 | |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 58 | if (ref == 0) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 59 | IWineD3DVertexShader_Release(This->wineD3DVertexShader); |
Vitaliy Margolen | 4a25828 | 2006-04-11 22:09:27 -0600 | [diff] [blame] | 60 | IUnknown_Release(This->parentDevice); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 61 | HeapFree(GetProcessHeap(), 0, This); |
| 62 | } |
| 63 | return ref; |
| 64 | } |
| 65 | |
| 66 | /* IDirect3DVertexShader9 Interface follow: */ |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 67 | static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 68 | IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 69 | IWineD3DDevice *myDevice = NULL; |
| 70 | HRESULT hr = D3D_OK; |
| 71 | TRACE("(%p) : Relay\n", This); |
| 72 | |
| 73 | if (D3D_OK == (hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice) && myDevice != NULL)) { |
| 74 | hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice); |
| 75 | IWineD3DDevice_Release(myDevice); |
| 76 | } else { |
| 77 | *ppDevice = NULL; |
| 78 | } |
| 79 | TRACE("(%p) returing (%p)", This, *ppDevice); |
| 80 | return hr; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 83 | static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 84 | IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 85 | |
| 86 | TRACE("(%p) : Relay\n", This); |
| 87 | return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | |
Alexandre Julliard | c30d4ec | 2006-06-10 11:51:05 +0200 | [diff] [blame] | 91 | static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl = |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 92 | { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 93 | /* IUnknown */ |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 94 | IDirect3DVertexShader9Impl_QueryInterface, |
| 95 | IDirect3DVertexShader9Impl_AddRef, |
Oliver Stieber | cd159e3 | 2005-08-23 09:34:57 +0000 | [diff] [blame] | 96 | IDirect3DVertexShader9Impl_Release, |
| 97 | /* IDirect3DVertexShader9 */ |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 98 | IDirect3DVertexShader9Impl_GetDevice, |
| 99 | IDirect3DVertexShader9Impl_GetFunction |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | /* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */ |
| 104 | HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 105 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 106 | HRESULT hrc = D3D_OK; |
| 107 | IDirect3DVertexShader9Impl *object; |
| 108 | |
| 109 | /* Setup a stub object for now */ |
| 110 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); |
| 111 | TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader); |
| 112 | if (NULL == object) { |
Oliver Stieber | 58fdd89 | 2005-11-14 11:21:46 +0000 | [diff] [blame] | 113 | FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 114 | return D3DERR_OUTOFVIDEOMEMORY; |
| 115 | } |
| 116 | |
| 117 | object->ref = 1; |
| 118 | object->lpVtbl = &Direct3DVertexShader9_Vtbl; |
Oliver Stieber | 7c482cb | 2005-12-09 11:23:52 +0100 | [diff] [blame] | 119 | hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 120 | |
| 121 | if (FAILED(hrc)) { |
Oliver Stieber | 58fdd89 | 2005-11-14 11:21:46 +0000 | [diff] [blame] | 122 | |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 123 | /* free up object */ |
| 124 | FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n"); |
| 125 | HeapFree(GetProcessHeap(), 0, object); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 126 | }else{ |
Vitaliy Margolen | 4a25828 | 2006-04-11 22:09:27 -0600 | [diff] [blame] | 127 | IUnknown_AddRef(iface); |
| 128 | object->parentDevice = iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 129 | *ppShader = (IDirect3DVertexShader9 *)object; |
Oliver Stieber | 58fdd89 | 2005-11-14 11:21:46 +0000 | [diff] [blame] | 130 | TRACE("(%p) : Created vertex shader %p\n", This, object); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | TRACE("(%p) : returning %p\n", This, *ppShader); |
| 134 | return hrc; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 138 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 139 | HRESULT hrc = D3D_OK; |
| 140 | |
Francois Gouget | 0edbaf7 | 2005-11-10 12:14:56 +0000 | [diff] [blame] | 141 | TRACE("(%p) : Relay\n", This); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 142 | hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader); |
| 143 | |
Francois Gouget | 0edbaf7 | 2005-11-10 12:14:56 +0000 | [diff] [blame] | 144 | TRACE("(%p) : returning hr(%lu)\n", This, hrc); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 145 | return hrc; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 149 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 150 | IWineD3DVertexShader *pShader; |
| 151 | HRESULT hrc = D3D_OK; |
| 152 | |
Francois Gouget | 0edbaf7 | 2005-11-10 12:14:56 +0000 | [diff] [blame] | 153 | TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice); |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 154 | hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader); |
H. Verbeet | 0a0e948 | 2005-12-14 11:29:05 +0100 | [diff] [blame] | 155 | if(hrc == D3D_OK && pShader != NULL){ |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 156 | hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader); |
| 157 | IWineD3DVertexShader_Release(pShader); |
| 158 | } else { |
| 159 | WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %lu (device %p)\n", This, hrc, This->WineD3DDevice); |
| 160 | } |
| 161 | TRACE("(%p) : returning %p\n", This, *ppShader); |
| 162 | return hrc; |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 166 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
| 167 | TRACE("(%p) : Relay\n", This); |
| 168 | return IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 172 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
| 173 | TRACE("(%p) : Relay\n", This); |
| 174 | return IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 178 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
| 179 | TRACE("(%p) : Relay\n", This); |
| 180 | return IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 184 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
| 185 | TRACE("(%p) : Relay\n", This); |
| 186 | return IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) { |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 190 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
| 191 | TRACE("(%p) : Relay\n", This); |
| 192 | return IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) { |
Alexandre Julliard | f5f7a18 | 2004-09-08 01:50:37 +0000 | [diff] [blame] | 196 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; |
Oliver Stieber | e403237 | 2005-08-18 11:45:17 +0000 | [diff] [blame] | 197 | TRACE("(%p) : Relay\n", This); |
| 198 | return IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount); |
Raphael Junqueira | a3dbd7e | 2003-07-01 01:09:17 +0000 | [diff] [blame] | 199 | } |