VirtualBox

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

最後變更 在這個檔案從20793是 20612,由 vboxsync 提交於 16 年 前

crOpenGL: update wine to 1.1.23

  • 屬性 svn:eol-style 設為 native
檔案大小: 9.7 KB
 
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, NULL,
141 &object->wineD3DPixelShader, (IUnknown *)object);
142 LeaveCriticalSection(&d3d9_cs);
143 if (hrc != D3D_OK) {
144
145 /* free up object */
146 FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
147 HeapFree(GetProcessHeap(), 0 , object);
148 } else {
149 IDirect3DDevice9Ex_AddRef(iface);
150 object->parentDevice = iface;
151 *ppShader = (IDirect3DPixelShader9*) object;
152 TRACE("(%p) : Created pixel shader %p\n", This, object);
153 }
154
155 TRACE("(%p) : returning %p\n", This, *ppShader);
156 return hrc;
157}
158
159HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {
160 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
161 IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
162 TRACE("(%p) Relay\n", This);
163
164 EnterCriticalSection(&d3d9_cs);
165 IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
166 LeaveCriticalSection(&d3d9_cs);
167 return D3D_OK;
168}
169
170HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) {
171 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
172 IWineD3DPixelShader *object;
173
174 HRESULT hrc = D3D_OK;
175 TRACE("(%p) Relay\n", This);
176 if (ppShader == NULL) {
177 TRACE("(%p) Invalid call\n", This);
178 return D3DERR_INVALIDCALL;
179 }
180
181 EnterCriticalSection(&d3d9_cs);
182 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
183 if (SUCCEEDED(hrc))
184 {
185 if (object)
186 {
187 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
188 IWineD3DPixelShader_Release(object);
189 }
190 else
191 {
192 *ppShader = NULL;
193 }
194 }
195 else
196 {
197 WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
198 }
199 LeaveCriticalSection(&d3d9_cs);
200
201 TRACE("(%p) : returning %p\n", This, *ppShader);
202 return hrc;
203}
204
205HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
206 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
207 HRESULT hr;
208 TRACE("(%p) Relay\n", This);
209
210 EnterCriticalSection(&d3d9_cs);
211 hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
212 LeaveCriticalSection(&d3d9_cs);
213 return hr;
214}
215
216HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
217 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
218 HRESULT hr;
219
220 TRACE("(%p) Relay\n", This);
221
222 EnterCriticalSection(&d3d9_cs);
223 hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
224 LeaveCriticalSection(&d3d9_cs);
225
226 return hr;
227}
228
229HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
230 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
231 HRESULT hr;
232 TRACE("(%p) Relay\n", This);
233
234 EnterCriticalSection(&d3d9_cs);
235 hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
236 LeaveCriticalSection(&d3d9_cs);
237 return hr;
238}
239
240HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
241 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
242 HRESULT hr;
243 TRACE("(%p) Relay\n", This);
244
245 EnterCriticalSection(&d3d9_cs);
246 hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
247 LeaveCriticalSection(&d3d9_cs);
248 return hr;
249}
250
251HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
252 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
253 HRESULT hr;
254 TRACE("(%p) Relay\n", This);
255
256 EnterCriticalSection(&d3d9_cs);
257 hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
258 LeaveCriticalSection(&d3d9_cs);
259 return hr;
260}
261
262HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
263 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
264 HRESULT hr;
265 TRACE("(%p) Relay\n", This);
266
267 EnterCriticalSection(&d3d9_cs);
268 hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
269 LeaveCriticalSection(&d3d9_cs);
270 return hr;
271}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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