VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/vertexshader.c@ 20612

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

crOpenGL: update wine to 1.1.23

  • Property svn:eol-style set to native
File size: 10.4 KB
Line 
1/*
2 * IDirect3DVertexShader9 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/* IDirect3DVertexShader9 IUnknown parts follow: */
37static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
38 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
39
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
42 IDirect3DVertexShader9_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 IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
53 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)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 IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
62 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)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 IWineD3DVertexShader_Release(This->wineD3DVertexShader);
70 LeaveCriticalSection(&d3d9_cs);
71 IDirect3DDevice9Ex_Release(This->parentDevice);
72 HeapFree(GetProcessHeap(), 0, This);
73 }
74 return ref;
75}
76
77/* IDirect3DVertexShader9 Interface follow: */
78static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
79 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
80 IWineD3DDevice *myDevice = NULL;
81 HRESULT hr;
82 TRACE("(%p) : Relay\n", This);
83
84 EnterCriticalSection(&d3d9_cs);
85 hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
86 if (WINED3D_OK == hr && myDevice != NULL) {
87 hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
88 IWineD3DDevice_Release(myDevice);
89 } else {
90 *ppDevice = NULL;
91 }
92 LeaveCriticalSection(&d3d9_cs);
93 TRACE("(%p) returning (%p)\n", This, *ppDevice);
94 return hr;
95}
96
97static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
98 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
99 HRESULT hr;
100 TRACE("(%p) : Relay\n", This);
101
102 EnterCriticalSection(&d3d9_cs);
103 hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
104 LeaveCriticalSection(&d3d9_cs);
105 return hr;
106}
107
108
109static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
110{
111 /* IUnknown */
112 IDirect3DVertexShader9Impl_QueryInterface,
113 IDirect3DVertexShader9Impl_AddRef,
114 IDirect3DVertexShader9Impl_Release,
115 /* IDirect3DVertexShader9 */
116 IDirect3DVertexShader9Impl_GetDevice,
117 IDirect3DVertexShader9Impl_GetFunction
118};
119
120
121/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
122HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
123 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
124 HRESULT hrc = D3D_OK;
125 IDirect3DVertexShader9Impl *object;
126
127 /* Setup a stub object for now */
128 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
129 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
130 if (NULL == object) {
131 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
132 return D3DERR_OUTOFVIDEOMEMORY;
133 }
134
135 object->ref = 1;
136 object->lpVtbl = &Direct3DVertexShader9_Vtbl;
137 EnterCriticalSection(&d3d9_cs);
138 hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction,
139 NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object);
140 LeaveCriticalSection(&d3d9_cs);
141
142 if (FAILED(hrc)) {
143
144 /* free up object */
145 FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
146 HeapFree(GetProcessHeap(), 0, object);
147 }else{
148 IDirect3DDevice9Ex_AddRef(iface);
149 object->parentDevice = iface;
150 *ppShader = (IDirect3DVertexShader9 *)object;
151 TRACE("(%p) : Created vertex shader %p\n", This, object);
152 }
153
154 TRACE("(%p) : returning %p\n", This, *ppShader);
155 return hrc;
156}
157
158HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
159 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
160 HRESULT hrc = D3D_OK;
161
162 TRACE("(%p) : Relay\n", This);
163 EnterCriticalSection(&d3d9_cs);
164 hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
165 LeaveCriticalSection(&d3d9_cs);
166
167 TRACE("(%p) : returning hr(%u)\n", This, hrc);
168 return hrc;
169}
170
171HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader) {
172 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
173 IWineD3DVertexShader *pShader;
174 HRESULT hrc = D3D_OK;
175
176 TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
177 EnterCriticalSection(&d3d9_cs);
178 hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
179 if (SUCCEEDED(hrc))
180 {
181 if (pShader)
182 {
183 hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
184 IWineD3DVertexShader_Release(pShader);
185 }
186 else
187 {
188 *ppShader = NULL;
189 }
190 }
191 else
192 {
193 WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
194 }
195 LeaveCriticalSection(&d3d9_cs);
196 TRACE("(%p) : returning %p\n", This, *ppShader);
197 return hrc;
198}
199
200HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
201 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
202 HRESULT hr;
203 TRACE("(%p) : Relay\n", This);
204
205 if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
206 WARN("Trying to access %u constants, but d3d9 only supports %u\n",
207 Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
208 return D3DERR_INVALIDCALL;
209 }
210
211 EnterCriticalSection(&d3d9_cs);
212 hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
213 LeaveCriticalSection(&d3d9_cs);
214 return hr;
215}
216
217HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
218 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
219 HRESULT hr;
220
221 if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
222 WARN("Trying to access %u constants, but d3d9 only supports %u\n",
223 Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
224 return D3DERR_INVALIDCALL;
225 }
226
227 TRACE("(%p) : Relay\n", This);
228 EnterCriticalSection(&d3d9_cs);
229 hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
230 LeaveCriticalSection(&d3d9_cs);
231 return hr;
232}
233
234HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
235 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
236 HRESULT hr;
237 TRACE("(%p) : Relay\n", This);
238
239 EnterCriticalSection(&d3d9_cs);
240 hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
241 LeaveCriticalSection(&d3d9_cs);
242 return hr;
243}
244
245HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
246 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
247 HRESULT hr;
248 TRACE("(%p) : Relay\n", This);
249
250 EnterCriticalSection(&d3d9_cs);
251 hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
252 LeaveCriticalSection(&d3d9_cs);
253 return hr;
254}
255
256HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
257 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
258 HRESULT hr;
259 TRACE("(%p) : Relay\n", This);
260
261 EnterCriticalSection(&d3d9_cs);
262 hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
263 LeaveCriticalSection(&d3d9_cs);
264 return hr;
265}
266
267HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
268 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
269 HRESULT hr;
270 TRACE("(%p) : Relay\n", This);
271
272 EnterCriticalSection(&d3d9_cs);
273 hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
274 LeaveCriticalSection(&d3d9_cs);
275 return hr;
276}
Note: See TracBrowser for help on using the repository browser.

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