~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d9/vertexshader.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  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
 19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 20  */
 21 
 22 #include "config.h"
 23 #include "d3d9_private.h"
 24 
 25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
 26 
 27 /* IDirect3DVertexShader9 IUnknown parts follow: */
 28 static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
 29     IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
 30 
 31     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
 32 
 33     if (IsEqualGUID(riid, &IID_IUnknown)
 34         || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
 35         IDirect3DVertexShader9_AddRef(iface);
 36         *ppobj = This;
 37         return S_OK;
 38     }
 39 
 40     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 41     *ppobj = NULL;
 42     return E_NOINTERFACE;
 43 }
 44 
 45 static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
 46     IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
 47     ULONG ref = InterlockedIncrement(&This->ref);
 48 
 49     TRACE("%p increasing refcount to %u.\n", iface, ref);
 50 
 51     if (ref == 1)
 52     {
 53         IDirect3DDevice9Ex_AddRef(This->parentDevice);
 54         wined3d_mutex_lock();
 55         IWineD3DVertexShader_AddRef(This->wineD3DVertexShader);
 56         wined3d_mutex_unlock();
 57     }
 58 
 59     return ref;
 60 }
 61 
 62 static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
 63     IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
 64     ULONG ref = InterlockedDecrement(&This->ref);
 65 
 66     TRACE("%p decreasing refcount to %u.\n", iface, ref);
 67 
 68     if (ref == 0) {
 69         IDirect3DDevice9Ex *parentDevice = This->parentDevice;
 70 
 71         wined3d_mutex_lock();
 72         IWineD3DVertexShader_Release(This->wineD3DVertexShader);
 73         wined3d_mutex_unlock();
 74 
 75         /* Release the device last, as it may cause the device to be destroyed. */
 76         IDirect3DDevice9Ex_Release(parentDevice);
 77     }
 78     return ref;
 79 }
 80 
 81 /* IDirect3DVertexShader9 Interface follow: */
 82 static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
 83     IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
 84     IWineD3DDevice *myDevice = NULL;
 85     HRESULT hr;
 86 
 87     TRACE("iface %p, device %p.\n", iface, ppDevice);
 88 
 89     wined3d_mutex_lock();
 90     hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
 91     if (WINED3D_OK == hr && myDevice != NULL) {
 92         hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
 93         IWineD3DDevice_Release(myDevice);
 94     } else {
 95         *ppDevice = NULL;
 96     }
 97     wined3d_mutex_unlock();
 98 
 99     TRACE("(%p) returning (%p)\n", This, *ppDevice);
100     return hr;
101 }
102 
103 static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
104     IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
105     HRESULT hr;
106 
107     TRACE("iface %p, data %p, data_size %p.\n", iface, pData, pSizeOfData);
108 
109     wined3d_mutex_lock();
110     hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
111     wined3d_mutex_unlock();
112 
113     return hr;
114 }
115 
116 
117 static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
118 {
119     /* IUnknown */
120     IDirect3DVertexShader9Impl_QueryInterface,
121     IDirect3DVertexShader9Impl_AddRef,
122     IDirect3DVertexShader9Impl_Release,
123     /* IDirect3DVertexShader9 */
124     IDirect3DVertexShader9Impl_GetDevice,
125     IDirect3DVertexShader9Impl_GetFunction
126 };
127 
128 static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
129 {
130     HeapFree(GetProcessHeap(), 0, parent);
131 }
132 
133 static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
134 {
135     d3d9_vertexshader_wined3d_object_destroyed,
136 };
137 
138 HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
139 {
140     HRESULT hr;
141 
142     shader->ref = 1;
143     shader->lpVtbl = &Direct3DVertexShader9_Vtbl;
144 
145     wined3d_mutex_lock();
146     hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
147             NULL /* output signature */, &shader->wineD3DVertexShader,
148             (IUnknown *)shader, &d3d9_vertexshader_wined3d_parent_ops);
149     wined3d_mutex_unlock();
150     if (FAILED(hr))
151     {
152         WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
153         return hr;
154     }
155 
156     shader->parentDevice = (IDirect3DDevice9Ex *)device;
157     IDirect3DDevice9Ex_AddRef(shader->parentDevice);
158 
159     return D3D_OK;
160 }
161 
162 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
163     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
164     HRESULT hrc = D3D_OK;
165 
166     TRACE("iface %p, shader %p.\n", iface, pShader);
167 
168     wined3d_mutex_lock();
169     hrc =  IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
170     wined3d_mutex_unlock();
171 
172     TRACE("(%p) : returning hr(%u)\n", This, hrc);
173     return hrc;
174 }
175 
176 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader) {
177     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
178     IWineD3DVertexShader *pShader;
179     HRESULT hrc = D3D_OK;
180 
181     TRACE("iface %p, shader %p.\n", iface, ppShader);
182 
183     wined3d_mutex_lock();
184     hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
185     if (SUCCEEDED(hrc))
186     {
187         if (pShader)
188         {
189             hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
190             IWineD3DVertexShader_Release(pShader);
191         }
192         else
193         {
194             *ppShader = NULL;
195         }
196     }
197     else
198     {
199         WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
200     }
201     wined3d_mutex_unlock();
202 
203     TRACE("(%p) : returning %p\n", This, *ppShader);
204     return hrc;
205 }
206 
207 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
208     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
209     HRESULT hr;
210 
211     TRACE("iface %p, register %u, data %p, count %u.\n",
212             iface, Register, pConstantData, Vector4fCount);
213 
214     if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
215         WARN("Trying to access %u constants, but d3d9 only supports %u\n",
216              Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
217         return D3DERR_INVALIDCALL;
218     }
219 
220     wined3d_mutex_lock();
221     hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
222     wined3d_mutex_unlock();
223 
224     return hr;
225 }
226 
227 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
228     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
229     HRESULT hr;
230 
231     TRACE("iface %p, register %u, data %p, count %u.\n",
232             iface, Register, pConstantData, Vector4fCount);
233 
234     if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
235         WARN("Trying to access %u constants, but d3d9 only supports %u\n",
236              Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
237         return D3DERR_INVALIDCALL;
238     }
239 
240     wined3d_mutex_lock();
241     hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
242     wined3d_mutex_unlock();
243 
244     return hr;
245 }
246 
247 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
248     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
249     HRESULT hr;
250 
251     TRACE("iface %p, register %u, data %p, count %u.\n",
252             iface, Register, pConstantData, Vector4iCount);
253 
254     wined3d_mutex_lock();
255     hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
256     wined3d_mutex_unlock();
257 
258     return hr;
259 }
260 
261 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
262     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
263     HRESULT hr;
264 
265     TRACE("iface %p, register %u, data %p, count %u.\n",
266             iface, Register, pConstantData, Vector4iCount);
267 
268     wined3d_mutex_lock();
269     hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
270     wined3d_mutex_unlock();
271 
272     return hr;
273 }
274 
275 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
276     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
277     HRESULT hr;
278 
279     TRACE("iface %p, register %u, data %p, count %u.\n",
280             iface, Register, pConstantData, BoolCount);
281 
282     wined3d_mutex_lock();
283     hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
284     wined3d_mutex_unlock();
285 
286     return hr;
287 }
288 
289 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
290     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
291     HRESULT hr;
292 
293     TRACE("iface %p, register %u, data %p, count %u.\n",
294             iface, Register, pConstantData, BoolCount);
295 
296     wined3d_mutex_lock();
297     hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
298     wined3d_mutex_unlock();
299 
300     return hr;
301 }
302 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.