1 | /*
|
---|
2 | * IDirect3DDevice9 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002-2005 Jason Edmeades
|
---|
5 | * Copyright 2002-2005 Raphael Junqueira
|
---|
6 | * Copyright 2005 Oliver Stieber
|
---|
7 | *
|
---|
8 | * This library is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU Lesser General Public
|
---|
10 | * License as published by the Free Software Foundation; either
|
---|
11 | * version 2.1 of the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This library is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * Lesser General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Lesser General Public
|
---|
19 | * License along with this library; if not, write to the Free Software
|
---|
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
25 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
26 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
27 | * a choice of LGPL license versions is made available with the language indicating
|
---|
28 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
29 | * of the LGPL is applied is otherwise unspecified.
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include "config.h"
|
---|
33 | #include "d3d9_private.h"
|
---|
34 |
|
---|
35 | WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
|
---|
36 |
|
---|
37 | D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
|
---|
38 | {
|
---|
39 | BYTE *c = (BYTE *)&format;
|
---|
40 |
|
---|
41 | /* Don't translate FOURCC formats */
|
---|
42 | if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
|
---|
43 |
|
---|
44 | switch(format)
|
---|
45 | {
|
---|
46 | case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN;
|
---|
47 | case WINED3DFMT_R8G8B8: return D3DFMT_R8G8B8;
|
---|
48 | case WINED3DFMT_A8R8G8B8: return D3DFMT_A8R8G8B8;
|
---|
49 | case WINED3DFMT_X8R8G8B8: return D3DFMT_X8R8G8B8;
|
---|
50 | case WINED3DFMT_R5G6B5: return D3DFMT_R5G6B5;
|
---|
51 | case WINED3DFMT_X1R5G5B5: return D3DFMT_X1R5G5B5;
|
---|
52 | case WINED3DFMT_A1R5G5B5: return D3DFMT_A1R5G5B5;
|
---|
53 | case WINED3DFMT_A4R4G4B4: return D3DFMT_A4R4G4B4;
|
---|
54 | case WINED3DFMT_R3G3B2: return D3DFMT_R3G3B2;
|
---|
55 | case WINED3DFMT_A8_UNORM: return D3DFMT_A8;
|
---|
56 | case WINED3DFMT_A8R3G3B2: return D3DFMT_A8R3G3B2;
|
---|
57 | case WINED3DFMT_X4R4G4B4: return D3DFMT_X4R4G4B4;
|
---|
58 | case WINED3DFMT_R10G10B10A2_UNORM: return D3DFMT_A2B10G10R10;
|
---|
59 | case WINED3DFMT_R8G8B8A8_UNORM: return D3DFMT_A8B8G8R8;
|
---|
60 | case WINED3DFMT_X8B8G8R8: return D3DFMT_X8B8G8R8;
|
---|
61 | case WINED3DFMT_R16G16_UNORM: return D3DFMT_G16R16;
|
---|
62 | case WINED3DFMT_A2R10G10B10: return D3DFMT_A2R10G10B10;
|
---|
63 | case WINED3DFMT_R16G16B16A16_UNORM: return D3DFMT_A16B16G16R16;
|
---|
64 | case WINED3DFMT_A8P8: return D3DFMT_A8P8;
|
---|
65 | case WINED3DFMT_P8: return D3DFMT_P8;
|
---|
66 | case WINED3DFMT_L8: return D3DFMT_L8;
|
---|
67 | case WINED3DFMT_A8L8: return D3DFMT_A8L8;
|
---|
68 | case WINED3DFMT_A4L4: return D3DFMT_A4L4;
|
---|
69 | case WINED3DFMT_R8G8_SNORM: return D3DFMT_V8U8;
|
---|
70 | case WINED3DFMT_L6V5U5: return D3DFMT_L6V5U5;
|
---|
71 | case WINED3DFMT_X8L8V8U8: return D3DFMT_X8L8V8U8;
|
---|
72 | case WINED3DFMT_R8G8B8A8_SNORM: return D3DFMT_Q8W8V8U8;
|
---|
73 | case WINED3DFMT_R16G16_SNORM: return D3DFMT_V16U16;
|
---|
74 | case WINED3DFMT_A2W10V10U10: return D3DFMT_A2W10V10U10;
|
---|
75 | case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE;
|
---|
76 | case WINED3DFMT_D32: return D3DFMT_D32;
|
---|
77 | case WINED3DFMT_D15S1: return D3DFMT_D15S1;
|
---|
78 | case WINED3DFMT_D24S8: return D3DFMT_D24S8;
|
---|
79 | case WINED3DFMT_D24X8: return D3DFMT_D24X8;
|
---|
80 | case WINED3DFMT_D24X4S4: return D3DFMT_D24X4S4;
|
---|
81 | case WINED3DFMT_D16_UNORM: return D3DFMT_D16;
|
---|
82 | case WINED3DFMT_L16: return D3DFMT_L16;
|
---|
83 | case WINED3DFMT_D32F_LOCKABLE: return D3DFMT_D32F_LOCKABLE;
|
---|
84 | case WINED3DFMT_D24FS8: return D3DFMT_D24FS8;
|
---|
85 | case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA;
|
---|
86 | case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
|
---|
87 | case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
|
---|
88 | case WINED3DFMT_R16G16B16A16_SNORM: return D3DFMT_Q16W16V16U16;
|
---|
89 | case WINED3DFMT_R16_FLOAT: return D3DFMT_R16F;
|
---|
90 | case WINED3DFMT_R16G16_FLOAT: return D3DFMT_G16R16F;
|
---|
91 | case WINED3DFMT_R16G16B16A16_FLOAT: return D3DFMT_A16B16G16R16F;
|
---|
92 | case WINED3DFMT_R32_FLOAT: return D3DFMT_R32F;
|
---|
93 | case WINED3DFMT_R32G32_FLOAT: return D3DFMT_G32R32F;
|
---|
94 | case WINED3DFMT_R32G32B32A32_FLOAT: return D3DFMT_A32B32G32R32F;
|
---|
95 | case WINED3DFMT_CxV8U8: return D3DFMT_CxV8U8;
|
---|
96 | default:
|
---|
97 | FIXME("Unhandled WINED3DFORMAT %#x\n", format);
|
---|
98 | return D3DFMT_UNKNOWN;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
|
---|
103 | {
|
---|
104 | BYTE *c = (BYTE *)&format;
|
---|
105 |
|
---|
106 | /* Don't translate FOURCC formats */
|
---|
107 | if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
|
---|
108 |
|
---|
109 | switch(format)
|
---|
110 | {
|
---|
111 | case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN;
|
---|
112 | case D3DFMT_R8G8B8: return WINED3DFMT_R8G8B8;
|
---|
113 | case D3DFMT_A8R8G8B8: return WINED3DFMT_A8R8G8B8;
|
---|
114 | case D3DFMT_X8R8G8B8: return WINED3DFMT_X8R8G8B8;
|
---|
115 | case D3DFMT_R5G6B5: return WINED3DFMT_R5G6B5;
|
---|
116 | case D3DFMT_X1R5G5B5: return WINED3DFMT_X1R5G5B5;
|
---|
117 | case D3DFMT_A1R5G5B5: return WINED3DFMT_A1R5G5B5;
|
---|
118 | case D3DFMT_A4R4G4B4: return WINED3DFMT_A4R4G4B4;
|
---|
119 | case D3DFMT_R3G3B2: return WINED3DFMT_R3G3B2;
|
---|
120 | case D3DFMT_A8: return WINED3DFMT_A8_UNORM;
|
---|
121 | case D3DFMT_A8R3G3B2: return WINED3DFMT_A8R3G3B2;
|
---|
122 | case D3DFMT_X4R4G4B4: return WINED3DFMT_X4R4G4B4;
|
---|
123 | case D3DFMT_A2B10G10R10: return WINED3DFMT_R10G10B10A2_UNORM;
|
---|
124 | case D3DFMT_A8B8G8R8: return WINED3DFMT_R8G8B8A8_UNORM;
|
---|
125 | case D3DFMT_X8B8G8R8: return WINED3DFMT_X8B8G8R8;
|
---|
126 | case D3DFMT_G16R16: return WINED3DFMT_R16G16_UNORM;
|
---|
127 | case D3DFMT_A2R10G10B10: return WINED3DFMT_A2R10G10B10;
|
---|
128 | case D3DFMT_A16B16G16R16: return WINED3DFMT_R16G16B16A16_UNORM;
|
---|
129 | case D3DFMT_A8P8: return WINED3DFMT_A8P8;
|
---|
130 | case D3DFMT_P8: return WINED3DFMT_P8;
|
---|
131 | case D3DFMT_L8: return WINED3DFMT_L8;
|
---|
132 | case D3DFMT_A8L8: return WINED3DFMT_A8L8;
|
---|
133 | case D3DFMT_A4L4: return WINED3DFMT_A4L4;
|
---|
134 | case D3DFMT_V8U8: return WINED3DFMT_R8G8_SNORM;
|
---|
135 | case D3DFMT_L6V5U5: return WINED3DFMT_L6V5U5;
|
---|
136 | case D3DFMT_X8L8V8U8: return WINED3DFMT_X8L8V8U8;
|
---|
137 | case D3DFMT_Q8W8V8U8: return WINED3DFMT_R8G8B8A8_SNORM;
|
---|
138 | case D3DFMT_V16U16: return WINED3DFMT_R16G16_SNORM;
|
---|
139 | case D3DFMT_A2W10V10U10: return WINED3DFMT_A2W10V10U10;
|
---|
140 | case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE;
|
---|
141 | case D3DFMT_D32: return WINED3DFMT_D32;
|
---|
142 | case D3DFMT_D15S1: return WINED3DFMT_D15S1;
|
---|
143 | case D3DFMT_D24S8: return WINED3DFMT_D24S8;
|
---|
144 | case D3DFMT_D24X8: return WINED3DFMT_D24X8;
|
---|
145 | case D3DFMT_D24X4S4: return WINED3DFMT_D24X4S4;
|
---|
146 | case D3DFMT_D16: return WINED3DFMT_D16_UNORM;
|
---|
147 | case D3DFMT_L16: return WINED3DFMT_L16;
|
---|
148 | case D3DFMT_D32F_LOCKABLE: return WINED3DFMT_D32F_LOCKABLE;
|
---|
149 | case D3DFMT_D24FS8: return WINED3DFMT_D24FS8;
|
---|
150 | case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
|
---|
151 | case D3DFMT_INDEX16: return WINED3DFMT_R16_UINT;
|
---|
152 | case D3DFMT_INDEX32: return WINED3DFMT_R32_UINT;
|
---|
153 | case D3DFMT_Q16W16V16U16: return WINED3DFMT_R16G16B16A16_SNORM;
|
---|
154 | case D3DFMT_R16F: return WINED3DFMT_R16_FLOAT;
|
---|
155 | case D3DFMT_G16R16F: return WINED3DFMT_R16G16_FLOAT;
|
---|
156 | case D3DFMT_A16B16G16R16F: return WINED3DFMT_R16G16B16A16_FLOAT;
|
---|
157 | case D3DFMT_R32F: return WINED3DFMT_R32_FLOAT;
|
---|
158 | case D3DFMT_G32R32F: return WINED3DFMT_R32G32_FLOAT;
|
---|
159 | case D3DFMT_A32B32G32R32F: return WINED3DFMT_R32G32B32A32_FLOAT;
|
---|
160 | case D3DFMT_CxV8U8: return WINED3DFMT_CxV8U8;
|
---|
161 | default:
|
---|
162 | FIXME("Unhandled D3DFORMAT %#x\n", format);
|
---|
163 | return WINED3DFMT_UNKNOWN;
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
|
---|
168 | {
|
---|
169 | switch(primitive_type)
|
---|
170 | {
|
---|
171 | case D3DPT_POINTLIST:
|
---|
172 | return primitive_count;
|
---|
173 |
|
---|
174 | case D3DPT_LINELIST:
|
---|
175 | return primitive_count * 2;
|
---|
176 |
|
---|
177 | case D3DPT_LINESTRIP:
|
---|
178 | return primitive_count + 1;
|
---|
179 |
|
---|
180 | case D3DPT_TRIANGLELIST:
|
---|
181 | return primitive_count * 3;
|
---|
182 |
|
---|
183 | case D3DPT_TRIANGLESTRIP:
|
---|
184 | case D3DPT_TRIANGLEFAN:
|
---|
185 | return primitive_count + 2;
|
---|
186 |
|
---|
187 | default:
|
---|
188 | FIXME("Unhandled primitive type %#x\n", primitive_type);
|
---|
189 | return 0;
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | /* IDirect3D IUnknown parts follow: */
|
---|
194 | static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface, REFIID riid, LPVOID* ppobj) {
|
---|
195 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
196 | IDirect3D9 *d3d;
|
---|
197 | IDirect3D9Impl *d3dimpl;
|
---|
198 |
|
---|
199 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
200 | || IsEqualGUID(riid, &IID_IDirect3DDevice9)) {
|
---|
201 | IDirect3DDevice9Ex_AddRef(iface);
|
---|
202 | *ppobj = This;
|
---|
203 | TRACE("Returning IDirect3DDevice9 interface at %p\n", *ppobj);
|
---|
204 | return S_OK;
|
---|
205 | } else if(IsEqualGUID(riid, &IID_IDirect3DDevice9Ex)) {
|
---|
206 | /* Find out if the creating d3d9 interface was created with Direct3DCreate9Ex.
|
---|
207 | * It doesn't matter with which function the device was created.
|
---|
208 | */
|
---|
209 | IDirect3DDevice9_GetDirect3D(iface, &d3d);
|
---|
210 | d3dimpl = (IDirect3D9Impl *) d3d;
|
---|
211 |
|
---|
212 | if(d3dimpl->extended) {
|
---|
213 | *ppobj = iface;
|
---|
214 | IDirect3DDevice9Ex_AddRef((IDirect3DDevice9Ex *) *ppobj);
|
---|
215 | IDirect3D9_Release(d3d);
|
---|
216 | TRACE("Returning IDirect3DDevice9Ex interface at %p\n", *ppobj);
|
---|
217 | return S_OK;
|
---|
218 | } else {
|
---|
219 | WARN("IDirect3D9 instance wasn't created with CreateDirect3D9Ex, returning E_NOINTERFACE\n");
|
---|
220 | IDirect3D9_Release(d3d);
|
---|
221 | *ppobj = NULL;
|
---|
222 | return E_NOINTERFACE;
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
|
---|
227 | {
|
---|
228 | IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
|
---|
229 | *ppobj = &This->device_parent_vtbl;
|
---|
230 | return S_OK;
|
---|
231 | }
|
---|
232 |
|
---|
233 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
234 | *ppobj = NULL;
|
---|
235 | return E_NOINTERFACE;
|
---|
236 | }
|
---|
237 |
|
---|
238 | static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface) {
|
---|
239 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
240 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
241 |
|
---|
242 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
243 |
|
---|
244 | return ref;
|
---|
245 | }
|
---|
246 |
|
---|
247 | static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) {
|
---|
248 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
249 | ULONG ref;
|
---|
250 |
|
---|
251 | if (This->inDestruction) return 0;
|
---|
252 | ref = InterlockedDecrement(&This->ref);
|
---|
253 |
|
---|
254 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
255 |
|
---|
256 | if (ref == 0) {
|
---|
257 | unsigned i;
|
---|
258 | This->inDestruction = TRUE;
|
---|
259 |
|
---|
260 | EnterCriticalSection(&d3d9_cs);
|
---|
261 | for(i = 0; i < This->numConvertedDecls; i++) {
|
---|
262 | /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
|
---|
263 | * device
|
---|
264 | */
|
---|
265 | IDirect3DVertexDeclaration9Impl_Destroy(This->convertedDecls[i]);
|
---|
266 | }
|
---|
267 | HeapFree(GetProcessHeap(), 0, This->convertedDecls);
|
---|
268 |
|
---|
269 | IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroyDepthStencilSurface, D3D9CB_DestroySwapChain);
|
---|
270 | IWineD3DDevice_Release(This->WineD3DDevice);
|
---|
271 | LeaveCriticalSection(&d3d9_cs);
|
---|
272 | HeapFree(GetProcessHeap(), 0, This);
|
---|
273 | }
|
---|
274 | return ref;
|
---|
275 | }
|
---|
276 |
|
---|
277 | /* IDirect3DDevice Interface follow: */
|
---|
278 | static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9EX iface) {
|
---|
279 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
280 | HRESULT hr;
|
---|
281 | TRACE("(%p)\n", This);
|
---|
282 |
|
---|
283 | EnterCriticalSection(&d3d9_cs);
|
---|
284 | hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
|
---|
285 | LeaveCriticalSection(&d3d9_cs);
|
---|
286 | if(hr == WINED3D_OK && This->notreset) {
|
---|
287 | TRACE("D3D9 Device is marked not reset\n");
|
---|
288 | hr = D3DERR_DEVICENOTRESET;
|
---|
289 | }
|
---|
290 |
|
---|
291 | return hr;
|
---|
292 | }
|
---|
293 |
|
---|
294 | static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface) {
|
---|
295 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
296 | HRESULT hr;
|
---|
297 | TRACE("(%p) Relay\n", This);
|
---|
298 |
|
---|
299 | EnterCriticalSection(&d3d9_cs);
|
---|
300 | hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
|
---|
301 | LeaveCriticalSection(&d3d9_cs);
|
---|
302 | return hr;
|
---|
303 | }
|
---|
304 |
|
---|
305 | static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface) {
|
---|
306 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
307 | HRESULT hr;
|
---|
308 | TRACE("(%p) : Relay\n", This);
|
---|
309 |
|
---|
310 | EnterCriticalSection(&d3d9_cs);
|
---|
311 | hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
|
---|
312 | LeaveCriticalSection(&d3d9_cs);
|
---|
313 | return hr;
|
---|
314 | }
|
---|
315 |
|
---|
316 | static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface, IDirect3D9** ppD3D9) {
|
---|
317 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
318 | HRESULT hr = D3D_OK;
|
---|
319 | IWineD3D* pWineD3D;
|
---|
320 |
|
---|
321 | TRACE("(%p) Relay\n", This);
|
---|
322 |
|
---|
323 | if (NULL == ppD3D9) {
|
---|
324 | return D3DERR_INVALIDCALL;
|
---|
325 | }
|
---|
326 |
|
---|
327 | EnterCriticalSection(&d3d9_cs);
|
---|
328 | hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
|
---|
329 | if (hr == D3D_OK && pWineD3D != NULL)
|
---|
330 | {
|
---|
331 | IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D9);
|
---|
332 | IWineD3D_Release(pWineD3D);
|
---|
333 | } else {
|
---|
334 | FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
|
---|
335 | *ppD3D9 = NULL;
|
---|
336 | }
|
---|
337 | TRACE("(%p) returning %p\n", This, *ppD3D9);
|
---|
338 | LeaveCriticalSection(&d3d9_cs);
|
---|
339 | return hr;
|
---|
340 | }
|
---|
341 |
|
---|
342 | static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface, D3DCAPS9* pCaps) {
|
---|
343 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
344 | HRESULT hrc = D3D_OK;
|
---|
345 | WINED3DCAPS *pWineCaps;
|
---|
346 |
|
---|
347 | TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
|
---|
348 | if(NULL == pCaps){
|
---|
349 | return D3DERR_INVALIDCALL;
|
---|
350 | }
|
---|
351 | pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
---|
352 | if(pWineCaps == NULL){
|
---|
353 | return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
|
---|
354 | }
|
---|
355 |
|
---|
356 | memset(pCaps, 0, sizeof(*pCaps));
|
---|
357 | EnterCriticalSection(&d3d9_cs);
|
---|
358 | hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
|
---|
359 | LeaveCriticalSection(&d3d9_cs);
|
---|
360 | WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
|
---|
361 | HeapFree(GetProcessHeap(), 0, pWineCaps);
|
---|
362 |
|
---|
363 | /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
|
---|
364 | pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
|
---|
365 |
|
---|
366 | filter_caps(pCaps);
|
---|
367 |
|
---|
368 | TRACE("Returning %p %p\n", This, pCaps);
|
---|
369 | return hrc;
|
---|
370 | }
|
---|
371 |
|
---|
372 | static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
|
---|
373 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
374 | HRESULT hr;
|
---|
375 | TRACE("(%p) Relay\n", This);
|
---|
376 |
|
---|
377 | EnterCriticalSection(&d3d9_cs);
|
---|
378 | hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
|
---|
379 | LeaveCriticalSection(&d3d9_cs);
|
---|
380 |
|
---|
381 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
382 |
|
---|
383 | return hr;
|
---|
384 | }
|
---|
385 |
|
---|
386 | static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
|
---|
387 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
388 | HRESULT hr;
|
---|
389 | TRACE("(%p) Relay\n", This);
|
---|
390 |
|
---|
391 | EnterCriticalSection(&d3d9_cs);
|
---|
392 | hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
|
---|
393 | LeaveCriticalSection(&d3d9_cs);
|
---|
394 | return hr;
|
---|
395 | }
|
---|
396 |
|
---|
397 | static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
|
---|
398 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
399 | IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
|
---|
400 | HRESULT hr;
|
---|
401 |
|
---|
402 | TRACE("(%p) Relay\n", This);
|
---|
403 | if(!pCursorBitmap) {
|
---|
404 | WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
|
---|
405 | return WINED3DERR_INVALIDCALL;
|
---|
406 | }
|
---|
407 |
|
---|
408 | EnterCriticalSection(&d3d9_cs);
|
---|
409 | hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, pSurface->wineD3DSurface);
|
---|
410 | LeaveCriticalSection(&d3d9_cs);
|
---|
411 | return hr;
|
---|
412 | }
|
---|
413 |
|
---|
414 | static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
|
---|
415 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
416 | TRACE("(%p) Relay\n", This);
|
---|
417 |
|
---|
418 | EnterCriticalSection(&d3d9_cs);
|
---|
419 | IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
|
---|
420 | LeaveCriticalSection(&d3d9_cs);
|
---|
421 | }
|
---|
422 |
|
---|
423 | static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface, BOOL bShow) {
|
---|
424 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
425 | BOOL ret;
|
---|
426 | TRACE("(%p) Relay\n", This);
|
---|
427 |
|
---|
428 | EnterCriticalSection(&d3d9_cs);
|
---|
429 | ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
|
---|
430 | LeaveCriticalSection(&d3d9_cs);
|
---|
431 | return ret;
|
---|
432 | }
|
---|
433 |
|
---|
434 | static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data) {
|
---|
435 | BOOL *resources_ok = data;
|
---|
436 | WINED3DRESOURCETYPE type;
|
---|
437 | HRESULT ret = S_OK;
|
---|
438 | WINED3DSURFACE_DESC surface_desc;
|
---|
439 | WINED3DVOLUME_DESC volume_desc;
|
---|
440 | D3DINDEXBUFFER_DESC index_desc;
|
---|
441 | D3DVERTEXBUFFER_DESC vertex_desc;
|
---|
442 | WINED3DFORMAT dummy_format;
|
---|
443 | WINED3DMULTISAMPLE_TYPE dummy_multisampletype;
|
---|
444 | DWORD dummy_dword;
|
---|
445 | WINED3DPOOL pool = WINED3DPOOL_SCRATCH; /* a harmless pool */
|
---|
446 | IDirect3DResource9 *parent;
|
---|
447 |
|
---|
448 | IWineD3DResource_GetParent(resource, (IUnknown **) &parent);
|
---|
449 | type = IDirect3DResource9_GetType(parent);
|
---|
450 | switch(type) {
|
---|
451 | case D3DRTYPE_SURFACE:
|
---|
452 | surface_desc.Format = &dummy_format;
|
---|
453 | surface_desc.Type = &type;
|
---|
454 | surface_desc.Usage = &dummy_dword;
|
---|
455 | surface_desc.Pool = &pool;
|
---|
456 | surface_desc.Size = &dummy_dword;
|
---|
457 | surface_desc.MultiSampleType = &dummy_multisampletype;
|
---|
458 | surface_desc.MultiSampleQuality = &dummy_dword;
|
---|
459 | surface_desc.Width = &dummy_dword;
|
---|
460 | surface_desc.Height = &dummy_dword;
|
---|
461 |
|
---|
462 | IWineD3DSurface_GetDesc((IWineD3DSurface *) resource, &surface_desc);
|
---|
463 | break;
|
---|
464 |
|
---|
465 | case D3DRTYPE_VOLUME:
|
---|
466 | volume_desc.Format = &dummy_format;
|
---|
467 | volume_desc.Type = &type;
|
---|
468 | volume_desc.Usage = &dummy_dword;
|
---|
469 | volume_desc.Pool = &pool;
|
---|
470 | volume_desc.Size = &dummy_dword;
|
---|
471 | volume_desc.Width = &dummy_dword;
|
---|
472 | volume_desc.Height = &dummy_dword;
|
---|
473 | volume_desc.Depth = &dummy_dword;
|
---|
474 | IWineD3DVolume_GetDesc((IWineD3DVolume *) resource, &volume_desc);
|
---|
475 | break;
|
---|
476 |
|
---|
477 | case D3DRTYPE_INDEXBUFFER:
|
---|
478 | IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9 *) parent, &index_desc);
|
---|
479 | pool = index_desc.Pool;
|
---|
480 | break;
|
---|
481 |
|
---|
482 | case D3DRTYPE_VERTEXBUFFER:
|
---|
483 | IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9 *)parent, &vertex_desc);
|
---|
484 | pool = vertex_desc.Pool;
|
---|
485 | break;
|
---|
486 |
|
---|
487 | /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
|
---|
488 | * is a D3DPOOL_DEFAULT surface or volume as well
|
---|
489 | */
|
---|
490 | default:
|
---|
491 | break;
|
---|
492 | }
|
---|
493 |
|
---|
494 | if(pool == WINED3DPOOL_DEFAULT) {
|
---|
495 | if(IUnknown_Release(parent) == 0) {
|
---|
496 | TRACE("Parent %p is an implicit resource with ref 0\n", parent);
|
---|
497 | } else {
|
---|
498 | WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent, resource);
|
---|
499 | ret = S_FALSE;
|
---|
500 | *resources_ok = FALSE;
|
---|
501 | }
|
---|
502 | } else {
|
---|
503 | IUnknown_Release(parent);
|
---|
504 | }
|
---|
505 | IWineD3DResource_Release(resource);
|
---|
506 |
|
---|
507 | return ret;
|
---|
508 | }
|
---|
509 |
|
---|
510 | static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
|
---|
511 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
512 | WINED3DPRESENT_PARAMETERS localParameters;
|
---|
513 | HRESULT hr;
|
---|
514 | BOOL resources_ok = TRUE;
|
---|
515 | UINT i;
|
---|
516 |
|
---|
517 | TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
|
---|
518 |
|
---|
519 | /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
|
---|
520 | * such objects can still be used for rendering after their external d3d9 object has been destroyed.
|
---|
521 | * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
|
---|
522 | * make use of the hidden reference and destroys the objects.
|
---|
523 | *
|
---|
524 | * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
|
---|
525 | * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
|
---|
526 | */
|
---|
527 | EnterCriticalSection(&d3d9_cs);
|
---|
528 | IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
|
---|
529 | for(i = 0; i < 16; i++) {
|
---|
530 | IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
|
---|
531 | }
|
---|
532 | for(i = 0; i < 16; i++) {
|
---|
533 | IWineD3DDevice_SetTexture(This->WineD3DDevice, i, NULL);
|
---|
534 | }
|
---|
535 |
|
---|
536 | IWineD3DDevice_EnumResources(This->WineD3DDevice, reset_enum_callback, &resources_ok);
|
---|
537 | if(!resources_ok) {
|
---|
538 | WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
|
---|
539 | This->notreset = TRUE;
|
---|
540 | LeaveCriticalSection(&d3d9_cs);
|
---|
541 | return WINED3DERR_INVALIDCALL;
|
---|
542 | }
|
---|
543 |
|
---|
544 | localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
---|
545 | localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
---|
546 | localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
---|
547 | localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
|
---|
548 | localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
|
---|
549 | localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
|
---|
550 | localParameters.SwapEffect = pPresentationParameters->SwapEffect;
|
---|
551 | localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
|
---|
552 | localParameters.Windowed = pPresentationParameters->Windowed;
|
---|
553 | localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
|
---|
554 | localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
|
---|
555 | localParameters.Flags = pPresentationParameters->Flags;
|
---|
556 | localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
|
---|
557 | localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
|
---|
558 | localParameters.AutoRestoreDisplayMode = TRUE;
|
---|
559 |
|
---|
560 | hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
|
---|
561 | if(FAILED(hr)) {
|
---|
562 | This->notreset = TRUE;
|
---|
563 |
|
---|
564 | pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
---|
565 | pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
|
---|
566 | pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
|
---|
567 | pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
|
---|
568 | pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
|
---|
569 | pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
|
---|
570 | pPresentationParameters->SwapEffect = localParameters.SwapEffect;
|
---|
571 | pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
|
---|
572 | pPresentationParameters->Windowed = localParameters.Windowed;
|
---|
573 | pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
|
---|
574 | pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
|
---|
575 | pPresentationParameters->Flags = localParameters.Flags;
|
---|
576 | pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
|
---|
577 | pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
|
---|
578 | } else {
|
---|
579 | This->notreset = FALSE;
|
---|
580 | }
|
---|
581 |
|
---|
582 | LeaveCriticalSection(&d3d9_cs);
|
---|
583 |
|
---|
584 | return hr;
|
---|
585 | }
|
---|
586 |
|
---|
587 | static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
|
---|
588 | pDirtyRegion) {
|
---|
589 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
590 | HRESULT hr;
|
---|
591 | TRACE("(%p) Relay\n", This);
|
---|
592 |
|
---|
593 | EnterCriticalSection(&d3d9_cs);
|
---|
594 | hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
---|
595 | LeaveCriticalSection(&d3d9_cs);
|
---|
596 | return hr;
|
---|
597 | }
|
---|
598 |
|
---|
599 | static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
|
---|
600 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
601 | IWineD3DSurface *retSurface = NULL;
|
---|
602 | HRESULT rc = D3D_OK;
|
---|
603 |
|
---|
604 | TRACE("(%p) Relay\n", This);
|
---|
605 |
|
---|
606 | EnterCriticalSection(&d3d9_cs);
|
---|
607 | rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
|
---|
608 | if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
|
---|
609 | IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
|
---|
610 | IWineD3DSurface_Release(retSurface);
|
---|
611 | }
|
---|
612 | LeaveCriticalSection(&d3d9_cs);
|
---|
613 | return rc;
|
---|
614 | }
|
---|
615 | static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
|
---|
616 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
617 | HRESULT hr;
|
---|
618 | TRACE("(%p) Relay\n", This);
|
---|
619 |
|
---|
620 | EnterCriticalSection(&d3d9_cs);
|
---|
621 | hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
|
---|
622 | LeaveCriticalSection(&d3d9_cs);
|
---|
623 | return hr;
|
---|
624 | }
|
---|
625 |
|
---|
626 | static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface, BOOL bEnableDialogs) {
|
---|
627 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
628 | HRESULT hr;
|
---|
629 | TRACE("(%p) Relay\n", This);
|
---|
630 |
|
---|
631 | EnterCriticalSection(&d3d9_cs);
|
---|
632 | hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
|
---|
633 | LeaveCriticalSection(&d3d9_cs);
|
---|
634 | return hr;
|
---|
635 | }
|
---|
636 |
|
---|
637 | static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
|
---|
638 |
|
---|
639 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
640 | TRACE("(%p) Relay\n", This);
|
---|
641 |
|
---|
642 | EnterCriticalSection(&d3d9_cs);
|
---|
643 | /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
|
---|
644 | IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
|
---|
645 | LeaveCriticalSection(&d3d9_cs);
|
---|
646 | }
|
---|
647 |
|
---|
648 | static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
|
---|
649 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
650 | TRACE("(%p) Relay\n", This);
|
---|
651 |
|
---|
652 | EnterCriticalSection(&d3d9_cs);
|
---|
653 | /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
|
---|
654 | IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
|
---|
655 | LeaveCriticalSection(&d3d9_cs);
|
---|
656 | }
|
---|
657 |
|
---|
658 |
|
---|
659 | static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) {
|
---|
660 | HRESULT hrc;
|
---|
661 | IDirect3DSurface9Impl *object;
|
---|
662 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
663 | TRACE("(%p) Relay\n", This);
|
---|
664 |
|
---|
665 | if(MultisampleQuality > 0){
|
---|
666 | FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
|
---|
667 | /*
|
---|
668 | MultisampleQuality
|
---|
669 | [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.
|
---|
670 | */
|
---|
671 |
|
---|
672 | MultisampleQuality=0;
|
---|
673 | }
|
---|
674 | /*FIXME: Check MAX bounds of MultisampleQuality*/
|
---|
675 |
|
---|
676 | /* Allocate the storage for the device */
|
---|
677 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
|
---|
678 | if (NULL == object) {
|
---|
679 | FIXME("Allocation of memory failed\n");
|
---|
680 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
681 | }
|
---|
682 |
|
---|
683 | object->lpVtbl = &Direct3DSurface9_Vtbl;
|
---|
684 | object->ref = 1;
|
---|
685 |
|
---|
686 | TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
|
---|
687 |
|
---|
688 | EnterCriticalSection(&d3d9_cs);
|
---|
689 | hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format),
|
---|
690 | Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK,
|
---|
691 | (WINED3DPOOL)Pool, MultiSample, MultisampleQuality, SURFACE_OPENGL, (IUnknown *)object);
|
---|
692 | LeaveCriticalSection(&d3d9_cs);
|
---|
693 |
|
---|
694 | if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
|
---|
695 |
|
---|
696 | /* free up object */
|
---|
697 | FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
|
---|
698 | HeapFree(GetProcessHeap(), 0, object);
|
---|
699 | } else {
|
---|
700 | IDirect3DDevice9Ex_AddRef(iface);
|
---|
701 | object->parentDevice = iface;
|
---|
702 | TRACE("(%p) : Created surface %p\n", This, object);
|
---|
703 | *ppSurface = (LPDIRECT3DSURFACE9) object;
|
---|
704 | }
|
---|
705 | return hrc;
|
---|
706 | }
|
---|
707 |
|
---|
708 |
|
---|
709 |
|
---|
710 | static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
---|
711 | D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
|
---|
712 | DWORD MultisampleQuality, BOOL Lockable,
|
---|
713 | IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
|
---|
714 | HRESULT hr;
|
---|
715 | TRACE("Relay\n");
|
---|
716 |
|
---|
717 | hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,Lockable,FALSE/*Discard*/, 0/*Level*/, ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_RENDERTARGET,D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
|
---|
718 | return hr;
|
---|
719 | }
|
---|
720 |
|
---|
721 | static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
---|
722 | D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
|
---|
723 | DWORD MultisampleQuality, BOOL Discard,
|
---|
724 | IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
|
---|
725 | HRESULT hr;
|
---|
726 | TRACE("Relay\n");
|
---|
727 |
|
---|
728 | hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/* Lockable */,Discard, 0/* Level */
|
---|
729 | ,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,
|
---|
730 | D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
|
---|
731 | return hr;
|
---|
732 | }
|
---|
733 |
|
---|
734 |
|
---|
735 | static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
|
---|
736 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
737 | HRESULT hr;
|
---|
738 | TRACE("(%p) Relay\n" , This);
|
---|
739 |
|
---|
740 | EnterCriticalSection(&d3d9_cs);
|
---|
741 | hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
|
---|
742 | LeaveCriticalSection(&d3d9_cs);
|
---|
743 | return hr;
|
---|
744 | }
|
---|
745 |
|
---|
746 | static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
|
---|
747 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
748 | HRESULT hr;
|
---|
749 | TRACE("(%p) Relay\n" , This);
|
---|
750 |
|
---|
751 | EnterCriticalSection(&d3d9_cs);
|
---|
752 | hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
|
---|
753 | LeaveCriticalSection(&d3d9_cs);
|
---|
754 | return hr;
|
---|
755 | }
|
---|
756 |
|
---|
757 | static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
|
---|
758 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
759 | IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
|
---|
760 | IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
|
---|
761 | HRESULT hr;
|
---|
762 | TRACE("(%p)->(%p,%p)\n" , This, renderTarget, destSurface);
|
---|
763 |
|
---|
764 | EnterCriticalSection(&d3d9_cs);
|
---|
765 | hr = IWineD3DSurface_BltFast(destSurface->wineD3DSurface, 0, 0, renderTarget->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
|
---|
766 | LeaveCriticalSection(&d3d9_cs);
|
---|
767 | return hr;
|
---|
768 | }
|
---|
769 |
|
---|
770 | static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
|
---|
771 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
772 | IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
|
---|
773 | HRESULT hr;
|
---|
774 | TRACE("(%p) Relay\n" , This);
|
---|
775 |
|
---|
776 | EnterCriticalSection(&d3d9_cs);
|
---|
777 | hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
|
---|
778 | LeaveCriticalSection(&d3d9_cs);
|
---|
779 | return hr;
|
---|
780 | }
|
---|
781 |
|
---|
782 | static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
|
---|
783 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
784 | IDirect3DSurface9Impl *src = (IDirect3DSurface9Impl *) pSourceSurface;
|
---|
785 | IDirect3DSurface9Impl *dst = (IDirect3DSurface9Impl *) pDestSurface;
|
---|
786 | HRESULT hr;
|
---|
787 |
|
---|
788 | TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This, src, pSourceRect, dst, pDestRect, Filter);
|
---|
789 | EnterCriticalSection(&d3d9_cs);
|
---|
790 | hr = IWineD3DSurface_Blt(dst->wineD3DSurface, pDestRect, src->wineD3DSurface, pSourceRect, 0, NULL, Filter);
|
---|
791 | LeaveCriticalSection(&d3d9_cs);
|
---|
792 | return hr;
|
---|
793 | }
|
---|
794 |
|
---|
795 | static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
|
---|
796 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
797 | IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
|
---|
798 | WINED3DPOOL pool;
|
---|
799 | WINED3DRESOURCETYPE restype;
|
---|
800 | DWORD usage;
|
---|
801 | WINED3DSURFACE_DESC desc;
|
---|
802 | HRESULT hr;
|
---|
803 | TRACE("(%p) Relay\n" , This);
|
---|
804 |
|
---|
805 | memset(&desc, 0, sizeof(desc));
|
---|
806 | desc.Usage = &usage;
|
---|
807 | desc.Pool = &pool;
|
---|
808 | desc.Type = &restype;
|
---|
809 |
|
---|
810 | EnterCriticalSection(&d3d9_cs);
|
---|
811 | IWineD3DSurface_GetDesc(surface->wineD3DSurface, &desc);
|
---|
812 |
|
---|
813 | /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
|
---|
814 | * in D3DPOOL_DEFAULT
|
---|
815 | */
|
---|
816 | if(!(usage & WINED3DUSAGE_RENDERTARGET) && (pool != D3DPOOL_DEFAULT || restype != D3DRTYPE_SURFACE)) {
|
---|
817 | LeaveCriticalSection(&d3d9_cs);
|
---|
818 | WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
|
---|
819 | return D3DERR_INVALIDCALL;
|
---|
820 | }
|
---|
821 |
|
---|
822 | /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
|
---|
823 | /* Note: D3DRECT is compatible with WINED3DRECT */
|
---|
824 | hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
|
---|
825 | LeaveCriticalSection(&d3d9_cs);
|
---|
826 | return hr;
|
---|
827 | }
|
---|
828 |
|
---|
829 | static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
|
---|
830 | HRESULT hr;
|
---|
831 | TRACE("Relay\n");
|
---|
832 | if(Pool == D3DPOOL_MANAGED ){
|
---|
833 | FIXME("Attempting to create a managed offscreen plain surface\n");
|
---|
834 | return D3DERR_INVALIDCALL;
|
---|
835 | }
|
---|
836 | /*
|
---|
837 | 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
|
---|
838 | but then...
|
---|
839 | D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
|
---|
840 | Why, their always lockable?
|
---|
841 | should I change the usage to dynamic?
|
---|
842 | */
|
---|
843 | hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/*Loackable*/,FALSE/*Discard*/,0/*Level*/ , ppSurface,D3DRTYPE_SURFACE, 0/*Usage (undefined/none)*/,(WINED3DPOOL) Pool,D3DMULTISAMPLE_NONE,0/*MultisampleQuality*/,pSharedHandle);
|
---|
844 |
|
---|
845 | return hr;
|
---|
846 | }
|
---|
847 |
|
---|
848 | /* TODO: move to wineD3D */
|
---|
849 | static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
|
---|
850 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
851 | IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
|
---|
852 | HRESULT hr;
|
---|
853 | TRACE("(%p) Relay\n" , This);
|
---|
854 |
|
---|
855 | EnterCriticalSection(&d3d9_cs);
|
---|
856 | hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? pSurface->wineD3DSurface : NULL);
|
---|
857 | LeaveCriticalSection(&d3d9_cs);
|
---|
858 | return hr;
|
---|
859 | }
|
---|
860 |
|
---|
861 | static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
|
---|
862 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
863 | HRESULT hr = D3D_OK;
|
---|
864 | IWineD3DSurface *pRenderTarget;
|
---|
865 |
|
---|
866 | TRACE("(%p) Relay\n" , This);
|
---|
867 |
|
---|
868 | if (ppRenderTarget == NULL) {
|
---|
869 | return D3DERR_INVALIDCALL;
|
---|
870 | }
|
---|
871 |
|
---|
872 | EnterCriticalSection(&d3d9_cs);
|
---|
873 | hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
|
---|
874 |
|
---|
875 | if (hr == D3D_OK && pRenderTarget != NULL) {
|
---|
876 | IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
|
---|
877 | IWineD3DSurface_Release(pRenderTarget);
|
---|
878 | } else {
|
---|
879 | FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
|
---|
880 | *ppRenderTarget = NULL;
|
---|
881 | }
|
---|
882 | LeaveCriticalSection(&d3d9_cs);
|
---|
883 |
|
---|
884 | return hr;
|
---|
885 | }
|
---|
886 |
|
---|
887 | static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pZStencilSurface) {
|
---|
888 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
889 | IDirect3DSurface9Impl *pSurface;
|
---|
890 | HRESULT hr;
|
---|
891 | TRACE("(%p) Relay\n" , This);
|
---|
892 |
|
---|
893 | pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
|
---|
894 | EnterCriticalSection(&d3d9_cs);
|
---|
895 | hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL==pSurface ? NULL : pSurface->wineD3DSurface);
|
---|
896 | LeaveCriticalSection(&d3d9_cs);
|
---|
897 | return hr;
|
---|
898 | }
|
---|
899 |
|
---|
900 | static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9 **ppZStencilSurface) {
|
---|
901 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
902 | HRESULT hr = D3D_OK;
|
---|
903 | IWineD3DSurface *pZStencilSurface;
|
---|
904 |
|
---|
905 | TRACE("(%p) Relay\n" , This);
|
---|
906 | if(ppZStencilSurface == NULL){
|
---|
907 | return D3DERR_INVALIDCALL;
|
---|
908 | }
|
---|
909 |
|
---|
910 | EnterCriticalSection(&d3d9_cs);
|
---|
911 | hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
|
---|
912 | if (hr == WINED3D_OK) {
|
---|
913 | IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
|
---|
914 | IWineD3DSurface_Release(pZStencilSurface);
|
---|
915 | } else {
|
---|
916 | if (hr != WINED3DERR_NOTFOUND)
|
---|
917 | WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
|
---|
918 | *ppZStencilSurface = NULL;
|
---|
919 | }
|
---|
920 | LeaveCriticalSection(&d3d9_cs);
|
---|
921 | return hr;
|
---|
922 | }
|
---|
923 |
|
---|
924 | static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface) {
|
---|
925 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
926 | HRESULT hr;
|
---|
927 | TRACE("(%p) Relay\n" , This);
|
---|
928 |
|
---|
929 | EnterCriticalSection(&d3d9_cs);
|
---|
930 | hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
|
---|
931 | LeaveCriticalSection(&d3d9_cs);
|
---|
932 | return hr;
|
---|
933 | }
|
---|
934 |
|
---|
935 | static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) {
|
---|
936 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
937 | HRESULT hr;
|
---|
938 | TRACE("(%p) Relay\n" , This);
|
---|
939 |
|
---|
940 | EnterCriticalSection(&d3d9_cs);
|
---|
941 | hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
|
---|
942 | LeaveCriticalSection(&d3d9_cs);
|
---|
943 | return hr;
|
---|
944 | }
|
---|
945 |
|
---|
946 | static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
|
---|
947 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
948 | HRESULT hr;
|
---|
949 | TRACE("(%p) Relay\n" , This);
|
---|
950 |
|
---|
951 | /* Note: D3DRECT is compatible with WINED3DRECT */
|
---|
952 | EnterCriticalSection(&d3d9_cs);
|
---|
953 | hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
|
---|
954 | LeaveCriticalSection(&d3d9_cs);
|
---|
955 | return hr;
|
---|
956 | }
|
---|
957 |
|
---|
958 | static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
|
---|
959 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
960 | HRESULT hr;
|
---|
961 | TRACE("(%p) Relay\n" , This);
|
---|
962 |
|
---|
963 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
964 | EnterCriticalSection(&d3d9_cs);
|
---|
965 | hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
|
---|
966 | LeaveCriticalSection(&d3d9_cs);
|
---|
967 | return hr;
|
---|
968 | }
|
---|
969 |
|
---|
970 | static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
|
---|
971 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
972 | HRESULT hr;
|
---|
973 |
|
---|
974 | TRACE("(%p) Relay\n" , This);
|
---|
975 |
|
---|
976 | EnterCriticalSection(&d3d9_cs);
|
---|
977 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
978 | hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
|
---|
979 | LeaveCriticalSection(&d3d9_cs);
|
---|
980 |
|
---|
981 | return hr;
|
---|
982 | }
|
---|
983 |
|
---|
984 | static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
|
---|
985 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
986 | HRESULT hr;
|
---|
987 | TRACE("(%p) Relay\n" , This);
|
---|
988 |
|
---|
989 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
990 | EnterCriticalSection(&d3d9_cs);
|
---|
991 | hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
|
---|
992 | LeaveCriticalSection(&d3d9_cs);
|
---|
993 | return hr;
|
---|
994 | }
|
---|
995 |
|
---|
996 | static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface, CONST D3DVIEWPORT9* pViewport) {
|
---|
997 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
998 | HRESULT hr;
|
---|
999 | TRACE("(%p) Relay\n" , This);
|
---|
1000 |
|
---|
1001 | /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
|
---|
1002 | EnterCriticalSection(&d3d9_cs);
|
---|
1003 | hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
|
---|
1004 | LeaveCriticalSection(&d3d9_cs);
|
---|
1005 | return hr;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface, D3DVIEWPORT9* pViewport) {
|
---|
1009 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1010 | HRESULT hr;
|
---|
1011 | TRACE("(%p) Relay\n" , This);
|
---|
1012 |
|
---|
1013 | /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
|
---|
1014 | EnterCriticalSection(&d3d9_cs);
|
---|
1015 | hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
|
---|
1016 | LeaveCriticalSection(&d3d9_cs);
|
---|
1017 | return hr;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface, CONST D3DMATERIAL9* pMaterial) {
|
---|
1021 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1022 | HRESULT hr;
|
---|
1023 | TRACE("(%p) Relay\n" , This);
|
---|
1024 |
|
---|
1025 | /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
|
---|
1026 | EnterCriticalSection(&d3d9_cs);
|
---|
1027 | hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
|
---|
1028 | LeaveCriticalSection(&d3d9_cs);
|
---|
1029 | return hr;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface, D3DMATERIAL9* pMaterial) {
|
---|
1033 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1034 | HRESULT hr;
|
---|
1035 | TRACE("(%p) Relay\n" , This);
|
---|
1036 |
|
---|
1037 | /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
|
---|
1038 | EnterCriticalSection(&d3d9_cs);
|
---|
1039 | hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
|
---|
1040 | LeaveCriticalSection(&d3d9_cs);
|
---|
1041 | return hr;
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface, DWORD Index, CONST D3DLIGHT9* pLight) {
|
---|
1045 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1046 | HRESULT hr;
|
---|
1047 | TRACE("(%p) Relay\n" , This);
|
---|
1048 |
|
---|
1049 | /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
|
---|
1050 | EnterCriticalSection(&d3d9_cs);
|
---|
1051 | hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
|
---|
1052 | LeaveCriticalSection(&d3d9_cs);
|
---|
1053 | return hr;
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface, DWORD Index, D3DLIGHT9* pLight) {
|
---|
1057 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1058 | HRESULT hr;
|
---|
1059 | TRACE("(%p) Relay\n" , This);
|
---|
1060 |
|
---|
1061 | /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
|
---|
1062 | EnterCriticalSection(&d3d9_cs);
|
---|
1063 | hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
|
---|
1064 | LeaveCriticalSection(&d3d9_cs);
|
---|
1065 | return hr;
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface, DWORD Index, BOOL Enable) {
|
---|
1069 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1070 | HRESULT hr;
|
---|
1071 | TRACE("(%p) Relay\n" , This);
|
---|
1072 |
|
---|
1073 | EnterCriticalSection(&d3d9_cs);
|
---|
1074 | hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
|
---|
1075 | LeaveCriticalSection(&d3d9_cs);
|
---|
1076 | return hr;
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface, DWORD Index, BOOL* pEnable) {
|
---|
1080 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1081 | HRESULT hr;
|
---|
1082 | TRACE("(%p) Relay\n" , This);
|
---|
1083 |
|
---|
1084 | EnterCriticalSection(&d3d9_cs);
|
---|
1085 | hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
|
---|
1086 | LeaveCriticalSection(&d3d9_cs);
|
---|
1087 | return hr;
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface, DWORD Index, CONST float* pPlane) {
|
---|
1091 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1092 | HRESULT hr;
|
---|
1093 | TRACE("(%p) Relay\n" , This);
|
---|
1094 |
|
---|
1095 | EnterCriticalSection(&d3d9_cs);
|
---|
1096 | hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
|
---|
1097 | LeaveCriticalSection(&d3d9_cs);
|
---|
1098 | return hr;
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface, DWORD Index, float* pPlane) {
|
---|
1102 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1103 | HRESULT hr;
|
---|
1104 | TRACE("(%p) Relay\n" , This);
|
---|
1105 |
|
---|
1106 | EnterCriticalSection(&d3d9_cs);
|
---|
1107 | hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
|
---|
1108 | LeaveCriticalSection(&d3d9_cs);
|
---|
1109 | return hr;
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) {
|
---|
1113 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1114 | HRESULT hr;
|
---|
1115 | TRACE("(%p) Relay\n" , This);
|
---|
1116 |
|
---|
1117 | EnterCriticalSection(&d3d9_cs);
|
---|
1118 | hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
|
---|
1119 | LeaveCriticalSection(&d3d9_cs);
|
---|
1120 | return hr;
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
|
---|
1124 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1125 | HRESULT hr;
|
---|
1126 | TRACE("(%p) Relay\n" , This);
|
---|
1127 |
|
---|
1128 | EnterCriticalSection(&d3d9_cs);
|
---|
1129 | hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
|
---|
1130 | LeaveCriticalSection(&d3d9_cs);
|
---|
1131 | return hr;
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface, CONST D3DCLIPSTATUS9* pClipStatus) {
|
---|
1135 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1136 | HRESULT hr;
|
---|
1137 | TRACE("(%p) Relay\n" , This);
|
---|
1138 |
|
---|
1139 | EnterCriticalSection(&d3d9_cs);
|
---|
1140 | hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
|
---|
1141 | LeaveCriticalSection(&d3d9_cs);
|
---|
1142 | return hr;
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface, D3DCLIPSTATUS9* pClipStatus) {
|
---|
1146 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1147 | HRESULT hr;
|
---|
1148 | TRACE("(%p) Relay\n" , This);
|
---|
1149 |
|
---|
1150 | EnterCriticalSection(&d3d9_cs);
|
---|
1151 | hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
|
---|
1152 | LeaveCriticalSection(&d3d9_cs);
|
---|
1153 | return hr;
|
---|
1154 | }
|
---|
1155 |
|
---|
1156 | static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
|
---|
1157 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1158 | IWineD3DBaseTexture *retTexture = NULL;
|
---|
1159 | HRESULT rc = D3D_OK;
|
---|
1160 |
|
---|
1161 | TRACE("(%p) Relay\n" , This);
|
---|
1162 |
|
---|
1163 | if(ppTexture == NULL){
|
---|
1164 | return D3DERR_INVALIDCALL;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | EnterCriticalSection(&d3d9_cs);
|
---|
1168 | rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
|
---|
1169 | if (SUCCEEDED(rc) && NULL != retTexture) {
|
---|
1170 | IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
|
---|
1171 | IWineD3DBaseTexture_Release(retTexture);
|
---|
1172 | } else {
|
---|
1173 | if(FAILED(rc)) {
|
---|
1174 | WARN("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
|
---|
1175 | }
|
---|
1176 | *ppTexture = NULL;
|
---|
1177 | }
|
---|
1178 | LeaveCriticalSection(&d3d9_cs);
|
---|
1179 |
|
---|
1180 | return rc;
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
|
---|
1184 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1185 | HRESULT hr;
|
---|
1186 | TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
|
---|
1187 |
|
---|
1188 | EnterCriticalSection(&d3d9_cs);
|
---|
1189 | hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
|
---|
1190 | pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
|
---|
1191 | LeaveCriticalSection(&d3d9_cs);
|
---|
1192 | return hr;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | static const WINED3DTEXTURESTAGESTATETYPE tss_lookup[] =
|
---|
1196 | {
|
---|
1197 | WINED3DTSS_FORCE_DWORD, /* 0, unused */
|
---|
1198 | WINED3DTSS_COLOROP, /* 1, D3DTSS_COLOROP */
|
---|
1199 | WINED3DTSS_COLORARG1, /* 2, D3DTSS_COLORARG1 */
|
---|
1200 | WINED3DTSS_COLORARG2, /* 3, D3DTSS_COLORARG2 */
|
---|
1201 | WINED3DTSS_ALPHAOP, /* 4, D3DTSS_ALPHAOP */
|
---|
1202 | WINED3DTSS_ALPHAARG1, /* 5, D3DTSS_ALPHAARG1 */
|
---|
1203 | WINED3DTSS_ALPHAARG2, /* 6, D3DTSS_ALPHAARG2 */
|
---|
1204 | WINED3DTSS_BUMPENVMAT00, /* 7, D3DTSS_BUMPENVMAT00 */
|
---|
1205 | WINED3DTSS_BUMPENVMAT01, /* 8, D3DTSS_BUMPENVMAT01 */
|
---|
1206 | WINED3DTSS_BUMPENVMAT10, /* 9, D3DTSS_BUMPENVMAT10 */
|
---|
1207 | WINED3DTSS_BUMPENVMAT11, /* 10, D3DTSS_BUMPENVMAT11 */
|
---|
1208 | WINED3DTSS_TEXCOORDINDEX, /* 11, D3DTSS_TEXCOORDINDEX */
|
---|
1209 | WINED3DTSS_FORCE_DWORD, /* 12, unused */
|
---|
1210 | WINED3DTSS_FORCE_DWORD, /* 13, unused */
|
---|
1211 | WINED3DTSS_FORCE_DWORD, /* 14, unused */
|
---|
1212 | WINED3DTSS_FORCE_DWORD, /* 15, unused */
|
---|
1213 | WINED3DTSS_FORCE_DWORD, /* 16, unused */
|
---|
1214 | WINED3DTSS_FORCE_DWORD, /* 17, unused */
|
---|
1215 | WINED3DTSS_FORCE_DWORD, /* 18, unused */
|
---|
1216 | WINED3DTSS_FORCE_DWORD, /* 19, unused */
|
---|
1217 | WINED3DTSS_FORCE_DWORD, /* 20, unused */
|
---|
1218 | WINED3DTSS_FORCE_DWORD, /* 21, unused */
|
---|
1219 | WINED3DTSS_BUMPENVLSCALE, /* 22, D3DTSS_BUMPENVLSCALE */
|
---|
1220 | WINED3DTSS_BUMPENVLOFFSET, /* 23, D3DTSS_BUMPENVLOFFSET */
|
---|
1221 | WINED3DTSS_TEXTURETRANSFORMFLAGS, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
|
---|
1222 | WINED3DTSS_FORCE_DWORD, /* 25, unused */
|
---|
1223 | WINED3DTSS_COLORARG0, /* 26, D3DTSS_COLORARG0 */
|
---|
1224 | WINED3DTSS_ALPHAARG0, /* 27, D3DTSS_ALPHAARG0 */
|
---|
1225 | WINED3DTSS_RESULTARG, /* 28, D3DTSS_RESULTARG */
|
---|
1226 | WINED3DTSS_FORCE_DWORD, /* 29, unused */
|
---|
1227 | WINED3DTSS_FORCE_DWORD, /* 30, unused */
|
---|
1228 | WINED3DTSS_FORCE_DWORD, /* 31, unused */
|
---|
1229 | WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
|
---|
1230 | };
|
---|
1231 |
|
---|
1232 | static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
|
---|
1233 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1234 | HRESULT hr;
|
---|
1235 | TRACE("(%p) Relay\n" , This);
|
---|
1236 |
|
---|
1237 | EnterCriticalSection(&d3d9_cs);
|
---|
1238 | hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
|
---|
1239 | LeaveCriticalSection(&d3d9_cs);
|
---|
1240 | return hr;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
|
---|
1244 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1245 | HRESULT hr;
|
---|
1246 | TRACE("(%p) Relay\n" , This);
|
---|
1247 |
|
---|
1248 | EnterCriticalSection(&d3d9_cs);
|
---|
1249 | hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
|
---|
1250 | LeaveCriticalSection(&d3d9_cs);
|
---|
1251 | return hr;
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 | static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
|
---|
1255 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1256 | HRESULT hr;
|
---|
1257 | TRACE("(%p) Relay\n" , This);
|
---|
1258 |
|
---|
1259 | EnterCriticalSection(&d3d9_cs);
|
---|
1260 | hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
|
---|
1261 | LeaveCriticalSection(&d3d9_cs);
|
---|
1262 | return hr;
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
|
---|
1266 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1267 | HRESULT hr;
|
---|
1268 | TRACE("(%p) Relay\n" , This);
|
---|
1269 |
|
---|
1270 | EnterCriticalSection(&d3d9_cs);
|
---|
1271 | hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
|
---|
1272 | LeaveCriticalSection(&d3d9_cs);
|
---|
1273 | return hr;
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface, DWORD* pNumPasses) {
|
---|
1277 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1278 | HRESULT hr;
|
---|
1279 | TRACE("(%p) Relay\n" , This);
|
---|
1280 |
|
---|
1281 | EnterCriticalSection(&d3d9_cs);
|
---|
1282 | hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
|
---|
1283 | LeaveCriticalSection(&d3d9_cs);
|
---|
1284 | return hr;
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9EX iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
|
---|
1288 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1289 | HRESULT hr;
|
---|
1290 | TRACE("(%p) Relay\n" , This);
|
---|
1291 |
|
---|
1292 | EnterCriticalSection(&d3d9_cs);
|
---|
1293 | hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
|
---|
1294 | LeaveCriticalSection(&d3d9_cs);
|
---|
1295 | return hr;
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
|
---|
1299 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1300 | HRESULT hr;
|
---|
1301 | TRACE("(%p) Relay\n" , This);
|
---|
1302 |
|
---|
1303 | EnterCriticalSection(&d3d9_cs);
|
---|
1304 | hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
|
---|
1305 | LeaveCriticalSection(&d3d9_cs);
|
---|
1306 | return hr;
|
---|
1307 | }
|
---|
1308 |
|
---|
1309 | static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface, UINT PaletteNumber) {
|
---|
1310 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1311 | HRESULT hr;
|
---|
1312 | TRACE("(%p) Relay\n" , This);
|
---|
1313 |
|
---|
1314 | EnterCriticalSection(&d3d9_cs);
|
---|
1315 | hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
|
---|
1316 | LeaveCriticalSection(&d3d9_cs);
|
---|
1317 | return hr;
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface, UINT* PaletteNumber) {
|
---|
1321 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1322 | HRESULT hr;
|
---|
1323 | TRACE("(%p) Relay\n" , This);
|
---|
1324 |
|
---|
1325 | EnterCriticalSection(&d3d9_cs);
|
---|
1326 | hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
|
---|
1327 | LeaveCriticalSection(&d3d9_cs);
|
---|
1328 | return hr;
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface, CONST RECT* pRect) {
|
---|
1332 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1333 | HRESULT hr;
|
---|
1334 | TRACE("(%p) Relay\n" , This);
|
---|
1335 |
|
---|
1336 | EnterCriticalSection(&d3d9_cs);
|
---|
1337 | hr = IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
|
---|
1338 | LeaveCriticalSection(&d3d9_cs);
|
---|
1339 | return hr;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 | static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface, RECT* pRect) {
|
---|
1343 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1344 | HRESULT hr;
|
---|
1345 | TRACE("(%p) Relay\n" , This);
|
---|
1346 |
|
---|
1347 | EnterCriticalSection(&d3d9_cs);
|
---|
1348 | hr = IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
|
---|
1349 | LeaveCriticalSection(&d3d9_cs);
|
---|
1350 | return hr;
|
---|
1351 | }
|
---|
1352 |
|
---|
1353 | static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface, BOOL bSoftware) {
|
---|
1354 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1355 | HRESULT hr;
|
---|
1356 | TRACE("(%p) Relay\n" , This);
|
---|
1357 |
|
---|
1358 | EnterCriticalSection(&d3d9_cs);
|
---|
1359 | hr = IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
|
---|
1360 | LeaveCriticalSection(&d3d9_cs);
|
---|
1361 | return hr;
|
---|
1362 | }
|
---|
1363 |
|
---|
1364 | static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface) {
|
---|
1365 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1366 | BOOL ret;
|
---|
1367 | TRACE("(%p) Relay\n" , This);
|
---|
1368 |
|
---|
1369 | EnterCriticalSection(&d3d9_cs);
|
---|
1370 | ret = IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
|
---|
1371 | LeaveCriticalSection(&d3d9_cs);
|
---|
1372 | return ret;
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface, float nSegments) {
|
---|
1376 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1377 | HRESULT hr;
|
---|
1378 | TRACE("(%p) Relay\n" , This);
|
---|
1379 |
|
---|
1380 | EnterCriticalSection(&d3d9_cs);
|
---|
1381 | hr = IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
|
---|
1382 | LeaveCriticalSection(&d3d9_cs);
|
---|
1383 | return hr;
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface) {
|
---|
1387 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1388 | float ret;
|
---|
1389 | TRACE("(%p) Relay\n" , This);
|
---|
1390 |
|
---|
1391 | EnterCriticalSection(&d3d9_cs);
|
---|
1392 | ret = IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
|
---|
1393 | LeaveCriticalSection(&d3d9_cs);
|
---|
1394 | return ret;
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
|
---|
1398 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1399 | HRESULT hr;
|
---|
1400 | TRACE("(%p) Relay\n" , This);
|
---|
1401 |
|
---|
1402 | EnterCriticalSection(&d3d9_cs);
|
---|
1403 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1404 | hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
|
---|
1405 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
|
---|
1406 | LeaveCriticalSection(&d3d9_cs);
|
---|
1407 | return hr;
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType,
|
---|
1411 | INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
|
---|
1412 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1413 | HRESULT hr;
|
---|
1414 | TRACE("(%p) Relay\n" , This);
|
---|
1415 |
|
---|
1416 | /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
|
---|
1417 | EnterCriticalSection(&d3d9_cs);
|
---|
1418 | IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
|
---|
1419 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1420 | hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, MinVertexIndex, NumVertices,
|
---|
1421 | startIndex, vertex_count_from_primitive_count(PrimitiveType, primCount));
|
---|
1422 | LeaveCriticalSection(&d3d9_cs);
|
---|
1423 | return hr;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
|
---|
1427 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1428 | HRESULT hr;
|
---|
1429 | TRACE("(%p) Relay\n" , This);
|
---|
1430 |
|
---|
1431 | EnterCriticalSection(&d3d9_cs);
|
---|
1432 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1433 | hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
|
---|
1434 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
|
---|
1435 | pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1436 | LeaveCriticalSection(&d3d9_cs);
|
---|
1437 | return hr;
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
|
---|
1441 | UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
|
---|
1442 | D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
|
---|
1443 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1444 | HRESULT hr;
|
---|
1445 | TRACE("(%p) Relay\n" , This);
|
---|
1446 |
|
---|
1447 | EnterCriticalSection(&d3d9_cs);
|
---|
1448 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1449 | hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, MinVertexIndex, NumVertexIndices,
|
---|
1450 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
|
---|
1451 | wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1452 | LeaveCriticalSection(&d3d9_cs);
|
---|
1453 | return hr;
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
|
---|
1457 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1458 | IDirect3DVertexDeclaration9Impl *Decl = (IDirect3DVertexDeclaration9Impl *) pVertexDecl;
|
---|
1459 | HRESULT hr;
|
---|
1460 | IDirect3DVertexBuffer9Impl *dest = (IDirect3DVertexBuffer9Impl *) pDestBuffer;
|
---|
1461 | TRACE("(%p) Relay\n" , This);
|
---|
1462 |
|
---|
1463 | EnterCriticalSection(&d3d9_cs);
|
---|
1464 | hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
|
---|
1465 | LeaveCriticalSection(&d3d9_cs);
|
---|
1466 | return hr;
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) {
|
---|
1470 | HRESULT hr;
|
---|
1471 | D3DVERTEXELEMENT9* elements = NULL;
|
---|
1472 | IDirect3DVertexDeclaration9* pDecl = NULL;
|
---|
1473 | int p, low, high; /* deliberately signed */
|
---|
1474 | IDirect3DVertexDeclaration9 **convertedDecls = This->convertedDecls;
|
---|
1475 |
|
---|
1476 | TRACE("Searching for declaration for fvf %08x... ", fvf);
|
---|
1477 |
|
---|
1478 | low = 0;
|
---|
1479 | high = This->numConvertedDecls - 1;
|
---|
1480 | while(low <= high) {
|
---|
1481 | p = (low + high) >> 1;
|
---|
1482 | TRACE("%d ", p);
|
---|
1483 | if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF == fvf) {
|
---|
1484 | TRACE("found %p\n", convertedDecls[p]);
|
---|
1485 | return convertedDecls[p];
|
---|
1486 | } else if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF < fvf) {
|
---|
1487 | low = p + 1;
|
---|
1488 | } else {
|
---|
1489 | high = p - 1;
|
---|
1490 | }
|
---|
1491 | }
|
---|
1492 | TRACE("not found. Creating and inserting at position %d.\n", low);
|
---|
1493 |
|
---|
1494 | hr = vdecl_convert_fvf(fvf, &elements);
|
---|
1495 | if (hr != S_OK) return NULL;
|
---|
1496 |
|
---|
1497 | hr = IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex *) This, elements, &pDecl);
|
---|
1498 | HeapFree(GetProcessHeap(), 0, elements); /* CreateVertexDeclaration makes a copy */
|
---|
1499 | if (hr != S_OK) return NULL;
|
---|
1500 |
|
---|
1501 | if(This->declArraySize == This->numConvertedDecls) {
|
---|
1502 | int grow = max(This->declArraySize / 2, 8);
|
---|
1503 | convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
|
---|
1504 | sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
|
---|
1505 | if(!convertedDecls) {
|
---|
1506 | /* This will destroy it */
|
---|
1507 | IDirect3DVertexDeclaration9_Release(pDecl);
|
---|
1508 | return NULL;
|
---|
1509 | }
|
---|
1510 | This->convertedDecls = convertedDecls;
|
---|
1511 | This->declArraySize += grow;
|
---|
1512 | }
|
---|
1513 |
|
---|
1514 | memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(IDirect3DVertexDeclaration9Impl *) * (This->numConvertedDecls - low));
|
---|
1515 | convertedDecls[low] = pDecl;
|
---|
1516 | This->numConvertedDecls++;
|
---|
1517 |
|
---|
1518 | /* Will prevent the decl from being destroyed */
|
---|
1519 | ((IDirect3DVertexDeclaration9Impl *) pDecl)->convFVF = fvf;
|
---|
1520 | IDirect3DVertexDeclaration9_Release(pDecl); /* Does not destroy now */
|
---|
1521 |
|
---|
1522 | TRACE("Returning %p. %d decls in array\n", pDecl, This->numConvertedDecls);
|
---|
1523 | return pDecl;
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 | static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) {
|
---|
1527 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1528 | IDirect3DVertexDeclaration9 *decl;
|
---|
1529 | HRESULT hr;
|
---|
1530 |
|
---|
1531 | TRACE("(%p) Relay\n" , This);
|
---|
1532 |
|
---|
1533 | if (!FVF)
|
---|
1534 | {
|
---|
1535 | WARN("%#x is not a valid FVF\n", FVF);
|
---|
1536 | return D3D_OK;
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | EnterCriticalSection(&d3d9_cs);
|
---|
1540 | decl = getConvertedDecl(This, FVF);
|
---|
1541 | LeaveCriticalSection(&d3d9_cs);
|
---|
1542 |
|
---|
1543 | if (!decl)
|
---|
1544 | {
|
---|
1545 | /* Any situation when this should happen, except out of memory? */
|
---|
1546 | ERR("Failed to create a converted vertex declaration\n");
|
---|
1547 | return D3DERR_DRIVERINTERNALERROR;
|
---|
1548 | }
|
---|
1549 |
|
---|
1550 | hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, decl);
|
---|
1551 | if (FAILED(hr)) ERR("Failed to set vertex declaration\n");
|
---|
1552 |
|
---|
1553 | return hr;
|
---|
1554 | }
|
---|
1555 |
|
---|
1556 | static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWORD* pFVF) {
|
---|
1557 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1558 | IDirect3DVertexDeclaration9 *decl;
|
---|
1559 | HRESULT hr;
|
---|
1560 | TRACE("(%p) Relay\n" , This);
|
---|
1561 |
|
---|
1562 | hr = IDirect3DDevice9_GetVertexDeclaration(iface, &decl);
|
---|
1563 | if (FAILED(hr))
|
---|
1564 | {
|
---|
1565 | WARN("Failed to get vertex declaration, %#x\n", hr);
|
---|
1566 | *pFVF = 0;
|
---|
1567 | return hr;
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | if (decl)
|
---|
1571 | {
|
---|
1572 | *pFVF = ((IDirect3DVertexDeclaration9Impl *)decl)->convFVF;
|
---|
1573 | IDirect3DVertexDeclaration9_Release(decl);
|
---|
1574 | }
|
---|
1575 | else
|
---|
1576 | {
|
---|
1577 | *pFVF = 0;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | TRACE("Returning FVF %#x\n", *pFVF);
|
---|
1581 |
|
---|
1582 | return hr;
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 | static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
|
---|
1586 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1587 | HRESULT hr;
|
---|
1588 | TRACE("(%p) Relay\n" , This);
|
---|
1589 |
|
---|
1590 | EnterCriticalSection(&d3d9_cs);
|
---|
1591 | hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
|
---|
1592 | pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
|
---|
1593 | OffsetInBytes, Stride);
|
---|
1594 | LeaveCriticalSection(&d3d9_cs);
|
---|
1595 | return hr;
|
---|
1596 | }
|
---|
1597 |
|
---|
1598 | static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
|
---|
1599 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1600 | IWineD3DBuffer *retStream = NULL;
|
---|
1601 | HRESULT rc = D3D_OK;
|
---|
1602 |
|
---|
1603 | TRACE("(%p) Relay\n" , This);
|
---|
1604 |
|
---|
1605 | if(pStream == NULL){
|
---|
1606 | return D3DERR_INVALIDCALL;
|
---|
1607 | }
|
---|
1608 |
|
---|
1609 | EnterCriticalSection(&d3d9_cs);
|
---|
1610 | rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
|
---|
1611 | if (rc == D3D_OK && NULL != retStream) {
|
---|
1612 | IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
|
---|
1613 | IWineD3DBuffer_Release(retStream);
|
---|
1614 | }else{
|
---|
1615 | if (rc != D3D_OK){
|
---|
1616 | FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
|
---|
1617 | }
|
---|
1618 | *pStream = NULL;
|
---|
1619 | }
|
---|
1620 | LeaveCriticalSection(&d3d9_cs);
|
---|
1621 |
|
---|
1622 | return rc;
|
---|
1623 | }
|
---|
1624 |
|
---|
1625 | static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, UINT Divider) {
|
---|
1626 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1627 | HRESULT hr;
|
---|
1628 | TRACE("(%p) Relay\n" , This);
|
---|
1629 |
|
---|
1630 | EnterCriticalSection(&d3d9_cs);
|
---|
1631 | hr = IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
|
---|
1632 | LeaveCriticalSection(&d3d9_cs);
|
---|
1633 | return hr;
|
---|
1634 | }
|
---|
1635 |
|
---|
1636 | static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, UINT* Divider) {
|
---|
1637 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1638 | HRESULT hr;
|
---|
1639 | TRACE("(%p) Relay\n" , This);
|
---|
1640 |
|
---|
1641 | EnterCriticalSection(&d3d9_cs);
|
---|
1642 | hr = IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
|
---|
1643 | LeaveCriticalSection(&d3d9_cs);
|
---|
1644 | return hr;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9* pIndexData) {
|
---|
1648 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1649 | HRESULT hr;
|
---|
1650 | IDirect3DIndexBuffer9Impl *ib = (IDirect3DIndexBuffer9Impl *) pIndexData;
|
---|
1651 | TRACE("(%p) Relay\n", This);
|
---|
1652 |
|
---|
1653 | EnterCriticalSection(&d3d9_cs);
|
---|
1654 | hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
|
---|
1655 | ib ? ib->wineD3DIndexBuffer : NULL,
|
---|
1656 | ib ? ib->format : WINED3DFMT_UNKNOWN);
|
---|
1657 | LeaveCriticalSection(&d3d9_cs);
|
---|
1658 | return hr;
|
---|
1659 | }
|
---|
1660 |
|
---|
1661 | static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9 **ppIndexData) {
|
---|
1662 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1663 | IWineD3DBuffer *retIndexData = NULL;
|
---|
1664 | HRESULT rc = D3D_OK;
|
---|
1665 |
|
---|
1666 | TRACE("(%p) Relay\n", This);
|
---|
1667 |
|
---|
1668 | if(ppIndexData == NULL){
|
---|
1669 | return D3DERR_INVALIDCALL;
|
---|
1670 | }
|
---|
1671 |
|
---|
1672 | EnterCriticalSection(&d3d9_cs);
|
---|
1673 | rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData);
|
---|
1674 | if (SUCCEEDED(rc) && retIndexData) {
|
---|
1675 | IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
|
---|
1676 | IWineD3DBuffer_Release(retIndexData);
|
---|
1677 | } else {
|
---|
1678 | if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
|
---|
1679 | *ppIndexData = NULL;
|
---|
1680 | }
|
---|
1681 | LeaveCriticalSection(&d3d9_cs);
|
---|
1682 | return rc;
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
|
---|
1686 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1687 | HRESULT hr;
|
---|
1688 | TRACE("(%p) Relay\n", This);
|
---|
1689 |
|
---|
1690 | EnterCriticalSection(&d3d9_cs);
|
---|
1691 | hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
|
---|
1692 | LeaveCriticalSection(&d3d9_cs);
|
---|
1693 | return hr;
|
---|
1694 | }
|
---|
1695 |
|
---|
1696 | static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
|
---|
1697 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1698 | HRESULT hr;
|
---|
1699 | TRACE("(%p) Relay\n", This);
|
---|
1700 |
|
---|
1701 | EnterCriticalSection(&d3d9_cs);
|
---|
1702 | hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
|
---|
1703 | LeaveCriticalSection(&d3d9_cs);
|
---|
1704 | return hr;
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 | static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface, UINT Handle) {
|
---|
1708 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
---|
1709 | HRESULT hr;
|
---|
1710 | TRACE("(%p) Relay\n", This);
|
---|
1711 |
|
---|
1712 | EnterCriticalSection(&d3d9_cs);
|
---|
1713 | hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
|
---|
1714 | LeaveCriticalSection(&d3d9_cs);
|
---|
1715 | return hr;
|
---|
1716 | }
|
---|
1717 |
|
---|
1718 | static HRESULT WINAPI IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(LPDIRECT3DDEVICE9EX iface, UINT width, UINT height, float *rows, float *columns) {
|
---|
1719 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1720 | FIXME("(%p)->(%d, %d, %p, %p) Stub!\n", This, width, height, rows, columns);
|
---|
1721 | return WINED3DERR_INVALIDCALL;
|
---|
1722 | }
|
---|
1723 |
|
---|
1724 | static HRESULT WINAPI IDirect3DDevice9ExImpl_ComposeRects(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9 *pSrc, IDirect3DDevice9 *pDst, IDirect3DVertexBuffer9 *pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset) {
|
---|
1725 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1726 | FIXME("(%p)->(%p, %p, %p, %d, %p, %d, %d, %d) Stub!\n", This, pSrc, pDst, pSrcRectDescs, NumRects, pDstRectDescs, Operation, Xoffset, Yoffset);
|
---|
1727 | return WINED3DERR_INVALIDCALL;
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 | static HRESULT WINAPI IDirect3DDevice9ExImpl_PresentEx(LPDIRECT3DDEVICE9EX iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
|
---|
1731 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1732 | FIXME("(%p= -> (%p), %p, %p, %p, 0x%08x) Stub!\n", This, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
|
---|
1733 | return WINED3DERR_INVALIDCALL;
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | static HRESULT WINAPI IDirect3DDevice9ExImpl_GetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface, INT *pPriority) {
|
---|
1737 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1738 | FIXME("(%p)->(%p) Stub!\n", This, pPriority);
|
---|
1739 | return WINED3DERR_INVALIDCALL;
|
---|
1740 | }
|
---|
1741 |
|
---|
1742 | static HRESULT WINAPI IDirect3DDevice9ExImpl_SetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface, INT Priority) {
|
---|
1743 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1744 | FIXME("(%p)->(%d) Stub!\n", This, Priority);
|
---|
1745 | return WINED3DERR_INVALIDCALL;
|
---|
1746 | }
|
---|
1747 |
|
---|
1748 | static HRESULT WINAPI IDirect3DDevice9ExImpl_WaitForVBlank(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain) {
|
---|
1749 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1750 | FIXME("(%p)->(%d) Stub!\n", This, iSwapChain);
|
---|
1751 | return WINED3DERR_INVALIDCALL;
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 | static HRESULT WINAPI IDirect3DDevice9ExImpl_CheckresourceResidency(LPDIRECT3DDEVICE9EX iface, IDirect3DResource9 ** pResourceArray, UINT32 Numresources) {
|
---|
1755 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1756 | FIXME("(%p)->(%p, %d) Stub!\n", This, pResourceArray, Numresources);
|
---|
1757 | return WINED3DERR_INVALIDCALL;
|
---|
1758 | }
|
---|
1759 |
|
---|
1760 | static HRESULT WINAPI IDirect3DDevice9ExImpl_SetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface, UINT MaxLatency) {
|
---|
1761 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1762 | FIXME("(%p)->(%d) Stub!\n", This, MaxLatency);
|
---|
1763 | return WINED3DERR_INVALIDCALL;
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | static HRESULT WINAPI IDirect3DDevice9ExImpl_GetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface, UINT *pMaxLatency) {
|
---|
1767 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1768 | FIXME("(%p)->(%p) Stub!\n", This, pMaxLatency);
|
---|
1769 | *pMaxLatency = 2;
|
---|
1770 | return WINED3DERR_INVALIDCALL;
|
---|
1771 | }
|
---|
1772 |
|
---|
1773 | static HRESULT WINAPI IDirect3DDevice9ExImpl_CheckdeviceState(LPDIRECT3DDEVICE9EX iface, HWND hDestinationWindow) {
|
---|
1774 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1775 | FIXME("(%p)->(%p) Stub!\n", This, hDestinationWindow);
|
---|
1776 | return WINED3DERR_INVALIDCALL;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateRenderTargetEx(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultiSampleQuality, BOOL Lockable, IDirect3DSurface9 ** ppSurface, HANDLE *pSharedHandle, DWORD Usage) {
|
---|
1780 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1781 | FIXME("(%p)->(%d, %d, %d, %d, %d, %s, %p, %p, 0x%08x) Stub!\n", This, Width, Height, Format, MultiSample, MultiSampleQuality, Lockable ? "true" : "false", ppSurface, pSharedHandle, Usage);
|
---|
1782 | return WINED3DERR_INVALIDCALL;
|
---|
1783 | }
|
---|
1784 |
|
---|
1785 | static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) {
|
---|
1786 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1787 | FIXME("(%p)->(%d, %d, %d, %d, %p, %p, 0x%08x) Stub!\n", This, Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage);
|
---|
1788 | return WINED3DERR_INVALIDCALL;
|
---|
1789 | }
|
---|
1790 |
|
---|
1791 | static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultiSampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) {
|
---|
1792 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1793 | FIXME("(%p)->(%d, %d, %d, %d, %d, %s, %p, %p, 0x%08x) Stub!\n", This, Width, Height, Format, MultiSample, MultiSampleQuality, Discard ? "true" : "false", ppSurface, pSharedHandle, Usage);
|
---|
1794 | return WINED3DERR_INVALIDCALL;
|
---|
1795 | }
|
---|
1796 |
|
---|
1797 | static HRESULT WINAPI IDirect3DDevice9ExImpl_ResetEx(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode) {
|
---|
1798 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1799 | FIXME("(%p)->(%p) Stub!\n", This, pPresentationParameters);
|
---|
1800 | return WINED3DERR_INVALIDCALL;
|
---|
1801 | }
|
---|
1802 |
|
---|
1803 | static HRESULT WINAPI IDirect3DDevice9ExImpl_GetDisplayModeEx(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) {
|
---|
1804 | IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *) iface;
|
---|
1805 | FIXME("(%p)->(%d, %p, %p) Stub!\n", This, iSwapChain, pMode, pRotation);
|
---|
1806 | return WINED3DERR_INVALIDCALL;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl =
|
---|
1810 | {
|
---|
1811 | /* IUnknown */
|
---|
1812 | IDirect3DDevice9Impl_QueryInterface,
|
---|
1813 | IDirect3DDevice9Impl_AddRef,
|
---|
1814 | IDirect3DDevice9Impl_Release,
|
---|
1815 | /* IDirect3DDevice9 */
|
---|
1816 | IDirect3DDevice9Impl_TestCooperativeLevel,
|
---|
1817 | IDirect3DDevice9Impl_GetAvailableTextureMem,
|
---|
1818 | IDirect3DDevice9Impl_EvictManagedResources,
|
---|
1819 | IDirect3DDevice9Impl_GetDirect3D,
|
---|
1820 | IDirect3DDevice9Impl_GetDeviceCaps,
|
---|
1821 | IDirect3DDevice9Impl_GetDisplayMode,
|
---|
1822 | IDirect3DDevice9Impl_GetCreationParameters,
|
---|
1823 | IDirect3DDevice9Impl_SetCursorProperties,
|
---|
1824 | IDirect3DDevice9Impl_SetCursorPosition,
|
---|
1825 | IDirect3DDevice9Impl_ShowCursor,
|
---|
1826 | IDirect3DDevice9Impl_CreateAdditionalSwapChain,
|
---|
1827 | IDirect3DDevice9Impl_GetSwapChain,
|
---|
1828 | IDirect3DDevice9Impl_GetNumberOfSwapChains,
|
---|
1829 | IDirect3DDevice9Impl_Reset,
|
---|
1830 | IDirect3DDevice9Impl_Present,
|
---|
1831 | IDirect3DDevice9Impl_GetBackBuffer,
|
---|
1832 | IDirect3DDevice9Impl_GetRasterStatus,
|
---|
1833 | IDirect3DDevice9Impl_SetDialogBoxMode,
|
---|
1834 | IDirect3DDevice9Impl_SetGammaRamp,
|
---|
1835 | IDirect3DDevice9Impl_GetGammaRamp,
|
---|
1836 | IDirect3DDevice9Impl_CreateTexture,
|
---|
1837 | IDirect3DDevice9Impl_CreateVolumeTexture,
|
---|
1838 | IDirect3DDevice9Impl_CreateCubeTexture,
|
---|
1839 | IDirect3DDevice9Impl_CreateVertexBuffer,
|
---|
1840 | IDirect3DDevice9Impl_CreateIndexBuffer,
|
---|
1841 | IDirect3DDevice9Impl_CreateRenderTarget,
|
---|
1842 | IDirect3DDevice9Impl_CreateDepthStencilSurface,
|
---|
1843 | IDirect3DDevice9Impl_UpdateSurface,
|
---|
1844 | IDirect3DDevice9Impl_UpdateTexture,
|
---|
1845 | IDirect3DDevice9Impl_GetRenderTargetData,
|
---|
1846 | IDirect3DDevice9Impl_GetFrontBufferData,
|
---|
1847 | IDirect3DDevice9Impl_StretchRect,
|
---|
1848 | IDirect3DDevice9Impl_ColorFill,
|
---|
1849 | IDirect3DDevice9Impl_CreateOffscreenPlainSurface,
|
---|
1850 | IDirect3DDevice9Impl_SetRenderTarget,
|
---|
1851 | IDirect3DDevice9Impl_GetRenderTarget,
|
---|
1852 | IDirect3DDevice9Impl_SetDepthStencilSurface,
|
---|
1853 | IDirect3DDevice9Impl_GetDepthStencilSurface,
|
---|
1854 | IDirect3DDevice9Impl_BeginScene,
|
---|
1855 | IDirect3DDevice9Impl_EndScene,
|
---|
1856 | IDirect3DDevice9Impl_Clear,
|
---|
1857 | IDirect3DDevice9Impl_SetTransform,
|
---|
1858 | IDirect3DDevice9Impl_GetTransform,
|
---|
1859 | IDirect3DDevice9Impl_MultiplyTransform,
|
---|
1860 | IDirect3DDevice9Impl_SetViewport,
|
---|
1861 | IDirect3DDevice9Impl_GetViewport,
|
---|
1862 | IDirect3DDevice9Impl_SetMaterial,
|
---|
1863 | IDirect3DDevice9Impl_GetMaterial,
|
---|
1864 | IDirect3DDevice9Impl_SetLight,
|
---|
1865 | IDirect3DDevice9Impl_GetLight,
|
---|
1866 | IDirect3DDevice9Impl_LightEnable,
|
---|
1867 | IDirect3DDevice9Impl_GetLightEnable,
|
---|
1868 | IDirect3DDevice9Impl_SetClipPlane,
|
---|
1869 | IDirect3DDevice9Impl_GetClipPlane,
|
---|
1870 | IDirect3DDevice9Impl_SetRenderState,
|
---|
1871 | IDirect3DDevice9Impl_GetRenderState,
|
---|
1872 | IDirect3DDevice9Impl_CreateStateBlock,
|
---|
1873 | IDirect3DDevice9Impl_BeginStateBlock,
|
---|
1874 | IDirect3DDevice9Impl_EndStateBlock,
|
---|
1875 | IDirect3DDevice9Impl_SetClipStatus,
|
---|
1876 | IDirect3DDevice9Impl_GetClipStatus,
|
---|
1877 | IDirect3DDevice9Impl_GetTexture,
|
---|
1878 | IDirect3DDevice9Impl_SetTexture,
|
---|
1879 | IDirect3DDevice9Impl_GetTextureStageState,
|
---|
1880 | IDirect3DDevice9Impl_SetTextureStageState,
|
---|
1881 | IDirect3DDevice9Impl_GetSamplerState,
|
---|
1882 | IDirect3DDevice9Impl_SetSamplerState,
|
---|
1883 | IDirect3DDevice9Impl_ValidateDevice,
|
---|
1884 | IDirect3DDevice9Impl_SetPaletteEntries,
|
---|
1885 | IDirect3DDevice9Impl_GetPaletteEntries,
|
---|
1886 | IDirect3DDevice9Impl_SetCurrentTexturePalette,
|
---|
1887 | IDirect3DDevice9Impl_GetCurrentTexturePalette,
|
---|
1888 | IDirect3DDevice9Impl_SetScissorRect,
|
---|
1889 | IDirect3DDevice9Impl_GetScissorRect,
|
---|
1890 | IDirect3DDevice9Impl_SetSoftwareVertexProcessing,
|
---|
1891 | IDirect3DDevice9Impl_GetSoftwareVertexProcessing,
|
---|
1892 | IDirect3DDevice9Impl_SetNPatchMode,
|
---|
1893 | IDirect3DDevice9Impl_GetNPatchMode,
|
---|
1894 | IDirect3DDevice9Impl_DrawPrimitive,
|
---|
1895 | IDirect3DDevice9Impl_DrawIndexedPrimitive,
|
---|
1896 | IDirect3DDevice9Impl_DrawPrimitiveUP,
|
---|
1897 | IDirect3DDevice9Impl_DrawIndexedPrimitiveUP,
|
---|
1898 | IDirect3DDevice9Impl_ProcessVertices,
|
---|
1899 | IDirect3DDevice9Impl_CreateVertexDeclaration,
|
---|
1900 | IDirect3DDevice9Impl_SetVertexDeclaration,
|
---|
1901 | IDirect3DDevice9Impl_GetVertexDeclaration,
|
---|
1902 | IDirect3DDevice9Impl_SetFVF,
|
---|
1903 | IDirect3DDevice9Impl_GetFVF,
|
---|
1904 | IDirect3DDevice9Impl_CreateVertexShader,
|
---|
1905 | IDirect3DDevice9Impl_SetVertexShader,
|
---|
1906 | IDirect3DDevice9Impl_GetVertexShader,
|
---|
1907 | IDirect3DDevice9Impl_SetVertexShaderConstantF,
|
---|
1908 | IDirect3DDevice9Impl_GetVertexShaderConstantF,
|
---|
1909 | IDirect3DDevice9Impl_SetVertexShaderConstantI,
|
---|
1910 | IDirect3DDevice9Impl_GetVertexShaderConstantI,
|
---|
1911 | IDirect3DDevice9Impl_SetVertexShaderConstantB,
|
---|
1912 | IDirect3DDevice9Impl_GetVertexShaderConstantB,
|
---|
1913 | IDirect3DDevice9Impl_SetStreamSource,
|
---|
1914 | IDirect3DDevice9Impl_GetStreamSource,
|
---|
1915 | IDirect3DDevice9Impl_SetStreamSourceFreq,
|
---|
1916 | IDirect3DDevice9Impl_GetStreamSourceFreq,
|
---|
1917 | IDirect3DDevice9Impl_SetIndices,
|
---|
1918 | IDirect3DDevice9Impl_GetIndices,
|
---|
1919 | IDirect3DDevice9Impl_CreatePixelShader,
|
---|
1920 | IDirect3DDevice9Impl_SetPixelShader,
|
---|
1921 | IDirect3DDevice9Impl_GetPixelShader,
|
---|
1922 | IDirect3DDevice9Impl_SetPixelShaderConstantF,
|
---|
1923 | IDirect3DDevice9Impl_GetPixelShaderConstantF,
|
---|
1924 | IDirect3DDevice9Impl_SetPixelShaderConstantI,
|
---|
1925 | IDirect3DDevice9Impl_GetPixelShaderConstantI,
|
---|
1926 | IDirect3DDevice9Impl_SetPixelShaderConstantB,
|
---|
1927 | IDirect3DDevice9Impl_GetPixelShaderConstantB,
|
---|
1928 | IDirect3DDevice9Impl_DrawRectPatch,
|
---|
1929 | IDirect3DDevice9Impl_DrawTriPatch,
|
---|
1930 | IDirect3DDevice9Impl_DeletePatch,
|
---|
1931 | IDirect3DDevice9Impl_CreateQuery,
|
---|
1932 | /* IDirect3DDevice9Ex */
|
---|
1933 | IDirect3DDevice9ExImpl_SetConvolutionMonoKernel,
|
---|
1934 | IDirect3DDevice9ExImpl_ComposeRects,
|
---|
1935 | IDirect3DDevice9ExImpl_PresentEx,
|
---|
1936 | IDirect3DDevice9ExImpl_GetGPUThreadPriority,
|
---|
1937 | IDirect3DDevice9ExImpl_SetGPUThreadPriority,
|
---|
1938 | IDirect3DDevice9ExImpl_WaitForVBlank,
|
---|
1939 | IDirect3DDevice9ExImpl_CheckresourceResidency,
|
---|
1940 | IDirect3DDevice9ExImpl_SetMaximumFrameLatency,
|
---|
1941 | IDirect3DDevice9ExImpl_GetMaximumFrameLatency,
|
---|
1942 | IDirect3DDevice9ExImpl_CheckdeviceState,
|
---|
1943 | IDirect3DDevice9ExImpl_CreateRenderTargetEx,
|
---|
1944 | IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx,
|
---|
1945 | IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx,
|
---|
1946 | IDirect3DDevice9ExImpl_ResetEx,
|
---|
1947 | IDirect3DDevice9ExImpl_GetDisplayModeEx
|
---|
1948 | };
|
---|
1949 |
|
---|
1950 | ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) {
|
---|
1951 | IDirect3DSurface9Impl* surfaceParent;
|
---|
1952 | TRACE("(%p) call back\n", pSurface);
|
---|
1953 |
|
---|
1954 | IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
|
---|
1955 | /* GetParent's AddRef was forwarded to an object in destruction.
|
---|
1956 | * Releasing it here again would cause an endless recursion. */
|
---|
1957 | surfaceParent->forwardReference = NULL;
|
---|
1958 | return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
|
---|
1959 | }
|
---|
1960 |
|
---|
1961 | /* IWineD3DDeviceParent IUnknown methods */
|
---|
1962 |
|
---|
1963 | static inline struct IDirect3DDevice9Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
|
---|
1964 | {
|
---|
1965 | return (struct IDirect3DDevice9Impl *)((char*)iface
|
---|
1966 | - FIELD_OFFSET(struct IDirect3DDevice9Impl, device_parent_vtbl));
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
|
---|
1970 | {
|
---|
1971 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
1972 | return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex *)This, riid, object);
|
---|
1973 | }
|
---|
1974 |
|
---|
1975 | static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
|
---|
1976 | {
|
---|
1977 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
1978 | return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex *)This);
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
|
---|
1982 | {
|
---|
1983 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
1984 | return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex *)This);
|
---|
1985 | }
|
---|
1986 |
|
---|
1987 | /* IWineD3DDeviceParent methods */
|
---|
1988 |
|
---|
1989 | static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
|
---|
1990 | {
|
---|
1991 | TRACE("iface %p, device %p\n", iface, device);
|
---|
1992 | }
|
---|
1993 |
|
---|
1994 | static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
|
---|
1995 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
|
---|
1996 | WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
|
---|
1997 | {
|
---|
1998 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
1999 | IDirect3DSurface9Impl *d3d_surface;
|
---|
2000 | BOOL lockable = TRUE;
|
---|
2001 | HRESULT hr;
|
---|
2002 |
|
---|
2003 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
|
---|
2004 | "\tpool %#x, level %u, face %u, surface %p\n",
|
---|
2005 | iface, superior, width, height, format, usage, pool, level, face, surface);
|
---|
2006 |
|
---|
2007 | if (pool == D3DPOOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC)) lockable = FALSE;
|
---|
2008 |
|
---|
2009 | hr = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex *)This, width, height,
|
---|
2010 | d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
|
---|
2011 | (IDirect3DSurface9 **)&d3d_surface, D3DRTYPE_SURFACE, usage, pool,
|
---|
2012 | D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, NULL);
|
---|
2013 | if (FAILED(hr))
|
---|
2014 | {
|
---|
2015 | ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
|
---|
2016 | return hr;
|
---|
2017 | }
|
---|
2018 |
|
---|
2019 | *surface = d3d_surface->wineD3DSurface;
|
---|
2020 | d3d_surface->container = superior;
|
---|
2021 | IDirect3DDevice9Ex_Release(d3d_surface->parentDevice);
|
---|
2022 | d3d_surface->parentDevice = NULL;
|
---|
2023 | d3d_surface->forwardReference = superior;
|
---|
2024 |
|
---|
2025 | return hr;
|
---|
2026 | }
|
---|
2027 |
|
---|
2028 | static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
|
---|
2029 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
|
---|
2030 | DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
|
---|
2031 | {
|
---|
2032 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
2033 | IDirect3DSurface9Impl *d3d_surface;
|
---|
2034 | HRESULT hr;
|
---|
2035 |
|
---|
2036 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
|
---|
2037 | "\tmultisample_quality %u, lockable %u, surface %p\n",
|
---|
2038 | iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
|
---|
2039 |
|
---|
2040 | hr = IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex *)This, width, height,
|
---|
2041 | d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, lockable,
|
---|
2042 | (IDirect3DSurface9 **)&d3d_surface, NULL);
|
---|
2043 | if (FAILED(hr))
|
---|
2044 | {
|
---|
2045 | ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
|
---|
2046 | return hr;
|
---|
2047 | }
|
---|
2048 |
|
---|
2049 | *surface = d3d_surface->wineD3DSurface;
|
---|
2050 | d3d_surface->container = superior;
|
---|
2051 | d3d_surface->isImplicit = TRUE;
|
---|
2052 | /* Implicit surfaces are created with an refcount of 0 */
|
---|
2053 | IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
|
---|
2054 |
|
---|
2055 | return hr;
|
---|
2056 | }
|
---|
2057 |
|
---|
2058 | static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
|
---|
2059 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
|
---|
2060 | DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
|
---|
2061 | {
|
---|
2062 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
2063 | IDirect3DSurface9Impl *d3d_surface;
|
---|
2064 | HRESULT hr;
|
---|
2065 |
|
---|
2066 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
|
---|
2067 | "\tmultisample_quality %u, discard %u, surface %p\n",
|
---|
2068 | iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
|
---|
2069 |
|
---|
2070 | hr = IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex *)This, width, height,
|
---|
2071 | d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, discard,
|
---|
2072 | (IDirect3DSurface9 **)&d3d_surface, NULL);
|
---|
2073 | if (FAILED(hr))
|
---|
2074 | {
|
---|
2075 | ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
|
---|
2076 | return hr;
|
---|
2077 | }
|
---|
2078 |
|
---|
2079 | *surface = d3d_surface->wineD3DSurface;
|
---|
2080 | d3d_surface->container = (IUnknown *)This;
|
---|
2081 | d3d_surface->isImplicit = TRUE;
|
---|
2082 | /* Implicit surfaces are created with an refcount of 0 */
|
---|
2083 | IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
|
---|
2084 |
|
---|
2085 | return hr;
|
---|
2086 | }
|
---|
2087 |
|
---|
2088 | static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
|
---|
2089 | IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
|
---|
2090 | WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
|
---|
2091 | {
|
---|
2092 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
2093 | IDirect3DVolume9Impl *object;
|
---|
2094 | HRESULT hr;
|
---|
2095 |
|
---|
2096 | TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
|
---|
2097 | iface, superior, width, height, depth, format, pool, usage, volume);
|
---|
2098 |
|
---|
2099 | /* Allocate the storage for the device */
|
---|
2100 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
2101 | if (!object)
|
---|
2102 | {
|
---|
2103 | FIXME("Allocation of memory failed\n");
|
---|
2104 | *volume = NULL;
|
---|
2105 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
2106 | }
|
---|
2107 |
|
---|
2108 | object->lpVtbl = &Direct3DVolume9_Vtbl;
|
---|
2109 | object->ref = 1;
|
---|
2110 | hr = IWineD3DDevice_CreateVolume(This->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
|
---|
2111 | format, pool, &object->wineD3DVolume, (IUnknown *)object);
|
---|
2112 | if (FAILED(hr))
|
---|
2113 | {
|
---|
2114 | ERR("(%p) CreateVolume failed, returning %#x\n", iface, hr);
|
---|
2115 | HeapFree(GetProcessHeap(), 0, object);
|
---|
2116 | *volume = NULL;
|
---|
2117 | return hr;
|
---|
2118 | }
|
---|
2119 |
|
---|
2120 | *volume = object->wineD3DVolume;
|
---|
2121 | object->container = superior;
|
---|
2122 | object->forwardReference = superior;
|
---|
2123 |
|
---|
2124 | TRACE("(%p) Created volume %p\n", iface, *volume);
|
---|
2125 |
|
---|
2126 | return hr;
|
---|
2127 | }
|
---|
2128 |
|
---|
2129 | static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
|
---|
2130 | WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
|
---|
2131 | {
|
---|
2132 | struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
|
---|
2133 | IDirect3DSwapChain9Impl *d3d_swapchain;
|
---|
2134 | D3DPRESENT_PARAMETERS local_parameters;
|
---|
2135 | HRESULT hr;
|
---|
2136 |
|
---|
2137 | TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
|
---|
2138 |
|
---|
2139 | /* Copy the presentation parameters */
|
---|
2140 | local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
|
---|
2141 | local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
|
---|
2142 | local_parameters.BackBufferFormat = d3dformat_from_wined3dformat(present_parameters->BackBufferFormat);
|
---|
2143 | local_parameters.BackBufferCount = present_parameters->BackBufferCount;
|
---|
2144 | local_parameters.MultiSampleType = present_parameters->MultiSampleType;
|
---|
2145 | local_parameters.MultiSampleQuality = present_parameters->MultiSampleQuality;
|
---|
2146 | local_parameters.SwapEffect = present_parameters->SwapEffect;
|
---|
2147 | local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
|
---|
2148 | local_parameters.Windowed = present_parameters->Windowed;
|
---|
2149 | local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
|
---|
2150 | local_parameters.AutoDepthStencilFormat = d3dformat_from_wined3dformat(present_parameters->AutoDepthStencilFormat);
|
---|
2151 | local_parameters.Flags = present_parameters->Flags;
|
---|
2152 | local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
|
---|
2153 | local_parameters.PresentationInterval = present_parameters->PresentationInterval;
|
---|
2154 |
|
---|
2155 | hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
|
---|
2156 | &local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
|
---|
2157 | if (FAILED(hr))
|
---|
2158 | {
|
---|
2159 | ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
|
---|
2160 | *swapchain = NULL;
|
---|
2161 | return hr;
|
---|
2162 | }
|
---|
2163 |
|
---|
2164 | *swapchain = d3d_swapchain->wineD3DSwapChain;
|
---|
2165 | d3d_swapchain->isImplicit = TRUE;
|
---|
2166 | /* Implicit swap chains are created with an refcount of 0 */
|
---|
2167 | IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
|
---|
2168 |
|
---|
2169 | /* Copy back the presentation parameters */
|
---|
2170 | present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
|
---|
2171 | present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
|
---|
2172 | present_parameters->BackBufferFormat = wined3dformat_from_d3dformat(local_parameters.BackBufferFormat);
|
---|
2173 | present_parameters->BackBufferCount = local_parameters.BackBufferCount;
|
---|
2174 | present_parameters->MultiSampleType = local_parameters.MultiSampleType;
|
---|
2175 | present_parameters->MultiSampleQuality = local_parameters.MultiSampleQuality;
|
---|
2176 | present_parameters->SwapEffect = local_parameters.SwapEffect;
|
---|
2177 | present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
|
---|
2178 | present_parameters->Windowed = local_parameters.Windowed;
|
---|
2179 | present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
|
---|
2180 | present_parameters->AutoDepthStencilFormat = wined3dformat_from_d3dformat(local_parameters.AutoDepthStencilFormat);
|
---|
2181 | present_parameters->Flags = local_parameters.Flags;
|
---|
2182 | present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
|
---|
2183 | present_parameters->PresentationInterval = local_parameters.PresentationInterval;
|
---|
2184 |
|
---|
2185 | return hr;
|
---|
2186 | }
|
---|
2187 |
|
---|
2188 | const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl =
|
---|
2189 | {
|
---|
2190 | /* IUnknown methods */
|
---|
2191 | device_parent_QueryInterface,
|
---|
2192 | device_parent_AddRef,
|
---|
2193 | device_parent_Release,
|
---|
2194 | /* IWineD3DDeviceParent methods */
|
---|
2195 | device_parent_WineD3DDeviceCreated,
|
---|
2196 | device_parent_CreateSurface,
|
---|
2197 | device_parent_CreateRenderTarget,
|
---|
2198 | device_parent_CreateDepthStencilSurface,
|
---|
2199 | device_parent_CreateVolume,
|
---|
2200 | device_parent_CreateSwapChain,
|
---|
2201 | };
|
---|