1 | /*
|
---|
2 | * IDirect3DDevice8 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002-2004 Jason Edmeades
|
---|
5 | * Copyright 2004 Christian Costa
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2.1 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
24 | * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
25 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
26 | * a choice of LGPL license versions is made available with the language indicating
|
---|
27 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
28 | * of the LGPL is applied is otherwise unspecified.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #include "config.h"
|
---|
32 | #include "d3d8_private.h"
|
---|
33 |
|
---|
34 | #include <math.h>
|
---|
35 | #include <stdarg.h>
|
---|
36 |
|
---|
37 | #define NONAMELESSUNION
|
---|
38 | #define NONAMELESSSTRUCT
|
---|
39 | #include "windef.h"
|
---|
40 | #include "winbase.h"
|
---|
41 | #include "winuser.h"
|
---|
42 | #include "wingdi.h"
|
---|
43 | #include "wine/debug.h"
|
---|
44 |
|
---|
45 | WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
---|
46 |
|
---|
47 | D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
|
---|
48 | {
|
---|
49 | BYTE *c = (BYTE *)&format;
|
---|
50 |
|
---|
51 | /* Don't translate FOURCC formats */
|
---|
52 | if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
|
---|
53 |
|
---|
54 | switch(format)
|
---|
55 | {
|
---|
56 | case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN;
|
---|
57 | case WINED3DFMT_B8G8R8_UNORM: return D3DFMT_R8G8B8;
|
---|
58 | case WINED3DFMT_B8G8R8A8_UNORM: return D3DFMT_A8R8G8B8;
|
---|
59 | case WINED3DFMT_B8G8R8X8_UNORM: return D3DFMT_X8R8G8B8;
|
---|
60 | case WINED3DFMT_B5G6R5_UNORM: return D3DFMT_R5G6B5;
|
---|
61 | case WINED3DFMT_B5G5R5X1_UNORM: return D3DFMT_X1R5G5B5;
|
---|
62 | case WINED3DFMT_B5G5R5A1_UNORM: return D3DFMT_A1R5G5B5;
|
---|
63 | case WINED3DFMT_B4G4R4A4_UNORM: return D3DFMT_A4R4G4B4;
|
---|
64 | case WINED3DFMT_B2G3R3_UNORM: return D3DFMT_R3G3B2;
|
---|
65 | case WINED3DFMT_A8_UNORM: return D3DFMT_A8;
|
---|
66 | case WINED3DFMT_B2G3R3A8_UNORM: return D3DFMT_A8R3G3B2;
|
---|
67 | case WINED3DFMT_B4G4R4X4_UNORM: return D3DFMT_X4R4G4B4;
|
---|
68 | case WINED3DFMT_R10G10B10A2_UNORM: return D3DFMT_A2B10G10R10;
|
---|
69 | case WINED3DFMT_R16G16_UNORM: return D3DFMT_G16R16;
|
---|
70 | case WINED3DFMT_P8_UINT_A8_UNORM: return D3DFMT_A8P8;
|
---|
71 | case WINED3DFMT_P8_UINT: return D3DFMT_P8;
|
---|
72 | case WINED3DFMT_L8_UNORM: return D3DFMT_L8;
|
---|
73 | case WINED3DFMT_L8A8_UNORM: return D3DFMT_A8L8;
|
---|
74 | case WINED3DFMT_L4A4_UNORM: return D3DFMT_A4L4;
|
---|
75 | case WINED3DFMT_R8G8_SNORM: return D3DFMT_V8U8;
|
---|
76 | case WINED3DFMT_R5G5_SNORM_L6_UNORM: return D3DFMT_L6V5U5;
|
---|
77 | case WINED3DFMT_R8G8_SNORM_L8X8_UNORM: return D3DFMT_X8L8V8U8;
|
---|
78 | case WINED3DFMT_R8G8B8A8_SNORM: return D3DFMT_Q8W8V8U8;
|
---|
79 | case WINED3DFMT_R16G16_SNORM: return D3DFMT_V16U16;
|
---|
80 | case WINED3DFMT_R10G11B11_SNORM: return D3DFMT_W11V11U10;
|
---|
81 | case WINED3DFMT_R10G10B10_SNORM_A2_UNORM: return D3DFMT_A2W10V10U10;
|
---|
82 | case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE;
|
---|
83 | case WINED3DFMT_D32_UNORM: return D3DFMT_D32;
|
---|
84 | case WINED3DFMT_S1_UINT_D15_UNORM: return D3DFMT_D15S1;
|
---|
85 | case WINED3DFMT_D24_UNORM_S8_UINT: return D3DFMT_D24S8;
|
---|
86 | case WINED3DFMT_X8D24_UNORM: return D3DFMT_D24X8;
|
---|
87 | case WINED3DFMT_S4X4_UINT_D24_UNORM: return D3DFMT_D24X4S4;
|
---|
88 | case WINED3DFMT_D16_UNORM: return D3DFMT_D16;
|
---|
89 | case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA;
|
---|
90 | case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
|
---|
91 | case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
|
---|
92 | default:
|
---|
93 | FIXME("Unhandled WINED3DFORMAT %#x\n", format);
|
---|
94 | return D3DFMT_UNKNOWN;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
|
---|
99 | {
|
---|
100 | BYTE *c = (BYTE *)&format;
|
---|
101 |
|
---|
102 | /* Don't translate FOURCC formats */
|
---|
103 | if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
|
---|
104 |
|
---|
105 | switch(format)
|
---|
106 | {
|
---|
107 | case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN;
|
---|
108 | case D3DFMT_R8G8B8: return WINED3DFMT_B8G8R8_UNORM;
|
---|
109 | case D3DFMT_A8R8G8B8: return WINED3DFMT_B8G8R8A8_UNORM;
|
---|
110 | case D3DFMT_X8R8G8B8: return WINED3DFMT_B8G8R8X8_UNORM;
|
---|
111 | case D3DFMT_R5G6B5: return WINED3DFMT_B5G6R5_UNORM;
|
---|
112 | case D3DFMT_X1R5G5B5: return WINED3DFMT_B5G5R5X1_UNORM;
|
---|
113 | case D3DFMT_A1R5G5B5: return WINED3DFMT_B5G5R5A1_UNORM;
|
---|
114 | case D3DFMT_A4R4G4B4: return WINED3DFMT_B4G4R4A4_UNORM;
|
---|
115 | case D3DFMT_R3G3B2: return WINED3DFMT_B2G3R3_UNORM;
|
---|
116 | case D3DFMT_A8: return WINED3DFMT_A8_UNORM;
|
---|
117 | case D3DFMT_A8R3G3B2: return WINED3DFMT_B2G3R3A8_UNORM;
|
---|
118 | case D3DFMT_X4R4G4B4: return WINED3DFMT_B4G4R4X4_UNORM;
|
---|
119 | case D3DFMT_A2B10G10R10: return WINED3DFMT_R10G10B10A2_UNORM;
|
---|
120 | case D3DFMT_G16R16: return WINED3DFMT_R16G16_UNORM;
|
---|
121 | case D3DFMT_A8P8: return WINED3DFMT_P8_UINT_A8_UNORM;
|
---|
122 | case D3DFMT_P8: return WINED3DFMT_P8_UINT;
|
---|
123 | case D3DFMT_L8: return WINED3DFMT_L8_UNORM;
|
---|
124 | case D3DFMT_A8L8: return WINED3DFMT_L8A8_UNORM;
|
---|
125 | case D3DFMT_A4L4: return WINED3DFMT_L4A4_UNORM;
|
---|
126 | case D3DFMT_V8U8: return WINED3DFMT_R8G8_SNORM;
|
---|
127 | case D3DFMT_L6V5U5: return WINED3DFMT_R5G5_SNORM_L6_UNORM;
|
---|
128 | case D3DFMT_X8L8V8U8: return WINED3DFMT_R8G8_SNORM_L8X8_UNORM;
|
---|
129 | case D3DFMT_Q8W8V8U8: return WINED3DFMT_R8G8B8A8_SNORM;
|
---|
130 | case D3DFMT_V16U16: return WINED3DFMT_R16G16_SNORM;
|
---|
131 | case D3DFMT_W11V11U10: return WINED3DFMT_R10G11B11_SNORM;
|
---|
132 | case D3DFMT_A2W10V10U10: return WINED3DFMT_R10G10B10_SNORM_A2_UNORM;
|
---|
133 | case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE;
|
---|
134 | case D3DFMT_D32: return WINED3DFMT_D32_UNORM;
|
---|
135 | case D3DFMT_D15S1: return WINED3DFMT_S1_UINT_D15_UNORM;
|
---|
136 | case D3DFMT_D24S8: return WINED3DFMT_D24_UNORM_S8_UINT;
|
---|
137 | case D3DFMT_D24X8: return WINED3DFMT_X8D24_UNORM;
|
---|
138 | case D3DFMT_D24X4S4: return WINED3DFMT_S4X4_UINT_D24_UNORM;
|
---|
139 | case D3DFMT_D16: return WINED3DFMT_D16_UNORM;
|
---|
140 | case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
|
---|
141 | case D3DFMT_INDEX16: return WINED3DFMT_R16_UINT;
|
---|
142 | case D3DFMT_INDEX32: return WINED3DFMT_R32_UINT;
|
---|
143 | default:
|
---|
144 | FIXME("Unhandled D3DFORMAT %#x\n", format);
|
---|
145 | return WINED3DFMT_UNKNOWN;
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 | static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
|
---|
150 | {
|
---|
151 | switch(primitive_type)
|
---|
152 | {
|
---|
153 | case D3DPT_POINTLIST:
|
---|
154 | return primitive_count;
|
---|
155 |
|
---|
156 | case D3DPT_LINELIST:
|
---|
157 | return primitive_count * 2;
|
---|
158 |
|
---|
159 | case D3DPT_LINESTRIP:
|
---|
160 | return primitive_count + 1;
|
---|
161 |
|
---|
162 | case D3DPT_TRIANGLELIST:
|
---|
163 | return primitive_count * 3;
|
---|
164 |
|
---|
165 | case D3DPT_TRIANGLESTRIP:
|
---|
166 | case D3DPT_TRIANGLEFAN:
|
---|
167 | return primitive_count + 2;
|
---|
168 |
|
---|
169 | default:
|
---|
170 | FIXME("Unhandled primitive type %#x\n", primitive_type);
|
---|
171 | return 0;
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | /* Handle table functions */
|
---|
176 | static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void *object, enum d3d8_handle_type type)
|
---|
177 | {
|
---|
178 | struct d3d8_handle_entry *entry;
|
---|
179 |
|
---|
180 | if (t->free_entries)
|
---|
181 | {
|
---|
182 | DWORD index = t->free_entries - t->entries;
|
---|
183 | /* Use a free handle */
|
---|
184 | entry = t->free_entries;
|
---|
185 | if (entry->type != D3D8_HANDLE_FREE)
|
---|
186 | {
|
---|
187 | ERR("Handle %u(%p) is in the free list, but has type %#x.\n", index, entry, entry->type);
|
---|
188 | return D3D8_INVALID_HANDLE;
|
---|
189 | }
|
---|
190 | t->free_entries = entry->object;
|
---|
191 | entry->object = object;
|
---|
192 | entry->type = type;
|
---|
193 |
|
---|
194 | return index;
|
---|
195 | }
|
---|
196 |
|
---|
197 | if (!(t->entry_count < t->table_size))
|
---|
198 | {
|
---|
199 | /* Grow the table */
|
---|
200 | UINT new_size = t->table_size + (t->table_size >> 1);
|
---|
201 | struct d3d8_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(),
|
---|
202 | 0, t->entries, new_size * sizeof(*t->entries));
|
---|
203 | if (!new_entries)
|
---|
204 | {
|
---|
205 | ERR("Failed to grow the handle table.\n");
|
---|
206 | return D3D8_INVALID_HANDLE;
|
---|
207 | }
|
---|
208 | t->entries = new_entries;
|
---|
209 | t->table_size = new_size;
|
---|
210 | }
|
---|
211 |
|
---|
212 | entry = &t->entries[t->entry_count];
|
---|
213 | entry->object = object;
|
---|
214 | entry->type = type;
|
---|
215 |
|
---|
216 | return t->entry_count++;
|
---|
217 | }
|
---|
218 |
|
---|
219 | static void *d3d8_free_handle(struct d3d8_handle_table *t, DWORD handle, enum d3d8_handle_type type)
|
---|
220 | {
|
---|
221 | struct d3d8_handle_entry *entry;
|
---|
222 | void *object;
|
---|
223 |
|
---|
224 | if (handle == D3D8_INVALID_HANDLE || handle >= t->entry_count)
|
---|
225 | {
|
---|
226 | WARN("Invalid handle %u passed.\n", handle);
|
---|
227 | return NULL;
|
---|
228 | }
|
---|
229 |
|
---|
230 | entry = &t->entries[handle];
|
---|
231 | if (entry->type != type)
|
---|
232 | {
|
---|
233 | WARN("Handle %u(%p) is not of type %#x.\n", handle, entry, type);
|
---|
234 | return NULL;
|
---|
235 | }
|
---|
236 |
|
---|
237 | object = entry->object;
|
---|
238 | entry->object = t->free_entries;
|
---|
239 | entry->type = D3D8_HANDLE_FREE;
|
---|
240 | t->free_entries = entry;
|
---|
241 |
|
---|
242 | return object;
|
---|
243 | }
|
---|
244 |
|
---|
245 | static void *d3d8_get_object(struct d3d8_handle_table *t, DWORD handle, enum d3d8_handle_type type)
|
---|
246 | {
|
---|
247 | struct d3d8_handle_entry *entry;
|
---|
248 |
|
---|
249 | if (handle == D3D8_INVALID_HANDLE || handle >= t->entry_count)
|
---|
250 | {
|
---|
251 | WARN("Invalid handle %u passed.\n", handle);
|
---|
252 | return NULL;
|
---|
253 | }
|
---|
254 |
|
---|
255 | entry = &t->entries[handle];
|
---|
256 | if (entry->type != type)
|
---|
257 | {
|
---|
258 | WARN("Handle %u(%p) is not of type %#x.\n", handle, entry, type);
|
---|
259 | return NULL;
|
---|
260 | }
|
---|
261 |
|
---|
262 | return entry->object;
|
---|
263 | }
|
---|
264 |
|
---|
265 | static ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
|
---|
266 | {
|
---|
267 | IUnknown *parent;
|
---|
268 |
|
---|
269 | TRACE("swapchain %p.\n", swapchain);
|
---|
270 |
|
---|
271 | IWineD3DSwapChain_GetParent(swapchain, &parent);
|
---|
272 | IUnknown_Release(parent);
|
---|
273 | return IUnknown_Release(parent);
|
---|
274 | }
|
---|
275 |
|
---|
276 | /* IDirect3D IUnknown parts follow: */
|
---|
277 | static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
|
---|
278 | {
|
---|
279 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
280 |
|
---|
281 | TRACE("iface %p, riid %s, object %p.\n",
|
---|
282 | iface, debugstr_guid(riid), ppobj);
|
---|
283 |
|
---|
284 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
285 | || IsEqualGUID(riid, &IID_IDirect3DDevice8)) {
|
---|
286 | IUnknown_AddRef(iface);
|
---|
287 | *ppobj = This;
|
---|
288 | return S_OK;
|
---|
289 | }
|
---|
290 |
|
---|
291 | if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
|
---|
292 | {
|
---|
293 | IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
|
---|
294 | *ppobj = &This->device_parent_vtbl;
|
---|
295 | return S_OK;
|
---|
296 | }
|
---|
297 |
|
---|
298 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
299 | *ppobj = NULL;
|
---|
300 | return E_NOINTERFACE;
|
---|
301 | }
|
---|
302 |
|
---|
303 | static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
|
---|
304 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
305 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
306 |
|
---|
307 | TRACE("%p increasing refcount to %u.\n", iface, ref);
|
---|
308 |
|
---|
309 | return ref;
|
---|
310 | }
|
---|
311 |
|
---|
312 | static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
|
---|
313 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
314 | ULONG ref;
|
---|
315 |
|
---|
316 | if (This->inDestruction) return 0;
|
---|
317 | ref = InterlockedDecrement(&This->ref);
|
---|
318 |
|
---|
319 | TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
---|
320 |
|
---|
321 | if (ref == 0) {
|
---|
322 | unsigned i;
|
---|
323 |
|
---|
324 | TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
|
---|
325 |
|
---|
326 | wined3d_mutex_lock();
|
---|
327 |
|
---|
328 | This->inDestruction = TRUE;
|
---|
329 |
|
---|
330 | for(i = 0; i < This->numConvertedDecls; i++) {
|
---|
331 | IDirect3DVertexDeclaration8_Release(This->decls[i].decl);
|
---|
332 | }
|
---|
333 | HeapFree(GetProcessHeap(), 0, This->decls);
|
---|
334 |
|
---|
335 | IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain);
|
---|
336 | IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
|
---|
337 | IWineD3DDevice_Release(This->WineD3DDevice);
|
---|
338 | HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
|
---|
339 | HeapFree(GetProcessHeap(), 0, This);
|
---|
340 |
|
---|
341 | wined3d_mutex_unlock();
|
---|
342 | }
|
---|
343 | return ref;
|
---|
344 | }
|
---|
345 |
|
---|
346 | /* IDirect3DDevice Interface follow: */
|
---|
347 | static HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(IDirect3DDevice8 *iface)
|
---|
348 | {
|
---|
349 | TRACE("iface %p.\n", iface);
|
---|
350 |
|
---|
351 | return D3D_OK;
|
---|
352 | }
|
---|
353 |
|
---|
354 | static UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface) {
|
---|
355 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
356 | HRESULT hr;
|
---|
357 |
|
---|
358 | TRACE("iface %p.\n", iface);
|
---|
359 |
|
---|
360 | wined3d_mutex_lock();
|
---|
361 | hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
|
---|
362 | wined3d_mutex_unlock();
|
---|
363 |
|
---|
364 | return hr;
|
---|
365 | }
|
---|
366 |
|
---|
367 | static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes) {
|
---|
368 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
369 | HRESULT hr;
|
---|
370 |
|
---|
371 | TRACE("iface %p, byte_count %u.\n", iface, Bytes);
|
---|
372 | FIXME("Byte count ignored.\n");
|
---|
373 |
|
---|
374 | wined3d_mutex_lock();
|
---|
375 | hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
|
---|
376 | wined3d_mutex_unlock();
|
---|
377 |
|
---|
378 | return hr;
|
---|
379 | }
|
---|
380 |
|
---|
381 | static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8) {
|
---|
382 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
383 | HRESULT hr = D3D_OK;
|
---|
384 | IWineD3D* pWineD3D;
|
---|
385 |
|
---|
386 | TRACE("iface %p, d3d8 %p.\n", iface, ppD3D8);
|
---|
387 |
|
---|
388 | if (NULL == ppD3D8) {
|
---|
389 | return D3DERR_INVALIDCALL;
|
---|
390 | }
|
---|
391 |
|
---|
392 | wined3d_mutex_lock();
|
---|
393 | hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
|
---|
394 | if (hr == D3D_OK && pWineD3D != NULL)
|
---|
395 | {
|
---|
396 | IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D8);
|
---|
397 | IWineD3D_Release(pWineD3D);
|
---|
398 | } else {
|
---|
399 | FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
|
---|
400 | *ppD3D8 = NULL;
|
---|
401 | }
|
---|
402 | wined3d_mutex_unlock();
|
---|
403 |
|
---|
404 | TRACE("(%p) returning %p\n",This , *ppD3D8);
|
---|
405 |
|
---|
406 | return hr;
|
---|
407 | }
|
---|
408 |
|
---|
409 | static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
|
---|
410 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
411 | HRESULT hrc = D3D_OK;
|
---|
412 | WINED3DCAPS *pWineCaps;
|
---|
413 |
|
---|
414 | TRACE("iface %p, caps %p.\n", iface, pCaps);
|
---|
415 |
|
---|
416 | if(NULL == pCaps){
|
---|
417 | return D3DERR_INVALIDCALL;
|
---|
418 | }
|
---|
419 | pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
---|
420 | if(pWineCaps == NULL){
|
---|
421 | return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
|
---|
422 | }
|
---|
423 |
|
---|
424 | wined3d_mutex_lock();
|
---|
425 | hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
|
---|
426 | wined3d_mutex_unlock();
|
---|
427 |
|
---|
428 | fixup_caps(pWineCaps);
|
---|
429 | WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
|
---|
430 | HeapFree(GetProcessHeap(), 0, pWineCaps);
|
---|
431 |
|
---|
432 | TRACE("Returning %p %p\n", This, pCaps);
|
---|
433 | return hrc;
|
---|
434 | }
|
---|
435 |
|
---|
436 | static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
|
---|
437 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
438 | HRESULT hr;
|
---|
439 |
|
---|
440 | TRACE("iface %p, mode %p.\n", iface, pMode);
|
---|
441 |
|
---|
442 | wined3d_mutex_lock();
|
---|
443 | hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
|
---|
444 | wined3d_mutex_unlock();
|
---|
445 |
|
---|
446 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
447 |
|
---|
448 | return hr;
|
---|
449 | }
|
---|
450 |
|
---|
451 | static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
|
---|
452 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
453 | HRESULT hr;
|
---|
454 |
|
---|
455 | TRACE("iface %p, parameters %p.\n", iface, pParameters);
|
---|
456 |
|
---|
457 | wined3d_mutex_lock();
|
---|
458 | hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
|
---|
459 | wined3d_mutex_unlock();
|
---|
460 |
|
---|
461 | return hr;
|
---|
462 | }
|
---|
463 |
|
---|
464 | static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap) {
|
---|
465 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
466 | IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl*)pCursorBitmap;
|
---|
467 | HRESULT hr;
|
---|
468 |
|
---|
469 | TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
|
---|
470 | iface, XHotSpot, YHotSpot, pCursorBitmap);
|
---|
471 |
|
---|
472 | if(!pCursorBitmap) {
|
---|
473 | WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
|
---|
474 | return WINED3DERR_INVALIDCALL;
|
---|
475 | }
|
---|
476 |
|
---|
477 | wined3d_mutex_lock();
|
---|
478 | hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,pSurface->wineD3DSurface);
|
---|
479 | wined3d_mutex_unlock();
|
---|
480 |
|
---|
481 | return hr;
|
---|
482 | }
|
---|
483 |
|
---|
484 | static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) {
|
---|
485 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
486 |
|
---|
487 | TRACE("iface %p, x %u, y %u, flags %#x.\n",
|
---|
488 | iface, XScreenSpace, YScreenSpace, Flags);
|
---|
489 |
|
---|
490 | wined3d_mutex_lock();
|
---|
491 | IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
|
---|
492 | wined3d_mutex_unlock();
|
---|
493 | }
|
---|
494 |
|
---|
495 | static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow) {
|
---|
496 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
497 | BOOL ret;
|
---|
498 |
|
---|
499 | TRACE("iface %p, show %#x.\n", iface, bShow);
|
---|
500 |
|
---|
501 | wined3d_mutex_lock();
|
---|
502 | ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
|
---|
503 | wined3d_mutex_unlock();
|
---|
504 |
|
---|
505 | return ret;
|
---|
506 | }
|
---|
507 |
|
---|
508 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDevice8 *iface,
|
---|
509 | D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
|
---|
510 | {
|
---|
511 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
512 | IDirect3DSwapChain8Impl *object;
|
---|
513 | HRESULT hr;
|
---|
514 |
|
---|
515 | TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
---|
516 | iface, present_parameters, swapchain);
|
---|
517 |
|
---|
518 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
519 | if (!object)
|
---|
520 | {
|
---|
521 | ERR("Failed to allocate swapchain memory.\n");
|
---|
522 | return E_OUTOFMEMORY;
|
---|
523 | }
|
---|
524 |
|
---|
525 | hr = swapchain_init(object, This, present_parameters);
|
---|
526 | if (FAILED(hr))
|
---|
527 | {
|
---|
528 | WARN("Failed to initialize swapchain, hr %#x.\n", hr);
|
---|
529 | HeapFree(GetProcessHeap(), 0, object);
|
---|
530 | return hr;
|
---|
531 | }
|
---|
532 |
|
---|
533 | TRACE("Created swapchain %p.\n", object);
|
---|
534 | *swapchain = (IDirect3DSwapChain8 *)object;
|
---|
535 |
|
---|
536 | return D3D_OK;
|
---|
537 | }
|
---|
538 |
|
---|
539 | static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
|
---|
540 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
541 | WINED3DPRESENT_PARAMETERS localParameters;
|
---|
542 | HRESULT hr;
|
---|
543 |
|
---|
544 | TRACE("iface %p, present_parameters %p.\n", iface, pPresentationParameters);
|
---|
545 |
|
---|
546 | localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
---|
547 | localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
---|
548 | localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
---|
549 | localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
|
---|
550 | localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
|
---|
551 | localParameters.MultiSampleQuality = 0; /* d3d9 only */
|
---|
552 | localParameters.SwapEffect = pPresentationParameters->SwapEffect;
|
---|
553 | localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
|
---|
554 | localParameters.Windowed = pPresentationParameters->Windowed;
|
---|
555 | localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
|
---|
556 | localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
|
---|
557 | localParameters.Flags = pPresentationParameters->Flags;
|
---|
558 | localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
|
---|
559 | localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
|
---|
560 | localParameters.AutoRestoreDisplayMode = TRUE;
|
---|
561 |
|
---|
562 | wined3d_mutex_lock();
|
---|
563 | hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
|
---|
564 | if(SUCCEEDED(hr)) {
|
---|
565 | hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
|
---|
566 | }
|
---|
567 | wined3d_mutex_unlock();
|
---|
568 |
|
---|
569 | pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
---|
570 | pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
|
---|
571 | pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
|
---|
572 | pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
|
---|
573 | pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
|
---|
574 | pPresentationParameters->SwapEffect = localParameters.SwapEffect;
|
---|
575 | pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
|
---|
576 | pPresentationParameters->Windowed = localParameters.Windowed;
|
---|
577 | pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
|
---|
578 | pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
|
---|
579 | pPresentationParameters->Flags = localParameters.Flags;
|
---|
580 | pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
|
---|
581 | pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
|
---|
582 |
|
---|
583 | return hr;
|
---|
584 | }
|
---|
585 |
|
---|
586 | static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
|
---|
587 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
588 | HRESULT hr;
|
---|
589 |
|
---|
590 | TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
|
---|
591 | iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
---|
592 |
|
---|
593 | wined3d_mutex_lock();
|
---|
594 | hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
---|
595 | wined3d_mutex_unlock();
|
---|
596 |
|
---|
597 | return hr;
|
---|
598 | }
|
---|
599 |
|
---|
600 | static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
|
---|
601 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
602 | IWineD3DSurface *retSurface = NULL;
|
---|
603 | HRESULT rc = D3D_OK;
|
---|
604 |
|
---|
605 | TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
|
---|
606 | iface, BackBuffer, Type, ppBackBuffer);
|
---|
607 |
|
---|
608 | wined3d_mutex_lock();
|
---|
609 | rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
|
---|
610 | if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
|
---|
611 | IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
|
---|
612 | IWineD3DSurface_Release(retSurface);
|
---|
613 | }
|
---|
614 | wined3d_mutex_unlock();
|
---|
615 |
|
---|
616 | return rc;
|
---|
617 | }
|
---|
618 |
|
---|
619 | static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
|
---|
620 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
621 | HRESULT hr;
|
---|
622 |
|
---|
623 | TRACE("iface %p, raster_status %p.\n", iface, pRasterStatus);
|
---|
624 |
|
---|
625 | wined3d_mutex_lock();
|
---|
626 | hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
|
---|
627 | wined3d_mutex_unlock();
|
---|
628 |
|
---|
629 | return hr;
|
---|
630 | }
|
---|
631 |
|
---|
632 | static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
|
---|
633 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
634 |
|
---|
635 | TRACE("iface %p, flags %#x, ramp %p.\n", iface, Flags, pRamp);
|
---|
636 |
|
---|
637 | /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
|
---|
638 | wined3d_mutex_lock();
|
---|
639 | IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (CONST WINED3DGAMMARAMP *) pRamp);
|
---|
640 | wined3d_mutex_unlock();
|
---|
641 | }
|
---|
642 |
|
---|
643 | static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp) {
|
---|
644 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
645 |
|
---|
646 | TRACE("iface %p, ramp %p.\n", iface, pRamp);
|
---|
647 |
|
---|
648 | /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
|
---|
649 | wined3d_mutex_lock();
|
---|
650 | IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp);
|
---|
651 | wined3d_mutex_unlock();
|
---|
652 | }
|
---|
653 |
|
---|
654 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(IDirect3DDevice8 *iface,
|
---|
655 | UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format,
|
---|
656 | D3DPOOL pool, IDirect3DTexture8 **texture)
|
---|
657 | {
|
---|
658 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
659 | IDirect3DTexture8Impl *object;
|
---|
660 | HRESULT hr;
|
---|
661 |
|
---|
662 | TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
|
---|
663 | iface, width, height, levels, usage, format, pool, texture);
|
---|
664 |
|
---|
665 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
666 | if (!object)
|
---|
667 | {
|
---|
668 | ERR("Failed to allocate texture memory.\n");
|
---|
669 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
670 | }
|
---|
671 |
|
---|
672 | hr = texture_init(object, This, width, height, levels, usage, format, pool);
|
---|
673 | if (FAILED(hr))
|
---|
674 | {
|
---|
675 | WARN("Failed to initialize texture, hr %#x.\n", hr);
|
---|
676 | HeapFree(GetProcessHeap(), 0, object);
|
---|
677 | return hr;
|
---|
678 | }
|
---|
679 |
|
---|
680 | TRACE("Created texture %p.\n", object);
|
---|
681 | *texture = (IDirect3DTexture8 *)object;
|
---|
682 |
|
---|
683 | return D3D_OK;
|
---|
684 | }
|
---|
685 |
|
---|
686 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8 *iface,
|
---|
687 | UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
|
---|
688 | D3DPOOL pool, IDirect3DVolumeTexture8 **texture)
|
---|
689 | {
|
---|
690 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
691 | IDirect3DVolumeTexture8Impl *object;
|
---|
692 | HRESULT hr;
|
---|
693 |
|
---|
694 | TRACE("iface %p, width %u, height %u, depth %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
|
---|
695 | iface, width, height, depth, levels, usage, format, pool, texture);
|
---|
696 |
|
---|
697 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
698 | if (!object)
|
---|
699 | {
|
---|
700 | ERR("Failed to allocate volume texture memory.\n");
|
---|
701 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
702 | }
|
---|
703 |
|
---|
704 | hr = volumetexture_init(object, This, width, height, depth, levels, usage, format, pool);
|
---|
705 | if (FAILED(hr))
|
---|
706 | {
|
---|
707 | WARN("Failed to initialize volume texture, hr %#x.\n", hr);
|
---|
708 | HeapFree(GetProcessHeap(), 0, object);
|
---|
709 | return hr;
|
---|
710 | }
|
---|
711 |
|
---|
712 | TRACE("Created volume texture %p.\n", object);
|
---|
713 | *texture = (IDirect3DVolumeTexture8 *)object;
|
---|
714 |
|
---|
715 | return D3D_OK;
|
---|
716 | }
|
---|
717 |
|
---|
718 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
|
---|
719 | UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
|
---|
720 | {
|
---|
721 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
722 | IDirect3DCubeTexture8Impl *object;
|
---|
723 | HRESULT hr;
|
---|
724 |
|
---|
725 | TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
|
---|
726 | iface, edge_length, levels, usage, format, pool, texture);
|
---|
727 |
|
---|
728 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
729 | if (!object)
|
---|
730 | {
|
---|
731 | ERR("Failed to allocate cube texture memory.\n");
|
---|
732 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
733 | }
|
---|
734 |
|
---|
735 | hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool);
|
---|
736 | if (FAILED(hr))
|
---|
737 | {
|
---|
738 | WARN("Failed to initialize cube texture, hr %#x.\n", hr);
|
---|
739 | HeapFree(GetProcessHeap(), 0, object);
|
---|
740 | return hr;
|
---|
741 | }
|
---|
742 |
|
---|
743 | TRACE("Created cube texture %p.\n", object);
|
---|
744 | *texture = (IDirect3DCubeTexture8 *)object;
|
---|
745 |
|
---|
746 | return hr;
|
---|
747 | }
|
---|
748 |
|
---|
749 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
|
---|
750 | DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer8 **buffer)
|
---|
751 | {
|
---|
752 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
753 | IDirect3DVertexBuffer8Impl *object;
|
---|
754 | HRESULT hr;
|
---|
755 |
|
---|
756 | TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n",
|
---|
757 | iface, size, usage, fvf, pool, buffer);
|
---|
758 |
|
---|
759 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
760 | if (!object)
|
---|
761 | {
|
---|
762 | ERR("Failed to allocate buffer memory.\n");
|
---|
763 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
764 | }
|
---|
765 |
|
---|
766 | hr = vertexbuffer_init(object, This, size, usage, fvf, pool);
|
---|
767 | if (FAILED(hr))
|
---|
768 | {
|
---|
769 | WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
|
---|
770 | HeapFree(GetProcessHeap(), 0, object);
|
---|
771 | return hr;
|
---|
772 | }
|
---|
773 |
|
---|
774 | TRACE("Created vertex buffer %p.\n", object);
|
---|
775 | *buffer = (IDirect3DVertexBuffer8 *)object;
|
---|
776 |
|
---|
777 | return D3D_OK;
|
---|
778 | }
|
---|
779 |
|
---|
780 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
|
---|
781 | D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **buffer)
|
---|
782 | {
|
---|
783 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
784 | IDirect3DIndexBuffer8Impl *object;
|
---|
785 | HRESULT hr;
|
---|
786 |
|
---|
787 | TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n",
|
---|
788 | iface, size, usage, format, pool, buffer);
|
---|
789 |
|
---|
790 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
791 | if (!object)
|
---|
792 | {
|
---|
793 | ERR("Failed to allocate buffer memory.\n");
|
---|
794 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
795 | }
|
---|
796 |
|
---|
797 | hr = indexbuffer_init(object, This, size, usage, format, pool);
|
---|
798 | if (FAILED(hr))
|
---|
799 | {
|
---|
800 | WARN("Failed to initialize index buffer, hr %#x.\n", hr);
|
---|
801 | HeapFree(GetProcessHeap(), 0, object);
|
---|
802 | return hr;
|
---|
803 | }
|
---|
804 |
|
---|
805 | TRACE("Created index buffer %p.\n", object);
|
---|
806 | *buffer = (IDirect3DIndexBuffer8 *)object;
|
---|
807 |
|
---|
808 | return D3D_OK;
|
---|
809 | }
|
---|
810 |
|
---|
811 | static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height,
|
---|
812 | D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,
|
---|
813 | UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
---|
814 | {
|
---|
815 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
816 | IDirect3DSurface8Impl *object;
|
---|
817 | HRESULT hr;
|
---|
818 |
|
---|
819 | TRACE("iface %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p,\n"
|
---|
820 | "\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
|
---|
821 | iface, Width, Height, Format, Lockable, Discard, Level, ppSurface,
|
---|
822 | Usage, Pool, MultiSample, MultisampleQuality);
|
---|
823 |
|
---|
824 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
|
---|
825 | if (!object)
|
---|
826 | {
|
---|
827 | FIXME("Failed to allocate surface memory.\n");
|
---|
828 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
829 | }
|
---|
830 |
|
---|
831 | hr = surface_init(object, This, Width, Height, Format, Lockable, Discard,
|
---|
832 | Level, Usage, Pool, MultiSample, MultisampleQuality);
|
---|
833 | if (FAILED(hr))
|
---|
834 | {
|
---|
835 | WARN("Failed to initialize surface, hr %#x.\n", hr);
|
---|
836 | HeapFree(GetProcessHeap(), 0, object);
|
---|
837 | return hr;
|
---|
838 | }
|
---|
839 |
|
---|
840 | TRACE("Created surface %p.\n", object);
|
---|
841 | *ppSurface = (IDirect3DSurface8 *)object;
|
---|
842 |
|
---|
843 | return D3D_OK;
|
---|
844 | }
|
---|
845 |
|
---|
846 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
|
---|
847 | HRESULT hr;
|
---|
848 |
|
---|
849 | TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, lockable %#x, surface %p.\n",
|
---|
850 | iface, Width, Height, Format, MultiSample, Lockable, ppSurface);
|
---|
851 |
|
---|
852 | hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */,
|
---|
853 | 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
|
---|
854 |
|
---|
855 | return hr;
|
---|
856 | }
|
---|
857 |
|
---|
858 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
|
---|
859 | HRESULT hr;
|
---|
860 |
|
---|
861 | TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, surface %p.\n",
|
---|
862 | iface, Width, Height, Format, MultiSample, ppSurface);
|
---|
863 |
|
---|
864 | /* TODO: Verify that Discard is false */
|
---|
865 | hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE,
|
---|
866 | 0 /* Level */, ppSurface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, MultiSample, 0);
|
---|
867 |
|
---|
868 | return hr;
|
---|
869 | }
|
---|
870 |
|
---|
871 | /* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
|
---|
872 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
|
---|
873 | HRESULT hr;
|
---|
874 |
|
---|
875 | TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n",
|
---|
876 | iface, Width, Height, Format, ppSurface);
|
---|
877 |
|
---|
878 | hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE /* Discard */,
|
---|
879 | 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE,
|
---|
880 | 0 /* MultisampleQuality */);
|
---|
881 |
|
---|
882 | return hr;
|
---|
883 | }
|
---|
884 |
|
---|
885 | static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
|
---|
886 | IDirect3DSurface8Impl *Source = (IDirect3DSurface8Impl *) pSourceSurface;
|
---|
887 | IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
|
---|
888 |
|
---|
889 | HRESULT hr = WINED3D_OK;
|
---|
890 | WINED3DFORMAT srcFormat, destFormat;
|
---|
891 | WINED3DSURFACE_DESC winedesc;
|
---|
892 |
|
---|
893 | TRACE("iface %p, src_surface %p, src_rects %p, rect_count %u, dst_surface %p, dst_points %p.\n",
|
---|
894 | iface, pSourceSurface, pSourceRects, cRects, pDestinationSurface, pDestPoints);
|
---|
895 |
|
---|
896 | /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the
|
---|
897 | * destination texture is in WINED3DPOOL_DEFAULT. */
|
---|
898 |
|
---|
899 | wined3d_mutex_lock();
|
---|
900 | IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
|
---|
901 | srcFormat = winedesc.format;
|
---|
902 |
|
---|
903 | IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
|
---|
904 | destFormat = winedesc.format;
|
---|
905 |
|
---|
906 | /* Check that the source and destination formats match */
|
---|
907 | if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
|
---|
908 | WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface);
|
---|
909 | wined3d_mutex_unlock();
|
---|
910 | return WINED3DERR_INVALIDCALL;
|
---|
911 | } else if (WINED3DFMT_UNKNOWN == destFormat) {
|
---|
912 | TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", iface);
|
---|
913 | IWineD3DSurface_SetFormat(Dest->wineD3DSurface, srcFormat);
|
---|
914 | }
|
---|
915 |
|
---|
916 | /* Quick if complete copy ... */
|
---|
917 | if (cRects == 0 && pSourceRects == NULL && pDestPoints == NULL) {
|
---|
918 | IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
|
---|
919 | } else {
|
---|
920 | unsigned int i;
|
---|
921 | /* Copy rect by rect */
|
---|
922 | if (NULL != pSourceRects && NULL != pDestPoints) {
|
---|
923 | for (i = 0; i < cRects; ++i) {
|
---|
924 | IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
|
---|
925 | }
|
---|
926 | } else {
|
---|
927 | for (i = 0; i < cRects; ++i) {
|
---|
928 | IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
|
---|
929 | }
|
---|
930 | }
|
---|
931 | }
|
---|
932 | wined3d_mutex_unlock();
|
---|
933 |
|
---|
934 | return hr;
|
---|
935 | }
|
---|
936 |
|
---|
937 | static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
|
---|
938 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
939 | HRESULT hr;
|
---|
940 |
|
---|
941 | TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, pSourceTexture, pDestinationTexture);
|
---|
942 |
|
---|
943 | wined3d_mutex_lock();
|
---|
944 | hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
|
---|
945 | wined3d_mutex_unlock();
|
---|
946 |
|
---|
947 | return hr;
|
---|
948 | }
|
---|
949 |
|
---|
950 | static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
|
---|
951 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
952 | IDirect3DSurface8Impl *destSurface = (IDirect3DSurface8Impl *)pDestSurface;
|
---|
953 | HRESULT hr;
|
---|
954 |
|
---|
955 | TRACE("iface %p, dst_surface %p.\n", iface, pDestSurface);
|
---|
956 |
|
---|
957 | if (pDestSurface == NULL) {
|
---|
958 | WARN("(%p) : Caller passed NULL as pDestSurface returning D3DERR_INVALIDCALL\n", This);
|
---|
959 | return D3DERR_INVALIDCALL;
|
---|
960 | }
|
---|
961 |
|
---|
962 | wined3d_mutex_lock();
|
---|
963 | hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface);
|
---|
964 | wined3d_mutex_unlock();
|
---|
965 |
|
---|
966 | return hr;
|
---|
967 | }
|
---|
968 |
|
---|
969 | static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) {
|
---|
970 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
971 | IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
|
---|
972 | IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
|
---|
973 | IWineD3DSurface *original_ds = NULL;
|
---|
974 | HRESULT hr;
|
---|
975 |
|
---|
976 | TRACE("iface %p, render_target %p, depth_stencil %p.\n", iface, pRenderTarget, pNewZStencil);
|
---|
977 |
|
---|
978 | wined3d_mutex_lock();
|
---|
979 |
|
---|
980 | hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &original_ds);
|
---|
981 | if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
|
---|
982 | {
|
---|
983 | hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, pZSurface ? pZSurface->wineD3DSurface : NULL);
|
---|
984 | if (SUCCEEDED(hr) && pSurface)
|
---|
985 | hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface->wineD3DSurface, TRUE);
|
---|
986 | if (FAILED(hr)) IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, original_ds);
|
---|
987 | }
|
---|
988 | if (original_ds) IWineD3DSurface_Release(original_ds);
|
---|
989 |
|
---|
990 | wined3d_mutex_unlock();
|
---|
991 |
|
---|
992 | return hr;
|
---|
993 | }
|
---|
994 |
|
---|
995 | static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
|
---|
996 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
997 | HRESULT hr = D3D_OK;
|
---|
998 | IWineD3DSurface *pRenderTarget;
|
---|
999 |
|
---|
1000 | TRACE("iface %p, render_target %p.\n", iface, ppRenderTarget);
|
---|
1001 |
|
---|
1002 | if (ppRenderTarget == NULL) {
|
---|
1003 | return D3DERR_INVALIDCALL;
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | wined3d_mutex_lock();
|
---|
1007 | hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
|
---|
1008 |
|
---|
1009 | if (hr == D3D_OK && pRenderTarget != NULL) {
|
---|
1010 | IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
|
---|
1011 | IWineD3DSurface_Release(pRenderTarget);
|
---|
1012 | } else {
|
---|
1013 | FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
|
---|
1014 | *ppRenderTarget = NULL;
|
---|
1015 | }
|
---|
1016 | wined3d_mutex_unlock();
|
---|
1017 |
|
---|
1018 | return hr;
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
|
---|
1022 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1023 | HRESULT hr = D3D_OK;
|
---|
1024 | IWineD3DSurface *pZStencilSurface;
|
---|
1025 |
|
---|
1026 | TRACE("iface %p, depth_stencil %p.\n", iface, ppZStencilSurface);
|
---|
1027 |
|
---|
1028 | if(ppZStencilSurface == NULL){
|
---|
1029 | return D3DERR_INVALIDCALL;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | wined3d_mutex_lock();
|
---|
1033 | hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
|
---|
1034 | if (hr == WINED3D_OK) {
|
---|
1035 | IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
|
---|
1036 | IWineD3DSurface_Release(pZStencilSurface);
|
---|
1037 | }else{
|
---|
1038 | if (hr != WINED3DERR_NOTFOUND)
|
---|
1039 | FIXME("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
|
---|
1040 | *ppZStencilSurface = NULL;
|
---|
1041 | }
|
---|
1042 | wined3d_mutex_unlock();
|
---|
1043 |
|
---|
1044 | return hr;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) {
|
---|
1048 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1049 | HRESULT hr;
|
---|
1050 |
|
---|
1051 | TRACE("iface %p.\n", iface);
|
---|
1052 |
|
---|
1053 | wined3d_mutex_lock();
|
---|
1054 | hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
|
---|
1055 | wined3d_mutex_unlock();
|
---|
1056 |
|
---|
1057 | return hr;
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
|
---|
1061 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1062 | HRESULT hr;
|
---|
1063 |
|
---|
1064 | TRACE("iface %p.\n", iface);
|
---|
1065 |
|
---|
1066 | wined3d_mutex_lock();
|
---|
1067 | hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
|
---|
1068 | wined3d_mutex_unlock();
|
---|
1069 |
|
---|
1070 | return hr;
|
---|
1071 | }
|
---|
1072 |
|
---|
1073 | static HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
|
---|
1074 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1075 | HRESULT hr;
|
---|
1076 |
|
---|
1077 | TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
|
---|
1078 | iface, Count, pRects, Flags, Color, Z, Stencil);
|
---|
1079 |
|
---|
1080 | /* Note: D3DRECT is compatible with WINED3DRECT */
|
---|
1081 | wined3d_mutex_lock();
|
---|
1082 | hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
|
---|
1083 | wined3d_mutex_unlock();
|
---|
1084 |
|
---|
1085 | return hr;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
|
---|
1089 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1090 | HRESULT hr;
|
---|
1091 |
|
---|
1092 | TRACE("iface %p, state %#x, matrix %p.\n", iface, State, lpMatrix);
|
---|
1093 |
|
---|
1094 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
1095 | wined3d_mutex_lock();
|
---|
1096 | hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
|
---|
1097 | wined3d_mutex_unlock();
|
---|
1098 |
|
---|
1099 | return hr;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) {
|
---|
1103 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1104 | HRESULT hr;
|
---|
1105 |
|
---|
1106 | TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
|
---|
1107 |
|
---|
1108 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
1109 | wined3d_mutex_lock();
|
---|
1110 | hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
|
---|
1111 | wined3d_mutex_unlock();
|
---|
1112 |
|
---|
1113 | return hr;
|
---|
1114 | }
|
---|
1115 |
|
---|
1116 | static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
|
---|
1117 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1118 | HRESULT hr;
|
---|
1119 |
|
---|
1120 | TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
|
---|
1121 |
|
---|
1122 | /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
---|
1123 | wined3d_mutex_lock();
|
---|
1124 | hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
|
---|
1125 | wined3d_mutex_unlock();
|
---|
1126 |
|
---|
1127 | return hr;
|
---|
1128 | }
|
---|
1129 |
|
---|
1130 | static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport) {
|
---|
1131 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1132 | HRESULT hr;
|
---|
1133 |
|
---|
1134 | TRACE("iface %p, viewport %p.\n", iface, pViewport);
|
---|
1135 |
|
---|
1136 | /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
|
---|
1137 | wined3d_mutex_lock();
|
---|
1138 | hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
|
---|
1139 | wined3d_mutex_unlock();
|
---|
1140 |
|
---|
1141 | return hr;
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport) {
|
---|
1145 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1146 | HRESULT hr;
|
---|
1147 |
|
---|
1148 | TRACE("iface %p, viewport %p.\n", iface, pViewport);
|
---|
1149 |
|
---|
1150 | /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
|
---|
1151 | wined3d_mutex_lock();
|
---|
1152 | hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
|
---|
1153 | wined3d_mutex_unlock();
|
---|
1154 |
|
---|
1155 | return hr;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) {
|
---|
1159 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1160 | HRESULT hr;
|
---|
1161 |
|
---|
1162 | TRACE("iface %p, material %p.\n", iface, pMaterial);
|
---|
1163 |
|
---|
1164 | /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
|
---|
1165 | wined3d_mutex_lock();
|
---|
1166 | hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
|
---|
1167 | wined3d_mutex_unlock();
|
---|
1168 |
|
---|
1169 | return hr;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) {
|
---|
1173 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1174 | HRESULT hr;
|
---|
1175 |
|
---|
1176 | TRACE("iface %p, material %p.\n", iface, pMaterial);
|
---|
1177 |
|
---|
1178 | /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
|
---|
1179 | wined3d_mutex_lock();
|
---|
1180 | hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
|
---|
1181 | wined3d_mutex_unlock();
|
---|
1182 |
|
---|
1183 | return hr;
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) {
|
---|
1187 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1188 | HRESULT hr;
|
---|
1189 |
|
---|
1190 | TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
|
---|
1191 |
|
---|
1192 | /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
|
---|
1193 | wined3d_mutex_lock();
|
---|
1194 | hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
|
---|
1195 | wined3d_mutex_unlock();
|
---|
1196 |
|
---|
1197 | return hr;
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
|
---|
1201 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1202 | HRESULT hr;
|
---|
1203 |
|
---|
1204 | TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
|
---|
1205 |
|
---|
1206 | /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
|
---|
1207 | wined3d_mutex_lock();
|
---|
1208 | hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
|
---|
1209 | wined3d_mutex_unlock();
|
---|
1210 |
|
---|
1211 | return hr;
|
---|
1212 | }
|
---|
1213 |
|
---|
1214 | static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) {
|
---|
1215 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1216 | HRESULT hr;
|
---|
1217 |
|
---|
1218 | TRACE("iface %p, index %u, enable %#x.\n", iface, Index, Enable);
|
---|
1219 |
|
---|
1220 | wined3d_mutex_lock();
|
---|
1221 | hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
|
---|
1222 | wined3d_mutex_unlock();
|
---|
1223 |
|
---|
1224 | return hr;
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 | static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
|
---|
1228 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1229 | HRESULT hr;
|
---|
1230 |
|
---|
1231 | TRACE("iface %p, index %u, enable %p.\n", iface, Index, pEnable);
|
---|
1232 |
|
---|
1233 | wined3d_mutex_lock();
|
---|
1234 | hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
|
---|
1235 | wined3d_mutex_unlock();
|
---|
1236 |
|
---|
1237 | return hr;
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) {
|
---|
1241 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1242 | HRESULT hr;
|
---|
1243 |
|
---|
1244 | TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
|
---|
1245 |
|
---|
1246 | wined3d_mutex_lock();
|
---|
1247 | hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
|
---|
1248 | wined3d_mutex_unlock();
|
---|
1249 |
|
---|
1250 | return hr;
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
|
---|
1254 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1255 | HRESULT hr;
|
---|
1256 |
|
---|
1257 | TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
|
---|
1258 |
|
---|
1259 | wined3d_mutex_lock();
|
---|
1260 | hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
|
---|
1261 | wined3d_mutex_unlock();
|
---|
1262 |
|
---|
1263 | return hr;
|
---|
1264 | }
|
---|
1265 |
|
---|
1266 | static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
|
---|
1267 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1268 | HRESULT hr;
|
---|
1269 |
|
---|
1270 | TRACE("iface %p, state %#x, value %#x.\n", iface, State, Value);
|
---|
1271 |
|
---|
1272 | wined3d_mutex_lock();
|
---|
1273 | hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
|
---|
1274 | wined3d_mutex_unlock();
|
---|
1275 |
|
---|
1276 | return hr;
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 | static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
|
---|
1280 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1281 | HRESULT hr;
|
---|
1282 |
|
---|
1283 | TRACE("iface %p, state %#x, value %p.\n", iface, State, pValue);
|
---|
1284 |
|
---|
1285 | wined3d_mutex_lock();
|
---|
1286 | hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
|
---|
1287 | wined3d_mutex_unlock();
|
---|
1288 |
|
---|
1289 | return hr;
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
|
---|
1293 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1294 | HRESULT hr;
|
---|
1295 |
|
---|
1296 | TRACE("iface %p.\n", iface);
|
---|
1297 |
|
---|
1298 | wined3d_mutex_lock();
|
---|
1299 | hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
|
---|
1300 | wined3d_mutex_unlock();
|
---|
1301 |
|
---|
1302 | return hr;
|
---|
1303 | }
|
---|
1304 |
|
---|
1305 | static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
|
---|
1306 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1307 | IWineD3DStateBlock *stateblock;
|
---|
1308 | HRESULT hr;
|
---|
1309 |
|
---|
1310 | TRACE("iface %p, token %p.\n", iface, pToken);
|
---|
1311 |
|
---|
1312 | /* Tell wineD3D to endstateblock before anything else (in case we run out
|
---|
1313 | * of memory later and cause locking problems)
|
---|
1314 | */
|
---|
1315 | wined3d_mutex_lock();
|
---|
1316 | hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &stateblock);
|
---|
1317 | if (hr != D3D_OK) {
|
---|
1318 | WARN("IWineD3DDevice_EndStateBlock returned an error\n");
|
---|
1319 | wined3d_mutex_unlock();
|
---|
1320 | return hr;
|
---|
1321 | }
|
---|
1322 |
|
---|
1323 | *pToken = d3d8_allocate_handle(&This->handle_table, stateblock, D3D8_HANDLE_SB);
|
---|
1324 | wined3d_mutex_unlock();
|
---|
1325 |
|
---|
1326 | if (*pToken == D3D8_INVALID_HANDLE)
|
---|
1327 | {
|
---|
1328 | ERR("Failed to create a handle\n");
|
---|
1329 | wined3d_mutex_lock();
|
---|
1330 | IWineD3DStateBlock_Release(stateblock);
|
---|
1331 | wined3d_mutex_unlock();
|
---|
1332 | return E_FAIL;
|
---|
1333 | }
|
---|
1334 | ++*pToken;
|
---|
1335 |
|
---|
1336 | TRACE("Returning %#x (%p).\n", *pToken, stateblock);
|
---|
1337 |
|
---|
1338 | return hr;
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
|
---|
1342 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1343 | IWineD3DStateBlock *stateblock;
|
---|
1344 | HRESULT hr;
|
---|
1345 |
|
---|
1346 | TRACE("iface %p, token %#x.\n", iface, Token);
|
---|
1347 |
|
---|
1348 | wined3d_mutex_lock();
|
---|
1349 | stateblock = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
|
---|
1350 | if (!stateblock)
|
---|
1351 | {
|
---|
1352 | WARN("Invalid handle (%#x) passed.\n", Token);
|
---|
1353 | wined3d_mutex_unlock();
|
---|
1354 | return D3DERR_INVALIDCALL;
|
---|
1355 | }
|
---|
1356 | hr = IWineD3DStateBlock_Apply(stateblock);
|
---|
1357 | wined3d_mutex_unlock();
|
---|
1358 |
|
---|
1359 | return hr;
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
|
---|
1363 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1364 | IWineD3DStateBlock *stateblock;
|
---|
1365 | HRESULT hr;
|
---|
1366 |
|
---|
1367 | TRACE("iface %p, token %#x.\n", iface, Token);
|
---|
1368 |
|
---|
1369 | wined3d_mutex_lock();
|
---|
1370 | stateblock = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
|
---|
1371 | if (!stateblock)
|
---|
1372 | {
|
---|
1373 | WARN("Invalid handle (%#x) passed.\n", Token);
|
---|
1374 | wined3d_mutex_unlock();
|
---|
1375 | return D3DERR_INVALIDCALL;
|
---|
1376 | }
|
---|
1377 | hr = IWineD3DStateBlock_Capture(stateblock);
|
---|
1378 | wined3d_mutex_unlock();
|
---|
1379 |
|
---|
1380 | return hr;
|
---|
1381 | }
|
---|
1382 |
|
---|
1383 | static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
|
---|
1384 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1385 | IWineD3DStateBlock *stateblock;
|
---|
1386 |
|
---|
1387 | TRACE("iface %p, token %#x.\n", iface, Token);
|
---|
1388 |
|
---|
1389 | wined3d_mutex_lock();
|
---|
1390 | stateblock = d3d8_free_handle(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
|
---|
1391 |
|
---|
1392 | if (!stateblock)
|
---|
1393 | {
|
---|
1394 | WARN("Invalid handle (%#x) passed.\n", Token);
|
---|
1395 | wined3d_mutex_unlock();
|
---|
1396 | return D3DERR_INVALIDCALL;
|
---|
1397 | }
|
---|
1398 |
|
---|
1399 | if (IWineD3DStateBlock_Release((IUnknown *)stateblock))
|
---|
1400 | {
|
---|
1401 | ERR("Stateblock %p has references left, this shouldn't happen.\n", stateblock);
|
---|
1402 | }
|
---|
1403 | wined3d_mutex_unlock();
|
---|
1404 |
|
---|
1405 | return D3D_OK;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *iface,
|
---|
1409 | D3DSTATEBLOCKTYPE Type, DWORD *handle)
|
---|
1410 | {
|
---|
1411 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1412 | IWineD3DStateBlock *stateblock;
|
---|
1413 | HRESULT hr;
|
---|
1414 |
|
---|
1415 | TRACE("iface %p, type %#x, handle %p.\n", iface, Type, handle);
|
---|
1416 |
|
---|
1417 | if (Type != D3DSBT_ALL
|
---|
1418 | && Type != D3DSBT_PIXELSTATE
|
---|
1419 | && Type != D3DSBT_VERTEXSTATE)
|
---|
1420 | {
|
---|
1421 | WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
|
---|
1422 | return D3DERR_INVALIDCALL;
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 | wined3d_mutex_lock();
|
---|
1426 | hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type,
|
---|
1427 | &stateblock, NULL);
|
---|
1428 | if (FAILED(hr))
|
---|
1429 | {
|
---|
1430 | wined3d_mutex_unlock();
|
---|
1431 | ERR("IWineD3DDevice_CreateStateBlock failed, hr %#x\n", hr);
|
---|
1432 | return hr;
|
---|
1433 | }
|
---|
1434 |
|
---|
1435 | *handle = d3d8_allocate_handle(&This->handle_table, stateblock, D3D8_HANDLE_SB);
|
---|
1436 | wined3d_mutex_unlock();
|
---|
1437 |
|
---|
1438 | if (*handle == D3D8_INVALID_HANDLE)
|
---|
1439 | {
|
---|
1440 | ERR("Failed to allocate a handle.\n");
|
---|
1441 | wined3d_mutex_lock();
|
---|
1442 | IWineD3DStateBlock_Release(stateblock);
|
---|
1443 | wined3d_mutex_unlock();
|
---|
1444 | return E_FAIL;
|
---|
1445 | }
|
---|
1446 | ++*handle;
|
---|
1447 |
|
---|
1448 | TRACE("Returning %#x (%p).\n", *handle, stateblock);
|
---|
1449 |
|
---|
1450 | return hr;
|
---|
1451 | }
|
---|
1452 |
|
---|
1453 | static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus) {
|
---|
1454 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1455 | HRESULT hr;
|
---|
1456 |
|
---|
1457 | TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
|
---|
1458 | /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
|
---|
1459 |
|
---|
1460 | wined3d_mutex_lock();
|
---|
1461 | hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
|
---|
1462 | wined3d_mutex_unlock();
|
---|
1463 |
|
---|
1464 | return hr;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus) {
|
---|
1468 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1469 | HRESULT hr;
|
---|
1470 |
|
---|
1471 | TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
|
---|
1472 |
|
---|
1473 | wined3d_mutex_lock();
|
---|
1474 | hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
|
---|
1475 | wined3d_mutex_unlock();
|
---|
1476 |
|
---|
1477 | return hr;
|
---|
1478 | }
|
---|
1479 |
|
---|
1480 | static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) {
|
---|
1481 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1482 | IWineD3DBaseTexture *retTexture;
|
---|
1483 | HRESULT hr;
|
---|
1484 |
|
---|
1485 | TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, ppTexture);
|
---|
1486 |
|
---|
1487 | if(ppTexture == NULL){
|
---|
1488 | return D3DERR_INVALIDCALL;
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | wined3d_mutex_lock();
|
---|
1492 | hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
|
---|
1493 | if (FAILED(hr))
|
---|
1494 | {
|
---|
1495 | WARN("Failed to get texture for stage %u, hr %#x.\n", Stage, hr);
|
---|
1496 | wined3d_mutex_unlock();
|
---|
1497 | *ppTexture = NULL;
|
---|
1498 | return hr;
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | if (retTexture)
|
---|
1502 | {
|
---|
1503 | IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
|
---|
1504 | IWineD3DBaseTexture_Release(retTexture);
|
---|
1505 | }
|
---|
1506 | else
|
---|
1507 | {
|
---|
1508 | *ppTexture = NULL;
|
---|
1509 | }
|
---|
1510 | wined3d_mutex_unlock();
|
---|
1511 |
|
---|
1512 | return D3D_OK;
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture) {
|
---|
1516 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1517 | HRESULT hr;
|
---|
1518 |
|
---|
1519 | TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, pTexture);
|
---|
1520 |
|
---|
1521 | wined3d_mutex_lock();
|
---|
1522 | hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
|
---|
1523 | pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
|
---|
1524 | wined3d_mutex_unlock();
|
---|
1525 |
|
---|
1526 | return hr;
|
---|
1527 | }
|
---|
1528 |
|
---|
1529 | static const struct tss_lookup
|
---|
1530 | {
|
---|
1531 | BOOL sampler_state;
|
---|
1532 | DWORD state;
|
---|
1533 | }
|
---|
1534 | tss_lookup[] =
|
---|
1535 | {
|
---|
1536 | {FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */
|
---|
1537 | {FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */
|
---|
1538 | {FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */
|
---|
1539 | {FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */
|
---|
1540 | {FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */
|
---|
1541 | {FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */
|
---|
1542 | {FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */
|
---|
1543 | {FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */
|
---|
1544 | {FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */
|
---|
1545 | {FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */
|
---|
1546 | {FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */
|
---|
1547 | {FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */
|
---|
1548 | {FALSE, WINED3DTSS_FORCE_DWORD}, /* 12, unused */
|
---|
1549 | {TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */
|
---|
1550 | {TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */
|
---|
1551 | {TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */
|
---|
1552 | {TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */
|
---|
1553 | {TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */
|
---|
1554 | {TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */
|
---|
1555 | {TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */
|
---|
1556 | {TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */
|
---|
1557 | {TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */
|
---|
1558 | {FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */
|
---|
1559 | {FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */
|
---|
1560 | {FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
|
---|
1561 | {TRUE, WINED3DSAMP_ADDRESSW}, /* 25, D3DTSS_ADDRESSW */
|
---|
1562 | {FALSE, WINED3DTSS_COLORARG0}, /* 26, D3DTSS_COLORARG0 */
|
---|
1563 | {FALSE, WINED3DTSS_ALPHAARG0}, /* 27, D3DTSS_ALPHAARG0 */
|
---|
1564 | {FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
|
---|
1565 | };
|
---|
1566 |
|
---|
1567 | static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
|
---|
1568 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1569 | const struct tss_lookup *l = &tss_lookup[Type];
|
---|
1570 | HRESULT hr;
|
---|
1571 |
|
---|
1572 | TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
|
---|
1573 |
|
---|
1574 | wined3d_mutex_lock();
|
---|
1575 | if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue);
|
---|
1576 | else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue);
|
---|
1577 | wined3d_mutex_unlock();
|
---|
1578 |
|
---|
1579 | return hr;
|
---|
1580 | }
|
---|
1581 |
|
---|
1582 | static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
|
---|
1583 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1584 | const struct tss_lookup *l = &tss_lookup[Type];
|
---|
1585 | HRESULT hr;
|
---|
1586 |
|
---|
1587 | TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
|
---|
1588 |
|
---|
1589 | wined3d_mutex_lock();
|
---|
1590 | if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value);
|
---|
1591 | else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value);
|
---|
1592 | wined3d_mutex_unlock();
|
---|
1593 |
|
---|
1594 | return hr;
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
|
---|
1598 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1599 | HRESULT hr;
|
---|
1600 |
|
---|
1601 | TRACE("iface %p, pass_count %p.\n", iface, pNumPasses);
|
---|
1602 |
|
---|
1603 | wined3d_mutex_lock();
|
---|
1604 | hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
|
---|
1605 | wined3d_mutex_unlock();
|
---|
1606 |
|
---|
1607 | return hr;
|
---|
1608 | }
|
---|
1609 |
|
---|
1610 | static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(IDirect3DDevice8 *iface,
|
---|
1611 | DWORD info_id, void *info, DWORD info_size)
|
---|
1612 | {
|
---|
1613 | FIXME("iface %p, info_id %#x, info %p, info_size %u stub!\n", iface, info_id, info, info_size);
|
---|
1614 |
|
---|
1615 | return D3D_OK;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
|
---|
1619 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1620 | HRESULT hr;
|
---|
1621 |
|
---|
1622 | TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
|
---|
1623 |
|
---|
1624 | wined3d_mutex_lock();
|
---|
1625 | hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
|
---|
1626 | wined3d_mutex_unlock();
|
---|
1627 |
|
---|
1628 | return hr;
|
---|
1629 | }
|
---|
1630 |
|
---|
1631 | static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
|
---|
1632 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1633 | HRESULT hr;
|
---|
1634 |
|
---|
1635 | TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
|
---|
1636 |
|
---|
1637 | wined3d_mutex_lock();
|
---|
1638 | hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
|
---|
1639 | wined3d_mutex_unlock();
|
---|
1640 |
|
---|
1641 | return hr;
|
---|
1642 | }
|
---|
1643 |
|
---|
1644 | static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
|
---|
1645 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1646 | HRESULT hr;
|
---|
1647 |
|
---|
1648 | TRACE("iface %p, palette_idx %u.\n", iface, PaletteNumber);
|
---|
1649 |
|
---|
1650 | wined3d_mutex_lock();
|
---|
1651 | hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
|
---|
1652 | wined3d_mutex_unlock();
|
---|
1653 |
|
---|
1654 | return hr;
|
---|
1655 | }
|
---|
1656 |
|
---|
1657 | static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
|
---|
1658 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1659 | HRESULT hr;
|
---|
1660 |
|
---|
1661 | TRACE("iface %p, palette_idx %p.\n", iface, PaletteNumber);
|
---|
1662 |
|
---|
1663 | wined3d_mutex_lock();
|
---|
1664 | hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
|
---|
1665 | wined3d_mutex_unlock();
|
---|
1666 |
|
---|
1667 | return hr;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface, D3DPRIMITIVETYPE PrimitiveType,
|
---|
1671 | UINT StartVertex, UINT PrimitiveCount)
|
---|
1672 | {
|
---|
1673 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1674 | HRESULT hr;
|
---|
1675 |
|
---|
1676 | TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
|
---|
1677 | iface, PrimitiveType, StartVertex, PrimitiveCount);
|
---|
1678 |
|
---|
1679 | wined3d_mutex_lock();
|
---|
1680 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1681 | hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
|
---|
1682 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
|
---|
1683 | wined3d_mutex_unlock();
|
---|
1684 |
|
---|
1685 | return hr;
|
---|
1686 | }
|
---|
1687 |
|
---|
1688 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
|
---|
1689 | UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
|
---|
1690 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1691 | HRESULT hr;
|
---|
1692 |
|
---|
1693 | TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, start_idx %u, primitive_count %u.\n",
|
---|
1694 | iface, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
|
---|
1695 |
|
---|
1696 | wined3d_mutex_lock();
|
---|
1697 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1698 | hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
|
---|
1699 | vertex_count_from_primitive_count(PrimitiveType, primCount));
|
---|
1700 | wined3d_mutex_unlock();
|
---|
1701 |
|
---|
1702 | return hr;
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
|
---|
1706 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1707 | HRESULT hr;
|
---|
1708 |
|
---|
1709 | TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
|
---|
1710 | iface, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1711 |
|
---|
1712 | wined3d_mutex_lock();
|
---|
1713 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1714 | hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
|
---|
1715 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
|
---|
1716 | pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1717 | wined3d_mutex_unlock();
|
---|
1718 |
|
---|
1719 | return hr;
|
---|
1720 | }
|
---|
1721 |
|
---|
1722 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
|
---|
1723 | UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
|
---|
1724 | D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
|
---|
1725 | UINT VertexStreamZeroStride) {
|
---|
1726 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1727 | HRESULT hr;
|
---|
1728 |
|
---|
1729 | TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, index_count %u, primitive_count %u,\n"
|
---|
1730 | "index_data %p, index_format %#x, vertex_data %p, vertex_stride %u.\n",
|
---|
1731 | iface, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
|
---|
1732 | pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1733 |
|
---|
1734 | wined3d_mutex_lock();
|
---|
1735 | IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
|
---|
1736 | hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
|
---|
1737 | vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
|
---|
1738 | wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
|
---|
1739 | wined3d_mutex_unlock();
|
---|
1740 |
|
---|
1741 | return hr;
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
|
---|
1745 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1746 | HRESULT hr;
|
---|
1747 | IDirect3DVertexBuffer8Impl *dest = (IDirect3DVertexBuffer8Impl *) pDestBuffer;
|
---|
1748 |
|
---|
1749 | TRACE("iface %p, src_start_idx %u, dst_idx %u, vertex_count %u, dst_buffer %p, flags %#x.\n",
|
---|
1750 | iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, Flags);
|
---|
1751 |
|
---|
1752 | wined3d_mutex_lock();
|
---|
1753 | hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
|
---|
1754 | wined3d_mutex_unlock();
|
---|
1755 |
|
---|
1756 | return hr;
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *iface,
|
---|
1760 | const DWORD *declaration, const DWORD *byte_code, DWORD *shader, DWORD usage)
|
---|
1761 | {
|
---|
1762 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1763 | IDirect3DVertexShader8Impl *object;
|
---|
1764 | DWORD shader_handle;
|
---|
1765 | DWORD handle;
|
---|
1766 | HRESULT hr;
|
---|
1767 |
|
---|
1768 | TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n",
|
---|
1769 | iface, declaration, byte_code, shader, usage);
|
---|
1770 |
|
---|
1771 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
1772 | if (!object)
|
---|
1773 | {
|
---|
1774 | ERR("Failed to allocate vertex shader memory.\n");
|
---|
1775 | *shader = 0;
|
---|
1776 | return E_OUTOFMEMORY;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | wined3d_mutex_lock();
|
---|
1780 | handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_VS);
|
---|
1781 | wined3d_mutex_unlock();
|
---|
1782 | if (handle == D3D8_INVALID_HANDLE)
|
---|
1783 | {
|
---|
1784 | ERR("Failed to allocate vertex shader handle.\n");
|
---|
1785 | HeapFree(GetProcessHeap(), 0, object);
|
---|
1786 | *shader = 0;
|
---|
1787 | return E_OUTOFMEMORY;
|
---|
1788 | }
|
---|
1789 |
|
---|
1790 | shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
|
---|
1791 |
|
---|
1792 | hr = vertexshader_init(object, This, declaration, byte_code, shader_handle, usage);
|
---|
1793 | if (FAILED(hr))
|
---|
1794 | {
|
---|
1795 | WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
|
---|
1796 | wined3d_mutex_lock();
|
---|
1797 | d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_VS);
|
---|
1798 | wined3d_mutex_unlock();
|
---|
1799 | HeapFree(GetProcessHeap(), 0, object);
|
---|
1800 | *shader = 0;
|
---|
1801 | return hr;
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 | TRACE("Created vertex shader %p (handle %#x).\n", object, shader_handle);
|
---|
1805 | *shader = shader_handle;
|
---|
1806 |
|
---|
1807 | return D3D_OK;
|
---|
1808 | }
|
---|
1809 |
|
---|
1810 | static IDirect3DVertexDeclaration8Impl *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *This, DWORD fvf)
|
---|
1811 | {
|
---|
1812 | IDirect3DVertexDeclaration8Impl *d3d8_declaration;
|
---|
1813 | HRESULT hr;
|
---|
1814 | int p, low, high; /* deliberately signed */
|
---|
1815 | struct FvfToDecl *convertedDecls = This->decls;
|
---|
1816 |
|
---|
1817 | TRACE("Searching for declaration for fvf %08x... ", fvf);
|
---|
1818 |
|
---|
1819 | low = 0;
|
---|
1820 | high = This->numConvertedDecls - 1;
|
---|
1821 | while(low <= high) {
|
---|
1822 | p = (low + high) >> 1;
|
---|
1823 | TRACE("%d ", p);
|
---|
1824 | if(convertedDecls[p].fvf == fvf) {
|
---|
1825 | TRACE("found %p\n", convertedDecls[p].decl);
|
---|
1826 | return (IDirect3DVertexDeclaration8Impl *)convertedDecls[p].decl;
|
---|
1827 | } else if(convertedDecls[p].fvf < fvf) {
|
---|
1828 | low = p + 1;
|
---|
1829 | } else {
|
---|
1830 | high = p - 1;
|
---|
1831 | }
|
---|
1832 | }
|
---|
1833 | TRACE("not found. Creating and inserting at position %d.\n", low);
|
---|
1834 |
|
---|
1835 | d3d8_declaration = HeapAlloc(GetProcessHeap(), 0, sizeof(*d3d8_declaration));
|
---|
1836 | if (!d3d8_declaration)
|
---|
1837 | {
|
---|
1838 | ERR("Memory allocation failed.\n");
|
---|
1839 | return NULL;
|
---|
1840 | }
|
---|
1841 |
|
---|
1842 | hr = vertexdeclaration_init_fvf(d3d8_declaration, This, fvf);
|
---|
1843 | if (FAILED(hr))
|
---|
1844 | {
|
---|
1845 | WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
|
---|
1846 | HeapFree(GetProcessHeap(), 0, d3d8_declaration);
|
---|
1847 | return NULL;
|
---|
1848 | }
|
---|
1849 |
|
---|
1850 | if(This->declArraySize == This->numConvertedDecls) {
|
---|
1851 | int grow = This->declArraySize / 2;
|
---|
1852 | convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
|
---|
1853 | sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
|
---|
1854 | if(!convertedDecls) {
|
---|
1855 | /* This will destroy it */
|
---|
1856 | IDirect3DVertexDeclaration8_Release((IDirect3DVertexDeclaration8 *)d3d8_declaration);
|
---|
1857 | return NULL;
|
---|
1858 | }
|
---|
1859 | This->decls = convertedDecls;
|
---|
1860 | This->declArraySize += grow;
|
---|
1861 | }
|
---|
1862 |
|
---|
1863 | memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(convertedDecls[0]) * (This->numConvertedDecls - low));
|
---|
1864 | convertedDecls[low].decl = (IDirect3DVertexDeclaration8 *)d3d8_declaration;
|
---|
1865 | convertedDecls[low].fvf = fvf;
|
---|
1866 | This->numConvertedDecls++;
|
---|
1867 |
|
---|
1868 | TRACE("Returning %p. %u decls in array\n", d3d8_declaration, This->numConvertedDecls);
|
---|
1869 | return d3d8_declaration;
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
---|
1873 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1874 | IDirect3DVertexShader8Impl *shader;
|
---|
1875 | HRESULT hr;
|
---|
1876 |
|
---|
1877 | TRACE("iface %p, shader %#x.\n", iface, pShader);
|
---|
1878 |
|
---|
1879 | if (VS_HIGHESTFIXEDFXF >= pShader) {
|
---|
1880 | TRACE("Setting FVF, %#x\n", pShader);
|
---|
1881 |
|
---|
1882 | wined3d_mutex_lock();
|
---|
1883 | IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
---|
1884 | IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
|
---|
1885 | IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
|
---|
1886 | wined3d_mutex_unlock();
|
---|
1887 |
|
---|
1888 | return D3D_OK;
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | TRACE("Setting shader\n");
|
---|
1892 |
|
---|
1893 | wined3d_mutex_lock();
|
---|
1894 | shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
|
---|
1895 | if (!shader)
|
---|
1896 | {
|
---|
1897 | WARN("Invalid handle (%#x) passed.\n", pShader);
|
---|
1898 | wined3d_mutex_unlock();
|
---|
1899 |
|
---|
1900 | return D3DERR_INVALIDCALL;
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
---|
1904 | ((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
|
---|
1905 | if (SUCCEEDED(hr)) hr = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
|
---|
1906 | wined3d_mutex_unlock();
|
---|
1907 |
|
---|
1908 | TRACE("Returning hr %#x\n", hr);
|
---|
1909 |
|
---|
1910 | return hr;
|
---|
1911 | }
|
---|
1912 |
|
---|
1913 | static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
|
---|
1914 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1915 | IWineD3DVertexDeclaration *wined3d_declaration;
|
---|
1916 | IDirect3DVertexDeclaration8 *d3d8_declaration;
|
---|
1917 | HRESULT hrc;
|
---|
1918 |
|
---|
1919 | TRACE("iface %p, shader %p.\n", iface, ppShader);
|
---|
1920 |
|
---|
1921 | wined3d_mutex_lock();
|
---|
1922 | hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
|
---|
1923 | if (FAILED(hrc))
|
---|
1924 | {
|
---|
1925 | wined3d_mutex_unlock();
|
---|
1926 | WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
|
---|
1927 | This, hrc, This->WineD3DDevice);
|
---|
1928 | return hrc;
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 | if (!wined3d_declaration)
|
---|
1932 | {
|
---|
1933 | wined3d_mutex_unlock();
|
---|
1934 | *ppShader = 0;
|
---|
1935 | return D3D_OK;
|
---|
1936 | }
|
---|
1937 |
|
---|
1938 | hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
|
---|
1939 | IWineD3DVertexDeclaration_Release(wined3d_declaration);
|
---|
1940 | wined3d_mutex_unlock();
|
---|
1941 | if (SUCCEEDED(hrc))
|
---|
1942 | {
|
---|
1943 | *ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
|
---|
1944 | IDirect3DVertexDeclaration8_Release(d3d8_declaration);
|
---|
1945 | }
|
---|
1946 |
|
---|
1947 | TRACE("(%p) : returning %#x\n", This, *ppShader);
|
---|
1948 |
|
---|
1949 | return hrc;
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
---|
1953 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1954 | IDirect3DVertexShader8Impl *shader;
|
---|
1955 | IWineD3DVertexShader *cur = NULL;
|
---|
1956 |
|
---|
1957 | TRACE("iface %p, shader %#x.\n", iface, pShader);
|
---|
1958 |
|
---|
1959 | wined3d_mutex_lock();
|
---|
1960 | shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
|
---|
1961 | if (!shader)
|
---|
1962 | {
|
---|
1963 | WARN("Invalid handle (%#x) passed.\n", pShader);
|
---|
1964 | wined3d_mutex_unlock();
|
---|
1965 |
|
---|
1966 | return D3DERR_INVALIDCALL;
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &cur);
|
---|
1970 |
|
---|
1971 | if (cur)
|
---|
1972 | {
|
---|
1973 | if (cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
|
---|
1974 | IWineD3DVertexShader_Release(cur);
|
---|
1975 | }
|
---|
1976 |
|
---|
1977 | wined3d_mutex_unlock();
|
---|
1978 |
|
---|
1979 | if (IUnknown_Release((IUnknown *)shader))
|
---|
1980 | {
|
---|
1981 | ERR("Shader %p has references left, this shouldn't happen.\n", shader);
|
---|
1982 | }
|
---|
1983 |
|
---|
1984 | return D3D_OK;
|
---|
1985 | }
|
---|
1986 |
|
---|
1987 | static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
|
---|
1988 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
1989 | HRESULT hr;
|
---|
1990 |
|
---|
1991 | TRACE("iface %p, register %u, data %p, count %u.\n",
|
---|
1992 | iface, Register, pConstantData, ConstantCount);
|
---|
1993 |
|
---|
1994 | if(Register + ConstantCount > D3D8_MAX_VERTEX_SHADER_CONSTANTF) {
|
---|
1995 | WARN("Trying to access %u constants, but d3d8 only supports %u\n",
|
---|
1996 | Register + ConstantCount, D3D8_MAX_VERTEX_SHADER_CONSTANTF);
|
---|
1997 | return D3DERR_INVALIDCALL;
|
---|
1998 | }
|
---|
1999 |
|
---|
2000 | wined3d_mutex_lock();
|
---|
2001 | hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
|
---|
2002 | wined3d_mutex_unlock();
|
---|
2003 |
|
---|
2004 | return hr;
|
---|
2005 | }
|
---|
2006 |
|
---|
2007 | static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
|
---|
2008 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2009 | HRESULT hr;
|
---|
2010 |
|
---|
2011 | TRACE("iface %p, register %u, data %p, count %u.\n",
|
---|
2012 | iface, Register, pConstantData, ConstantCount);
|
---|
2013 |
|
---|
2014 | if(Register + ConstantCount > D3D8_MAX_VERTEX_SHADER_CONSTANTF) {
|
---|
2015 | WARN("Trying to access %u constants, but d3d8 only supports %u\n",
|
---|
2016 | Register + ConstantCount, D3D8_MAX_VERTEX_SHADER_CONSTANTF);
|
---|
2017 | return D3DERR_INVALIDCALL;
|
---|
2018 | }
|
---|
2019 |
|
---|
2020 | wined3d_mutex_lock();
|
---|
2021 | hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
|
---|
2022 | wined3d_mutex_unlock();
|
---|
2023 |
|
---|
2024 | return hr;
|
---|
2025 | }
|
---|
2026 |
|
---|
2027 | static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
|
---|
2028 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2029 | IDirect3DVertexDeclaration8Impl *declaration;
|
---|
2030 | IDirect3DVertexShader8Impl *shader;
|
---|
2031 |
|
---|
2032 | TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
|
---|
2033 | iface, pVertexShader, pData, pSizeOfData);
|
---|
2034 |
|
---|
2035 | wined3d_mutex_lock();
|
---|
2036 | shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
|
---|
2037 | wined3d_mutex_unlock();
|
---|
2038 |
|
---|
2039 | if (!shader)
|
---|
2040 | {
|
---|
2041 | WARN("Invalid handle (%#x) passed.\n", pVertexShader);
|
---|
2042 | return D3DERR_INVALIDCALL;
|
---|
2043 | }
|
---|
2044 | declaration = (IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration;
|
---|
2045 |
|
---|
2046 | /* If pData is NULL, we just return the required size of the buffer. */
|
---|
2047 | if (!pData) {
|
---|
2048 | *pSizeOfData = declaration->elements_size;
|
---|
2049 | return D3D_OK;
|
---|
2050 | }
|
---|
2051 |
|
---|
2052 | /* MSDN claims that if *pSizeOfData is smaller than the required size
|
---|
2053 | * we should write the required size and return D3DERR_MOREDATA.
|
---|
2054 | * That's not actually true. */
|
---|
2055 | if (*pSizeOfData < declaration->elements_size) {
|
---|
2056 | return D3DERR_INVALIDCALL;
|
---|
2057 | }
|
---|
2058 |
|
---|
2059 | CopyMemory(pData, declaration->elements, declaration->elements_size);
|
---|
2060 |
|
---|
2061 | return D3D_OK;
|
---|
2062 | }
|
---|
2063 |
|
---|
2064 | static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
|
---|
2065 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2066 | IDirect3DVertexShader8Impl *shader = NULL;
|
---|
2067 | HRESULT hr;
|
---|
2068 |
|
---|
2069 | TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
|
---|
2070 | iface, pVertexShader, pData, pSizeOfData);
|
---|
2071 |
|
---|
2072 | wined3d_mutex_lock();
|
---|
2073 | shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
|
---|
2074 | if (!shader)
|
---|
2075 | {
|
---|
2076 | WARN("Invalid handle (%#x) passed.\n", pVertexShader);
|
---|
2077 | wined3d_mutex_unlock();
|
---|
2078 |
|
---|
2079 | return D3DERR_INVALIDCALL;
|
---|
2080 | }
|
---|
2081 |
|
---|
2082 | if (!shader->wineD3DVertexShader)
|
---|
2083 | {
|
---|
2084 | wined3d_mutex_unlock();
|
---|
2085 | *pSizeOfData = 0;
|
---|
2086 | return D3D_OK;
|
---|
2087 | }
|
---|
2088 |
|
---|
2089 | hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
|
---|
2090 | wined3d_mutex_unlock();
|
---|
2091 |
|
---|
2092 | return hr;
|
---|
2093 | }
|
---|
2094 |
|
---|
2095 | static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
|
---|
2096 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2097 | HRESULT hr;
|
---|
2098 | IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
|
---|
2099 |
|
---|
2100 | TRACE("iface %p, buffer %p, base_vertex_idx %u.\n", iface, pIndexData, baseVertexIndex);
|
---|
2101 |
|
---|
2102 | /* WineD3D takes an INT(due to d3d9), but d3d8 uses UINTs. Do I have to add a check here that
|
---|
2103 | * the UINT doesn't cause an overflow in the INT? It seems rather unlikely because such large
|
---|
2104 | * vertex buffers can't be created to address them with an index that requires the 32nd bit
|
---|
2105 | * (4 Byte minimum vertex size * 2^31-1 -> 8 gb buffer. The index sign would be the least
|
---|
2106 | * problem)
|
---|
2107 | */
|
---|
2108 | wined3d_mutex_lock();
|
---|
2109 | IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
|
---|
2110 | hr = IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice,
|
---|
2111 | ib ? ib->wineD3DIndexBuffer : NULL,
|
---|
2112 | ib ? ib->format : WINED3DFMT_UNKNOWN);
|
---|
2113 | wined3d_mutex_unlock();
|
---|
2114 |
|
---|
2115 | return hr;
|
---|
2116 | }
|
---|
2117 |
|
---|
2118 | static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
|
---|
2119 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2120 | IWineD3DBuffer *retIndexData = NULL;
|
---|
2121 | HRESULT rc = D3D_OK;
|
---|
2122 |
|
---|
2123 | TRACE("iface %p, buffer %p, base_vertex_index %p.\n", iface, ppIndexData, pBaseVertexIndex);
|
---|
2124 |
|
---|
2125 | if(ppIndexData == NULL){
|
---|
2126 | return D3DERR_INVALIDCALL;
|
---|
2127 | }
|
---|
2128 |
|
---|
2129 | /* The case from UINT to INT is safe because d3d8 will never set negative values */
|
---|
2130 | wined3d_mutex_lock();
|
---|
2131 | IWineD3DDevice_GetBaseVertexIndex(This->WineD3DDevice, (INT *) pBaseVertexIndex);
|
---|
2132 | rc = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
|
---|
2133 | if (SUCCEEDED(rc) && retIndexData) {
|
---|
2134 | IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
|
---|
2135 | IWineD3DBuffer_Release(retIndexData);
|
---|
2136 | } else {
|
---|
2137 | if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
|
---|
2138 | *ppIndexData = NULL;
|
---|
2139 | }
|
---|
2140 | wined3d_mutex_unlock();
|
---|
2141 |
|
---|
2142 | return rc;
|
---|
2143 | }
|
---|
2144 |
|
---|
2145 | static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface,
|
---|
2146 | const DWORD *byte_code, DWORD *shader)
|
---|
2147 | {
|
---|
2148 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2149 | IDirect3DPixelShader8Impl *object;
|
---|
2150 | DWORD shader_handle;
|
---|
2151 | DWORD handle;
|
---|
2152 | HRESULT hr;
|
---|
2153 |
|
---|
2154 | TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
|
---|
2155 |
|
---|
2156 | if (!shader)
|
---|
2157 | {
|
---|
2158 | TRACE("(%p) Invalid call\n", This);
|
---|
2159 | return D3DERR_INVALIDCALL;
|
---|
2160 | }
|
---|
2161 |
|
---|
2162 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
2163 | if (!object)
|
---|
2164 | {
|
---|
2165 | ERR("Failed to allocate pixel shader memmory.\n");
|
---|
2166 | return E_OUTOFMEMORY;
|
---|
2167 | }
|
---|
2168 |
|
---|
2169 | wined3d_mutex_lock();
|
---|
2170 | handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS);
|
---|
2171 | wined3d_mutex_unlock();
|
---|
2172 | if (handle == D3D8_INVALID_HANDLE)
|
---|
2173 | {
|
---|
2174 | ERR("Failed to allocate pixel shader handle.\n");
|
---|
2175 | HeapFree(GetProcessHeap(), 0, object);
|
---|
2176 | return E_OUTOFMEMORY;
|
---|
2177 | }
|
---|
2178 |
|
---|
2179 | shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
|
---|
2180 |
|
---|
2181 | hr = pixelshader_init(object, This, byte_code, shader_handle);
|
---|
2182 | if (FAILED(hr))
|
---|
2183 | {
|
---|
2184 | WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
|
---|
2185 | wined3d_mutex_lock();
|
---|
2186 | d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_PS);
|
---|
2187 | wined3d_mutex_unlock();
|
---|
2188 | HeapFree(GetProcessHeap(), 0, object);
|
---|
2189 | *shader = 0;
|
---|
2190 | return hr;
|
---|
2191 | }
|
---|
2192 |
|
---|
2193 | TRACE("Created pixel shader %p (handle %#x).\n", object, shader_handle);
|
---|
2194 | *shader = shader_handle;
|
---|
2195 |
|
---|
2196 | return D3D_OK;
|
---|
2197 | }
|
---|
2198 |
|
---|
2199 | static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
---|
2200 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2201 | IDirect3DPixelShader8Impl *shader;
|
---|
2202 | HRESULT hr;
|
---|
2203 |
|
---|
2204 | TRACE("iface %p, shader %#x.\n", iface, pShader);
|
---|
2205 |
|
---|
2206 | wined3d_mutex_lock();
|
---|
2207 |
|
---|
2208 | if (!pShader)
|
---|
2209 | {
|
---|
2210 | hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, NULL);
|
---|
2211 | wined3d_mutex_unlock();
|
---|
2212 | return hr;
|
---|
2213 | }
|
---|
2214 |
|
---|
2215 | shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
|
---|
2216 | if (!shader)
|
---|
2217 | {
|
---|
2218 | WARN("Invalid handle (%#x) passed.\n", pShader);
|
---|
2219 | wined3d_mutex_unlock();
|
---|
2220 | return D3DERR_INVALIDCALL;
|
---|
2221 | }
|
---|
2222 |
|
---|
2223 | TRACE("(%p) : Setting shader %p\n", This, shader);
|
---|
2224 | hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wineD3DPixelShader);
|
---|
2225 | wined3d_mutex_unlock();
|
---|
2226 |
|
---|
2227 | return hr;
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
|
---|
2231 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2232 | IWineD3DPixelShader *object;
|
---|
2233 | HRESULT hrc = D3D_OK;
|
---|
2234 |
|
---|
2235 | TRACE("iface %p, shader %p.\n", iface, ppShader);
|
---|
2236 |
|
---|
2237 | if (NULL == ppShader) {
|
---|
2238 | TRACE("(%p) Invalid call\n", This);
|
---|
2239 | return D3DERR_INVALIDCALL;
|
---|
2240 | }
|
---|
2241 |
|
---|
2242 | wined3d_mutex_lock();
|
---|
2243 | hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
|
---|
2244 | if (D3D_OK == hrc && NULL != object) {
|
---|
2245 | IDirect3DPixelShader8Impl *d3d8_shader;
|
---|
2246 | hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)&d3d8_shader);
|
---|
2247 | IWineD3DPixelShader_Release(object);
|
---|
2248 | *ppShader = d3d8_shader->handle;
|
---|
2249 | IDirect3DPixelShader8_Release((IDirect3DPixelShader8 *)d3d8_shader);
|
---|
2250 | } else {
|
---|
2251 | *ppShader = 0;
|
---|
2252 | }
|
---|
2253 | wined3d_mutex_unlock();
|
---|
2254 |
|
---|
2255 | TRACE("(%p) : returning %#x\n", This, *ppShader);
|
---|
2256 |
|
---|
2257 | return hrc;
|
---|
2258 | }
|
---|
2259 |
|
---|
2260 | static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
---|
2261 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2262 | IDirect3DPixelShader8Impl *shader;
|
---|
2263 | IWineD3DPixelShader *cur = NULL;
|
---|
2264 |
|
---|
2265 | TRACE("iface %p, shader %#x.\n", iface, pShader);
|
---|
2266 |
|
---|
2267 | wined3d_mutex_lock();
|
---|
2268 |
|
---|
2269 | shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
|
---|
2270 | if (!shader)
|
---|
2271 | {
|
---|
2272 | WARN("Invalid handle (%#x) passed.\n", pShader);
|
---|
2273 | wined3d_mutex_unlock();
|
---|
2274 | return D3DERR_INVALIDCALL;
|
---|
2275 | }
|
---|
2276 |
|
---|
2277 | IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &cur);
|
---|
2278 |
|
---|
2279 | if (cur)
|
---|
2280 | {
|
---|
2281 | if (cur == shader->wineD3DPixelShader) IDirect3DDevice8_SetPixelShader(iface, 0);
|
---|
2282 | IWineD3DPixelShader_Release(cur);
|
---|
2283 | }
|
---|
2284 |
|
---|
2285 | wined3d_mutex_unlock();
|
---|
2286 |
|
---|
2287 | if (IUnknown_Release((IUnknown *)shader))
|
---|
2288 | {
|
---|
2289 | ERR("Shader %p has references left, this shouldn't happen.\n", shader);
|
---|
2290 | }
|
---|
2291 |
|
---|
2292 | return D3D_OK;
|
---|
2293 | }
|
---|
2294 |
|
---|
2295 | static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
|
---|
2296 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2297 | HRESULT hr;
|
---|
2298 |
|
---|
2299 | TRACE("iface %p, register %u, data %p, count %u.\n",
|
---|
2300 | iface, Register, pConstantData, ConstantCount);
|
---|
2301 |
|
---|
2302 | wined3d_mutex_lock();
|
---|
2303 | hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
|
---|
2304 | wined3d_mutex_unlock();
|
---|
2305 |
|
---|
2306 | return hr;
|
---|
2307 | }
|
---|
2308 |
|
---|
2309 | static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
|
---|
2310 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2311 | HRESULT hr;
|
---|
2312 |
|
---|
2313 | TRACE("iface %p, register %u, data %p, count %u.\n",
|
---|
2314 | iface, Register, pConstantData, ConstantCount);
|
---|
2315 |
|
---|
2316 | wined3d_mutex_lock();
|
---|
2317 | hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
|
---|
2318 | wined3d_mutex_unlock();
|
---|
2319 |
|
---|
2320 | return hr;
|
---|
2321 | }
|
---|
2322 |
|
---|
2323 | static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pPixelShader, void* pData, DWORD* pSizeOfData) {
|
---|
2324 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2325 | IDirect3DPixelShader8Impl *shader = NULL;
|
---|
2326 | HRESULT hr;
|
---|
2327 |
|
---|
2328 | TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
|
---|
2329 | iface, pPixelShader, pData, pSizeOfData);
|
---|
2330 |
|
---|
2331 | wined3d_mutex_lock();
|
---|
2332 | shader = d3d8_get_object(&This->handle_table, pPixelShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
|
---|
2333 | if (!shader)
|
---|
2334 | {
|
---|
2335 | WARN("Invalid handle (%#x) passed.\n", pPixelShader);
|
---|
2336 | wined3d_mutex_unlock();
|
---|
2337 |
|
---|
2338 | return D3DERR_INVALIDCALL;
|
---|
2339 | }
|
---|
2340 |
|
---|
2341 | hr = IWineD3DPixelShader_GetFunction(shader->wineD3DPixelShader, pData, pSizeOfData);
|
---|
2342 | wined3d_mutex_unlock();
|
---|
2343 |
|
---|
2344 | return hr;
|
---|
2345 | }
|
---|
2346 |
|
---|
2347 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
|
---|
2348 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2349 | HRESULT hr;
|
---|
2350 |
|
---|
2351 | TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
|
---|
2352 | iface, Handle, pNumSegs, pRectPatchInfo);
|
---|
2353 |
|
---|
2354 | wined3d_mutex_lock();
|
---|
2355 | hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
|
---|
2356 | wined3d_mutex_unlock();
|
---|
2357 |
|
---|
2358 | return hr;
|
---|
2359 | }
|
---|
2360 |
|
---|
2361 | static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
|
---|
2362 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2363 | HRESULT hr;
|
---|
2364 |
|
---|
2365 | TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
|
---|
2366 | iface, Handle, pNumSegs, pTriPatchInfo);
|
---|
2367 |
|
---|
2368 | wined3d_mutex_lock();
|
---|
2369 | hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
|
---|
2370 | wined3d_mutex_unlock();
|
---|
2371 |
|
---|
2372 | return hr;
|
---|
2373 | }
|
---|
2374 |
|
---|
2375 | static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle) {
|
---|
2376 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2377 | HRESULT hr;
|
---|
2378 |
|
---|
2379 | TRACE("iface %p, handle %#x.\n", iface, Handle);
|
---|
2380 |
|
---|
2381 | wined3d_mutex_lock();
|
---|
2382 | hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
|
---|
2383 | wined3d_mutex_unlock();
|
---|
2384 |
|
---|
2385 | return hr;
|
---|
2386 | }
|
---|
2387 |
|
---|
2388 | static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) {
|
---|
2389 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2390 | HRESULT hr;
|
---|
2391 |
|
---|
2392 | TRACE("iface %p, stream_idx %u, buffer %p, stride %u.\n",
|
---|
2393 | iface, StreamNumber, pStreamData, Stride);
|
---|
2394 |
|
---|
2395 | wined3d_mutex_lock();
|
---|
2396 | hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
|
---|
2397 | NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer,
|
---|
2398 | 0/* Offset in bytes */, Stride);
|
---|
2399 | wined3d_mutex_unlock();
|
---|
2400 |
|
---|
2401 | return hr;
|
---|
2402 | }
|
---|
2403 |
|
---|
2404 | static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
|
---|
2405 | IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
---|
2406 | IWineD3DBuffer *retStream = NULL;
|
---|
2407 | HRESULT rc = D3D_OK;
|
---|
2408 |
|
---|
2409 | TRACE("iface %p, stream_idx %u, buffer %p, stride %p.\n",
|
---|
2410 | iface, StreamNumber, pStream, pStride);
|
---|
2411 |
|
---|
2412 | if(pStream == NULL){
|
---|
2413 | return D3DERR_INVALIDCALL;
|
---|
2414 | }
|
---|
2415 |
|
---|
2416 | wined3d_mutex_lock();
|
---|
2417 | rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, 0 /* Offset in bytes */, pStride);
|
---|
2418 | if (rc == D3D_OK && NULL != retStream) {
|
---|
2419 | IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
|
---|
2420 | IWineD3DBuffer_Release(retStream);
|
---|
2421 | }else{
|
---|
2422 | if (rc != D3D_OK){
|
---|
2423 | FIXME("Call to GetStreamSource failed %p\n", pStride);
|
---|
2424 | }
|
---|
2425 | *pStream = NULL;
|
---|
2426 | }
|
---|
2427 | wined3d_mutex_unlock();
|
---|
2428 |
|
---|
2429 | return rc;
|
---|
2430 | }
|
---|
2431 |
|
---|
2432 | static const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
|
---|
2433 | {
|
---|
2434 | IDirect3DDevice8Impl_QueryInterface,
|
---|
2435 | IDirect3DDevice8Impl_AddRef,
|
---|
2436 | IDirect3DDevice8Impl_Release,
|
---|
2437 | IDirect3DDevice8Impl_TestCooperativeLevel,
|
---|
2438 | IDirect3DDevice8Impl_GetAvailableTextureMem,
|
---|
2439 | IDirect3DDevice8Impl_ResourceManagerDiscardBytes,
|
---|
2440 | IDirect3DDevice8Impl_GetDirect3D,
|
---|
2441 | IDirect3DDevice8Impl_GetDeviceCaps,
|
---|
2442 | IDirect3DDevice8Impl_GetDisplayMode,
|
---|
2443 | IDirect3DDevice8Impl_GetCreationParameters,
|
---|
2444 | IDirect3DDevice8Impl_SetCursorProperties,
|
---|
2445 | IDirect3DDevice8Impl_SetCursorPosition,
|
---|
2446 | IDirect3DDevice8Impl_ShowCursor,
|
---|
2447 | IDirect3DDevice8Impl_CreateAdditionalSwapChain,
|
---|
2448 | IDirect3DDevice8Impl_Reset,
|
---|
2449 | IDirect3DDevice8Impl_Present,
|
---|
2450 | IDirect3DDevice8Impl_GetBackBuffer,
|
---|
2451 | IDirect3DDevice8Impl_GetRasterStatus,
|
---|
2452 | IDirect3DDevice8Impl_SetGammaRamp,
|
---|
2453 | IDirect3DDevice8Impl_GetGammaRamp,
|
---|
2454 | IDirect3DDevice8Impl_CreateTexture,
|
---|
2455 | IDirect3DDevice8Impl_CreateVolumeTexture,
|
---|
2456 | IDirect3DDevice8Impl_CreateCubeTexture,
|
---|
2457 | IDirect3DDevice8Impl_CreateVertexBuffer,
|
---|
2458 | IDirect3DDevice8Impl_CreateIndexBuffer,
|
---|
2459 | IDirect3DDevice8Impl_CreateRenderTarget,
|
---|
2460 | IDirect3DDevice8Impl_CreateDepthStencilSurface,
|
---|
2461 | IDirect3DDevice8Impl_CreateImageSurface,
|
---|
2462 | IDirect3DDevice8Impl_CopyRects,
|
---|
2463 | IDirect3DDevice8Impl_UpdateTexture,
|
---|
2464 | IDirect3DDevice8Impl_GetFrontBuffer,
|
---|
2465 | IDirect3DDevice8Impl_SetRenderTarget,
|
---|
2466 | IDirect3DDevice8Impl_GetRenderTarget,
|
---|
2467 | IDirect3DDevice8Impl_GetDepthStencilSurface,
|
---|
2468 | IDirect3DDevice8Impl_BeginScene,
|
---|
2469 | IDirect3DDevice8Impl_EndScene,
|
---|
2470 | IDirect3DDevice8Impl_Clear,
|
---|
2471 | IDirect3DDevice8Impl_SetTransform,
|
---|
2472 | IDirect3DDevice8Impl_GetTransform,
|
---|
2473 | IDirect3DDevice8Impl_MultiplyTransform,
|
---|
2474 | IDirect3DDevice8Impl_SetViewport,
|
---|
2475 | IDirect3DDevice8Impl_GetViewport,
|
---|
2476 | IDirect3DDevice8Impl_SetMaterial,
|
---|
2477 | IDirect3DDevice8Impl_GetMaterial,
|
---|
2478 | IDirect3DDevice8Impl_SetLight,
|
---|
2479 | IDirect3DDevice8Impl_GetLight,
|
---|
2480 | IDirect3DDevice8Impl_LightEnable,
|
---|
2481 | IDirect3DDevice8Impl_GetLightEnable,
|
---|
2482 | IDirect3DDevice8Impl_SetClipPlane,
|
---|
2483 | IDirect3DDevice8Impl_GetClipPlane,
|
---|
2484 | IDirect3DDevice8Impl_SetRenderState,
|
---|
2485 | IDirect3DDevice8Impl_GetRenderState,
|
---|
2486 | IDirect3DDevice8Impl_BeginStateBlock,
|
---|
2487 | IDirect3DDevice8Impl_EndStateBlock,
|
---|
2488 | IDirect3DDevice8Impl_ApplyStateBlock,
|
---|
2489 | IDirect3DDevice8Impl_CaptureStateBlock,
|
---|
2490 | IDirect3DDevice8Impl_DeleteStateBlock,
|
---|
2491 | IDirect3DDevice8Impl_CreateStateBlock,
|
---|
2492 | IDirect3DDevice8Impl_SetClipStatus,
|
---|
2493 | IDirect3DDevice8Impl_GetClipStatus,
|
---|
2494 | IDirect3DDevice8Impl_GetTexture,
|
---|
2495 | IDirect3DDevice8Impl_SetTexture,
|
---|
2496 | IDirect3DDevice8Impl_GetTextureStageState,
|
---|
2497 | IDirect3DDevice8Impl_SetTextureStageState,
|
---|
2498 | IDirect3DDevice8Impl_ValidateDevice,
|
---|
2499 | IDirect3DDevice8Impl_GetInfo,
|
---|
2500 | IDirect3DDevice8Impl_SetPaletteEntries,
|
---|
2501 | IDirect3DDevice8Impl_GetPaletteEntries,
|
---|
2502 | IDirect3DDevice8Impl_SetCurrentTexturePalette,
|
---|
2503 | IDirect3DDevice8Impl_GetCurrentTexturePalette,
|
---|
2504 | IDirect3DDevice8Impl_DrawPrimitive,
|
---|
2505 | IDirect3DDevice8Impl_DrawIndexedPrimitive,
|
---|
2506 | IDirect3DDevice8Impl_DrawPrimitiveUP,
|
---|
2507 | IDirect3DDevice8Impl_DrawIndexedPrimitiveUP,
|
---|
2508 | IDirect3DDevice8Impl_ProcessVertices,
|
---|
2509 | IDirect3DDevice8Impl_CreateVertexShader,
|
---|
2510 | IDirect3DDevice8Impl_SetVertexShader,
|
---|
2511 | IDirect3DDevice8Impl_GetVertexShader,
|
---|
2512 | IDirect3DDevice8Impl_DeleteVertexShader,
|
---|
2513 | IDirect3DDevice8Impl_SetVertexShaderConstant,
|
---|
2514 | IDirect3DDevice8Impl_GetVertexShaderConstant,
|
---|
2515 | IDirect3DDevice8Impl_GetVertexShaderDeclaration,
|
---|
2516 | IDirect3DDevice8Impl_GetVertexShaderFunction,
|
---|
2517 | IDirect3DDevice8Impl_SetStreamSource,
|
---|
2518 | IDirect3DDevice8Impl_GetStreamSource,
|
---|
2519 | IDirect3DDevice8Impl_SetIndices,
|
---|
2520 | IDirect3DDevice8Impl_GetIndices,
|
---|
2521 | IDirect3DDevice8Impl_CreatePixelShader,
|
---|
2522 | IDirect3DDevice8Impl_SetPixelShader,
|
---|
2523 | IDirect3DDevice8Impl_GetPixelShader,
|
---|
2524 | IDirect3DDevice8Impl_DeletePixelShader,
|
---|
2525 | IDirect3DDevice8Impl_SetPixelShaderConstant,
|
---|
2526 | IDirect3DDevice8Impl_GetPixelShaderConstant,
|
---|
2527 | IDirect3DDevice8Impl_GetPixelShaderFunction,
|
---|
2528 | IDirect3DDevice8Impl_DrawRectPatch,
|
---|
2529 | IDirect3DDevice8Impl_DrawTriPatch,
|
---|
2530 | IDirect3DDevice8Impl_DeletePatch
|
---|
2531 | };
|
---|
2532 |
|
---|
2533 | /* IWineD3DDeviceParent IUnknown methods */
|
---|
2534 |
|
---|
2535 | static inline struct IDirect3DDevice8Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
|
---|
2536 | {
|
---|
2537 | return (struct IDirect3DDevice8Impl *)((char*)iface
|
---|
2538 | - FIELD_OFFSET(struct IDirect3DDevice8Impl, device_parent_vtbl));
|
---|
2539 | }
|
---|
2540 |
|
---|
2541 | static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
|
---|
2542 | {
|
---|
2543 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2544 | return IDirect3DDevice8Impl_QueryInterface((IDirect3DDevice8 *)This, riid, object);
|
---|
2545 | }
|
---|
2546 |
|
---|
2547 | static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
|
---|
2548 | {
|
---|
2549 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2550 | return IDirect3DDevice8Impl_AddRef((IDirect3DDevice8 *)This);
|
---|
2551 | }
|
---|
2552 |
|
---|
2553 | static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
|
---|
2554 | {
|
---|
2555 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2556 | return IDirect3DDevice8Impl_Release((IDirect3DDevice8 *)This);
|
---|
2557 | }
|
---|
2558 |
|
---|
2559 | /* IWineD3DDeviceParent methods */
|
---|
2560 |
|
---|
2561 | static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
|
---|
2562 | {
|
---|
2563 | TRACE("iface %p, device %p\n", iface, device);
|
---|
2564 | }
|
---|
2565 |
|
---|
2566 | static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
|
---|
2567 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
|
---|
2568 | WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
|
---|
2569 | {
|
---|
2570 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2571 | IDirect3DSurface8Impl *d3d_surface;
|
---|
2572 | BOOL lockable = TRUE;
|
---|
2573 | HRESULT hr;
|
---|
2574 |
|
---|
2575 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
|
---|
2576 | "\tpool %#x, level %u, face %u, surface %p\n",
|
---|
2577 | iface, superior, width, height, format, usage, pool, level, face, surface);
|
---|
2578 |
|
---|
2579 |
|
---|
2580 | if (pool == WINED3DPOOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC)) lockable = FALSE;
|
---|
2581 |
|
---|
2582 | hr = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)This, width, height,
|
---|
2583 | d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
|
---|
2584 | (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
|
---|
2585 | if (FAILED(hr))
|
---|
2586 | {
|
---|
2587 | ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
|
---|
2588 | return hr;
|
---|
2589 | }
|
---|
2590 |
|
---|
2591 | *surface = d3d_surface->wineD3DSurface;
|
---|
2592 | IWineD3DSurface_AddRef(*surface);
|
---|
2593 |
|
---|
2594 | d3d_surface->container = superior;
|
---|
2595 | IUnknown_Release(d3d_surface->parentDevice);
|
---|
2596 | d3d_surface->parentDevice = NULL;
|
---|
2597 |
|
---|
2598 | IDirect3DSurface8_Release((IDirect3DSurface8 *)d3d_surface);
|
---|
2599 | d3d_surface->forwardReference = superior;
|
---|
2600 |
|
---|
2601 | return hr;
|
---|
2602 | }
|
---|
2603 |
|
---|
2604 | static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
|
---|
2605 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
|
---|
2606 | DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
|
---|
2607 | {
|
---|
2608 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2609 | IDirect3DSurface8Impl *d3d_surface;
|
---|
2610 | HRESULT hr;
|
---|
2611 |
|
---|
2612 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
|
---|
2613 | "\tmultisample_quality %u, lockable %u, surface %p\n",
|
---|
2614 | iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
|
---|
2615 |
|
---|
2616 | hr = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)This, width, height,
|
---|
2617 | d3dformat_from_wined3dformat(format), multisample_type, lockable, (IDirect3DSurface8 **)&d3d_surface);
|
---|
2618 | if (FAILED(hr))
|
---|
2619 | {
|
---|
2620 | ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
|
---|
2621 | return hr;
|
---|
2622 | }
|
---|
2623 |
|
---|
2624 | *surface = d3d_surface->wineD3DSurface;
|
---|
2625 | IWineD3DSurface_AddRef(*surface);
|
---|
2626 |
|
---|
2627 | d3d_surface->container = (IUnknown *)This;
|
---|
2628 | /* Implicit surfaces are created with an refcount of 0 */
|
---|
2629 | IUnknown_Release((IUnknown *)d3d_surface);
|
---|
2630 |
|
---|
2631 | return hr;
|
---|
2632 | }
|
---|
2633 |
|
---|
2634 | static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
|
---|
2635 | IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
|
---|
2636 | DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
|
---|
2637 | {
|
---|
2638 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2639 | IDirect3DSurface8Impl *d3d_surface;
|
---|
2640 | HRESULT hr;
|
---|
2641 |
|
---|
2642 | TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
|
---|
2643 | "\tmultisample_quality %u, discard %u, surface %p\n",
|
---|
2644 | iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
|
---|
2645 |
|
---|
2646 | hr = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)This, width, height,
|
---|
2647 | d3dformat_from_wined3dformat(format), multisample_type, (IDirect3DSurface8 **)&d3d_surface);
|
---|
2648 | if (FAILED(hr))
|
---|
2649 | {
|
---|
2650 | ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
|
---|
2651 | return hr;
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | *surface = d3d_surface->wineD3DSurface;
|
---|
2655 | IWineD3DSurface_AddRef(*surface);
|
---|
2656 |
|
---|
2657 | d3d_surface->container = (IUnknown *)This;
|
---|
2658 | /* Implicit surfaces are created with an refcount of 0 */
|
---|
2659 | IUnknown_Release((IUnknown *)d3d_surface);
|
---|
2660 |
|
---|
2661 | return hr;
|
---|
2662 | }
|
---|
2663 |
|
---|
2664 | static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
|
---|
2665 | IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
|
---|
2666 | WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
|
---|
2667 | {
|
---|
2668 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2669 | IDirect3DVolume8Impl *object;
|
---|
2670 | HRESULT hr;
|
---|
2671 |
|
---|
2672 | TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
|
---|
2673 | iface, superior, width, height, depth, format, pool, usage, volume);
|
---|
2674 |
|
---|
2675 | /* Allocate the storage for the device */
|
---|
2676 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
---|
2677 | if (!object)
|
---|
2678 | {
|
---|
2679 | FIXME("Allocation of memory failed\n");
|
---|
2680 | *volume = NULL;
|
---|
2681 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
2682 | }
|
---|
2683 |
|
---|
2684 | hr = volume_init(object, This, width, height, depth, usage, format, pool);
|
---|
2685 | if (FAILED(hr))
|
---|
2686 | {
|
---|
2687 | WARN("Failed to initialize volume, hr %#x.\n", hr);
|
---|
2688 | HeapFree(GetProcessHeap(), 0, object);
|
---|
2689 | return hr;
|
---|
2690 | }
|
---|
2691 |
|
---|
2692 | *volume = object->wineD3DVolume;
|
---|
2693 | IWineD3DVolume_AddRef(*volume);
|
---|
2694 | IDirect3DVolume8_Release((IDirect3DVolume8 *)object);
|
---|
2695 |
|
---|
2696 | object->container = superior;
|
---|
2697 | object->forwardReference = superior;
|
---|
2698 |
|
---|
2699 | TRACE("(%p) Created volume %p\n", iface, object);
|
---|
2700 |
|
---|
2701 | return hr;
|
---|
2702 | }
|
---|
2703 |
|
---|
2704 | static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
|
---|
2705 | WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
|
---|
2706 | {
|
---|
2707 | struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
|
---|
2708 | IDirect3DSwapChain8Impl *d3d_swapchain;
|
---|
2709 | D3DPRESENT_PARAMETERS local_parameters;
|
---|
2710 | HRESULT hr;
|
---|
2711 |
|
---|
2712 | TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
|
---|
2713 |
|
---|
2714 | /* Copy the presentation parameters */
|
---|
2715 | local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
|
---|
2716 | local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
|
---|
2717 | local_parameters.BackBufferFormat = d3dformat_from_wined3dformat(present_parameters->BackBufferFormat);
|
---|
2718 | local_parameters.BackBufferCount = present_parameters->BackBufferCount;
|
---|
2719 | local_parameters.MultiSampleType = present_parameters->MultiSampleType;
|
---|
2720 | local_parameters.SwapEffect = present_parameters->SwapEffect;
|
---|
2721 | local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
|
---|
2722 | local_parameters.Windowed = present_parameters->Windowed;
|
---|
2723 | local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
|
---|
2724 | local_parameters.AutoDepthStencilFormat = d3dformat_from_wined3dformat(present_parameters->AutoDepthStencilFormat);
|
---|
2725 | local_parameters.Flags = present_parameters->Flags;
|
---|
2726 | local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
|
---|
2727 | local_parameters.FullScreen_PresentationInterval = present_parameters->PresentationInterval;
|
---|
2728 |
|
---|
2729 | hr = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)This,
|
---|
2730 | &local_parameters, (IDirect3DSwapChain8 **)&d3d_swapchain);
|
---|
2731 | if (FAILED(hr))
|
---|
2732 | {
|
---|
2733 | ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
|
---|
2734 | *swapchain = NULL;
|
---|
2735 | return hr;
|
---|
2736 | }
|
---|
2737 |
|
---|
2738 | *swapchain = d3d_swapchain->wineD3DSwapChain;
|
---|
2739 | IUnknown_Release(d3d_swapchain->parentDevice);
|
---|
2740 | d3d_swapchain->parentDevice = NULL;
|
---|
2741 |
|
---|
2742 | /* Copy back the presentation parameters */
|
---|
2743 | present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
|
---|
2744 | present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
|
---|
2745 | present_parameters->BackBufferFormat = wined3dformat_from_d3dformat(local_parameters.BackBufferFormat);
|
---|
2746 | present_parameters->BackBufferCount = local_parameters.BackBufferCount;
|
---|
2747 | present_parameters->MultiSampleType = local_parameters.MultiSampleType;
|
---|
2748 | present_parameters->SwapEffect = local_parameters.SwapEffect;
|
---|
2749 | present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
|
---|
2750 | present_parameters->Windowed = local_parameters.Windowed;
|
---|
2751 | present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
|
---|
2752 | present_parameters->AutoDepthStencilFormat = wined3dformat_from_d3dformat(local_parameters.AutoDepthStencilFormat);
|
---|
2753 | present_parameters->Flags = local_parameters.Flags;
|
---|
2754 | present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
|
---|
2755 | present_parameters->PresentationInterval = local_parameters.FullScreen_PresentationInterval;
|
---|
2756 |
|
---|
2757 | return hr;
|
---|
2758 | }
|
---|
2759 |
|
---|
2760 | static const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
|
---|
2761 | {
|
---|
2762 | /* IUnknown methods */
|
---|
2763 | device_parent_QueryInterface,
|
---|
2764 | device_parent_AddRef,
|
---|
2765 | device_parent_Release,
|
---|
2766 | /* IWineD3DDeviceParent methods */
|
---|
2767 | device_parent_WineD3DDeviceCreated,
|
---|
2768 | device_parent_CreateSurface,
|
---|
2769 | device_parent_CreateRenderTarget,
|
---|
2770 | device_parent_CreateDepthStencilSurface,
|
---|
2771 | device_parent_CreateVolume,
|
---|
2772 | device_parent_CreateSwapChain,
|
---|
2773 | };
|
---|
2774 |
|
---|
2775 | HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapter,
|
---|
2776 | D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters)
|
---|
2777 | {
|
---|
2778 | WINED3DPRESENT_PARAMETERS wined3d_parameters;
|
---|
2779 | HRESULT hr;
|
---|
2780 |
|
---|
2781 | device->lpVtbl = &Direct3DDevice8_Vtbl;
|
---|
2782 | device->device_parent_vtbl = &d3d8_wined3d_device_parent_vtbl;
|
---|
2783 | device->ref = 1;
|
---|
2784 | device->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
2785 | D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*device->handle_table.entries));
|
---|
2786 | if (!device->handle_table.entries)
|
---|
2787 | {
|
---|
2788 | ERR("Failed to allocate handle table memory.\n");
|
---|
2789 | return E_OUTOFMEMORY;
|
---|
2790 | }
|
---|
2791 | device->handle_table.table_size = D3D8_INITIAL_HANDLE_TABLE_SIZE;
|
---|
2792 |
|
---|
2793 | wined3d_mutex_lock();
|
---|
2794 | hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags, (IUnknown *)device,
|
---|
2795 | (IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
|
---|
2796 | if (FAILED(hr))
|
---|
2797 | {
|
---|
2798 | WARN("Failed to create wined3d device, hr %#x.\n", hr);
|
---|
2799 | wined3d_mutex_unlock();
|
---|
2800 | HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
---|
2801 | return hr;
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 | if (!parameters->Windowed)
|
---|
2805 | {
|
---|
2806 | if (!focus_window) focus_window = parameters->hDeviceWindow;
|
---|
2807 | if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
|
---|
2808 | {
|
---|
2809 | ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
---|
2810 | IWineD3DDevice_Release(device->WineD3DDevice);
|
---|
2811 | wined3d_mutex_unlock();
|
---|
2812 | HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
---|
2813 | return hr;
|
---|
2814 | }
|
---|
2815 | }
|
---|
2816 |
|
---|
2817 | if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
|
---|
2818 |
|
---|
2819 | wined3d_parameters.BackBufferWidth = parameters->BackBufferWidth;
|
---|
2820 | wined3d_parameters.BackBufferHeight = parameters->BackBufferHeight;
|
---|
2821 | wined3d_parameters.BackBufferFormat = wined3dformat_from_d3dformat(parameters->BackBufferFormat);
|
---|
2822 | wined3d_parameters.BackBufferCount = parameters->BackBufferCount;
|
---|
2823 | wined3d_parameters.MultiSampleType = parameters->MultiSampleType;
|
---|
2824 | wined3d_parameters.MultiSampleQuality = 0; /* d3d9 only */
|
---|
2825 | wined3d_parameters.SwapEffect = parameters->SwapEffect;
|
---|
2826 | wined3d_parameters.hDeviceWindow = parameters->hDeviceWindow;
|
---|
2827 | wined3d_parameters.Windowed = parameters->Windowed;
|
---|
2828 | wined3d_parameters.EnableAutoDepthStencil = parameters->EnableAutoDepthStencil;
|
---|
2829 | wined3d_parameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(parameters->AutoDepthStencilFormat);
|
---|
2830 | wined3d_parameters.Flags = parameters->Flags;
|
---|
2831 | wined3d_parameters.FullScreen_RefreshRateInHz = parameters->FullScreen_RefreshRateInHz;
|
---|
2832 | wined3d_parameters.PresentationInterval = parameters->FullScreen_PresentationInterval;
|
---|
2833 | wined3d_parameters.AutoRestoreDisplayMode = TRUE;
|
---|
2834 |
|
---|
2835 | hr = IWineD3DDevice_Init3D(device->WineD3DDevice, &wined3d_parameters);
|
---|
2836 | if (FAILED(hr))
|
---|
2837 | {
|
---|
2838 | WARN("Failed to initialize 3D, hr %#x.\n", hr);
|
---|
2839 | IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
---|
2840 | IWineD3DDevice_Release(device->WineD3DDevice);
|
---|
2841 | wined3d_mutex_unlock();
|
---|
2842 | HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
---|
2843 | return hr;
|
---|
2844 | }
|
---|
2845 |
|
---|
2846 | hr = IWineD3DDevice_SetRenderState(device->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
|
---|
2847 | wined3d_mutex_unlock();
|
---|
2848 | if (FAILED(hr))
|
---|
2849 | {
|
---|
2850 | ERR("Failed to set minimum pointsize, hr %#x.\n", hr);
|
---|
2851 | goto err;
|
---|
2852 | }
|
---|
2853 |
|
---|
2854 | parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
|
---|
2855 | parameters->BackBufferHeight = wined3d_parameters.BackBufferHeight;
|
---|
2856 | parameters->BackBufferFormat = d3dformat_from_wined3dformat(wined3d_parameters.BackBufferFormat);
|
---|
2857 | parameters->BackBufferCount = wined3d_parameters.BackBufferCount;
|
---|
2858 | parameters->MultiSampleType = wined3d_parameters.MultiSampleType;
|
---|
2859 | parameters->SwapEffect = wined3d_parameters.SwapEffect;
|
---|
2860 | parameters->hDeviceWindow = wined3d_parameters.hDeviceWindow;
|
---|
2861 | parameters->Windowed = wined3d_parameters.Windowed;
|
---|
2862 | parameters->EnableAutoDepthStencil = wined3d_parameters.EnableAutoDepthStencil;
|
---|
2863 | parameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(wined3d_parameters.AutoDepthStencilFormat);
|
---|
2864 | parameters->Flags = wined3d_parameters.Flags;
|
---|
2865 | parameters->FullScreen_RefreshRateInHz = wined3d_parameters.FullScreen_RefreshRateInHz;
|
---|
2866 | parameters->FullScreen_PresentationInterval = wined3d_parameters.PresentationInterval;
|
---|
2867 |
|
---|
2868 | device->declArraySize = 16;
|
---|
2869 | device->decls = HeapAlloc(GetProcessHeap(), 0, device->declArraySize * sizeof(*device->decls));
|
---|
2870 | if (!device->decls)
|
---|
2871 | {
|
---|
2872 | ERR("Failed to allocate FVF vertex delcaration map memory.\n");
|
---|
2873 | hr = E_OUTOFMEMORY;
|
---|
2874 | goto err;
|
---|
2875 | }
|
---|
2876 |
|
---|
2877 | return D3D_OK;
|
---|
2878 |
|
---|
2879 | err:
|
---|
2880 | wined3d_mutex_lock();
|
---|
2881 | IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D8CB_DestroySwapChain);
|
---|
2882 | IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
|
---|
2883 | IWineD3DDevice_Release(device->WineD3DDevice);
|
---|
2884 | wined3d_mutex_unlock();
|
---|
2885 | HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
|
---|
2886 | return hr;
|
---|
2887 | }
|
---|