VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/pixelshader.c@ 33281

Last change on this file since 33281 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

  • Property svn:eol-style set to native
File size: 9.9 KB
Line 
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
34WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
35
36/* IDirect3DPixelShader9 IUnknown parts follow: */
37static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
38 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
39
40 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
41
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
44 IDirect3DPixelShader9_AddRef(iface);
45 *ppobj = This;
46 return S_OK;
47 }
48
49 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
50 *ppobj = NULL;
51 return E_NOINTERFACE;
52}
53
54static ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
55 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
56 ULONG ref = InterlockedIncrement(&This->ref);
57
58 TRACE("%p increasing refcount to %u.\n", iface, ref);
59
60 if (ref == 1)
61 {
62 IDirect3DDevice9Ex_AddRef(This->parentDevice);
63 wined3d_mutex_lock();
64 IWineD3DPixelShader_AddRef(This->wineD3DPixelShader);
65 wined3d_mutex_unlock();
66 }
67
68 return ref;
69}
70
71static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
72 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
73 ULONG ref = InterlockedDecrement(&This->ref);
74
75 TRACE("%p decreasing refcount to %u.\n", iface, ref);
76
77 if (ref == 0) {
78 IDirect3DDevice9Ex *parentDevice = This->parentDevice;
79
80 wined3d_mutex_lock();
81 IWineD3DPixelShader_Release(This->wineD3DPixelShader);
82 wined3d_mutex_unlock();
83
84 /* Release the device last, as it may cause the device to be destroyed. */
85 IDirect3DDevice9Ex_Release(parentDevice);
86 }
87 return ref;
88}
89
90/* IDirect3DPixelShader9 Interface follow: */
91static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
92{
93 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
94
95 TRACE("iface %p, device %p.\n", iface, device);
96
97 *device = (IDirect3DDevice9 *)This->parentDevice;
98 IDirect3DDevice9_AddRef(*device);
99
100 TRACE("Returning device %p.\n", *device);
101
102 return D3D_OK;
103}
104
105static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
106 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
107 HRESULT hr;
108
109 TRACE("iface %p, data %p, data_size %p.\n", iface, pData, pSizeOfData);
110
111 wined3d_mutex_lock();
112 hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
113 wined3d_mutex_unlock();
114
115 return hr;
116}
117
118
119static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
120{
121 /* IUnknown */
122 IDirect3DPixelShader9Impl_QueryInterface,
123 IDirect3DPixelShader9Impl_AddRef,
124 IDirect3DPixelShader9Impl_Release,
125 /* IDirect3DPixelShader9 */
126 IDirect3DPixelShader9Impl_GetDevice,
127 IDirect3DPixelShader9Impl_GetFunction
128};
129
130static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
131{
132 HeapFree(GetProcessHeap(), 0, parent);
133}
134
135static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
136{
137 d3d9_pixelshader_wined3d_object_destroyed,
138};
139
140HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
141{
142 HRESULT hr;
143
144 shader->ref = 1;
145 shader->lpVtbl = &Direct3DPixelShader9_Vtbl;
146
147 wined3d_mutex_lock();
148 hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
149 NULL, &shader->wineD3DPixelShader, (IUnknown *)shader,
150 &d3d9_pixelshader_wined3d_parent_ops);
151 wined3d_mutex_unlock();
152 if (FAILED(hr))
153 {
154 WARN("Failed to created wined3d pixel shader, hr %#x.\n", hr);
155 return hr;
156 }
157
158 shader->parentDevice = (IDirect3DDevice9Ex *)device;
159 IDirect3DDevice9Ex_AddRef(shader->parentDevice);
160
161 return D3D_OK;
162}
163
164HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {
165 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
166 IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
167
168 TRACE("iface %p, shader %p.\n", iface, shader);
169
170 wined3d_mutex_lock();
171 IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
172 wined3d_mutex_unlock();
173
174 return D3D_OK;
175}
176
177HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) {
178 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
179 IWineD3DPixelShader *object;
180 HRESULT hrc;
181
182 TRACE("iface %p, shader %p.\n", iface, ppShader);
183
184 if (ppShader == NULL) {
185 TRACE("(%p) Invalid call\n", This);
186 return D3DERR_INVALIDCALL;
187 }
188
189 wined3d_mutex_lock();
190 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
191 if (SUCCEEDED(hrc))
192 {
193 if (object)
194 {
195 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
196 IWineD3DPixelShader_Release(object);
197 }
198 else
199 {
200 *ppShader = NULL;
201 }
202 }
203 else
204 {
205 WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
206 }
207 wined3d_mutex_unlock();
208
209 TRACE("(%p) : returning %p\n", This, *ppShader);
210 return hrc;
211}
212
213HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
214 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
215 HRESULT hr;
216
217 TRACE("iface %p, register %u, data %p, count %u.\n",
218 iface, Register, pConstantData, Vector4fCount);
219
220 wined3d_mutex_lock();
221 hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
222 wined3d_mutex_unlock();
223
224 return hr;
225}
226
227HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(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 wined3d_mutex_lock();
235 hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
236 wined3d_mutex_unlock();
237
238 return hr;
239}
240
241HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
242 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
243 HRESULT hr;
244
245 TRACE("iface %p, register %u, data %p, count %u.\n",
246 iface, Register, pConstantData, Vector4iCount);
247
248 wined3d_mutex_lock();
249 hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
250 wined3d_mutex_unlock();
251
252 return hr;
253}
254
255HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
256 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
257 HRESULT hr;
258
259 TRACE("iface %p, register %u, data %p, count %u.\n",
260 iface, Register, pConstantData, Vector4iCount);
261
262 wined3d_mutex_lock();
263 hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
264 wined3d_mutex_unlock();
265
266 return hr;
267}
268
269HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
270 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
271 HRESULT hr;
272
273 TRACE("iface %p, register %u, data %p, count %u.\n",
274 iface, Register, pConstantData, BoolCount);
275
276 wined3d_mutex_lock();
277 hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
278 wined3d_mutex_unlock();
279
280 return hr;
281}
282
283HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
284 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
285 HRESULT hr;
286
287 TRACE("iface %p, register %u, data %p, count %u.\n",
288 iface, Register, pConstantData, BoolCount);
289
290 wined3d_mutex_lock();
291 hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
292 wined3d_mutex_unlock();
293
294 return hr;
295}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette