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

Wine Cross Reference
wine/dlls/d3d9/pixelshader.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  * IDirect3DPixelShader9 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 /* IDirect3DPixelShader9 IUnknown parts follow: */
 28 static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
 29     IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)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_IDirect3DPixelShader9)) {
 35         IDirect3DPixelShader9_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 IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
 46     IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)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         IWineD3DPixelShader_AddRef(This->wineD3DPixelShader);
 56         wined3d_mutex_unlock();
 57     }
 58 
 59     return ref;
 60 }
 61 
 62 static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
 63     IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)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         IWineD3DPixelShader_Release(This->wineD3DPixelShader);
 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 /* IDirect3DPixelShader9 Interface follow: */
 82 static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
 83     IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
 84     IWineD3DDevice *myDevice = NULL;
 85 
 86     TRACE("iface %p, device %p.\n", iface, ppDevice);
 87 
 88     wined3d_mutex_lock();
 89     IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
 90     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
 91     IWineD3DDevice_Release(myDevice);
 92     wined3d_mutex_unlock();
 93 
 94     TRACE("(%p) returning (%p)\n", This, *ppDevice);
 95     return D3D_OK;
 96 }
 97 
 98 static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
 99     IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
100     HRESULT hr;
101 
102     TRACE("iface %p, data %p, data_size %p.\n", iface, pData, pSizeOfData);
103 
104     wined3d_mutex_lock();
105     hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
106     wined3d_mutex_unlock();
107 
108     return hr;
109 }
110 
111 
112 static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
113 {
114     /* IUnknown */
115     IDirect3DPixelShader9Impl_QueryInterface,
116     IDirect3DPixelShader9Impl_AddRef,
117     IDirect3DPixelShader9Impl_Release,
118     /* IDirect3DPixelShader9 */
119     IDirect3DPixelShader9Impl_GetDevice,
120     IDirect3DPixelShader9Impl_GetFunction
121 };
122 
123 static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
124 {
125     HeapFree(GetProcessHeap(), 0, parent);
126 }
127 
128 static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
129 {
130     d3d9_pixelshader_wined3d_object_destroyed,
131 };
132 
133 HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
134 {
135     HRESULT hr;
136 
137     shader->ref = 1;
138     shader->lpVtbl = &Direct3DPixelShader9_Vtbl;
139 
140     wined3d_mutex_lock();
141     hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
142             NULL, &shader->wineD3DPixelShader, (IUnknown *)shader,
143             &d3d9_pixelshader_wined3d_parent_ops);
144     wined3d_mutex_unlock();
145     if (FAILED(hr))
146     {
147         WARN("Failed to created wined3d pixel shader, hr %#x.\n", hr);
148         return hr;
149     }
150 
151     shader->parentDevice = (IDirect3DDevice9Ex *)device;
152     IDirect3DDevice9Ex_AddRef(shader->parentDevice);
153 
154     return D3D_OK;
155 }
156 
157 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {
158     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
159     IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
160 
161     TRACE("iface %p, shader %p.\n", iface, shader);
162 
163     wined3d_mutex_lock();
164     IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
165     wined3d_mutex_unlock();
166 
167     return D3D_OK;
168 }
169 
170 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) {
171     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
172     IWineD3DPixelShader *object;
173     HRESULT hrc;
174 
175     TRACE("iface %p, shader %p.\n", iface, ppShader);
176 
177     if (ppShader == NULL) {
178         TRACE("(%p) Invalid call\n", This);
179         return D3DERR_INVALIDCALL;
180     }
181 
182     wined3d_mutex_lock();
183     hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
184     if (SUCCEEDED(hrc))
185     {
186         if (object)
187         {
188             hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
189             IWineD3DPixelShader_Release(object);
190         }
191         else
192         {
193             *ppShader = NULL;
194         }
195     }
196     else
197     {
198         WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
199     }
200     wined3d_mutex_unlock();
201 
202     TRACE("(%p) : returning %p\n", This, *ppShader);
203     return hrc;
204 }
205 
206 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
207    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
208     HRESULT hr;
209 
210     TRACE("iface %p, register %u, data %p, count %u.\n",
211             iface, Register, pConstantData, Vector4fCount);
212 
213     wined3d_mutex_lock();
214     hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
215     wined3d_mutex_unlock();
216 
217     return hr;
218 }
219 
220 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
221     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
222     HRESULT hr;
223 
224     TRACE("iface %p, register %u, data %p, count %u.\n",
225             iface, Register, pConstantData, Vector4fCount);
226 
227     wined3d_mutex_lock();
228     hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
229     wined3d_mutex_unlock();
230 
231     return hr;
232 }
233 
234 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
235     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
236     HRESULT hr;
237 
238     TRACE("iface %p, register %u, data %p, count %u.\n",
239             iface, Register, pConstantData, Vector4iCount);
240 
241     wined3d_mutex_lock();
242     hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
243     wined3d_mutex_unlock();
244 
245     return hr;
246 }
247 
248 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
249     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
250     HRESULT hr;
251 
252     TRACE("iface %p, register %u, data %p, count %u.\n",
253             iface, Register, pConstantData, Vector4iCount);
254 
255     wined3d_mutex_lock();
256     hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
257     wined3d_mutex_unlock();
258 
259     return hr;
260 }
261 
262 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
263     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
264     HRESULT hr;
265 
266     TRACE("iface %p, register %u, data %p, count %u.\n",
267             iface, Register, pConstantData, BoolCount);
268 
269     wined3d_mutex_lock();
270     hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
271     wined3d_mutex_unlock();
272 
273     return hr;
274 }
275 
276 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
277     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
278     HRESULT hr;
279 
280     TRACE("iface %p, register %u, data %p, count %u.\n",
281             iface, Register, pConstantData, BoolCount);
282 
283     wined3d_mutex_lock();
284     hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
285     wined3d_mutex_unlock();
286 
287     return hr;
288 }
289 

~ [ 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.