VirtualBox

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

Last change on this file since 16684 was 16477, checked in by vboxsync, 16 years ago

LGPL disclaimer by filemuncher

  • Property svn:eol-style set to native
File size: 9.4 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 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
52static 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
61static 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: */
78static 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
93static 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
105static 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: */
118HRESULT 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
158HRESULT 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
169HRESULT 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 (hrc == D3D_OK && object != NULL) {
183 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
184 IWineD3DPixelShader_Release(object);
185 } else {
186 *ppShader = NULL;
187 }
188 LeaveCriticalSection(&d3d9_cs);
189
190 TRACE("(%p) : returning %p\n", This, *ppShader);
191 return hrc;
192}
193
194HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
195 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
196 HRESULT hr;
197 TRACE("(%p) Relay\n", This);
198
199 EnterCriticalSection(&d3d9_cs);
200 hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
201 LeaveCriticalSection(&d3d9_cs);
202 return hr;
203}
204
205HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
206 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
207 TRACE("(%p) Relay\n", This);
208 return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
209}
210
211HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
212 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
213 HRESULT hr;
214 TRACE("(%p) Relay\n", This);
215
216 EnterCriticalSection(&d3d9_cs);
217 hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
218 LeaveCriticalSection(&d3d9_cs);
219 return hr;
220}
221
222HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
223 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
224 HRESULT hr;
225 TRACE("(%p) Relay\n", This);
226
227 EnterCriticalSection(&d3d9_cs);
228 hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
229 LeaveCriticalSection(&d3d9_cs);
230 return hr;
231}
232
233HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
234 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
235 HRESULT hr;
236 TRACE("(%p) Relay\n", This);
237
238 EnterCriticalSection(&d3d9_cs);
239 hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
240 LeaveCriticalSection(&d3d9_cs);
241 return hr;
242}
243
244HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
245 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
246 HRESULT hr;
247 TRACE("(%p) Relay\n", This);
248
249 EnterCriticalSection(&d3d9_cs);
250 hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
251 LeaveCriticalSection(&d3d9_cs);
252 return hr;
253}
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