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 | /*
|
---|
23 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
24 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
25 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
26 | * a choice of LGPL license versions is made available with the language indicating
|
---|
27 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
28 | * of the LGPL is applied is otherwise unspecified.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #include "config.h"
|
---|
32 | #include "d3d9_private.h"
|
---|
33 |
|
---|
34 | WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
|
---|
35 |
|
---|
36 | /* IDirect3DPixelShader9 IUnknown parts follow: */
|
---|
37 | static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
|
---|
38 | IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
|
---|
39 |
|
---|
40 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
41 | || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
|
---|
42 | IDirect3DPixelShader9_AddRef(iface);
|
---|
43 | *ppobj = This;
|
---|
44 | return S_OK;
|
---|
45 | }
|
---|
46 |
|
---|
47 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
48 | *ppobj = NULL;
|
---|
49 | return E_NOINTERFACE;
|
---|
50 | }
|
---|
51 |
|
---|
52 | static ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
|
---|
53 | IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
|
---|
54 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
55 |
|
---|
56 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
57 |
|
---|
58 | return ref;
|
---|
59 | }
|
---|
60 |
|
---|
61 | static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
|
---|
62 | IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
|
---|
63 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
64 |
|
---|
65 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
66 |
|
---|
67 | if (ref == 0) {
|
---|
68 | EnterCriticalSection(&d3d9_cs);
|
---|
69 | IWineD3DPixelShader_Release(This->wineD3DPixelShader);
|
---|
70 | LeaveCriticalSection(&d3d9_cs);
|
---|
71 | IDirect3DDevice9Ex_Release(This->parentDevice);
|
---|
72 | HeapFree(GetProcessHeap(), 0, This);
|
---|
73 | }
|
---|
74 | return ref;
|
---|
75 | }
|
---|
76 |
|
---|
77 | /* IDirect3DPixelShader9 Interface follow: */
|
---|
78 | static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
|
---|
79 | IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
|
---|
80 | IWineD3DDevice *myDevice = NULL;
|
---|
81 |
|
---|
82 | TRACE("(%p) : Relay\n", This);
|
---|
83 |
|
---|
84 | EnterCriticalSection(&d3d9_cs);
|
---|
85 | IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
|
---|
86 | IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
|
---|
87 | IWineD3DDevice_Release(myDevice);
|
---|
88 | LeaveCriticalSection(&d3d9_cs);
|
---|
89 | TRACE("(%p) returning (%p)\n", This, *ppDevice);
|
---|
90 | return D3D_OK;
|
---|
91 | }
|
---|
92 |
|
---|
93 | static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
|
---|
94 | IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
|
---|
95 | HRESULT hr;
|
---|
96 | TRACE("(%p) Relay\n", This);
|
---|
97 |
|
---|
98 | EnterCriticalSection(&d3d9_cs);
|
---|
99 | hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
|
---|
100 | LeaveCriticalSection(&d3d9_cs);
|
---|
101 | return hr;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
|
---|
106 | {
|
---|
107 | /* IUnknown */
|
---|
108 | IDirect3DPixelShader9Impl_QueryInterface,
|
---|
109 | IDirect3DPixelShader9Impl_AddRef,
|
---|
110 | IDirect3DPixelShader9Impl_Release,
|
---|
111 | /* IDirect3DPixelShader9 */
|
---|
112 | IDirect3DPixelShader9Impl_GetDevice,
|
---|
113 | IDirect3DPixelShader9Impl_GetFunction
|
---|
114 | };
|
---|
115 |
|
---|
116 |
|
---|
117 | /* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
|
---|
118 | HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
|
---|
119 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
120 | IDirect3DPixelShader9Impl *object;
|
---|
121 | HRESULT hrc = D3D_OK;
|
---|
122 |
|
---|
123 | TRACE("(%p) Relay\n", This);
|
---|
124 |
|
---|
125 | if (ppShader == NULL) {
|
---|
126 | TRACE("(%p) Invalid call\n", This);
|
---|
127 | return D3DERR_INVALIDCALL;
|
---|
128 | }
|
---|
129 |
|
---|
130 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
131 |
|
---|
132 | if (NULL == object) {
|
---|
133 | FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
|
---|
134 | return E_OUTOFMEMORY;
|
---|
135 | }
|
---|
136 |
|
---|
137 | object->ref = 1;
|
---|
138 | object->lpVtbl = &Direct3DPixelShader9_Vtbl;
|
---|
139 | EnterCriticalSection(&d3d9_cs);
|
---|
140 | hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
|
---|
141 | LeaveCriticalSection(&d3d9_cs);
|
---|
142 | if (hrc != D3D_OK) {
|
---|
143 |
|
---|
144 | /* free up object */
|
---|
145 | FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
|
---|
146 | HeapFree(GetProcessHeap(), 0 , object);
|
---|
147 | } else {
|
---|
148 | IDirect3DDevice9Ex_AddRef(iface);
|
---|
149 | object->parentDevice = iface;
|
---|
150 | *ppShader = (IDirect3DPixelShader9*) object;
|
---|
151 | TRACE("(%p) : Created pixel shader %p\n", This, object);
|
---|
152 | }
|
---|
153 |
|
---|
154 | TRACE("(%p) : returning %p\n", This, *ppShader);
|
---|
155 | return hrc;
|
---|
156 | }
|
---|
157 |
|
---|
158 | HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {
|
---|
159 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
160 | IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
|
---|
161 | TRACE("(%p) Relay\n", This);
|
---|
162 |
|
---|
163 | EnterCriticalSection(&d3d9_cs);
|
---|
164 | IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
|
---|
165 | LeaveCriticalSection(&d3d9_cs);
|
---|
166 | return D3D_OK;
|
---|
167 | }
|
---|
168 |
|
---|
169 | HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) {
|
---|
170 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
171 | IWineD3DPixelShader *object;
|
---|
172 |
|
---|
173 | HRESULT hrc = D3D_OK;
|
---|
174 | TRACE("(%p) Relay\n", This);
|
---|
175 | if (ppShader == NULL) {
|
---|
176 | TRACE("(%p) Invalid call\n", This);
|
---|
177 | return D3DERR_INVALIDCALL;
|
---|
178 | }
|
---|
179 |
|
---|
180 | EnterCriticalSection(&d3d9_cs);
|
---|
181 | hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
|
---|
182 | if (SUCCEEDED(hrc))
|
---|
183 | {
|
---|
184 | if (object)
|
---|
185 | {
|
---|
186 | hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
|
---|
187 | IWineD3DPixelShader_Release(object);
|
---|
188 | }
|
---|
189 | else
|
---|
190 | {
|
---|
191 | *ppShader = NULL;
|
---|
192 | }
|
---|
193 | }
|
---|
194 | else
|
---|
195 | {
|
---|
196 | WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
|
---|
197 | }
|
---|
198 | LeaveCriticalSection(&d3d9_cs);
|
---|
199 |
|
---|
200 | TRACE("(%p) : returning %p\n", This, *ppShader);
|
---|
201 | return hrc;
|
---|
202 | }
|
---|
203 |
|
---|
204 | HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
|
---|
205 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
206 | HRESULT hr;
|
---|
207 | TRACE("(%p) Relay\n", This);
|
---|
208 |
|
---|
209 | EnterCriticalSection(&d3d9_cs);
|
---|
210 | hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
|
---|
211 | LeaveCriticalSection(&d3d9_cs);
|
---|
212 | return hr;
|
---|
213 | }
|
---|
214 |
|
---|
215 | HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
|
---|
216 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
217 | HRESULT hr;
|
---|
218 |
|
---|
219 | TRACE("(%p) Relay\n", This);
|
---|
220 |
|
---|
221 | EnterCriticalSection(&d3d9_cs);
|
---|
222 | hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
|
---|
223 | LeaveCriticalSection(&d3d9_cs);
|
---|
224 |
|
---|
225 | return hr;
|
---|
226 | }
|
---|
227 |
|
---|
228 | HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
|
---|
229 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
230 | HRESULT hr;
|
---|
231 | TRACE("(%p) Relay\n", This);
|
---|
232 |
|
---|
233 | EnterCriticalSection(&d3d9_cs);
|
---|
234 | hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
|
---|
235 | LeaveCriticalSection(&d3d9_cs);
|
---|
236 | return hr;
|
---|
237 | }
|
---|
238 |
|
---|
239 | HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
|
---|
240 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
241 | HRESULT hr;
|
---|
242 | TRACE("(%p) Relay\n", This);
|
---|
243 |
|
---|
244 | EnterCriticalSection(&d3d9_cs);
|
---|
245 | hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
|
---|
246 | LeaveCriticalSection(&d3d9_cs);
|
---|
247 | return hr;
|
---|
248 | }
|
---|
249 |
|
---|
250 | HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
|
---|
251 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
252 | HRESULT hr;
|
---|
253 | TRACE("(%p) Relay\n", This);
|
---|
254 |
|
---|
255 | EnterCriticalSection(&d3d9_cs);
|
---|
256 | hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
|
---|
257 | LeaveCriticalSection(&d3d9_cs);
|
---|
258 | return hr;
|
---|
259 | }
|
---|
260 |
|
---|
261 | HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
|
---|
262 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
263 | HRESULT hr;
|
---|
264 | TRACE("(%p) Relay\n", This);
|
---|
265 |
|
---|
266 | EnterCriticalSection(&d3d9_cs);
|
---|
267 | hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
|
---|
268 | LeaveCriticalSection(&d3d9_cs);
|
---|
269 | return hr;
|
---|
270 | }
|
---|