ReactOS 0.4.17-dev-966-gf06eace
device.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1998-2004 Lionel Ulmer
3 * Copyright (c) 2002-2005 Christian Costa
4 * Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
5 * Copyright (c) 2008 Alexander Dorofeyev
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 * IDirect3DDevice implementation, version 1, 2, 3 and 7. Rendering is relayed
22 * to WineD3D, some minimal DirectDraw specific management is handled here.
23 * The Direct3DDevice is NOT the parent of the WineD3DDevice, because d3d
24 * is initialized when DirectDraw creates the primary surface.
25 * Some type management is necessary, because some D3D types changed between
26 * D3D7 and D3D9.
27 *
28 */
29
30#include "ddraw_private.h"
31
34
35/* The device ID */
37 0xaef72d43,
38 0xb09a,
39 0x4b7b,
40 { 0xb7,0x98,0xc6,0x8a,0x77,0x2d,0x72,0x2a }
41};
42
43static inline void set_fpu_control_word(WORD fpucw)
44{
45#if defined(__i386__) && defined(_MSC_VER)
46 __asm fldcw fpucw;
47#elif defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__) && (defined(__GNUC__) || defined(__clang__)))
48 __asm__ volatile ("fldcw %0" : : "m" (fpucw));
49#endif
50}
51
52static inline WORD d3d_fpu_setup(void)
53{
54 WORD oldcw;
55
56#if defined(__i386__) && defined(_MSC_VER)
57 __asm fnstcw oldcw;
58#elif defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__) && (defined(__GNUC__) || defined(__clang__)))
59 __asm__ volatile ("fnstcw %0" : "=m" (oldcw));
60#else
61 static BOOL warned = FALSE;
62 if(!warned)
63 {
64 FIXME("FPUPRESERVE not implemented for this platform / compiler\n");
65 warned = TRUE;
66 }
67 return 0;
68#endif
69
71
72 return oldcw;
73}
74
76{
77 switch (state)
78 {
83 default:
84 return (enum wined3d_render_state)state;
85 }
86}
87
89{
90 switch (state)
91 {
100 default:
101 return (enum wined3d_transform_state)state;
102 }
103}
104
106{
107 return (enum wined3d_primitive_type)type;
108}
109
111{
112 return (enum wined3d_stateblock_type)type;
113}
114
115static inline struct d3d_device *impl_from_IUnknown(IUnknown *iface)
116{
117 return CONTAINING_RECORD(iface, struct d3d_device, IUnknown_inner);
118}
119
121{
122 struct d3d_device *device = impl_from_IUnknown(iface);
123
124 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
125
126 if (!riid)
127 {
128 *out = NULL;
129 return DDERR_INVALIDPARAMS;
130 }
131
133 {
134 IDirect3DDevice7_AddRef(&device->IDirect3DDevice7_iface);
135 *out = &device->IDirect3DDevice7_iface;
136 return S_OK;
137 }
138
139 if (device->version == 7)
140 {
141 if (IsEqualGUID(&IID_IDirect3DDevice7, riid))
142 {
143 IDirect3DDevice7_AddRef(&device->IDirect3DDevice7_iface);
144 *out = &device->IDirect3DDevice7_iface;
145 return S_OK;
146 }
147 }
148 else
149 {
150 if (IsEqualGUID(&IID_IDirect3DDevice3, riid) && device->version == 3)
151 {
152 IDirect3DDevice3_AddRef(&device->IDirect3DDevice3_iface);
153 *out = &device->IDirect3DDevice3_iface;
154 return S_OK;
155 }
156
157 if (IsEqualGUID(&IID_IDirect3DDevice2, riid) && device->version >= 2)
158 {
159 IDirect3DDevice2_AddRef(&device->IDirect3DDevice2_iface);
160 *out = &device->IDirect3DDevice2_iface;
161 return S_OK;
162 }
163
164 if (IsEqualGUID(&IID_IDirect3DDevice, riid))
165 {
166 IDirect3DDevice_AddRef(&device->IDirect3DDevice_iface);
167 *out = &device->IDirect3DDevice_iface;
168 return S_OK;
169 }
170 }
171
172 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
173
174 *out = NULL;
175 return E_NOINTERFACE;
176}
177
178static HRESULT WINAPI d3d_device7_QueryInterface(IDirect3DDevice7 *iface, REFIID riid, void **out)
179{
181
182 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
183
184 return IUnknown_QueryInterface(device->outer_unknown, riid, out);
185}
186
187static HRESULT WINAPI d3d_device3_QueryInterface(IDirect3DDevice3 *iface, REFIID riid, void **out)
188{
190
191 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
192
193 return IUnknown_QueryInterface(device->outer_unknown, riid, out);
194}
195
196static HRESULT WINAPI d3d_device2_QueryInterface(IDirect3DDevice2 *iface, REFIID riid, void **out)
197{
199
200 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
201
202 return IUnknown_QueryInterface(device->outer_unknown, riid, out);
203}
204
205static HRESULT WINAPI d3d_device1_QueryInterface(IDirect3DDevice *iface, REFIID riid, void **out)
206{
208
209 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
210
211 return IUnknown_QueryInterface(device->outer_unknown, riid, out);
212}
213
215{
216 struct d3d_device *device = impl_from_IUnknown(iface);
218
219 TRACE("%p increasing refcount to %lu.\n", device, ref);
220
221 return ref;
222}
223
224static ULONG WINAPI d3d_device7_AddRef(IDirect3DDevice7 *iface)
225{
227
228 TRACE("iface %p.\n", iface);
229
230 return IUnknown_AddRef(device->outer_unknown);
231}
232
233static ULONG WINAPI d3d_device3_AddRef(IDirect3DDevice3 *iface)
234{
236
237 TRACE("iface %p.\n", iface);
238
239 return IUnknown_AddRef(device->outer_unknown);
240}
241
242static ULONG WINAPI d3d_device2_AddRef(IDirect3DDevice2 *iface)
243{
245
246 TRACE("iface %p.\n", iface);
247
248 return IUnknown_AddRef(device->outer_unknown);
249}
250
251static ULONG WINAPI d3d_device1_AddRef(IDirect3DDevice *iface)
252{
254
255 TRACE("iface %p.\n", iface);
256
257 return IUnknown_AddRef(device->outer_unknown);
258}
259
261{
262 struct d3d_device *This = impl_from_IUnknown(iface);
265
266 TRACE("%p decreasing refcount to %lu.\n", This, ref);
267
268 /* This method doesn't destroy the wined3d device, because it's still in
269 * use for 2D rendering. IDirectDrawSurface7::Release will destroy the
270 * wined3d device when the render target is released. */
271 if (!ref)
272 {
273 static struct wined3d_rendertarget_view *const null_rtv;
274 DWORD i;
275 struct list *vp_entry, *vp_entry2;
276
278
279 /* There is no need to unset any resources here, wined3d will take
280 * care of that on uninit_3d(). */
281
283 wined3d_streaming_buffer_cleanup(&This->vertex_buffer);
284
285 wined3d_device_context_set_rendertarget_views(This->immediate_context, 0, 1, &null_rtv, FALSE);
286
287 /* Release the wined3d device. This won't destroy it. */
288 if (!wined3d_device_decref(This->wined3d_device))
289 ERR("The wined3d device (%p) was destroyed unexpectedly.\n", This->wined3d_device);
290
291 /* The texture handles should be unset by now, but there might be some bits
292 * missing in our reference counting(needs test). Do a sanity check. */
293 for (i = 0; i < This->handle_table.entry_count; ++i)
294 {
295 struct ddraw_handle_entry *entry = &This->handle_table.entries[i];
296
297 switch (entry->type)
298 {
300 break;
301
303 {
304 /* No FIXME here because this might happen because of sloppy applications. */
305 WARN("Leftover stateblock handle %#lx (%p), deleting.\n", i + 1, entry->object);
306 IDirect3DDevice7_DeleteStateBlock(&This->IDirect3DDevice7_iface, i + 1);
307 break;
308 }
309
310 default:
311 FIXME("Handle %#lx (%p) has unknown type %#x.\n", i + 1, entry->object, entry->type);
312 break;
313 }
314 }
315
316 ddraw_handle_table_destroy(&This->handle_table);
317
318 LIST_FOR_EACH_SAFE(vp_entry, vp_entry2, &This->viewport_list)
319 {
320 struct d3d_viewport *vp = LIST_ENTRY(vp_entry, struct d3d_viewport, entry);
321 IDirect3DDevice3_DeleteViewport(&This->IDirect3DDevice3_iface, &vp->IDirect3DViewport3_iface);
322 }
323
325 if (This->recording)
327
328 /* Releasing the render target below may release the last reference to the ddraw object. Detach
329 * the device from it before so it doesn't try to save / restore state on the teared down device. */
330 if (This->ddraw)
331 {
332 if (This->ddraw->device_last_applied_state == This)
333 This->ddraw->device_last_applied_state = NULL;
334 list_remove(&This->ddraw_entry);
335 This->ddraw = NULL;
336 }
337
338 TRACE("Releasing render target %p.\n", This->rt_iface);
339 rt_iface = This->rt_iface;
340 This->rt_iface = NULL;
341 This->target = NULL;
342 This->target_ds = NULL;
343 if (This->version != 1)
344 IUnknown_Release(rt_iface);
345 TRACE("Render target release done.\n");
346
347 /* Now free the structure */
348 free(This);
350 }
351
352 TRACE("Done\n");
353 return ref;
354}
355
356static ULONG WINAPI d3d_device7_Release(IDirect3DDevice7 *iface)
357{
359
360 TRACE("iface %p.\n", iface);
361
362 return IUnknown_Release(device->outer_unknown);
363}
364
365static ULONG WINAPI d3d_device3_Release(IDirect3DDevice3 *iface)
366{
368
369 TRACE("iface %p.\n", iface);
370
371 return IUnknown_Release(device->outer_unknown);
372}
373
374static ULONG WINAPI d3d_device2_Release(IDirect3DDevice2 *iface)
375{
377
378 TRACE("iface %p.\n", iface);
379
380 return IUnknown_Release(device->outer_unknown);
381}
382
383static ULONG WINAPI d3d_device1_Release(IDirect3DDevice *iface)
384{
386
387 TRACE("iface %p.\n", iface);
388
389 return IUnknown_Release(device->outer_unknown);
390}
391
392/*****************************************************************************
393 * IDirect3DDevice Methods
394 *****************************************************************************/
395
396/*****************************************************************************
397 * IDirect3DDevice::Initialize
398 *
399 * Initializes a Direct3DDevice. This implementation is a no-op, as all
400 * initialization is done at create time.
401 *
402 * Exists in Version 1
403 *
404 * Parameters:
405 * No idea what they mean, as the MSDN page is gone
406 *
407 * Returns: DD_OK
408 *
409 *****************************************************************************/
410static HRESULT WINAPI d3d_device1_Initialize(IDirect3DDevice *iface,
411 IDirect3D *d3d, GUID *guid, D3DDEVICEDESC *device_desc)
412{
413 /* It shouldn't be crucial, but print a FIXME, I'm interested if
414 * any game calls it and when. */
415 FIXME("iface %p, d3d %p, guid %s, device_desc %p nop!\n",
416 iface, d3d, debugstr_guid(guid), device_desc);
417
418 return D3D_OK;
419}
420
421static HRESULT d3d_device7_GetCaps(IDirect3DDevice7 *iface, D3DDEVICEDESC7 *device_desc)
422{
424
425 TRACE("iface %p, device_desc %p.\n", iface, device_desc);
426
427 if (!device_desc)
428 {
429 WARN("device_desc is NULL, returning DDERR_INVALIDPARAMS.\n");
430 return DDERR_INVALIDPARAMS;
431 }
432
433 /* Call the same function used by IDirect3D, this saves code */
434 return ddraw_get_d3dcaps(device->ddraw, device_desc);
435}
436
438{
439 return d3d_device7_GetCaps(iface, desc);
440}
441
443{
444 HRESULT hr;
445 WORD old_fpucw;
446
447 old_fpucw = d3d_fpu_setup();
448 hr = d3d_device7_GetCaps(iface, desc);
449 set_fpu_control_word(old_fpucw);
450
451 return hr;
452}
453/*****************************************************************************
454 * IDirect3DDevice3::GetCaps
455 *
456 * Retrieves the capabilities of the hardware device and the emulation
457 * device. For Wine, hardware and emulation are the same (it's all HW).
458 *
459 * This implementation is used for Version 1, 2, and 3. Version 7 has its own
460 *
461 * Parameters:
462 * HWDesc: Structure to fill with the HW caps
463 * HelDesc: Structure to fill with the hardware emulation caps
464 *
465 * Returns:
466 * D3D_OK on success
467 * D3DERR_* if a problem occurs. See WineD3D
468 *
469 *****************************************************************************/
470
471/* There are 3 versions of D3DDEVICEDESC. All 3 share the same name because
472 * Microsoft just expanded the existing structure without naming them
473 * D3DDEVICEDESC2 and D3DDEVICEDESC3. Which version is used have depends
474 * on the version of the DirectX SDK. DirectX 6+ and Wine use the latest
475 * one with 252 bytes.
476 *
477 * All 3 versions are allowed as parameters and only the specified amount of
478 * bytes is written.
479 *
480 * Note that Direct3D7 and earlier are not available in native Win64
481 * ddraw.dll builds, so possible size differences between 32 bit and
482 * 64 bit are a non-issue.
483 */
485{
486 if (size == FIELD_OFFSET(D3DDEVICEDESC, dwMinTextureWidth) /* 172 */
487 || size == FIELD_OFFSET(D3DDEVICEDESC, dwMaxTextureRepeat) /* 204 */
488 || size == sizeof(D3DDEVICEDESC) /* 252 */) return TRUE;
489 return FALSE;
490}
491
492static HRESULT WINAPI d3d_device3_GetCaps(IDirect3DDevice3 *iface,
493 D3DDEVICEDESC *HWDesc, D3DDEVICEDESC *HelDesc)
494{
496 D3DDEVICEDESC7 desc7;
497 D3DDEVICEDESC desc1;
498 HRESULT hr;
499
500 TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, HWDesc, HelDesc);
501
502 if (!HWDesc)
503 {
504 WARN("HWDesc is NULL, returning DDERR_INVALIDPARAMS.\n");
505 return DDERR_INVALIDPARAMS;
506 }
507 if (!check_d3ddevicedesc_size(HWDesc->dwSize))
508 {
509 WARN("HWDesc->dwSize is %lu, returning DDERR_INVALIDPARAMS.\n", HWDesc->dwSize);
510 return DDERR_INVALIDPARAMS;
511 }
512 if (!HelDesc)
513 {
514 WARN("HelDesc is NULL, returning DDERR_INVALIDPARAMS.\n");
515 return DDERR_INVALIDPARAMS;
516 }
517 if (!check_d3ddevicedesc_size(HelDesc->dwSize))
518 {
519 WARN("HelDesc->dwSize is %lu, returning DDERR_INVALIDPARAMS.\n", HelDesc->dwSize);
520 return DDERR_INVALIDPARAMS;
521 }
522
523 if (FAILED(hr = ddraw_get_d3dcaps(device->ddraw, &desc7)))
524 return hr;
525
526 ddraw_d3dcaps1_from_7(&desc1, &desc7);
527 DD_STRUCT_COPY_BYSIZE(HWDesc, &desc1);
528 DD_STRUCT_COPY_BYSIZE(HelDesc, &desc1);
529 return D3D_OK;
530}
531
532static HRESULT WINAPI d3d_device2_GetCaps(IDirect3DDevice2 *iface,
533 D3DDEVICEDESC *hw_desc, D3DDEVICEDESC *hel_desc)
534{
536
537 TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, hw_desc, hel_desc);
538
539 return d3d_device3_GetCaps(&device->IDirect3DDevice3_iface, hw_desc, hel_desc);
540}
541
542static HRESULT WINAPI d3d_device1_GetCaps(IDirect3DDevice *iface,
543 D3DDEVICEDESC *hw_desc, D3DDEVICEDESC *hel_desc)
544{
546
547 TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, hw_desc, hel_desc);
548
549 return d3d_device3_GetCaps(&device->IDirect3DDevice3_iface, hw_desc, hel_desc);
550}
551
552/*****************************************************************************
553 * IDirect3DDevice2::SwapTextureHandles
554 *
555 * Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
556 *
557 * Parameters:
558 * Tex1, Tex2: The 2 Textures to swap
559 *
560 * Returns:
561 * D3D_OK
562 *
563 *****************************************************************************/
564static HRESULT WINAPI d3d_device2_SwapTextureHandles(IDirect3DDevice2 *iface,
565 IDirect3DTexture2 *tex1, IDirect3DTexture2 *tex2)
566{
569 DWORD h1, h2, h;
570 HRESULT hr;
571
572 TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, tex1, tex2);
573
574 if (!surf1->Handle || !surf2->Handle)
575 return E_INVALIDARG;
576
578 return hr;
579
581
582 h1 = surf1->Handle - 1;
583 h2 = surf2->Handle - 1;
584 global_handle_table.entries[h1].object = surf2;
585 global_handle_table.entries[h2].object = surf1;
586 surf2->Handle = h1 + 1;
587 surf1->Handle = h2 + 1;
588
590
591 if ((h == surf1->Handle || h == surf2->Handle)
593 return hr;
594 return D3D_OK;
595}
596
597static HRESULT WINAPI d3d_device1_SwapTextureHandles(IDirect3DDevice *iface,
598 IDirect3DTexture *tex1, IDirect3DTexture *tex2)
599{
603 IDirect3DTexture2 *t1 = surf1 ? &surf1->IDirect3DTexture2_iface : NULL;
604 IDirect3DTexture2 *t2 = surf2 ? &surf2->IDirect3DTexture2_iface : NULL;
605
606 TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, tex1, tex2);
607
608 return d3d_device2_SwapTextureHandles(&device->IDirect3DDevice2_iface, t1, t2);
609}
610
611/*****************************************************************************
612 * IDirect3DDevice3::GetStats
613 *
614 * This method seems to retrieve some stats from the device.
615 * The MSDN documentation doesn't exist any more, but the D3DSTATS
616 * structure suggests that the amount of drawn primitives and processed
617 * vertices is returned.
618 *
619 * Exists in Version 1, 2 and 3
620 *
621 * Parameters:
622 * Stats: Pointer to a D3DSTATS structure to be filled
623 *
624 * Returns:
625 * D3D_OK on success
626 * DDERR_INVALIDPARAMS if Stats == NULL
627 *
628 *****************************************************************************/
629static HRESULT WINAPI d3d_device3_GetStats(IDirect3DDevice3 *iface, D3DSTATS *Stats)
630{
631 FIXME("iface %p, stats %p stub!\n", iface, Stats);
632
633 if(!Stats)
634 return DDERR_INVALIDPARAMS;
635
636 /* Fill the Stats with 0 */
637 Stats->dwTrianglesDrawn = 0;
638 Stats->dwLinesDrawn = 0;
639 Stats->dwPointsDrawn = 0;
640 Stats->dwSpansDrawn = 0;
641 Stats->dwVerticesProcessed = 0;
642
643 return D3D_OK;
644}
645
646static HRESULT WINAPI d3d_device2_GetStats(IDirect3DDevice2 *iface, D3DSTATS *stats)
647{
649
650 TRACE("iface %p, stats %p.\n", iface, stats);
651
652 return d3d_device3_GetStats(&device->IDirect3DDevice3_iface, stats);
653}
654
655static HRESULT WINAPI d3d_device1_GetStats(IDirect3DDevice *iface, D3DSTATS *stats)
656{
658
659 TRACE("iface %p, stats %p.\n", iface, stats);
660
661 return d3d_device3_GetStats(&device->IDirect3DDevice3_iface, stats);
662}
663
664/*****************************************************************************
665 * IDirect3DDevice::CreateExecuteBuffer
666 *
667 * Creates an IDirect3DExecuteBuffer, used for rendering with a
668 * Direct3DDevice.
669 *
670 * Version 1 only.
671 *
672 * Params:
673 * Desc: Buffer description
674 * ExecuteBuffer: Address to return the Interface pointer at
675 * UnkOuter: Must be NULL. Basically for aggregation, which ddraw doesn't
676 * support
677 *
678 * Returns:
679 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
680 * DDERR_OUTOFMEMORY if we ran out of memory
681 * D3D_OK on success
682 *
683 *****************************************************************************/
684static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface,
685 D3DEXECUTEBUFFERDESC *buffer_desc, IDirect3DExecuteBuffer **ExecuteBuffer, IUnknown *outer_unknown)
686{
689 HRESULT hr;
690
691 TRACE("iface %p, buffer_desc %p, buffer %p, outer_unknown %p.\n",
692 iface, buffer_desc, ExecuteBuffer, outer_unknown);
693
694 if (outer_unknown)
696
697 /* Allocate the new Execute Buffer */
698 if (!(object = calloc(1, sizeof(*object))))
699 {
700 ERR("Failed to allocate execute buffer memory.\n");
701 return DDERR_OUTOFMEMORY;
702 }
703
704 hr = d3d_execute_buffer_init(object, device, buffer_desc);
705 if (FAILED(hr))
706 {
707 WARN("Failed to initialize execute buffer, hr %#lx.\n", hr);
708 free(object);
709 return hr;
710 }
711
712 *ExecuteBuffer = &object->IDirect3DExecuteBuffer_iface;
713
714 TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer, object);
715
716 return D3D_OK;
717}
718
719/*****************************************************************************
720 * IDirect3DDevice::Execute
721 *
722 * Executes all the stuff in an execute buffer.
723 *
724 * Params:
725 * ExecuteBuffer: The buffer to execute
726 * Viewport: The viewport used for rendering
727 * Flags: Some flags
728 *
729 * Returns:
730 * DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
731 * D3D_OK on success
732 *
733 *****************************************************************************/
734static HRESULT WINAPI d3d_device1_Execute(IDirect3DDevice *iface,
735 IDirect3DExecuteBuffer *ExecuteBuffer, IDirect3DViewport *viewport, DWORD flags)
736{
739 struct d3d_viewport *viewport_impl = unsafe_impl_from_IDirect3DViewport(viewport);
740 HRESULT hr;
741
742 TRACE("iface %p, buffer %p, viewport %p, flags %#lx.\n", iface, ExecuteBuffer, viewport, flags);
743
744 if(!buffer)
745 return DDERR_INVALIDPARAMS;
746
748 (&device->IDirect3DDevice3_iface, &viewport_impl->IDirect3DViewport3_iface)))
749 return hr;
750
751 /* Execute... */
755
756 return hr;
757}
758
759/*****************************************************************************
760 * IDirect3DDevice3::AddViewport
761 *
762 * Add a Direct3DViewport to the device's viewport list. These viewports
763 * are wrapped to IDirect3DDevice7 viewports in viewport.c
764 *
765 * Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
766 * are the same interfaces.
767 *
768 * Params:
769 * Viewport: The viewport to add
770 *
771 * Returns:
772 * DDERR_INVALIDPARAMS if Viewport == NULL
773 * D3D_OK on success
774 *
775 *****************************************************************************/
776static HRESULT WINAPI d3d_device3_AddViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
777{
780
781 TRACE("iface %p, viewport %p.\n", iface, viewport);
782
783 /* Sanity check */
784 if(!vp)
785 return DDERR_INVALIDPARAMS;
786
789 list_add_head(&device->viewport_list, &vp->entry);
790 /* Viewport must be usable for Clear() after AddViewport, so set active_device here. */
791 vp->active_device = device;
793
794 return D3D_OK;
795}
796
797static HRESULT WINAPI d3d_device2_AddViewport(IDirect3DDevice2 *iface,
798 IDirect3DViewport2 *viewport)
799{
802
803 TRACE("iface %p, viewport %p.\n", iface, viewport);
804
805 return d3d_device3_AddViewport(&device->IDirect3DDevice3_iface, &vp->IDirect3DViewport3_iface);
806}
807
808static HRESULT WINAPI d3d_device1_AddViewport(IDirect3DDevice *iface, IDirect3DViewport *viewport)
809{
812
813 TRACE("iface %p, viewport %p.\n", iface, viewport);
814
815 return d3d_device3_AddViewport(&device->IDirect3DDevice3_iface, &vp->IDirect3DViewport3_iface);
816}
817
818/*****************************************************************************
819 * IDirect3DDevice3::DeleteViewport
820 *
821 * Deletes a Direct3DViewport from the device's viewport list.
822 *
823 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
824 * are equal.
825 *
826 * Params:
827 * Viewport: The viewport to delete
828 *
829 * Returns:
830 * D3D_OK on success
831 * DDERR_INVALIDPARAMS if the viewport wasn't found in the list
832 *
833 *****************************************************************************/
834static HRESULT WINAPI d3d_device3_DeleteViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
835{
838
839 TRACE("iface %p, viewport %p.\n", iface, viewport);
840
841 if (!vp)
842 {
843 WARN("NULL viewport, returning DDERR_INVALIDPARAMS\n");
844 return DDERR_INVALIDPARAMS;
845 }
846
848
849 if (vp->active_device != device)
850 {
851 WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
853 return DDERR_INVALIDPARAMS;
854 }
855
856 if (device->current_viewport == vp)
857 {
858 TRACE("Deleting current viewport, unsetting and releasing.\n");
859
862 device->current_viewport = NULL;
863 }
864
865 vp->active_device = NULL;
866 list_remove(&vp->entry);
867
869
871
872 return D3D_OK;
873}
874
875static HRESULT WINAPI d3d_device2_DeleteViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport)
876{
879
880 TRACE("iface %p, viewport %p.\n", iface, viewport);
881
882 return d3d_device3_DeleteViewport(&device->IDirect3DDevice3_iface,
883 vp ? &vp->IDirect3DViewport3_iface : NULL);
884}
885
886static HRESULT WINAPI d3d_device1_DeleteViewport(IDirect3DDevice *iface, IDirect3DViewport *viewport)
887{
890
891 TRACE("iface %p, viewport %p.\n", iface, viewport);
892
893 return d3d_device3_DeleteViewport(&device->IDirect3DDevice3_iface,
894 vp ? &vp->IDirect3DViewport3_iface : NULL);
895}
896
897/*****************************************************************************
898 * IDirect3DDevice3::NextViewport
899 *
900 * Returns a viewport from the viewport list, depending on the
901 * passed viewport and the flags.
902 *
903 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
904 * are equal.
905 *
906 * Params:
907 * Viewport: Viewport to use for beginning the search
908 * Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
909 *
910 * Returns:
911 * D3D_OK on success
912 * DDERR_INVALIDPARAMS if the flags were wrong, or Viewport was NULL
913 *
914 *****************************************************************************/
915static HRESULT WINAPI d3d_device3_NextViewport(IDirect3DDevice3 *iface,
916 IDirect3DViewport3 *Viewport3, IDirect3DViewport3 **lplpDirect3DViewport3, DWORD flags)
917{
920 struct d3d_viewport *next;
921 struct list *entry;
922
923 TRACE("iface %p, viewport %p, next %p, flags %#lx.\n",
924 iface, Viewport3, lplpDirect3DViewport3, flags);
925
926 if(!vp)
927 {
928 *lplpDirect3DViewport3 = NULL;
929 return DDERR_INVALIDPARAMS;
930 }
931
932
934 switch (flags)
935 {
936 case D3DNEXT_NEXT:
937 entry = list_next(&This->viewport_list, &vp->entry);
938 break;
939
940 case D3DNEXT_HEAD:
941 entry = list_head(&This->viewport_list);
942 break;
943
944 case D3DNEXT_TAIL:
945 entry = list_tail(&This->viewport_list);
946 break;
947
948 default:
949 WARN("Invalid flags %#lx.\n", flags);
950 *lplpDirect3DViewport3 = NULL;
952 return DDERR_INVALIDPARAMS;
953 }
954
955 if (entry)
956 {
958 *lplpDirect3DViewport3 = &next->IDirect3DViewport3_iface;
959 }
960 else
961 *lplpDirect3DViewport3 = NULL;
962
964
965 return D3D_OK;
966}
967
968static HRESULT WINAPI d3d_device2_NextViewport(IDirect3DDevice2 *iface,
969 IDirect3DViewport2 *viewport, IDirect3DViewport2 **next, DWORD flags)
970{
973 IDirect3DViewport3 *res;
974 HRESULT hr;
975
976 TRACE("iface %p, viewport %p, next %p, flags %#lx.\n",
977 iface, viewport, next, flags);
978
979 hr = d3d_device3_NextViewport(&device->IDirect3DDevice3_iface,
981 *next = (IDirect3DViewport2 *)res;
982 return hr;
983}
984
985static HRESULT WINAPI d3d_device1_NextViewport(IDirect3DDevice *iface,
986 IDirect3DViewport *viewport, IDirect3DViewport **next, DWORD flags)
987{
990 IDirect3DViewport3 *res;
991 HRESULT hr;
992
993 TRACE("iface %p, viewport %p, next %p, flags %#lx.\n",
994 iface, viewport, next, flags);
995
996 hr = d3d_device3_NextViewport(&device->IDirect3DDevice3_iface,
998 *next = (IDirect3DViewport *)res;
999 return hr;
1000}
1001
1002/*****************************************************************************
1003 * IDirect3DDevice::Pick
1004 *
1005 * Executes an execute buffer without performing rendering. Instead, a
1006 * list of primitives that intersect with (x1,y1) of the passed rectangle
1007 * is created. IDirect3DDevice::GetPickRecords can be used to retrieve
1008 * this list.
1009 *
1010 * Version 1 only
1011 *
1012 * Params:
1013 * ExecuteBuffer: Buffer to execute
1014 * Viewport: Viewport to use for execution
1015 * Flags: None are defined, according to the SDK
1016 * Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
1017 * x2 and y2 are ignored.
1018 *
1019 * Returns:
1020 * D3D_OK because it's a stub
1021 *
1022 *****************************************************************************/
1023static HRESULT WINAPI d3d_device1_Pick(IDirect3DDevice *iface, IDirect3DExecuteBuffer *buffer,
1024 IDirect3DViewport *viewport, DWORD flags, D3DRECT *rect)
1025{
1026 FIXME("iface %p, buffer %p, viewport %p, flags %#lx, rect %s stub!\n",
1027 iface, buffer, viewport, flags, wine_dbgstr_rect((RECT *)rect));
1028
1029 return D3D_OK;
1030}
1031
1032/*****************************************************************************
1033 * IDirect3DDevice::GetPickRecords
1034 *
1035 * Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
1036 *
1037 * Version 1 only
1038 *
1039 * Params:
1040 * Count: Pointer to a DWORD containing the numbers of pick records to
1041 * retrieve
1042 * D3DPickRec: Address to store the resulting D3DPICKRECORD array.
1043 *
1044 * Returns:
1045 * D3D_OK, because it's a stub
1046 *
1047 *****************************************************************************/
1048static HRESULT WINAPI d3d_device1_GetPickRecords(IDirect3DDevice *iface,
1049 DWORD *count, D3DPICKRECORD *records)
1050{
1051 FIXME("iface %p, count %p, records %p stub!\n", iface, count, records);
1052
1053 return D3D_OK;
1054}
1055
1056/*****************************************************************************
1057 * IDirect3DDevice7::EnumTextureformats
1058 *
1059 * Enumerates the supported texture formats. It checks against a list of all possible
1060 * formats to see if WineD3D supports it. If so, then it is passed to the app.
1061 *
1062 * This is for Version 7 and 3, older versions have a different
1063 * callback function and their own implementation
1064 *
1065 * Params:
1066 * Callback: Callback to call for each enumerated format
1067 * Arg: Argument to pass to the callback
1068 *
1069 * Returns:
1070 * D3D_OK on success
1071 * DDERR_INVALIDPARAMS if Callback == NULL
1072 *
1073 *****************************************************************************/
1074static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface,
1076{
1079 HRESULT hr;
1080 unsigned int i;
1081
1082 static const enum wined3d_format_id FormatList[] =
1083 {
1084 /* 16 bit */
1089 /* 32 bit */
1092 /* 8 bit */
1095 /* FOURCC codes */
1101 };
1102
1103 static const enum wined3d_format_id BumpFormatList[] =
1104 {
1110 };
1111
1112 TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
1113
1114 if (!callback)
1115 return DDERR_INVALIDPARAMS;
1116
1118
1119 memset(&mode, 0, sizeof(mode));
1120 if (FAILED(hr = wined3d_output_get_display_mode(device->ddraw->wined3d_output, &mode, NULL)))
1121 {
1123 WARN("Failed to get output display mode, hr %#lx.\n", hr);
1124 return hr;
1125 }
1126
1127 for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
1128 {
1129 if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
1131 WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
1132 {
1133 DDPIXELFORMAT pformat;
1134
1135 memset(&pformat, 0, sizeof(pformat));
1136 pformat.dwSize = sizeof(pformat);
1137 ddrawformat_from_wined3dformat(&pformat, FormatList[i]);
1138
1139 TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
1140 hr = callback(&pformat, context);
1141 if(hr != DDENUMRET_OK)
1142 {
1143 TRACE("Format enumeration cancelled by application\n");
1145 return D3D_OK;
1146 }
1147 }
1148 }
1149
1150 for (i = 0; i < ARRAY_SIZE(BumpFormatList); ++i)
1151 {
1152 if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
1155 {
1156 DDPIXELFORMAT pformat;
1157
1158 memset(&pformat, 0, sizeof(pformat));
1159 pformat.dwSize = sizeof(pformat);
1160 ddrawformat_from_wined3dformat(&pformat, BumpFormatList[i]);
1161
1162 TRACE("Enumerating WineD3DFormat %d\n", BumpFormatList[i]);
1163 hr = callback(&pformat, context);
1164 if(hr != DDENUMRET_OK)
1165 {
1166 TRACE("Format enumeration cancelled by application\n");
1168 return D3D_OK;
1169 }
1170 }
1171 }
1172 TRACE("End of enumeration\n");
1174
1175 return D3D_OK;
1176}
1177
1180{
1182}
1183
1186{
1187 HRESULT hr;
1188 WORD old_fpucw;
1189
1190 old_fpucw = d3d_fpu_setup();
1192 set_fpu_control_word(old_fpucw);
1193
1194 return hr;
1195}
1196
1197static HRESULT WINAPI d3d_device3_EnumTextureFormats(IDirect3DDevice3 *iface,
1199{
1201
1202 TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
1203
1204 return IDirect3DDevice7_EnumTextureFormats(&device->IDirect3DDevice7_iface, callback, context);
1205}
1206
1207/*****************************************************************************
1208 * IDirect3DDevice2::EnumTextureformats
1209 *
1210 * EnumTextureFormats for Version 1 and 2, see
1211 * IDirect3DDevice7::EnumTextureFormats for a more detailed description.
1212 *
1213 * This version has a different callback and does not enumerate FourCC
1214 * formats
1215 *
1216 *****************************************************************************/
1217static HRESULT WINAPI d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface,
1219{
1222 HRESULT hr;
1223 unsigned int i;
1224
1225 static const enum wined3d_format_id FormatList[] =
1226 {
1227 /* 16 bit */
1232 /* 32 bit */
1235 /* 8 bit */
1238 /* FOURCC codes - Not in this version*/
1239 };
1240
1241 TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
1242
1243 if (!callback)
1244 return DDERR_INVALIDPARAMS;
1245
1247
1248 memset(&mode, 0, sizeof(mode));
1249 if (FAILED(hr = wined3d_output_get_display_mode(device->ddraw->wined3d_output, &mode, NULL)))
1250 {
1252 WARN("Failed to get output display mode, hr %#lx.\n", hr);
1253 return hr;
1254 }
1255
1256 for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
1257 {
1258 if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
1260 WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
1261 {
1262 DDSURFACEDESC sdesc;
1263
1264 memset(&sdesc, 0, sizeof(sdesc));
1265 sdesc.dwSize = sizeof(sdesc);
1266 sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;
1267 sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
1268 sdesc.ddpfPixelFormat.dwSize = sizeof(sdesc.ddpfPixelFormat);
1269 ddrawformat_from_wined3dformat(&sdesc.ddpfPixelFormat, FormatList[i]);
1270
1271 TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
1272 hr = callback(&sdesc, context);
1273 if(hr != DDENUMRET_OK)
1274 {
1275 TRACE("Format enumeration cancelled by application\n");
1277 return D3D_OK;
1278 }
1279 }
1280 }
1281 TRACE("End of enumeration\n");
1283
1284 return D3D_OK;
1285}
1286
1287static HRESULT WINAPI d3d_device1_EnumTextureFormats(IDirect3DDevice *iface,
1289{
1291
1292 TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
1293
1294 return d3d_device2_EnumTextureFormats(&device->IDirect3DDevice2_iface, callback, context);
1295}
1296
1297/*****************************************************************************
1298 * IDirect3DDevice::CreateMatrix
1299 *
1300 * Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
1301 * allocated for the handle.
1302 *
1303 * Version 1 only
1304 *
1305 * Params
1306 * D3DMatHandle: Address to return the handle at
1307 *
1308 * Returns:
1309 * D3D_OK on success
1310 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1311 *
1312 *****************************************************************************/
1313static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DMatHandle)
1314{
1316 DWORD h;
1317
1318 TRACE("iface %p, matrix_handle %p.\n", iface, D3DMatHandle);
1319
1320 if(!D3DMatHandle)
1321 return DDERR_INVALIDPARAMS;
1322
1323 if (!(matrix = calloc(1, sizeof(*matrix))))
1324 {
1325 ERR("Out of memory when allocating a D3DMATRIX\n");
1326 return DDERR_OUTOFMEMORY;
1327 }
1328
1330
1332 if (h == DDRAW_INVALID_HANDLE)
1333 {
1334 ERR("Failed to allocate a matrix handle.\n");
1335 free(matrix);
1337 return DDERR_OUTOFMEMORY;
1338 }
1339
1340 *D3DMatHandle = h + 1;
1341
1342 TRACE(" returning matrix handle %#lx\n", *D3DMatHandle);
1343
1345
1346 return D3D_OK;
1347}
1348
1349/*****************************************************************************
1350 * IDirect3DDevice::SetMatrix
1351 *
1352 * Sets a matrix for a matrix handle. The matrix is copied into the memory
1353 * allocated for the handle
1354 *
1355 * Version 1 only
1356 *
1357 * Params:
1358 * D3DMatHandle: Handle to set the matrix to
1359 * D3DMatrix: Matrix to set
1360 *
1361 * Returns:
1362 * D3D_OK on success
1363 * DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
1364 * to set is NULL
1365 *
1366 *****************************************************************************/
1367static HRESULT WINAPI d3d_device1_SetMatrix(IDirect3DDevice *iface,
1368 D3DMATRIXHANDLE matrix_handle, D3DMATRIX *matrix)
1369{
1371 D3DMATRIX *m;
1372
1373 TRACE("iface %p, matrix_handle %#lx, matrix %p.\n", iface, matrix_handle, matrix);
1374
1375 if (!matrix)
1376 return DDERR_INVALIDPARAMS;
1377
1379
1380 m = ddraw_get_object(NULL, matrix_handle - 1, DDRAW_HANDLE_MATRIX);
1381 if (!m)
1382 {
1383 WARN("Invalid matrix handle.\n");
1385 return DDERR_INVALIDPARAMS;
1386 }
1387
1388 if (TRACE_ON(ddraw))
1390
1391 *m = *matrix;
1392
1393 if (matrix_handle == device->world)
1396
1397 if (matrix_handle == device->view)
1400
1401 if (matrix_handle == device->proj)
1404
1406
1407 return D3D_OK;
1408}
1409
1410/*****************************************************************************
1411 * IDirect3DDevice::GetMatrix
1412 *
1413 * Returns the content of a D3DMATRIX handle
1414 *
1415 * Version 1 only
1416 *
1417 * Params:
1418 * D3DMatHandle: Matrix handle to read the content from
1419 * D3DMatrix: Address to store the content at
1420 *
1421 * Returns:
1422 * D3D_OK on success
1423 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
1424 *
1425 *****************************************************************************/
1426static HRESULT WINAPI d3d_device1_GetMatrix(IDirect3DDevice *iface,
1427 D3DMATRIXHANDLE D3DMatHandle, D3DMATRIX *D3DMatrix)
1428{
1429 D3DMATRIX *m;
1430
1431 TRACE("iface %p, matrix_handle %#lx, matrix %p.\n", iface, D3DMatHandle, D3DMatrix);
1432
1433 if (!D3DMatrix) return DDERR_INVALIDPARAMS;
1434
1436
1437 m = ddraw_get_object(NULL, D3DMatHandle - 1, DDRAW_HANDLE_MATRIX);
1438 if (!m)
1439 {
1440 WARN("Invalid matrix handle.\n");
1442 return DDERR_INVALIDPARAMS;
1443 }
1444
1445 *D3DMatrix = *m;
1446
1448
1449 return D3D_OK;
1450}
1451
1452/*****************************************************************************
1453 * IDirect3DDevice::DeleteMatrix
1454 *
1455 * Destroys a Matrix handle. Frees the memory and unsets the handle data
1456 *
1457 * Version 1 only
1458 *
1459 * Params:
1460 * D3DMatHandle: Handle to destroy
1461 *
1462 * Returns:
1463 * D3D_OK on success
1464 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid
1465 *
1466 *****************************************************************************/
1467static HRESULT WINAPI d3d_device1_DeleteMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE D3DMatHandle)
1468{
1469 D3DMATRIX *m;
1470
1471 TRACE("iface %p, matrix_handle %#lx.\n", iface, D3DMatHandle);
1472
1474
1475 m = ddraw_free_handle(NULL, D3DMatHandle - 1, DDRAW_HANDLE_MATRIX);
1476 if (!m)
1477 {
1478 WARN("Invalid matrix handle.\n");
1480 return DDERR_INVALIDPARAMS;
1481 }
1482
1484
1485 free(m);
1486
1487 return D3D_OK;
1488}
1489
1490/*****************************************************************************
1491 * IDirect3DDevice7::BeginScene
1492 *
1493 * This method must be called before any rendering is performed.
1494 * IDirect3DDevice::EndScene has to be called after the scene is complete
1495 *
1496 * Version 1, 2, 3 and 7
1497 *
1498 * Returns:
1499 * D3D_OK on success,
1500 * D3DERR_SCENE_IN_SCENE if WineD3D returns an error(Only in case of an already
1501 * started scene).
1502 *
1503 *****************************************************************************/
1504static HRESULT d3d_device7_BeginScene(IDirect3DDevice7 *iface)
1505{
1507 HRESULT hr;
1508
1509 TRACE("iface %p.\n", iface);
1510
1512 hr = wined3d_device_begin_scene(device->wined3d_device);
1514
1515 if(hr == WINED3D_OK) return D3D_OK;
1516 else return D3DERR_SCENE_IN_SCENE; /* TODO: Other possible causes of failure */
1517}
1518
1519static HRESULT WINAPI d3d_device7_BeginScene_FPUSetup(IDirect3DDevice7 *iface)
1520{
1521 return d3d_device7_BeginScene(iface);
1522}
1523
1525{
1526 HRESULT hr;
1527 WORD old_fpucw;
1528
1529 old_fpucw = d3d_fpu_setup();
1530 hr = d3d_device7_BeginScene(iface);
1531 set_fpu_control_word(old_fpucw);
1532
1533 return hr;
1534}
1535
1536static HRESULT WINAPI d3d_device3_BeginScene(IDirect3DDevice3 *iface)
1537{
1539
1540 TRACE("iface %p.\n", iface);
1541
1542 return IDirect3DDevice7_BeginScene(&device->IDirect3DDevice7_iface);
1543}
1544
1545static HRESULT WINAPI d3d_device2_BeginScene(IDirect3DDevice2 *iface)
1546{
1548
1549 TRACE("iface %p.\n", iface);
1550
1551 return IDirect3DDevice7_BeginScene(&device->IDirect3DDevice7_iface);
1552}
1553
1554static HRESULT WINAPI d3d_device1_BeginScene(IDirect3DDevice *iface)
1555{
1557
1558 TRACE("iface %p.\n", iface);
1559
1560 return IDirect3DDevice7_BeginScene(&device->IDirect3DDevice7_iface);
1561}
1562
1563/*****************************************************************************
1564 * IDirect3DDevice7::EndScene
1565 *
1566 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1567 * This method must be called after rendering is finished.
1568 *
1569 * Version 1, 2, 3 and 7
1570 *
1571 * Returns:
1572 * D3D_OK on success,
1573 * D3DERR_SCENE_NOT_IN_SCENE is returned if WineD3D returns an error. It does
1574 * that only if the scene was already ended.
1575 *
1576 *****************************************************************************/
1577static HRESULT d3d_device7_EndScene(IDirect3DDevice7 *iface)
1578{
1580 HRESULT hr;
1581
1582 TRACE("iface %p.\n", iface);
1583
1585 hr = wined3d_device_end_scene(device->wined3d_device);
1587
1588 if(hr == WINED3D_OK) return D3D_OK;
1589 else return D3DERR_SCENE_NOT_IN_SCENE;
1590}
1591
1593{
1594 return d3d_device7_EndScene(iface);
1595}
1596
1598{
1599 HRESULT hr;
1600 WORD old_fpucw;
1601
1602 old_fpucw = d3d_fpu_setup();
1603 hr = d3d_device7_EndScene(iface);
1604 set_fpu_control_word(old_fpucw);
1605
1606 return hr;
1607}
1608
1610{
1612
1613 TRACE("iface %p.\n", iface);
1614
1615 return IDirect3DDevice7_EndScene(&device->IDirect3DDevice7_iface);
1616}
1617
1619{
1621
1622 TRACE("iface %p.\n", iface);
1623
1624 return IDirect3DDevice7_EndScene(&device->IDirect3DDevice7_iface);
1625}
1626
1628{
1630
1631 TRACE("iface %p.\n", iface);
1632
1633 return IDirect3DDevice7_EndScene(&device->IDirect3DDevice7_iface);
1634}
1635
1636/*****************************************************************************
1637 * IDirect3DDevice7::GetDirect3D
1638 *
1639 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1640 * this device.
1641 *
1642 * Params:
1643 * Direct3D7: Address to store the interface pointer at
1644 *
1645 * Returns:
1646 * D3D_OK on success
1647 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1648 *
1649 *****************************************************************************/
1650static HRESULT WINAPI d3d_device7_GetDirect3D(IDirect3DDevice7 *iface, IDirect3D7 **d3d)
1651{
1653
1654 TRACE("iface %p, d3d %p.\n", iface, d3d);
1655
1656 if (!d3d)
1657 return DDERR_INVALIDPARAMS;
1658
1659 *d3d = &device->ddraw->IDirect3D7_iface;
1660 IDirect3D7_AddRef(*d3d);
1661
1662 TRACE("Returning interface %p.\n", *d3d);
1663 return D3D_OK;
1664}
1665
1666static HRESULT WINAPI d3d_device3_GetDirect3D(IDirect3DDevice3 *iface, IDirect3D3 **d3d)
1667{
1669
1670 TRACE("iface %p, d3d %p.\n", iface, d3d);
1671
1672 if (!d3d)
1673 return DDERR_INVALIDPARAMS;
1674
1675 *d3d = &device->ddraw->IDirect3D3_iface;
1676 IDirect3D3_AddRef(*d3d);
1677
1678 TRACE("Returning interface %p.\n", *d3d);
1679 return D3D_OK;
1680}
1681
1682static HRESULT WINAPI d3d_device2_GetDirect3D(IDirect3DDevice2 *iface, IDirect3D2 **d3d)
1683{
1685
1686 TRACE("iface %p, d3d %p.\n", iface, d3d);
1687
1688 if (!d3d)
1689 return DDERR_INVALIDPARAMS;
1690
1691 *d3d = &device->ddraw->IDirect3D2_iface;
1692 IDirect3D2_AddRef(*d3d);
1693
1694 TRACE("Returning interface %p.\n", *d3d);
1695 return D3D_OK;
1696}
1697
1698static HRESULT WINAPI d3d_device1_GetDirect3D(IDirect3DDevice *iface, IDirect3D **d3d)
1699{
1701
1702 TRACE("iface %p, d3d %p.\n", iface, d3d);
1703
1704 if (!d3d)
1705 return DDERR_INVALIDPARAMS;
1706
1707 *d3d = &device->ddraw->IDirect3D_iface;
1708 IDirect3D_AddRef(*d3d);
1709
1710 TRACE("Returning interface %p.\n", *d3d);
1711 return D3D_OK;
1712}
1713
1714/*****************************************************************************
1715 * IDirect3DDevice3::SetCurrentViewport
1716 *
1717 * Sets a Direct3DViewport as the current viewport.
1718 * For the thunks note that all viewport interface versions are equal
1719 *
1720 * Params:
1721 * Direct3DViewport3: The viewport to set
1722 *
1723 * Version 2 and 3
1724 *
1725 * Returns:
1726 * D3D_OK on success
1727 * (Is a NULL viewport valid?)
1728 *
1729 *****************************************************************************/
1730static HRESULT WINAPI d3d_device3_SetCurrentViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
1731{
1734
1735 TRACE("iface %p, viewport %p, current_viewport %p.\n", iface, viewport, device->current_viewport);
1736
1737 if (!vp)
1738 {
1739 WARN("Direct3DViewport3 is NULL.\n");
1740 return DDERR_INVALIDPARAMS;
1741 }
1742
1744 /* Do nothing if the specified viewport is the same as the current one */
1745 if (device->current_viewport == vp)
1746 {
1748 return D3D_OK;
1749 }
1750
1751 if (vp->active_device != device)
1752 {
1753 WARN("Viewport %p, active device %p.\n", vp, vp->active_device);
1755 return DDERR_INVALIDPARAMS;
1756 }
1757
1758 IDirect3DViewport3_AddRef(viewport);
1759 if (device->current_viewport)
1760 {
1761 viewport_deactivate(device->current_viewport);
1762 IDirect3DViewport3_Release(&device->current_viewport->IDirect3DViewport3_iface);
1763 }
1764 device->current_viewport = vp;
1765 viewport_activate(device->current_viewport, FALSE);
1766
1768
1769 return D3D_OK;
1770}
1771
1772static HRESULT WINAPI d3d_device2_SetCurrentViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport)
1773{
1776
1777 TRACE("iface %p, viewport %p.\n", iface, viewport);
1778
1779 return d3d_device3_SetCurrentViewport(&device->IDirect3DDevice3_iface,
1780 vp ? &vp->IDirect3DViewport3_iface : NULL);
1781}
1782
1783/*****************************************************************************
1784 * IDirect3DDevice3::GetCurrentViewport
1785 *
1786 * Returns the currently active viewport.
1787 *
1788 * Version 2 and 3
1789 *
1790 * Params:
1791 * Direct3DViewport3: Address to return the interface pointer at
1792 *
1793 * Returns:
1794 * D3D_OK on success
1795 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1796 *
1797 *****************************************************************************/
1798static HRESULT WINAPI d3d_device3_GetCurrentViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 **viewport)
1799{
1801
1802 TRACE("iface %p, viewport %p.\n", iface, viewport);
1803
1805 if (!device->current_viewport)
1806 {
1808 WARN("No current viewport, returning D3DERR_NOCURRENTVIEWPORT\n");
1810 }
1811
1812 *viewport = &device->current_viewport->IDirect3DViewport3_iface;
1813 IDirect3DViewport3_AddRef(*viewport);
1814
1815 TRACE("Returning interface %p.\n", *viewport);
1817 return D3D_OK;
1818}
1819
1820static HRESULT WINAPI d3d_device2_GetCurrentViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 **viewport)
1821{
1823
1824 TRACE("iface %p, viewport %p.\n", iface, viewport);
1825
1826 return d3d_device3_GetCurrentViewport(&device->IDirect3DDevice3_iface,
1827 (IDirect3DViewport3 **)viewport);
1828}
1829
1831{
1833 || surface->palette;
1834}
1835
1838{
1839 struct wined3d_rendertarget_view *rtv;
1840 HRESULT hr;
1841
1842 if (device->rt_iface == rt_iface)
1843 {
1844 TRACE("No-op SetRenderTarget operation, not doing anything\n");
1845 return D3D_OK;
1846 }
1847 if (!target)
1848 {
1849 WARN("Trying to set render target to NULL.\n");
1850 return DDERR_INVALIDPARAMS;
1851 }
1852
1854 if (FAILED(hr = wined3d_device_context_set_rendertarget_views(device->immediate_context, 0, 1, &rtv, FALSE)))
1855 return hr;
1856
1857 IUnknown_AddRef(rt_iface);
1858 IUnknown_Release(device->rt_iface);
1859 device->rt_iface = rt_iface;
1860 device->target = target;
1862
1863 return D3D_OK;
1864}
1865
1866static HRESULT d3d_device7_SetRenderTarget(IDirect3DDevice7 *iface,
1868{
1871 HRESULT hr;
1872
1873 TRACE("iface %p, target %p, flags %#lx.\n", iface, target, flags);
1874
1876
1877 if (!validate_surface_palette(target_impl))
1878 {
1879 WARN("Surface %p has an indexed pixel format, but no palette.\n", target_impl);
1881 return DDERR_INVALIDCAPS;
1882 }
1883
1884 if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
1885 {
1886 WARN("Surface %p is not a render target.\n", target_impl);
1888 return DDERR_INVALIDCAPS;
1889 }
1890
1891 if (device->hardware_device && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
1892 {
1893 WARN("Surface %p is not in video memory.\n", target_impl);
1895 return DDERR_INVALIDPARAMS;
1896 }
1897
1898 if (target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
1899 {
1900 WARN("Surface %p is a depth buffer.\n", target_impl);
1901 IDirectDrawSurface7_AddRef(target);
1902 IUnknown_Release(device->rt_iface);
1903 device->rt_iface = (IUnknown *)target;
1904 device->target = NULL;
1905 device->target_ds = NULL;
1908 }
1909
1912 return hr;
1913}
1914
1916 IDirectDrawSurface7 *NewTarget, DWORD flags)
1917{
1918 return d3d_device7_SetRenderTarget(iface, NewTarget, flags);
1919}
1920
1922 IDirectDrawSurface7 *NewTarget, DWORD flags)
1923{
1924 HRESULT hr;
1925 WORD old_fpucw;
1926
1927 old_fpucw = d3d_fpu_setup();
1928 hr = d3d_device7_SetRenderTarget(iface, NewTarget, flags);
1929 set_fpu_control_word(old_fpucw);
1930
1931 return hr;
1932}
1933
1934static HRESULT WINAPI d3d_device3_SetRenderTarget(IDirect3DDevice3 *iface,
1935 IDirectDrawSurface4 *target, DWORD flags)
1936{
1939 HRESULT hr;
1940
1941 TRACE("iface %p, target %p, flags %#lx.\n", iface, target, flags);
1942
1944
1945 if (!validate_surface_palette(target_impl))
1946 {
1947 WARN("Surface %p has an indexed pixel format, but no palette.\n", target_impl);
1949 return DDERR_INVALIDCAPS;
1950 }
1951
1952 if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
1953 {
1954 WARN("Surface %p is not a render target.\n", target_impl);
1956 return DDERR_INVALIDCAPS;
1957 }
1958
1959 if (target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
1960 {
1961 WARN("Surface %p is a depth buffer.\n", target_impl);
1962 IDirectDrawSurface4_AddRef(target);
1963 IUnknown_Release(device->rt_iface);
1964 device->rt_iface = (IUnknown *)target;
1965 device->target = NULL;
1966 device->target_ds = NULL;
1969 }
1970
1971 if (device->hardware_device && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
1972 {
1973 WARN("Surface %p is not in video memory.\n", target_impl);
1974 IDirectDrawSurface4_AddRef(target);
1975 IUnknown_Release(device->rt_iface);
1976 device->rt_iface = (IUnknown *)target;
1977 device->target = NULL;
1978 device->target_ds = NULL;
1980 return D3D_OK;
1981 }
1982
1985 return hr;
1986}
1987
1988static HRESULT WINAPI d3d_device2_SetRenderTarget(IDirect3DDevice2 *iface,
1989 IDirectDrawSurface *target, DWORD flags)
1990{
1993 HRESULT hr;
1994
1995 TRACE("iface %p, target %p, flags %#lx.\n", iface, target, flags);
1996
1998
1999 if (!validate_surface_palette(target_impl))
2000 {
2001 WARN("Surface %p has an indexed pixel format, but no palette.\n", target_impl);
2003 return DDERR_INVALIDCAPS;
2004 }
2005
2006 if (!(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
2007 {
2008 WARN("Surface %p is not a render target.\n", target_impl);
2010 return DDERR_INVALIDCAPS;
2011 }
2012
2013 if (target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
2014 {
2015 WARN("Surface %p is a depth buffer.\n", target_impl);
2016 IUnknown_Release(device->rt_iface);
2017 device->rt_iface = (IUnknown *)target;
2018 device->target = NULL;
2019 device->target_ds = NULL;
2022 }
2023
2024 if (device->hardware_device && !(target_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
2025 {
2026 WARN("Surface %p is not in video memory.\n", target_impl);
2027 IDirectDrawSurface_AddRef(target);
2028 IUnknown_Release(device->rt_iface);
2029 device->rt_iface = (IUnknown *)target;
2030 device->target = NULL;
2031 device->target_ds = NULL;
2033 return D3D_OK;
2034 }
2035
2038 return hr;
2039}
2040
2041/*****************************************************************************
2042 * IDirect3DDevice7::GetRenderTarget
2043 *
2044 * Returns the current render target.
2045 * This is handled locally, because the WineD3D render target's parent
2046 * is an IParent
2047 *
2048 * Version 2, 3 and 7
2049 *
2050 * Params:
2051 * RenderTarget: Address to store the surface interface pointer
2052 *
2053 * Returns:
2054 * D3D_OK on success
2055 * DDERR_INVALIDPARAMS if RenderTarget == NULL
2056 *
2057 *****************************************************************************/
2058static HRESULT WINAPI d3d_device7_GetRenderTarget(IDirect3DDevice7 *iface, IDirectDrawSurface7 **RenderTarget)
2059{
2061 HRESULT hr;
2062
2063 TRACE("iface %p, target %p.\n", iface, RenderTarget);
2064
2065 if(!RenderTarget)
2066 return DDERR_INVALIDPARAMS;
2067
2069 hr = IUnknown_QueryInterface(device->rt_iface, &IID_IDirectDrawSurface7, (void **)RenderTarget);
2071
2072 return hr;
2073}
2074
2075static HRESULT WINAPI d3d_device3_GetRenderTarget(IDirect3DDevice3 *iface, IDirectDrawSurface4 **RenderTarget)
2076{
2078 IDirectDrawSurface7 *RenderTarget7;
2079 struct ddraw_surface *RenderTargetImpl;
2080 HRESULT hr;
2081
2082 TRACE("iface %p, target %p.\n", iface, RenderTarget);
2083
2084 if(!RenderTarget)
2085 return DDERR_INVALIDPARAMS;
2086
2087 hr = d3d_device7_GetRenderTarget(&device->IDirect3DDevice7_iface, &RenderTarget7);
2088 if(hr != D3D_OK) return hr;
2089 RenderTargetImpl = impl_from_IDirectDrawSurface7(RenderTarget7);
2090 *RenderTarget = &RenderTargetImpl->IDirectDrawSurface4_iface;
2091 IDirectDrawSurface4_AddRef(*RenderTarget);
2092 IDirectDrawSurface7_Release(RenderTarget7);
2093 return D3D_OK;
2094}
2095
2096static HRESULT WINAPI d3d_device2_GetRenderTarget(IDirect3DDevice2 *iface, IDirectDrawSurface **RenderTarget)
2097{
2099 IDirectDrawSurface7 *RenderTarget7;
2100 struct ddraw_surface *RenderTargetImpl;
2101 HRESULT hr;
2102
2103 TRACE("iface %p, target %p.\n", iface, RenderTarget);
2104
2105 if(!RenderTarget)
2106 return DDERR_INVALIDPARAMS;
2107
2108 hr = d3d_device7_GetRenderTarget(&device->IDirect3DDevice7_iface, &RenderTarget7);
2109 if(hr != D3D_OK) return hr;
2110 RenderTargetImpl = impl_from_IDirectDrawSurface7(RenderTarget7);
2111 *RenderTarget = &RenderTargetImpl->IDirectDrawSurface_iface;
2112 IDirectDrawSurface_AddRef(*RenderTarget);
2113 IDirectDrawSurface7_Release(RenderTarget7);
2114 return D3D_OK;
2115}
2116
2117/*****************************************************************************
2118 * IDirect3DDevice3::Begin
2119 *
2120 * Begins a description block of vertices. This is similar to glBegin()
2121 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
2122 * described with IDirect3DDevice::Vertex are drawn.
2123 *
2124 * Version 2 and 3
2125 *
2126 * Params:
2127 * PrimitiveType: The type of primitives to draw
2128 * VertexTypeDesc: A flexible vertex format description of the vertices
2129 * Flags: Some flags..
2130 *
2131 * Returns:
2132 * D3D_OK on success
2133 *
2134 *****************************************************************************/
2135static HRESULT WINAPI d3d_device3_Begin(IDirect3DDevice3 *iface,
2136 D3DPRIMITIVETYPE primitive_type, DWORD fvf, DWORD flags)
2137{
2139
2140 TRACE("iface %p, primitive_type %#x, fvf %#lx, flags %#lx.\n",
2141 iface, primitive_type, fvf, flags);
2142
2144 device->primitive_type = primitive_type;
2145 device->vertex_type = fvf;
2146 device->render_flags = flags;
2147 device->vertex_size = get_flexible_vertex_size(device->vertex_type);
2148 device->nb_vertices = 0;
2150
2151 return D3D_OK;
2152}
2153
2154static HRESULT WINAPI d3d_device2_Begin(IDirect3DDevice2 *iface,
2156{
2158 DWORD fvf;
2159
2160 TRACE("iface %p, primitive_type %#x, vertex_type %#x, flags %#lx.\n",
2162
2163 switch (vertex_type)
2164 {
2165 case D3DVT_VERTEX: fvf = D3DFVF_VERTEX; break;
2166 case D3DVT_LVERTEX: fvf = D3DFVF_LVERTEX; break;
2167 case D3DVT_TLVERTEX: fvf = D3DFVF_TLVERTEX; break;
2168 default:
2169 ERR("Unexpected vertex type %#x.\n", vertex_type);
2170 return DDERR_INVALIDPARAMS; /* Should never happen */
2171 };
2172
2173 return d3d_device3_Begin(&device->IDirect3DDevice3_iface, primitive_type, fvf, flags);
2174}
2175
2176/*****************************************************************************
2177 * IDirect3DDevice3::BeginIndexed
2178 *
2179 * Draws primitives based on vertices in a vertex array which are specified
2180 * by indices.
2181 *
2182 * Version 2 and 3
2183 *
2184 * Params:
2185 * PrimitiveType: Primitive type to draw
2186 * VertexType: A FVF description of the vertex format
2187 * Vertices: pointer to an array containing the vertices
2188 * NumVertices: The number of vertices in the vertex array
2189 * Flags: Some flags ...
2190 *
2191 * Returns:
2192 * D3D_OK, because it's a stub
2193 *
2194 *****************************************************************************/
2195static HRESULT WINAPI d3d_device3_BeginIndexed(IDirect3DDevice3 *iface,
2197 void *vertices, DWORD vertex_count, DWORD flags)
2198{
2199 FIXME("iface %p, primitive_type %#x, fvf %#lx, vertices %p, vertex_count %lu, flags %#lx stub!\n",
2200 iface, primitive_type, fvf, vertices, vertex_count, flags);
2201
2202 return D3D_OK;
2203}
2204
2205
2206static HRESULT WINAPI d3d_device2_BeginIndexed(IDirect3DDevice2 *iface,
2208 void *vertices, DWORD vertex_count, DWORD flags)
2209{
2211 DWORD fvf;
2212
2213 TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %lu, flags %#lx.\n",
2214 iface, primitive_type, vertex_type, vertices, vertex_count, flags);
2215
2216 switch (vertex_type)
2217 {
2218 case D3DVT_VERTEX: fvf = D3DFVF_VERTEX; break;
2219 case D3DVT_LVERTEX: fvf = D3DFVF_LVERTEX; break;
2220 case D3DVT_TLVERTEX: fvf = D3DFVF_TLVERTEX; break;
2221 default:
2222 ERR("Unexpected vertex type %#x.\n", vertex_type);
2223 return DDERR_INVALIDPARAMS; /* Should never happen */
2224 };
2225
2226 return d3d_device3_BeginIndexed(&device->IDirect3DDevice3_iface,
2227 primitive_type, fvf, vertices, vertex_count, flags);
2228}
2229
2230/*****************************************************************************
2231 * IDirect3DDevice3::Vertex
2232 *
2233 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
2234 * drawn vertices in a vertex buffer. If the buffer is too small, its
2235 * size is increased.
2236 *
2237 * Version 2 and 3
2238 *
2239 * Params:
2240 * Vertex: Pointer to the vertex
2241 *
2242 * Returns:
2243 * D3D_OK, on success
2244 * DDERR_INVALIDPARAMS if Vertex is NULL
2245 *
2246 *****************************************************************************/
2247static HRESULT WINAPI d3d_device3_Vertex(IDirect3DDevice3 *iface, void *vertex)
2248{
2250
2251 TRACE("iface %p, vertex %p.\n", iface, vertex);
2252
2253 if (!vertex)
2254 return DDERR_INVALIDPARAMS;
2255
2257 if ((device->nb_vertices + 1) * device->vertex_size > device->buffer_size)
2258 {
2259 BYTE *old_buffer;
2260
2261 device->buffer_size = device->buffer_size ? device->buffer_size * 2 : device->vertex_size * 3;
2262 old_buffer = device->sysmem_vertex_buffer;
2263 device->sysmem_vertex_buffer = malloc(device->buffer_size);
2264 if (old_buffer)
2265 {
2266 memcpy(device->sysmem_vertex_buffer, old_buffer, device->nb_vertices * device->vertex_size);
2267 free(old_buffer);
2268 }
2269 }
2270
2271 memcpy(device->sysmem_vertex_buffer + device->nb_vertices++ * device->vertex_size, vertex, device->vertex_size);
2273
2274 return D3D_OK;
2275}
2276
2277static HRESULT WINAPI d3d_device2_Vertex(IDirect3DDevice2 *iface, void *vertex)
2278{
2280
2281 TRACE("iface %p, vertex %p.\n", iface, vertex);
2282
2283 return d3d_device3_Vertex(&device->IDirect3DDevice3_iface, vertex);
2284}
2285
2286/*****************************************************************************
2287 * IDirect3DDevice3::Index
2288 *
2289 * Specifies an index to a vertex to be drawn. The vertex array has to
2290 * be specified with BeginIndexed first.
2291 *
2292 * Parameters:
2293 * VertexIndex: The index of the vertex to draw
2294 *
2295 * Returns:
2296 * D3D_OK because it's a stub
2297 *
2298 *****************************************************************************/
2299static HRESULT WINAPI d3d_device3_Index(IDirect3DDevice3 *iface, WORD index)
2300{
2301 FIXME("iface %p, index %#x stub!\n", iface, index);
2302
2303 return D3D_OK;
2304}
2305
2306static HRESULT WINAPI d3d_device2_Index(IDirect3DDevice2 *iface, WORD index)
2307{
2309
2310 TRACE("iface %p, index %#x.\n", iface, index);
2311
2312 return d3d_device3_Index(&device->IDirect3DDevice3_iface, index);
2313}
2314
2315/*****************************************************************************
2316 * IDirect3DDevice7::GetRenderState
2317 *
2318 * Returns the value of a render state. The possible render states are
2319 * defined in include/d3dtypes.h
2320 *
2321 * Version 2, 3 and 7
2322 *
2323 * Params:
2324 * RenderStateType: Render state to return the current setting of
2325 * Value: Address to store the value at
2326 *
2327 * Returns:
2328 * D3D_OK on success,
2329 * DDERR_INVALIDPARAMS if Value == NULL
2330 *
2331 *****************************************************************************/
2332static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
2334{
2337 HRESULT hr = D3D_OK;
2338
2339 TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
2340
2341 if (!value)
2342 return DDERR_INVALIDPARAMS;
2343
2345 device_state = device->stateblock_state;
2346 switch (state)
2347 {
2349 {
2350 enum wined3d_texture_filter_type tex_mag = device_state->sampler_states[0][WINED3D_SAMP_MAG_FILTER];
2351
2352 switch (tex_mag)
2353 {
2354 case WINED3D_TEXF_POINT:
2356 break;
2359 break;
2360 default:
2361 ERR("Unhandled texture mag %d !\n",tex_mag);
2362 *value = 0;
2363 }
2364 break;
2365 }
2366
2368 {
2369 enum wined3d_texture_filter_type tex_min;
2370 enum wined3d_texture_filter_type tex_mip;
2371
2372 tex_min = device_state->sampler_states[0][WINED3D_SAMP_MIN_FILTER];
2373 tex_mip = device_state->sampler_states[0][WINED3D_SAMP_MIP_FILTER];
2374 switch (tex_min)
2375 {
2376 case WINED3D_TEXF_POINT:
2377 switch (tex_mip)
2378 {
2379 case WINED3D_TEXF_NONE:
2381 break;
2382 case WINED3D_TEXF_POINT:
2384 break;
2387 break;
2388 default:
2389 ERR("Unhandled mip filter %#x.\n", tex_mip);
2391 break;
2392 }
2393 break;
2395 switch (tex_mip)
2396 {
2397 case WINED3D_TEXF_NONE:
2399 break;
2400 case WINED3D_TEXF_POINT:
2402 break;
2405 break;
2406 default:
2407 ERR("Unhandled mip filter %#x.\n", tex_mip);
2409 break;
2410 }
2411 break;
2412 default:
2413 ERR("Unhandled texture min filter %#x.\n",tex_min);
2415 break;
2416 }
2417 break;
2418 }
2419
2422 *value = device_state->sampler_states[0][WINED3D_SAMP_ADDRESS_U];
2423 break;
2425 *value = device_state->sampler_states[0][WINED3D_SAMP_ADDRESS_V];
2426 break;
2427
2429 FIXME("Unhandled render state D3DRENDERSTATE_BORDERCOLOR.\n");
2430 hr = E_NOTIMPL;
2431 break;
2432
2435 WARN("Render state %#x is invalid in d3d7.\n", state);
2437 break;
2438
2439 default:
2442 {
2443 FIXME("Unhandled stipple pattern render state (%#x).\n", state);
2444 hr = E_NOTIMPL;
2445 break;
2446 }
2448 }
2450
2451 return hr;
2452}
2453
2456{
2457 return d3d_device7_GetRenderState(iface, state, value);
2458}
2459
2462{
2463 HRESULT hr;
2464 WORD old_fpucw;
2465
2466 old_fpucw = d3d_fpu_setup();
2468 set_fpu_control_word(old_fpucw);
2469
2470 return hr;
2471}
2472
2473static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
2475{
2477
2478 TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
2479
2480 switch (state)
2481 {
2483 {
2484 /* This state is wrapped to SetTexture in SetRenderState, so
2485 * it has to be wrapped to GetTexture here. */
2486 struct wined3d_texture *tex = NULL;
2487 *value = 0;
2488
2490 if ((tex = device->stateblock_state->textures[0]))
2491 {
2492 /* The parent of the texture is the IDirectDrawSurface7
2493 * interface of the ddraw surface. */
2495 if (parent)
2496 *value = parent->root->Handle;
2497 }
2499
2500 return D3D_OK;
2501 }
2502
2504 {
2505 *value = device->texture_map_blend;
2506 return D3D_OK;
2507 }
2508
2512 *value = 0xffffffff;
2513 return D3D_OK;
2514
2515 default:
2516 return IDirect3DDevice7_GetRenderState(&device->IDirect3DDevice7_iface, state, value);
2517 }
2518}
2519
2520static HRESULT WINAPI d3d_device2_GetRenderState(IDirect3DDevice2 *iface,
2522{
2524
2525 TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
2526
2527 return IDirect3DDevice3_GetRenderState(&device->IDirect3DDevice3_iface, state, value);
2528}
2529
2530/*****************************************************************************
2531 * IDirect3DDevice7::SetRenderState
2532 *
2533 * Sets a render state. The possible render states are defined in
2534 * include/d3dtypes.h
2535 *
2536 * Version 2, 3 and 7
2537 *
2538 * Params:
2539 * RenderStateType: State to set
2540 * Value: Value to assign to that state
2541 *
2542 *****************************************************************************/
2543static HRESULT d3d_device7_SetRenderState(IDirect3DDevice7 *iface,
2545{
2547 HRESULT hr = D3D_OK;
2548
2549 TRACE("iface %p, state %#x, value %#lx.\n", iface, state, value);
2550
2552 /* Some render states need special care */
2553 switch (state)
2554 {
2555 /*
2556 * The ddraw texture filter mapping works like this:
2557 * D3DFILTER_NEAREST Point min/mag, no mip
2558 * D3DFILTER_MIPNEAREST Point min/mag, point mip
2559 * D3DFILTER_LINEARMIPNEAREST: Point min/mag, linear mip
2560 *
2561 * D3DFILTER_LINEAR Linear min/mag, no mip
2562 * D3DFILTER_MIPLINEAR Linear min/mag, point mip
2563 * D3DFILTER_LINEARMIPLINEAR Linear min/mag, linear mip
2564 *
2565 * This is the opposite of the GL naming convention,
2566 * D3DFILTER_LINEARMIPNEAREST corresponds to GL_NEAREST_MIPMAP_LINEAR.
2567 */
2569 {
2570 enum wined3d_texture_filter_type tex_mag;
2571
2572 switch (value)
2573 {
2574 case D3DFILTER_NEAREST:
2577 tex_mag = WINED3D_TEXF_POINT;
2578 break;
2579 case D3DFILTER_LINEAR:
2582 tex_mag = WINED3D_TEXF_LINEAR;
2583 break;
2584 default:
2585 tex_mag = WINED3D_TEXF_POINT;
2586 FIXME("Unhandled texture mag %#lx.\n", value);
2587 break;
2588 }
2589
2591 break;
2592 }
2593
2595 {
2596 enum wined3d_texture_filter_type tex_min;
2597 enum wined3d_texture_filter_type tex_mip;
2598
2599 switch (value)
2600 {
2601 case D3DFILTER_NEAREST:
2602 tex_min = WINED3D_TEXF_POINT;
2603 tex_mip = WINED3D_TEXF_NONE;
2604 break;
2605 case D3DFILTER_LINEAR:
2606 tex_min = WINED3D_TEXF_LINEAR;
2607 tex_mip = WINED3D_TEXF_NONE;
2608 break;
2610 tex_min = WINED3D_TEXF_POINT;
2611 tex_mip = WINED3D_TEXF_POINT;
2612 break;
2614 tex_min = WINED3D_TEXF_LINEAR;
2615 tex_mip = WINED3D_TEXF_POINT;
2616 break;
2618 tex_min = WINED3D_TEXF_POINT;
2619 tex_mip = WINED3D_TEXF_LINEAR;
2620 break;
2622 tex_min = WINED3D_TEXF_LINEAR;
2623 tex_mip = WINED3D_TEXF_LINEAR;
2624 break;
2625
2626 default:
2627 FIXME("Unhandled texture min %#lx.\n",value);
2628 tex_min = WINED3D_TEXF_POINT;
2629 tex_mip = WINED3D_TEXF_NONE;
2630 break;
2631 }
2632
2635 break;
2636 }
2637
2640 /* Drop through */
2643 break;
2646 break;
2647
2649 /* This should probably just forward to the corresponding sampler
2650 * state. Needs tests. */
2651 FIXME("Unhandled render state D3DRENDERSTATE_BORDERCOLOR.\n");
2652 hr = E_NOTIMPL;
2653 break;
2654
2657 WARN("Render state %#x is invalid in d3d7.\n", state);
2659 break;
2660
2661 default:
2664 {
2665 FIXME("Unhandled stipple pattern render state (%#x).\n", state);
2666 hr = E_NOTIMPL;
2667 break;
2668 }
2669
2671 break;
2672 }
2674
2675 return hr;
2676}
2677
2680{
2681 return d3d_device7_SetRenderState(iface, state, value);
2682}
2683
2686{
2687 HRESULT hr;
2688 WORD old_fpucw;
2689
2690 old_fpucw = d3d_fpu_setup();
2692 set_fpu_control_word(old_fpucw);
2693
2694 return hr;
2695}
2696
2698{
2699 /* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states.
2700 See d3d_device3_SetRenderState() for details. */
2701 struct wined3d_texture *tex;
2702 BOOL tex_alpha = TRUE;
2703 DDPIXELFORMAT ddfmt;
2704
2705 if (!(device->legacyTextureBlending && device->texture_map_blend == D3DTBLEND_MODULATE))
2706 return;
2707
2708 if ((tex = device->stateblock_state->textures[0]))
2709 {
2711
2713 ddfmt.dwSize = sizeof(ddfmt);
2714 ddrawformat_from_wined3dformat(&ddfmt, desc.format);
2715 if (!ddfmt.dwRGBAlphaBitMask)
2716 tex_alpha = FALSE;
2717 }
2718
2719 /* Args 1 and 2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
2722}
2723
2724static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
2726{
2727 /* Note about D3DRENDERSTATE_TEXTUREMAPBLEND implementation: most of values
2728 for this state can be directly mapped to texture stage colorop and alphaop, but
2729 D3DTBLEND_MODULATE is tricky: it uses alpha from texture when available and alpha
2730 from diffuse otherwise. So changing the texture must be monitored in SetTexture to modify
2731 alphaarg when needed.
2732
2733 Aliens vs Predator 1 depends on accurate D3DTBLEND_MODULATE emulation
2734
2735 Legacy texture blending (TEXTUREMAPBLEND) and texture stage states: directx6 docs state that
2736 TEXTUREMAPBLEND is deprecated, yet can still be used. Games must not use both or results
2737 are undefined. D3DTBLEND_MODULATE mode in particular is dependent on texture pixel format and
2738 requires fixup of stage 0 texture states when texture changes, but this fixup can interfere
2739 with games not using this deprecated state. So a flag 'legacyTextureBlending' has to be kept
2740 in device - TRUE if the app is using TEXTUREMAPBLEND.
2741
2742 Tests show that setting TEXTUREMAPBLEND on native doesn't seem to change values returned by
2743 GetTextureStageState and vice versa. */
2744
2746 HRESULT hr;
2747
2748 TRACE("iface %p, state %#x, value %#lx.\n", iface, state, value);
2749
2751 {
2752 WARN("Unhandled state %#x.\n", state);
2753 return DDERR_INVALIDPARAMS;
2754 }
2755
2757
2758 switch (state)
2759 {
2761 {
2762 struct ddraw_surface *surf;
2763
2764 if (value == 0)
2765 {
2767 hr = D3D_OK;
2768 break;
2769 }
2770
2772 if (!surf)
2773 {
2774 WARN("Invalid texture handle.\n");
2776 break;
2777 }
2778
2780 break;
2781 }
2782
2784 {
2785 if (value == device->texture_map_blend)
2786 {
2787 TRACE("Application is setting the same value over, nothing to do.\n");
2788
2789 hr = D3D_OK;
2790 break;
2791 }
2792
2793 device->legacyTextureBlending = TRUE;
2794 device->texture_map_blend = value;
2795
2796 switch (value)
2797 {
2798 case D3DTBLEND_MODULATE:
2799 {
2801
2812 break;
2813 }
2814
2815 case D3DTBLEND_ADD:
2826 break;
2827
2841 break;
2842
2843 case D3DTBLEND_COPY:
2844 case D3DTBLEND_DECAL:
2853 break;
2854
2866 break;
2867
2868 default:
2869 FIXME("Unhandled texture environment %#lx.\n", value);
2870 }
2871 hr = D3D_OK;
2872 break;
2873 }
2874
2878 hr = D3D_OK;
2879 break;
2880
2881 default:
2882 hr = IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, state, value);
2883 break;
2884 }
2886
2887 return hr;
2888}
2889
2890static HRESULT WINAPI d3d_device2_SetRenderState(IDirect3DDevice2 *iface,
2892{
2894
2895 TRACE("iface %p, state %#x, value %#lx.\n", iface, state, value);
2896
2897 return IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface, state, value);
2898}
2899
2900/*****************************************************************************
2901 * Direct3DDevice3::SetLightState
2902 *
2903 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2904 * light states are forwarded to Direct3DDevice7 render states
2905 *
2906 * Version 2 and 3
2907 *
2908 * Params:
2909 * LightStateType: The light state to change
2910 * Value: The value to assign to that light state
2911 *
2912 * Returns:
2913 * D3D_OK on success
2914 * DDERR_INVALIDPARAMS if the parameters were incorrect
2915 * Also check IDirect3DDevice7::SetRenderState
2916 *
2917 *****************************************************************************/
2918static HRESULT WINAPI d3d_device3_SetLightState(IDirect3DDevice3 *iface,
2920{
2922 HRESULT hr;
2923
2924 TRACE("iface %p, state %#x, value %#lx.\n", iface, state, value);
2925
2927 {
2928 TRACE("Unexpected Light State Type\n");
2929 return DDERR_INVALIDPARAMS;
2930 }
2931
2934 {
2935 if (value)
2936 {
2937 struct d3d_material *m;
2938
2940 {
2941 WARN("Invalid material handle.\n");
2943 return DDERR_INVALIDPARAMS;
2944 }
2945
2947 }
2948
2949 device->material = value;
2950 }
2951 else if (state == D3DLIGHTSTATE_COLORMODEL)
2952 {
2953 switch (value)
2954 {
2955 case D3DCOLOR_MONO:
2956 ERR("DDCOLOR_MONO should not happen!\n");
2957 break;
2958 case D3DCOLOR_RGB:
2959 /* We are already in this mode */
2960 TRACE("Setting color model to RGB (no-op).\n");
2961 break;
2962 default:
2963 ERR("Unknown color model!\n");
2965 return DDERR_INVALIDPARAMS;
2966 }
2967 }
2968 else
2969 {
2971 switch (state)
2972 {
2973 case D3DLIGHTSTATE_AMBIENT: /* 2 */
2975 break;
2976 case D3DLIGHTSTATE_FOGMODE: /* 4 */
2978 break;
2979 case D3DLIGHTSTATE_FOGSTART: /* 5 */
2981 break;
2982 case D3DLIGHTSTATE_FOGEND: /* 6 */
2984 break;
2985 case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
2987 break;
2988 case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
2990 break;
2991 default:
2992 FIXME("Unhandled D3DLIGHTSTATETYPE %#x.\n", state);
2994 return DDERR_INVALIDPARAMS;
2995 }
2996
2997 hr = IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, rs, value);
2999 return hr;
3000 }
3002
3003 return D3D_OK;
3004}
3005
3006static HRESULT WINAPI d3d_device2_SetLightState(IDirect3DDevice2 *iface,
3008{
3010
3011 TRACE("iface %p, state %#x, value %#lx.\n", iface, state, value);
3012
3013 return d3d_device3_SetLightState(&device->IDirect3DDevice3_iface, state, value);
3014}
3015
3016/*****************************************************************************
3017 * IDirect3DDevice3::GetLightState
3018 *
3019 * Returns the current setting of a light state. The state is read from
3020 * the Direct3DDevice7 render state.
3021 *
3022 * Version 2 and 3
3023 *
3024 * Params:
3025 * LightStateType: The light state to return
3026 * Value: The address to store the light state setting at
3027 *
3028 * Returns:
3029 * D3D_OK on success
3030 * DDDERR_INVALIDPARAMS if the parameters were incorrect
3031 * Also see IDirect3DDevice7::GetRenderState
3032 *
3033 *****************************************************************************/
3034static HRESULT WINAPI d3d_device3_GetLightState(IDirect3DDevice3 *iface,
3036{
3038 HRESULT hr;
3039
3040 TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
3041
3043 {
3044 TRACE("Unexpected Light State Type\n");
3045 return DDERR_INVALIDPARAMS;
3046 }
3047
3048 if (!value)
3049 return DDERR_INVALIDPARAMS;
3050
3053 {
3054 *value = device->material;
3055 }
3056 else if (state == D3DLIGHTSTATE_COLORMODEL)
3057 {
3059 }
3060 else
3061 {
3063 switch (state)
3064 {
3065 case D3DLIGHTSTATE_AMBIENT: /* 2 */
3067 break;
3068 case D3DLIGHTSTATE_FOGMODE: /* 4 */
3070 break;
3071 case D3DLIGHTSTATE_FOGSTART: /* 5 */
3073 break;
3074 case D3DLIGHTSTATE_FOGEND: /* 6 */
3076 break;
3077 case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
3079 break;
3080 case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
3082 break;
3083 default:
3084 FIXME("Unhandled D3DLIGHTSTATETYPE %#x.\n", state);
3086 return DDERR_INVALIDPARAMS;
3087 }
3088
3089 hr = IDirect3DDevice7_GetRenderState(&device->IDirect3DDevice7_iface, rs, value);
3091 return hr;
3092 }
3094
3095 return D3D_OK;
3096}
3097
3098static HRESULT WINAPI d3d_device2_GetLightState(IDirect3DDevice2 *iface,
3100{
3102
3103 TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
3104
3105 return d3d_device3_GetLightState(&device->IDirect3DDevice3_iface, state, value);
3106}
3107
3108/*****************************************************************************
3109 * IDirect3DDevice7::SetTransform
3110 *
3111 * Assigns a D3DMATRIX to a transform type. The transform types are defined
3112 * in include/d3dtypes.h.
3113 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
3114 * (=255) for wined3d, because the 1 transform state was removed in d3d8
3115 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
3116 *
3117 * Version 2, 3 and 7
3118 *
3119 * Params:
3120 * TransformStateType: transform state to set
3121 * Matrix: Matrix to assign to the state
3122 *
3123 * Returns:
3124 * D3D_OK on success
3125 * DDERR_INVALIDPARAMS if Matrix == NULL
3126 *
3127 *****************************************************************************/
3128static HRESULT d3d_device7_SetTransform(IDirect3DDevice7 *iface,
3130{
3132
3133 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3134
3135 if (!matrix)
3136 return DDERR_INVALIDPARAMS;
3137
3138 /* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
3143
3144 return D3D_OK;
3145}
3146
3147static HRESULT WINAPI d3d_device7_SetTransform_FPUSetup(IDirect3DDevice7 *iface,
3149{
3150 return d3d_device7_SetTransform(iface, state, matrix);
3151}
3152
3155{
3156 HRESULT hr;
3157 WORD old_fpucw;
3158
3159 old_fpucw = d3d_fpu_setup();
3161 set_fpu_control_word(old_fpucw);
3162
3163 return hr;
3164}
3165
3166static HRESULT WINAPI d3d_device3_SetTransform(IDirect3DDevice3 *iface,
3168{
3170
3171 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3172
3173 if (!matrix)
3174 return DDERR_INVALIDPARAMS;
3175
3177 {
3178 struct wined3d_matrix projection;
3179
3181 multiply_matrix(&projection, &device->legacy_clipspace, (struct wined3d_matrix *)matrix);
3183 memcpy(&device->legacy_projection, matrix, sizeof(*matrix));
3185
3186 return D3D_OK;
3187 }
3188
3189 return IDirect3DDevice7_SetTransform(&device->IDirect3DDevice7_iface, state, matrix);
3190}
3191
3192static HRESULT WINAPI d3d_device2_SetTransform(IDirect3DDevice2 *iface,
3194{
3196
3197 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3198
3199 return IDirect3DDevice3_SetTransform(&device->IDirect3DDevice3_iface, state, matrix);
3200}
3201
3202/*****************************************************************************
3203 * IDirect3DDevice7::GetTransform
3204 *
3205 * Returns the matrix assigned to a transform state
3206 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
3207 * SetTransform
3208 *
3209 * Params:
3210 * TransformStateType: State to read the matrix from
3211 * Matrix: Address to store the matrix at
3212 *
3213 * Returns:
3214 * D3D_OK on success
3215 * DDERR_INVALIDPARAMS if Matrix == NULL
3216 *
3217 *****************************************************************************/
3218static HRESULT d3d_device7_GetTransform(IDirect3DDevice7 *iface,
3220{
3222
3223 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3224
3225 if (!matrix)
3226 return DDERR_INVALIDPARAMS;
3227
3228 /* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
3230 memcpy(matrix, &device->stateblock_state->transforms[wined3d_transform_state_from_ddraw(state)], sizeof(*matrix));
3232
3233 return D3D_OK;
3234}
3235
3236static HRESULT WINAPI d3d_device7_GetTransform_FPUSetup(IDirect3DDevice7 *iface,
3238{
3239 return d3d_device7_GetTransform(iface, state, matrix);
3240}
3241
3244{
3245 HRESULT hr;
3246 WORD old_fpucw;
3247
3248 old_fpucw = d3d_fpu_setup();
3250 set_fpu_control_word(old_fpucw);
3251
3252 return hr;
3253}
3254
3255static HRESULT WINAPI d3d_device3_GetTransform(IDirect3DDevice3 *iface,
3257{
3259
3260 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3261
3262 if (!matrix)
3263 return DDERR_INVALIDPARAMS;
3264
3266 {
3268 memcpy(matrix, &device->legacy_projection, sizeof(*matrix));
3270 return DD_OK;
3271 }
3272
3273 return IDirect3DDevice7_GetTransform(&device->IDirect3DDevice7_iface, state, matrix);
3274}
3275
3276static HRESULT WINAPI d3d_device2_GetTransform(IDirect3DDevice2 *iface,
3278{
3280
3281 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3282
3283 return IDirect3DDevice3_GetTransform(&device->IDirect3DDevice3_iface, state, matrix);
3284}
3285
3286/*****************************************************************************
3287 * IDirect3DDevice7::MultiplyTransform
3288 *
3289 * Multiplies the already-set transform matrix of a transform state
3290 * with another matrix. For the world matrix, see SetTransform
3291 *
3292 * Version 2, 3 and 7
3293 *
3294 * Params:
3295 * TransformStateType: Transform state to multiply
3296 * D3DMatrix Matrix to multiply with.
3297 *
3298 * Returns
3299 * D3D_OK on success
3300 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
3301 *
3302 *****************************************************************************/
3303static HRESULT d3d_device7_MultiplyTransform(IDirect3DDevice7 *iface,
3305{
3307
3308 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3309
3310 /* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
3315
3316 return D3D_OK;
3317}
3318
3321{
3323}
3324
3327{
3328 HRESULT hr;
3329 WORD old_fpucw;
3330
3331 old_fpucw = d3d_fpu_setup();
3333 set_fpu_control_word(old_fpucw);
3334
3335 return hr;
3336}
3337
3338static HRESULT WINAPI d3d_device3_MultiplyTransform(IDirect3DDevice3 *iface,
3340{
3342
3343 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3344
3346 {
3347 struct wined3d_matrix projection, tmp;
3348
3350 multiply_matrix(&tmp, &device->legacy_projection, (struct wined3d_matrix *)matrix);
3351 multiply_matrix(&projection, &device->legacy_clipspace, &tmp);
3353 device->legacy_projection = tmp;
3355
3356 return D3D_OK;
3357 }
3358
3359 return IDirect3DDevice7_MultiplyTransform(&device->IDirect3DDevice7_iface, state, matrix);
3360}
3361
3362static HRESULT WINAPI d3d_device2_MultiplyTransform(IDirect3DDevice2 *iface,
3364{
3366
3367 TRACE("iface %p, state %#x, matrix %p.\n", iface, state, matrix);
3368
3369 return IDirect3DDevice3_MultiplyTransform(&device->IDirect3DDevice3_iface, state, matrix);
3370}
3371
3372/*****************************************************************************
3373 * IDirect3DDevice7::DrawPrimitive
3374 *
3375 * Draws primitives based on vertices in an application-provided pointer
3376 *
3377 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
3378 * an FVF format for D3D7
3379 *
3380 * Params:
3381 * PrimitiveType: The type of the primitives to draw
3382 * Vertex type: Flexible vertex format vertex description
3383 * Vertices: Pointer to the vertex array
3384 * VertexCount: The number of vertices to draw
3385 * Flags: As usual a few flags
3386 *
3387 * Returns:
3388 * D3D_OK on success
3389 * DDERR_INVALIDPARAMS if Vertices is NULL
3390 *
3391 *****************************************************************************/
3393{
3394 struct wined3d_rendertarget_view *rtv, *dsv;
3395
3396 rtv = device->target ? ddraw_surface_get_rendertarget_view(device->target) : NULL;
3397 if (rtv)
3398 {
3399 if (FAILED(wined3d_device_context_set_rendertarget_views(device->immediate_context, 0, 1, &rtv, FALSE)))
3400 ERR("wined3d_device_context_set_rendertarget_views failed.\n");
3401 }
3402 else if (!device->target)
3403 {
3404 /* NULL device->target may appear when the game was setting invalid render target which in some cases
3405 * still keeps the invalid render target in the device even while returning an error.
3406 *
3407 * TODO: make render go nowhere instead of lefover render target (like it seems to work on Windows on HW devices
3408 * while may just crash on software devices. */
3409 FIXME("Keeping leftover render target.\n");
3410 }
3411
3412 dsv = device->target_ds ? ddraw_surface_get_rendertarget_view(device->target_ds) : NULL;
3413 if (FAILED(wined3d_device_context_set_depth_stencil_view(device->immediate_context, dsv)))
3414 ERR("wined3d_device_context_set_depth_stencil_view failed.\n");
3416
3417 if (device->hardware_device)
3418 return;
3419
3420 if (rtv)
3422
3423 if (dsv)
3425}
3426
3428{
3429 const struct wined3d_stateblock_state *state = device->stateblock_state;
3430 struct ddraw_surface *surface;
3431 unsigned int i, j;
3432
3434
3435 if (!device->have_draw_textures)
3436 return;
3437
3438 for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
3439 {
3440 if (!state->textures[i])
3441 continue;
3442
3443 j = 0;
3444 while ((surface = wined3d_texture_get_sub_resource_parent(state->textures[i], j)))
3445 {
3446 if (!surface->draw_texture)
3447 break;
3449 ++j;
3450 }
3451 }
3452}
3453
3455{
3456 if (device->ddraw && device->ddraw->device_last_applied_state != device)
3457 {
3459 device->ddraw->device_last_applied_state = device;
3460 }
3461 if (clear_state)
3462 wined3d_stateblock_apply_clear_state(device->state, device->wined3d_device);
3463 else
3464 wined3d_device_apply_stateblock(device->wined3d_device, device->state);
3466}
3467
3468static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface,
3469 D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices,
3471{
3473 UINT stride, vb_pos, size;
3474 HRESULT hr;
3475
3476 TRACE("iface %p, primitive_type %#x, fvf %#lx, vertices %p, vertex_count %lu, flags %#lx.\n",
3477 iface, primitive_type, fvf, vertices, vertex_count, flags);
3478
3479 if (!vertex_count)
3480 {
3481 WARN("0 vertex count.\n");
3482 return D3D_OK;
3483 }
3484
3485 /* Get the stride */
3488
3490
3491 if (FAILED(hr = wined3d_streaming_buffer_upload(device->wined3d_device,
3492 &device->vertex_buffer, vertices, size, stride, &vb_pos)))
3493 goto done;
3494
3495 hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer.buffer, 0, stride);
3496 if (FAILED(hr))
3497 goto done;
3498
3503 wined3d_device_context_draw(device->immediate_context, vb_pos / stride, vertex_count, 0, 0);
3504
3505done:
3507 return hr;
3508}
3509
3511 D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices,
3513{
3514 return d3d_device7_DrawPrimitive(iface, primitive_type, fvf, vertices, vertex_count, flags);
3515}
3516
3518 D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices,
3520{
3521 HRESULT hr;
3522 WORD old_fpucw;
3523
3524 old_fpucw = d3d_fpu_setup();
3526 set_fpu_control_word(old_fpucw);
3527
3528 return hr;
3529}
3530
3531static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD flags)
3532{
3533 BOOL enable = TRUE;
3534
3535 /* Ignore the D3DFVF_XYZRHW case here, wined3d takes care of that */
3536 if (!device->material || !(fvf & D3DFVF_NORMAL) || (flags & D3DDP_DONOTLIGHT))
3537 enable = FALSE;
3538
3540}
3541
3542
3543static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface,
3545 DWORD flags)
3546{
3548
3549 TRACE("iface %p, primitive_type %#x, fvf %#lx, vertices %p, vertex_count %lu, flags %#lx.\n",
3550 iface, primitive_type, fvf, vertices, vertex_count, flags);
3551
3553
3554 return IDirect3DDevice7_DrawPrimitive(&device->IDirect3DDevice7_iface,
3555 primitive_type, fvf, vertices, vertex_count, flags);
3556}
3557
3558static HRESULT WINAPI d3d_device2_DrawPrimitive(IDirect3DDevice2 *iface,
3561{
3563 DWORD fvf;
3564
3565 TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %lu, flags %#lx.\n",
3566 iface, primitive_type, vertex_type, vertices, vertex_count, flags);
3567
3568 switch (vertex_type)
3569 {
3570 case D3DVT_VERTEX: fvf = D3DFVF_VERTEX; break;
3571 case D3DVT_LVERTEX: fvf = D3DFVF_LVERTEX; break;
3572 case D3DVT_TLVERTEX: fvf = D3DFVF_TLVERTEX; break;
3573 default:
3574 FIXME("Unhandled vertex type %#x.\n", vertex_type);
3575 return DDERR_INVALIDPARAMS; /* Should never happen */
3576 }
3577
3578 return d3d_device3_DrawPrimitive(&device->IDirect3DDevice3_iface,
3579 primitive_type, fvf, vertices, vertex_count, flags);
3580}
3581
3582/*****************************************************************************
3583 * IDirect3DDevice7::DrawIndexedPrimitive
3584 *
3585 * Draws vertices from an application-provided pointer, based on the index
3586 * numbers in a WORD array.
3587 *
3588 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
3589 * an FVF format for D3D7
3590 *
3591 * Params:
3592 * PrimitiveType: The primitive type to draw
3593 * VertexType: The FVF vertex description
3594 * Vertices: Pointer to the vertex array
3595 * VertexCount: ?
3596 * Indices: Pointer to the index array
3597 * IndexCount: Number of indices = Number of vertices to draw
3598 * Flags: As usual, some flags
3599 *
3600 * Returns:
3601 * D3D_OK on success
3602 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
3603 *
3604 *****************************************************************************/
3605static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
3607 WORD *indices, DWORD index_count, DWORD flags)
3608{
3610 unsigned int idx_size = index_count * sizeof(*indices);
3611 unsigned short min_index = USHRT_MAX, max_index = 0;
3612 unsigned int i;
3613 HRESULT hr;
3615 UINT vb_pos, ib_pos;
3616
3617 TRACE("iface %p, primitive_type %#x, fvf %#lx, vertices %p, vertex_count %lu, "
3618 "indices %p, index_count %lu, flags %#lx.\n",
3619 iface, primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
3620
3621 if (!vertex_count || !index_count)
3622 {
3623 WARN("0 vertex or index count.\n");
3624 return D3D_OK;
3625 }
3626
3627 /* Prince of Persia 3D creates large vertex buffers but only actually uses
3628 * a few vertices from them. This improves performance dramatically. */
3629 for (i = 0; i < index_count; ++i)
3630 {
3631 min_index = min(min_index, indices[i]);
3632 max_index = max(max_index, indices[i]);
3633 }
3634
3635 /* Set the D3DDevice's FVF */
3637
3638 if (FAILED(hr = wined3d_streaming_buffer_upload(device->wined3d_device, &device->vertex_buffer,
3639 (char *)vertices + (min_index * stride), (max_index + 1 - min_index) * stride, stride, &vb_pos)))
3640 goto done;
3641
3642 if (FAILED(hr = wined3d_streaming_buffer_upload(device->wined3d_device,
3643 &device->index_buffer, indices, idx_size, sizeof(*indices), &ib_pos)))
3644 goto done;
3645
3646 hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer.buffer, 0, stride);
3647 if (FAILED(hr))
3648 goto done;
3650
3655 wined3d_device_context_draw_indexed(device->immediate_context, (int)(vb_pos / stride) - min_index,
3656 ib_pos / sizeof(*indices), index_count, 0, 0);
3657
3658done:
3660 return hr;
3661}
3662
3665 WORD *indices, DWORD index_count, DWORD flags)
3666{
3668 vertices, vertex_count, indices, index_count, flags);
3669}
3670
3673 WORD *indices, DWORD index_count, DWORD flags)
3674{
3675 HRESULT hr;
3676 WORD old_fpucw;
3677
3678 old_fpucw = d3d_fpu_setup();
3680 vertices, vertex_count, indices, index_count, flags);
3681 set_fpu_control_word(old_fpucw);
3682
3683 return hr;
3684}
3685
3686static HRESULT WINAPI d3d_device3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
3688 WORD *indices, DWORD index_count, DWORD flags)
3689{
3691
3692 TRACE("iface %p, primitive_type %#x, fvf %#lx, vertices %p, vertex_count %lu, "
3693 "indices %p, index_count %lu, flags %#lx.\n",
3694 iface, primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
3695
3697
3698 return IDirect3DDevice7_DrawIndexedPrimitive(&device->IDirect3DDevice7_iface,
3699 primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
3700}
3701
3702static HRESULT WINAPI d3d_device2_DrawIndexedPrimitive(IDirect3DDevice2 *iface,
3704 DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
3705{
3707 DWORD fvf;
3708
3709 TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %lu, "
3710 "indices %p, index_count %lu, flags %#lx.\n",
3711 iface, primitive_type, vertex_type, vertices, vertex_count, indices, index_count, flags);
3712
3713 switch (vertex_type)
3714 {
3715 case D3DVT_VERTEX: fvf = D3DFVF_VERTEX; break;
3716 case D3DVT_LVERTEX: fvf = D3DFVF_LVERTEX; break;
3717 case D3DVT_TLVERTEX: fvf = D3DFVF_TLVERTEX; break;
3718 default:
3719 ERR("Unhandled vertex type %#x.\n", vertex_type);
3720 return DDERR_INVALIDPARAMS; /* Should never happen */
3721 }
3722
3723 return d3d_device3_DrawIndexedPrimitive(&device->IDirect3DDevice3_iface,
3724 primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
3725}
3726
3727/*****************************************************************************
3728 * IDirect3DDevice3::End
3729 *
3730 * Ends a draw begun with IDirect3DDevice3::Begin or
3731 * IDirect3DDevice::BeginIndexed. The vertices specified with
3732 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
3733 * the IDirect3DDevice3::DrawPrimitive method. So far only
3734 * non-indexed mode is supported
3735 *
3736 * Version 2 and 3
3737 *
3738 * Params:
3739 * Flags: Some flags, as usual. Don't know which are defined
3740 *
3741 * Returns:
3742 * The return value of IDirect3DDevice3::DrawPrimitive
3743 *
3744 *****************************************************************************/
3745static HRESULT WINAPI d3d_device3_End(IDirect3DDevice3 *iface, DWORD flags)
3746{
3748
3749 TRACE("iface %p, flags %#lx.\n", iface, flags);
3750
3751 return d3d_device3_DrawPrimitive(&device->IDirect3DDevice3_iface, device->primitive_type,
3752 device->vertex_type, device->sysmem_vertex_buffer, device->nb_vertices, device->render_flags);
3753}
3754
3755static HRESULT WINAPI d3d_device2_End(IDirect3DDevice2 *iface, DWORD flags)
3756{
3758
3759 TRACE("iface %p, flags %#lx.\n", iface, flags);
3760
3761 return d3d_device3_End(&device->IDirect3DDevice3_iface, flags);
3762}
3763
3764/*****************************************************************************
3765 * IDirect3DDevice7::SetClipStatus
3766 *
3767 * Sets the clip status. This defines things as clipping conditions and
3768 * the extents of the clipping region.
3769 *
3770 * Version 2, 3 and 7
3771 *
3772 * Params:
3773 * ClipStatus:
3774 *
3775 * Returns:
3776 * D3D_OK because it's a stub
3777 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
3778 *
3779 *****************************************************************************/
3780static HRESULT WINAPI d3d_device7_SetClipStatus(IDirect3DDevice7 *iface, D3DCLIPSTATUS *clip_status)
3781{
3782 FIXME("iface %p, clip_status %p stub!\n", iface, clip_status);
3783
3784 return D3D_OK;
3785}
3786
3787static HRESULT WINAPI d3d_device3_SetClipStatus(IDirect3DDevice3 *iface, D3DCLIPSTATUS *clip_status)
3788{
3790
3791 TRACE("iface %p, clip_status %p.\n", iface, clip_status);
3792
3793 return IDirect3DDevice7_SetClipStatus(&device->IDirect3DDevice7_iface, clip_status);
3794}
3795
3796static HRESULT WINAPI d3d_device2_SetClipStatus(IDirect3DDevice2 *iface, D3DCLIPSTATUS *clip_status)
3797{
3799
3800 TRACE("iface %p, clip_status %p.\n", iface, clip_status);
3801
3802 return IDirect3DDevice7_SetClipStatus(&device->IDirect3DDevice7_iface, clip_status);
3803}
3804
3805/*****************************************************************************
3806 * IDirect3DDevice7::GetClipStatus
3807 *
3808 * Returns the clip status
3809 *
3810 * Params:
3811 * ClipStatus: Address to write the clip status to
3812 *
3813 * Returns:
3814 * D3D_OK because it's a stub
3815 *
3816 *****************************************************************************/
3817static HRESULT WINAPI d3d_device7_GetClipStatus(IDirect3DDevice7 *iface, D3DCLIPSTATUS *clip_status)
3818{
3820 struct wined3d_viewport vp;
3821
3822 FIXME("iface %p, clip_status %p stub.\n", iface, clip_status);
3823
3824 vp = device->stateblock_state->viewport;
3825 clip_status->minx = vp.x;
3826 clip_status->maxx = vp.x + vp.width;
3827 clip_status->miny = vp.y;
3828 clip_status->maxy = vp.y + vp.height;
3829 clip_status->minz = 0.0f;
3830 clip_status->maxz = 0.0f;
3831 clip_status->dwFlags = D3DCLIPSTATUS_EXTENTS2;
3832 clip_status->dwStatus = 0;
3833
3834 return D3D_OK;
3835}
3836
3837static HRESULT WINAPI d3d_device3_GetClipStatus(IDirect3DDevice3 *iface, D3DCLIPSTATUS *clip_status)
3838{
3840
3841 TRACE("iface %p, clip_status %p.\n", iface, clip_status);
3842
3843 return IDirect3DDevice7_GetClipStatus(&device->IDirect3DDevice7_iface, clip_status);
3844}
3845
3846static HRESULT WINAPI d3d_device2_GetClipStatus(IDirect3DDevice2 *iface, D3DCLIPSTATUS *clip_status)
3847{
3849
3850 TRACE("iface %p, clip_status %p.\n", iface, clip_status);
3851
3852 return IDirect3DDevice7_GetClipStatus(&device->IDirect3DDevice7_iface, clip_status);
3853}
3854
3855/*****************************************************************************
3856 * IDirect3DDevice::DrawPrimitiveStrided
3857 *
3858 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3859 *
3860 * Version 3 and 7
3861 *
3862 * Params:
3863 * PrimitiveType: The primitive type to draw
3864 * VertexType: The FVF description of the vertices to draw (for the stride??)
3865 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3866 * the vertex data locations
3867 * VertexCount: The number of vertices to draw
3868 * Flags: Some flags
3869 *
3870 * Returns:
3871 * D3D_OK, because it's a stub
3872 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3873 *
3874 *****************************************************************************/
3876{
3877 DWORD i, tex, offset;
3878
3879 for (i = 0; i < count; i++)
3880 {
3881 /* The contents of the strided data are determined by the fvf,
3882 * not by the members set in src. So it's valid
3883 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3884 * not set in the fvf. */
3885 if (fvf & D3DFVF_POSITION_MASK)
3886 {
3887 offset = i * src->position.dwStride;
3888 if (fvf & D3DFVF_XYZRHW)
3889 {
3890 memcpy(dst, ((BYTE *)src->position.lpvData) + offset, 4 * sizeof(float));
3891 dst += 4 * sizeof(float);
3892 }
3893 else
3894 {
3895 memcpy(dst, ((BYTE *)src->position.lpvData) + offset, 3 * sizeof(float));
3896 dst += 3 * sizeof(float);
3897 }
3898 }
3899
3900 if (fvf & D3DFVF_NORMAL)
3901 {
3902 offset = i * src->normal.dwStride;
3903 memcpy(dst, ((BYTE *)src->normal.lpvData) + offset, 3 * sizeof(float));
3904 dst += 3 * sizeof(float);
3905 }
3906
3907 if (fvf & D3DFVF_DIFFUSE)
3908 {
3909 offset = i * src->diffuse.dwStride;
3910 memcpy(dst, ((BYTE *)src->diffuse.lpvData) + offset, sizeof(DWORD));
3911 dst += sizeof(DWORD);
3912 }
3913
3914 if (fvf & D3DFVF_SPECULAR)
3915 {
3916 offset = i * src->specular.dwStride;
3917 memcpy(dst, ((BYTE *)src->specular.lpvData) + offset, sizeof(DWORD));
3918 dst += sizeof(DWORD);
3919 }
3920
3921 for (tex = 0; tex < GET_TEXCOUNT_FROM_FVF(fvf); ++tex)
3922 {
3923 DWORD attrib_count = GET_TEXCOORD_SIZE_FROM_FVF(fvf, tex);
3924 offset = i * src->textureCoords[tex].dwStride;
3925 memcpy(dst, ((BYTE *)src->textureCoords[tex].lpvData) + offset, attrib_count * sizeof(float));
3926 dst += attrib_count * sizeof(float);
3927 }
3928 }
3929}
3930
3933{
3935 HRESULT hr;
3936 UINT dst_stride = get_flexible_vertex_size(fvf);
3937 UINT dst_size = dst_stride * vertex_count;
3938 void *dst_data;
3939 UINT vb_pos;
3940
3941 TRACE("iface %p, primitive_type %#x, fvf %#lx, strided_data %p, vertex_count %lu, flags %#lx.\n",
3942 iface, primitive_type, fvf, strided_data, vertex_count, flags);
3943
3944 if (!vertex_count)
3945 {
3946 WARN("0 vertex count.\n");
3947 return D3D_OK;
3948 }
3949
3951
3952 if (FAILED(hr = wined3d_streaming_buffer_map(device->wined3d_device,
3953 &device->vertex_buffer, dst_size, dst_stride, &vb_pos, &dst_data)))
3954 goto done;
3955 pack_strided_data(dst_data, vertex_count, strided_data, fvf);
3956 wined3d_streaming_buffer_unmap(&device->vertex_buffer);
3957
3958 hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer.buffer, 0, dst_stride);
3959 if (FAILED(hr))
3960 goto done;
3962
3966 wined3d_device_context_draw(device->immediate_context, vb_pos / dst_stride, vertex_count, 0, 0);
3967
3968done:
3970 return hr;
3971}
3972
3974 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
3975 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
3976{
3977 return d3d_device7_DrawPrimitiveStrided(iface, PrimitiveType,
3978 VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
3979}
3980
3982 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
3983 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
3984{
3985 HRESULT hr;
3986 WORD old_fpucw;
3987
3988 old_fpucw = d3d_fpu_setup();
3989 hr = d3d_device7_DrawPrimitiveStrided(iface, PrimitiveType,
3990 VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
3991 set_fpu_control_word(old_fpucw);
3992
3993 return hr;
3994}
3995
3996static HRESULT WINAPI d3d_device3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
3997 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
3998 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
3999{
4001
4002 TRACE("iface %p, primitive_type %#x, FVF %#lx, strided_data %p, vertex_count %lu, flags %#lx.\n",
4003 iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
4004
4005 setup_lighting(device, VertexType, Flags);
4006
4007 return IDirect3DDevice7_DrawPrimitiveStrided(&device->IDirect3DDevice7_iface,
4008 PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
4009}
4010
4011/*****************************************************************************
4012 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
4013 *
4014 * Draws primitives specified by strided data locations based on indices
4015 *
4016 * Version 3 and 7
4017 *
4018 * Params:
4019 * PrimitiveType:
4020 *
4021 * Returns:
4022 * D3D_OK, because it's a stub
4023 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
4024 * (DDERR_INVALIDPARAMS if Indices is NULL)
4025 *
4026 *****************************************************************************/
4029 DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
4030{
4032 UINT vtx_dst_stride = get_flexible_vertex_size(fvf);
4033 UINT vtx_dst_size = vertex_count * vtx_dst_stride;
4034 UINT idx_size = index_count * sizeof(WORD);
4035 void *dst_data;
4036 UINT vb_pos;
4037 UINT ib_pos;
4038 HRESULT hr;
4039
4040 TRACE("iface %p, primitive_type %#x, fvf %#lx, strided_data %p, "
4041 "vertex_count %lu, indices %p, index_count %lu, flags %#lx.\n",
4042 iface, primitive_type, fvf, strided_data, vertex_count, indices, index_count, flags);
4043
4044 if (!vertex_count || !index_count)
4045 {
4046 WARN("0 vertex or index count.\n");
4047 return D3D_OK;
4048 }
4049
4051
4052 if (FAILED(hr = wined3d_streaming_buffer_map(device->wined3d_device,
4053 &device->vertex_buffer, vtx_dst_size, vtx_dst_stride, &vb_pos, &dst_data)))
4054 goto done;
4055 pack_strided_data(dst_data, vertex_count, strided_data, fvf);
4056 wined3d_streaming_buffer_unmap(&device->vertex_buffer);
4057
4058 if (FAILED(hr = wined3d_streaming_buffer_upload(device->wined3d_device,
4059 &device->index_buffer, indices, idx_size, sizeof(WORD), &ib_pos)))
4060 goto done;
4061
4062 hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer.buffer, 0, vtx_dst_stride);
4063 if (FAILED(hr))
4064 goto done;
4066
4072 vb_pos / vtx_dst_stride, ib_pos / sizeof(WORD), index_count, 0, 0);
4073
4074done:
4076 return hr;
4077}
4078
4080 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
4081 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount,
4082 WORD *Indices, DWORD IndexCount, DWORD Flags)
4083{
4084 return d3d_device7_DrawIndexedPrimitiveStrided(iface, PrimitiveType, VertexType,
4085 D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
4086}
4087
4089 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
4090 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount,
4091 WORD *Indices, DWORD IndexCount, DWORD Flags)
4092{
4093 HRESULT hr;
4094 WORD old_fpucw;
4095
4096 old_fpucw = d3d_fpu_setup();
4097 hr = d3d_device7_DrawIndexedPrimitiveStrided(iface, PrimitiveType, VertexType,
4098 D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
4099 set_fpu_control_word(old_fpucw);
4100
4101 return hr;
4102}
4103
4105 D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
4106 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices,
4107 DWORD IndexCount, DWORD Flags)
4108{
4110
4111 TRACE("iface %p, primitive_type %#x, FVF %#lx, strided_data %p, vertex_count %lu, indices %p, index_count %lu, flags %#lx.\n",
4112 iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
4113
4114 setup_lighting(device, VertexType, Flags);
4115
4116 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(&device->IDirect3DDevice7_iface,
4117 PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
4118}
4119
4120/*****************************************************************************
4121 * IDirect3DDevice7::DrawPrimitiveVB
4122 *
4123 * Draws primitives from a vertex buffer to the screen.
4124 *
4125 * Version 3 and 7
4126 *
4127 * Params:
4128 * PrimitiveType: Type of primitive to be rendered.
4129 * D3DVertexBuf: Source Vertex Buffer
4130 * StartVertex: Index of the first vertex from the buffer to be rendered
4131 * NumVertices: Number of vertices to be rendered
4132 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
4133 *
4134 * Return values
4135 * D3D_OK on success
4136 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
4137 *
4138 *****************************************************************************/
4140 IDirect3DVertexBuffer7 *vb, DWORD start_vertex, DWORD vertex_count, DWORD flags)
4141{
4146 struct wined3d_box wined3d_box = {0};
4147 DWORD stride;
4148 HRESULT hr;
4149
4150 TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %lu, vertex_count %lu, flags %#lx.\n",
4151 iface, primitive_type, vb, start_vertex, vertex_count, flags);
4152
4153 if (!vertex_count)
4154 {
4155 WARN("0 vertex count.\n");
4156 return D3D_OK;
4157 }
4158
4159 vb_impl->discarded = false;
4160
4162
4163 if (vb_impl->sysmem)
4164 {
4165 TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawPrimitive().\n");
4168 wined3d_box.left = start_vertex * stride;
4172 {
4175 }
4176 hr = d3d_device7_DrawPrimitive(iface, primitive_type, vb_impl->fvf, wined3d_map_desc.data,
4180 return hr;
4181 }
4182
4186 0, vb_impl->wined3d_buffer, 0, stride)))
4187 {
4188 WARN("Failed to set stream source, hr %#lx.\n", hr);
4190 return hr;
4191 }
4192
4193 /* Now draw the primitives */
4195 wined3d_primitive_type_from_ddraw(primitive_type), 0);
4197 wined3d_device_context_draw(device->immediate_context, start_vertex, vertex_count, 0, 0);
4198
4200
4201 return hr;
4202}
4203
4204static HRESULT WINAPI d3d_device7_DrawPrimitiveVB_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType,
4205 IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
4206{
4207 return d3d_device7_DrawPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
4208}
4209
4210static HRESULT WINAPI d3d_device7_DrawPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType,
4211 IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
4212{
4213 HRESULT hr;
4214 WORD old_fpucw;
4215
4216 old_fpucw = d3d_fpu_setup();
4217 hr = d3d_device7_DrawPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
4218 set_fpu_control_word(old_fpucw);
4219
4220 return hr;
4221}
4222
4223static HRESULT WINAPI d3d_device3_DrawPrimitiveVB(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE PrimitiveType,
4224 IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
4225{
4227 struct d3d_vertex_buffer *vb = unsafe_impl_from_IDirect3DVertexBuffer7((IDirect3DVertexBuffer7 *)D3DVertexBuf);
4228
4229 TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %lu, vertex_count %lu, flags %#lx.\n",
4230 iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
4231
4233
4234 return IDirect3DDevice7_DrawPrimitiveVB(&device->IDirect3DDevice7_iface,
4235 PrimitiveType, &vb->IDirect3DVertexBuffer7_iface, StartVertex, NumVertices, Flags);
4236}
4237
4238/*****************************************************************************
4239 * IDirect3DDevice7::DrawIndexedPrimitiveVB
4240 *
4241 * Draws primitives from a vertex buffer to the screen
4242 *
4243 * Params:
4244 * PrimitiveType: Type of primitive to be rendered.
4245 * D3DVertexBuf: Source Vertex Buffer
4246 * StartVertex: Index of the first vertex from the buffer to be rendered
4247 * NumVertices: Number of vertices to be rendered
4248 * Indices: Array of DWORDs used to index into the Vertices
4249 * IndexCount: Number of indices in Indices
4250 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
4251 *
4252 * Return values
4253 *
4254 *****************************************************************************/
4255static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
4256 D3DPRIMITIVETYPE primitive_type, IDirect3DVertexBuffer7 *vb,
4257 DWORD start_vertex, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
4258{
4264 struct wined3d_box wined3d_box = {0};
4265 HRESULT hr;
4266 UINT ib_pos;
4267
4268 TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %lu, "
4269 "vertex_count %lu, indices %p, index_count %lu, flags %#lx.\n",
4270 iface, primitive_type, vb, start_vertex, vertex_count, indices, index_count, flags);
4271
4272 if (!vertex_count || !index_count)
4273 {
4274 WARN("0 vertex or index count.\n");
4275 return D3D_OK;
4276 }
4277
4278 vb_impl->discarded = false;
4279
4280 if (vb_impl->sysmem)
4281 {
4282 TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawIndexedPrimitive().\n");
4284 wined3d_box.left = start_vertex * stride;
4289 {
4292 }
4293 hr = d3d_device7_DrawIndexedPrimitive(iface, primitive_type, vb_impl->fvf,
4297 return hr;
4298 }
4299
4300 /* Steps:
4301 * 1) Upload the indices to the index buffer
4302 * 2) Set the index source
4303 * 3) Set the Vertex Buffer as the Stream source
4304 * 4) Call wined3d_device_context_draw_indexed()
4305 */
4306
4308
4310
4311 if (FAILED(hr = wined3d_streaming_buffer_upload(device->wined3d_device,
4312 &device->index_buffer, indices, index_count * sizeof(WORD), sizeof(WORD), &ib_pos)))
4313 {
4315 return hr;
4316 }
4317
4318 /* Set the index stream */
4320
4321 /* Set the vertex stream source */
4323 0, vb_impl->wined3d_buffer, 0, stride)))
4324 {
4325 ERR("Failed to set stream source for device %p, hr %#lx.\n", device, hr);
4327 return hr;
4328 }
4329
4331 wined3d_primitive_type_from_ddraw(primitive_type), 0);
4333 wined3d_device_context_draw_indexed(device->immediate_context, start_vertex,
4334 ib_pos / sizeof(WORD), index_count, 0, 0);
4335
4337
4338 return hr;
4339}
4340
4342 D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf,
4343 DWORD StartVertex, DWORD NumVertices, WORD *Indices, DWORD IndexCount, DWORD Flags)
4344{
4345 return d3d_device7_DrawIndexedPrimitiveVB(iface, PrimitiveType,
4346 D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
4347}
4348
4350 D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf,
4351 DWORD StartVertex, DWORD NumVertices, WORD *Indices, DWORD IndexCount, DWORD Flags)
4352{
4353 HRESULT hr;
4354 WORD old_fpucw;
4355
4356 old_fpucw = d3d_fpu_setup();
4357 hr = d3d_device7_DrawIndexedPrimitiveVB(iface, PrimitiveType,
4358 D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
4359 set_fpu_control_word(old_fpucw);
4360
4361 return hr;
4362}
4363
4365 D3DPRIMITIVETYPE primitive_type, IDirect3DVertexBuffer *vertex_buffer,
4366 WORD *indices, DWORD index_count, DWORD flags)
4367{
4368 struct d3d_vertex_buffer *vb =
4369 unsafe_impl_from_IDirect3DVertexBuffer7((IDirect3DVertexBuffer7 *)vertex_buffer);
4371 DWORD stride;
4372
4373 TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %lu, flags %#lx.\n",
4374 iface, primitive_type, vertex_buffer, indices, index_count, flags);
4375
4377
4378 if (!(stride = get_flexible_vertex_size(vb->fvf)))
4379 return D3D_OK;
4380
4381 return IDirect3DDevice7_DrawIndexedPrimitiveVB(&device->IDirect3DDevice7_iface, primitive_type,
4382 &vb->IDirect3DVertexBuffer7_iface, 0, vb->size / stride, indices, index_count, flags);
4383}
4384
4385/*****************************************************************************
4386 * IDirect3DDevice7::ComputeSphereVisibility
4387 *
4388 * Calculates the visibility of spheres in the current viewport. The spheres
4389 * are passed in the Centers and Radii arrays, the results are passed back
4390 * in the ReturnValues array. Return values are either completely visible,
4391 * partially visible or completely invisible.
4392 * The return value consists of a combination of D3DCLIP_* flags, or is
4393 * 0 if the sphere is completely visible (according to the SDK, not checked)
4394 *
4395 * Version 3 and 7
4396 *
4397 * Params:
4398 * Centers: Array containing the sphere centers
4399 * Radii: Array containing the sphere radii
4400 * NumSpheres: The number of centers and radii in the arrays
4401 * Flags: Some flags
4402 * ReturnValues: Array to write the results to
4403 *
4404 * Returns:
4405 * D3D_OK
4406 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
4407 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
4408 * is singular)
4409 *
4410 *****************************************************************************/
4411
4412static DWORD in_plane(UINT idx, struct wined3d_vec4 p, D3DVECTOR center, D3DVALUE radius, BOOL equality)
4413{
4414 float distance, norm;
4415
4416 norm = sqrtf(p.x * p.x + p.y * p.y + p.z * p.z);
4417 distance = (p.x * center.x + p.y * center.y + p.z * center.z + p.w) / norm;
4418
4419 if (equality)
4420 {
4421 if (fabs(distance) <= radius)
4422 return D3DSTATUS_CLIPUNIONLEFT << idx;
4423 if (distance <= -radius)
4425 }
4426 else
4427 {
4428 if (fabs(distance) < radius)
4429 return D3DSTATUS_CLIPUNIONLEFT << idx;
4430 if (distance < -radius)
4432 }
4433 return 0;
4434}
4435
4437{
4438 const struct wined3d_stateblock_state *state;
4439 struct wined3d_matrix m;
4440
4441 /* We want the wined3d matrices since those include the legacy viewport
4442 * transformation. */
4444 state = device->stateblock_state;
4445 multiply_matrix(&m, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD]);
4446 multiply_matrix(&m, &state->transforms[WINED3D_TS_PROJECTION], &m);
4448
4449 /* Left plane. */
4450 plane[0].x = m._14 + m._11;
4451 plane[0].y = m._24 + m._21;
4452 plane[0].z = m._34 + m._31;
4453 plane[0].w = m._44 + m._41;
4454
4455 /* Right plane. */
4456 plane[1].x = m._14 - m._11;
4457 plane[1].y = m._24 - m._21;
4458 plane[1].z = m._34 - m._31;
4459 plane[1].w = m._44 - m._41;
4460
4461 /* Top plane. */
4462 plane[2].x = m._14 - m._12;
4463 plane[2].y = m._24 - m._22;
4464 plane[2].z = m._34 - m._32;
4465 plane[2].w = m._44 - m._42;
4466
4467 /* Bottom plane. */
4468 plane[3].x = m._14 + m._12;
4469 plane[3].y = m._24 + m._22;
4470 plane[3].z = m._34 + m._32;
4471 plane[3].w = m._44 + m._42;
4472
4473 /* Front plane. */
4474 plane[4].x = m._13;
4475 plane[4].y = m._23;
4476 plane[4].z = m._33;
4477 plane[4].w = m._43;
4478
4479 /* Back plane. */
4480 plane[5].x = m._14 - m._13;
4481 plane[5].y = m._24 - m._23;
4482 plane[5].z = m._34 - m._33;
4483 plane[5].w = m._44 - m._43;
4484}
4485
4486static void compute_sphere_visibility(const struct wined3d_vec4 *planes, DWORD enabled_planes, BOOL equality,
4487 const D3DVECTOR *centres, const D3DVALUE *radii, unsigned int sphere_count, DWORD *return_values)
4488{
4489 unsigned int mask, i, j;
4490
4491 memset(return_values, 0, sphere_count * sizeof(*return_values));
4492 for (i = 0; i < sphere_count; ++i)
4493 {
4494 mask = enabled_planes;
4495 while (mask)
4496 {
4498 return_values[i] |= in_plane(j, planes[j], centres[i], radii[i], equality);
4499 }
4500 }
4501}
4502
4504 D3DVECTOR *centers, D3DVALUE *radii, DWORD sphere_count, DWORD flags, DWORD *return_values)
4505{
4506 struct wined3d_vec4 plane[12];
4507 DWORD enabled_planes = 0x3f;
4508 DWORD user_clip_planes;
4509 UINT j;
4510
4511 TRACE("iface %p, centers %p, radii %p, sphere_count %lu, flags %#lx, return_values %p.\n",
4512 iface, centers, radii, sphere_count, flags, return_values);
4513
4515
4517 enabled_planes |= user_clip_planes << 6;
4518 for (j = 6; j < 12; ++j)
4520
4521 compute_sphere_visibility(plane, enabled_planes, FALSE, centers, radii, sphere_count, return_values);
4522 return D3D_OK;
4523}
4524
4526 D3DVECTOR *centers, D3DVALUE *radii, DWORD sphere_count, DWORD flags, DWORD *return_values)
4527{
4528 static const DWORD enabled_planes = 0x3f;
4529 struct wined3d_vec4 plane[6];
4530 unsigned int i, j;
4531
4532 TRACE("iface %p, centers %p, radii %p, sphere_count %lu, flags %#lx, return_values %p.\n",
4533 iface, centers, radii, sphere_count, flags, return_values);
4534
4536
4537 compute_sphere_visibility(plane, enabled_planes, TRUE, centers, radii, sphere_count, return_values);
4538 for (i = 0; i < sphere_count; ++i)
4539 {
4540 BOOL intersect_frustum = FALSE, outside_frustum = FALSE;
4541 DWORD d3d7_result = return_values[i];
4542
4543 return_values[i] = 0;
4544
4545 for (j = 0; j < 6; ++j)
4546 {
4547 DWORD clip = (d3d7_result >> j) & (D3DSTATUS_CLIPUNIONLEFT | D3DSTATUS_CLIPINTERSECTIONLEFT);
4548
4549 if (clip == D3DSTATUS_CLIPUNIONLEFT)
4550 {
4551 return_values[i] |= D3DVIS_INTERSECT_LEFT << j * 2;
4552 intersect_frustum = TRUE;
4553 }
4554 else if (clip)
4555 {
4556 return_values[i] |= D3DVIS_OUTSIDE_LEFT << j * 2;
4557 outside_frustum = TRUE;
4558 }
4559 }
4560 if (outside_frustum)
4561 return_values[i] |= D3DVIS_OUTSIDE_FRUSTUM;
4562 else if (intersect_frustum)
4563 return_values[i] |= D3DVIS_INTERSECT_FRUSTUM;
4564 }
4565 return D3D_OK;
4566}
4567
4568/*****************************************************************************
4569 * IDirect3DDevice7::GetTexture
4570 *
4571 * Returns the texture interface handle assigned to a texture stage.
4572 * The returned texture is AddRefed. This is taken from old ddraw,
4573 * not checked in Windows.
4574 *
4575 * Version 3 and 7
4576 *
4577 * Params:
4578 * Stage: Texture stage to read the texture from
4579 * Texture: Address to store the interface pointer at
4580 *
4581 * Returns:
4582 * D3D_OK on success
4583 * DDERR_INVALIDPARAMS if Texture is NULL
4584 *
4585 *****************************************************************************/
4586static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
4588{
4592
4593 TRACE("iface %p, stage %lu, texture %p.\n", iface, stage, texture);
4594
4595 if (!texture)
4596 return DDERR_INVALIDPARAMS;
4597
4598 if (stage >= DDRAW_MAX_TEXTURES)
4599 {
4600 WARN("Invalid stage %lu.\n", stage);
4601 *texture = NULL;
4602 return D3D_OK;
4603 }
4604
4606 if (!(wined3d_texture = device->stateblock_state->textures[stage]))
4607 {
4608 *texture = NULL;
4610 return D3D_OK;
4611 }
4612
4614 *texture = &ddraw_texture->root->IDirectDrawSurface7_iface;
4615 IDirectDrawSurface7_AddRef(*texture);
4617
4618 return D3D_OK;
4619}
4620
4621static HRESULT WINAPI d3d_device7_GetTexture_FPUSetup(IDirect3DDevice7 *iface,
4622 DWORD stage, IDirectDrawSurface7 **Texture)
4623{
4624 return d3d_device7_GetTexture(iface, stage, Texture);
4625}
4626
4628 DWORD stage, IDirectDrawSurface7 **Texture)
4629{
4630 HRESULT hr;
4631 WORD old_fpucw;
4632
4633 old_fpucw = d3d_fpu_setup();
4634 hr = d3d_device7_GetTexture(iface, stage, Texture);
4635 set_fpu_control_word(old_fpucw);
4636
4637 return hr;
4638}
4639
4640static HRESULT WINAPI d3d_device3_GetTexture(IDirect3DDevice3 *iface, DWORD stage, IDirect3DTexture2 **Texture2)
4641{
4643 struct ddraw_surface *ret_val_impl;
4644 HRESULT ret;
4645 IDirectDrawSurface7 *ret_val;
4646
4647 TRACE("iface %p, stage %lu, texture %p.\n", iface, stage, Texture2);
4648
4649 ret = IDirect3DDevice7_GetTexture(&device->IDirect3DDevice7_iface, stage, &ret_val);
4650
4651 ret_val_impl = unsafe_impl_from_IDirectDrawSurface7(ret_val);
4652 *Texture2 = ret_val_impl ? &ret_val_impl->IDirect3DTexture2_iface : NULL;
4653
4654 TRACE("Returning texture %p.\n", *Texture2);
4655
4656 return ret;
4657}
4658
4659/*****************************************************************************
4660 * IDirect3DDevice7::SetTexture
4661 *
4662 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
4663 *
4664 * Version 3 and 7
4665 *
4666 * Params:
4667 * Stage: The stage to assign the texture to
4668 * Texture: Interface pointer to the texture surface
4669 *
4670 * Returns
4671 * D3D_OK on success
4672 *
4673 *****************************************************************************/
4674static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface,
4676{
4680
4681 TRACE("iface %p, stage %lu, texture %p.\n", iface, stage, texture);
4682
4683 if (surf && (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
4684 {
4685 if (surf->draw_texture)
4686 {
4688 device->have_draw_textures = TRUE;
4689 }
4690 else
4691 {
4693 }
4694 }
4695
4699
4700 return D3D_OK;
4701}
4702
4703static HRESULT WINAPI d3d_device7_SetTexture_FPUSetup(IDirect3DDevice7 *iface,
4705{
4706 return d3d_device7_SetTexture(iface, stage, texture);
4707}
4708
4711{
4712 HRESULT hr;
4713 WORD old_fpucw;
4714
4715 old_fpucw = d3d_fpu_setup();
4716 hr = d3d_device7_SetTexture(iface, stage, texture);
4717 set_fpu_control_word(old_fpucw);
4718
4719 return hr;
4720}
4721
4722static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
4723 DWORD stage, IDirect3DTexture2 *texture)
4724{
4728
4729 TRACE("iface %p, stage %lu, texture %p.\n", iface, stage, texture);
4730
4732
4733 if (tex && ((tex->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) || !device->hardware_device))
4734 {
4735 if (tex->draw_texture)
4736 {
4738 device->have_draw_textures = TRUE;
4739 }
4740 else
4741 {
4743 }
4744 }
4745
4748
4750
4751 return D3D_OK;
4752}
4753
4754static const struct tss_lookup
4755{
4757 union
4758 {
4761 } u;
4762}
4763tss_lookup[] =
4764{
4765 {FALSE, .u.texture_state = WINED3D_TSS_INVALID}, /* 0, unused */
4766 {FALSE, .u.texture_state = WINED3D_TSS_COLOR_OP}, /* 1, D3DTSS_COLOROP */
4767 {FALSE, .u.texture_state = WINED3D_TSS_COLOR_ARG1}, /* 2, D3DTSS_COLORARG1 */
4768 {FALSE, .u.texture_state = WINED3D_TSS_COLOR_ARG2}, /* 3, D3DTSS_COLORARG2 */
4769 {FALSE, .u.texture_state = WINED3D_TSS_ALPHA_OP}, /* 4, D3DTSS_ALPHAOP */
4770 {FALSE, .u.texture_state = WINED3D_TSS_ALPHA_ARG1}, /* 5, D3DTSS_ALPHAARG1 */
4771 {FALSE, .u.texture_state = WINED3D_TSS_ALPHA_ARG2}, /* 6, D3DTSS_ALPHAARG2 */
4772 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_MAT00}, /* 7, D3DTSS_BUMPENVMAT00 */
4773 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_MAT01}, /* 8, D3DTSS_BUMPENVMAT01 */
4774 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_MAT10}, /* 9, D3DTSS_BUMPENVMAT10 */
4775 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_MAT11}, /* 10, D3DTSS_BUMPENVMAT11 */
4776 {FALSE, .u.texture_state = WINED3D_TSS_TEXCOORD_INDEX}, /* 11, D3DTSS_TEXCOORDINDEX */
4777 {TRUE, .u.sampler_state = WINED3D_SAMP_ADDRESS_U}, /* 12, D3DTSS_ADDRESS */
4778 {TRUE, .u.sampler_state = WINED3D_SAMP_ADDRESS_U}, /* 13, D3DTSS_ADDRESSU */
4779 {TRUE, .u.sampler_state = WINED3D_SAMP_ADDRESS_V}, /* 14, D3DTSS_ADDRESSV */
4780 {TRUE, .u.sampler_state = WINED3D_SAMP_BORDER_COLOR}, /* 15, D3DTSS_BORDERCOLOR */
4781 {TRUE, .u.sampler_state = WINED3D_SAMP_MAG_FILTER}, /* 16, D3DTSS_MAGFILTER */
4782 {TRUE, .u.sampler_state = WINED3D_SAMP_MIN_FILTER}, /* 17, D3DTSS_MINFILTER */
4783 {TRUE, .u.sampler_state = WINED3D_SAMP_MIP_FILTER}, /* 18, D3DTSS_MIPFILTER */
4784 {TRUE, .u.sampler_state = WINED3D_SAMP_MIPMAP_LOD_BIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */
4785 {TRUE, .u.sampler_state = WINED3D_SAMP_MAX_MIP_LEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */
4786 {TRUE, .u.sampler_state = WINED3D_SAMP_MAX_ANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */
4787 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_LSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */
4788 {FALSE, .u.texture_state = WINED3D_TSS_BUMPENV_LOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */
4789 {FALSE, .u.texture_state = WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
4791
4792/*****************************************************************************
4793 * IDirect3DDevice7::GetTextureStageState
4794 *
4795 * Retrieves a state from a texture stage.
4796 *
4797 * Version 3 and 7
4798 *
4799 * Params:
4800 * Stage: The stage to retrieve the state from
4801 * TexStageStateType: The state type to retrieve
4802 * State: Address to store the state's value at
4803 *
4804 * Returns:
4805 * D3D_OK on success
4806 * DDERR_INVALIDPARAMS if State is NULL
4807 *
4808 *****************************************************************************/
4809static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface,
4811{
4814 const struct tss_lookup *l;
4815
4816 TRACE("iface %p, stage %lu, state %#x, value %p.\n",
4817 iface, stage, state, value);
4818
4819 if (!value)
4820 return DDERR_INVALIDPARAMS;
4821
4823 {
4824 WARN("Invalid state %#x passed.\n", state);
4825 return DD_OK;
4826 }
4827
4828 if (stage >= DDRAW_MAX_TEXTURES)
4829 {
4830 WARN("Invalid stage %lu.\n", stage);
4831 *value = 0;
4832 return D3D_OK;
4833 }
4834
4835 l = &tss_lookup[state];
4836
4838
4839 device_state = device->stateblock_state;
4840
4841 if (l->sampler_state)
4842 {
4843 *value = device_state->sampler_states[stage][l->u.sampler_state];
4844
4845 switch (state)
4846 {
4847 /* Mipfilter is a sampler state with different values */
4848 case D3DTSS_MIPFILTER:
4849 {
4850 switch (*value)
4851 {
4852 case WINED3D_TEXF_NONE:
4853 *value = D3DTFP_NONE;
4854 break;
4855 case WINED3D_TEXF_POINT:
4857 break;
4860 break;
4861 default:
4862 ERR("Unexpected mipfilter value %#lx.\n", *value);
4863 *value = D3DTFP_NONE;
4864 break;
4865 }
4866 break;
4867 }
4868
4869 /* Magfilter has slightly different values */
4870 case D3DTSS_MAGFILTER:
4871 {
4872 switch (*value)
4873 {
4874 case WINED3D_TEXF_POINT:
4876 break;
4879 break;
4882 break;
4885 break;
4888 break;
4889 default:
4890 ERR("Unexpected wined3d mag filter value %#lx.\n", *value);
4892 break;
4893 }
4894 break;
4895 }
4896
4897 default:
4898 break;
4899 }
4900 }
4901 else
4902 {
4903 *value = device_state->texture_states[stage][l->u.texture_state];
4904 }
4905
4907
4908 return D3D_OK;
4909}
4910
4913{
4914 return d3d_device7_GetTextureStageState(iface, stage, state, value);
4915}
4916
4919{
4920 HRESULT hr;
4921 WORD old_fpucw;
4922
4923 old_fpucw = d3d_fpu_setup();
4925 set_fpu_control_word(old_fpucw);
4926
4927 return hr;
4928}
4929
4930static HRESULT WINAPI d3d_device3_GetTextureStageState(IDirect3DDevice3 *iface,
4932{
4934
4935 TRACE("iface %p, stage %lu, state %#x, value %p.\n",
4936 iface, stage, state, value);
4937
4938 return IDirect3DDevice7_GetTextureStageState(&device->IDirect3DDevice7_iface, stage, state, value);
4939}
4940
4941/*****************************************************************************
4942 * IDirect3DDevice7::SetTextureStageState
4943 *
4944 * Sets a texture stage state. Some stage types need to be handled specially,
4945 * because they do not exist in WineD3D and were moved to another place
4946 *
4947 * Version 3 and 7
4948 *
4949 * Params:
4950 * Stage: The stage to modify
4951 * TexStageStateType: The state to change
4952 * State: The new value for the state
4953 *
4954 * Returns:
4955 * D3D_OK on success
4956 *
4957 *****************************************************************************/
4958static HRESULT d3d_device7_SetTextureStageState(IDirect3DDevice7 *iface,
4960{
4962 const struct tss_lookup *l;
4963
4964 TRACE("iface %p, stage %lu, state %#x, value %#lx.\n",
4965 iface, stage, state, value);
4966
4968 {
4969 WARN("Invalid state %#x passed.\n", state);
4970 return DD_OK;
4971 }
4972
4973 l = &tss_lookup[state];
4974
4976
4977 if (l->sampler_state)
4978 {
4979 switch (state)
4980 {
4981 /* Mipfilter is a sampler state with different values */
4982 case D3DTSS_MIPFILTER:
4983 {
4984 switch (value)
4985 {
4986 case D3DTFP_NONE:
4988 break;
4989 case D3DTFP_POINT:
4991 break;
4992 case 0: /* Unchecked */
4993 case D3DTFP_LINEAR:
4995 break;
4996 default:
4997 ERR("Unexpected mipfilter value %#lx.\n", value);
4999 break;
5000 }
5001 break;
5002 }
5003
5004 /* Magfilter has slightly different values */
5005 case D3DTSS_MAGFILTER:
5006 {
5007 switch (value)
5008 {
5009 case D3DTFG_POINT:
5011 break;
5012 case D3DTFG_LINEAR:
5014 break;
5015 case D3DTFG_FLATCUBIC:
5017 break;
5020 break;
5021 case D3DTFG_ANISOTROPIC:
5023 break;
5024 default:
5025 ERR("Unexpected d3d7 mag filter value %#lx.\n", value);
5027 break;
5028 }
5029 break;
5030 }
5031
5032 case D3DTSS_ADDRESS:
5034 break;
5035
5036 default:
5037 break;
5038 }
5039
5040 wined3d_stateblock_set_sampler_state(device->state, stage, l->u.sampler_state, value);
5041 }
5042 else
5043 wined3d_stateblock_set_texture_stage_state(device->update_state, stage, l->u.texture_state, value);
5044
5046
5047 return D3D_OK;
5048}
5049
5052{
5053 return d3d_device7_SetTextureStageState(iface, stage, state, value);
5054}
5055
5058{
5059 HRESULT hr;
5060 WORD old_fpucw;
5061
5062 old_fpucw = d3d_fpu_setup();
5064 set_fpu_control_word(old_fpucw);
5065
5066 return hr;
5067}
5068
5069static HRESULT WINAPI d3d_device3_SetTextureStageState(IDirect3DDevice3 *iface,
5071{
5074 HRESULT hr;
5075
5076 TRACE("iface %p, stage %lu, state %#x, value %#lx.\n",
5077 iface, stage, state, value);
5078
5079 /* Tests show that legacy texture blending is not reset if the texture stage state
5080 * value is unchanged. */
5081 if (FAILED(hr = IDirect3DDevice7_GetTextureStageState(&device->IDirect3DDevice7_iface,
5082 stage, state, &old_value)))
5083 return hr;
5084
5085 if (old_value == value)
5086 {
5087 TRACE("Application is setting the same value over, nothing to do.\n");
5088 return D3D_OK;
5089 }
5090
5091 device->legacyTextureBlending = FALSE;
5092
5093 return IDirect3DDevice7_SetTextureStageState(&device->IDirect3DDevice7_iface, stage, state, value);
5094}
5095
5096/*****************************************************************************
5097 * IDirect3DDevice7::ValidateDevice
5098 *
5099 * SDK: "Reports the device's ability to render the currently set
5100 * texture-blending operations in a single pass". Whatever that means
5101 * exactly...
5102 *
5103 * Version 3 and 7
5104 *
5105 * Params:
5106 * NumPasses: Address to write the number of necessary passes for the
5107 * desired effect to.
5108 *
5109 * Returns:
5110 * D3D_OK on success
5111 *
5112 *****************************************************************************/
5113static HRESULT d3d_device7_ValidateDevice(IDirect3DDevice7 *iface, DWORD *pass_count)
5114{
5116 HRESULT hr;
5117
5118 TRACE("iface %p, pass_count %p.\n", iface, pass_count);
5119
5121 hr = wined3d_device_validate_device(device->wined3d_device, device->stateblock_state, pass_count);
5123
5124 return hr;
5125}
5126
5127static HRESULT WINAPI d3d_device7_ValidateDevice_FPUSetup(IDirect3DDevice7 *iface, DWORD *pass_count)
5128{
5129 return d3d_device7_ValidateDevice(iface, pass_count);
5130}
5131
5132static HRESULT WINAPI d3d_device7_ValidateDevice_FPUPreserve(IDirect3DDevice7 *iface, DWORD *pass_count)
5133{
5134 HRESULT hr;
5135 WORD old_fpucw;
5136
5137 old_fpucw = d3d_fpu_setup();
5138 hr = d3d_device7_ValidateDevice(iface, pass_count);
5139 set_fpu_control_word(old_fpucw);
5140
5141 return hr;
5142}
5143
5144static HRESULT WINAPI d3d_device3_ValidateDevice(IDirect3DDevice3 *iface, DWORD *pass_count)
5145{
5147
5148 TRACE("iface %p, pass_count %p.\n", iface, pass_count);
5149
5150 return IDirect3DDevice7_ValidateDevice(&device->IDirect3DDevice7_iface, pass_count);
5151}
5152
5153/*****************************************************************************
5154 * IDirect3DDevice7::Clear
5155 *
5156 * Fills the render target, the z buffer and the stencil buffer with a
5157 * clear color / value
5158 *
5159 * Version 7 only
5160 *
5161 * Params:
5162 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
5163 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
5164 * Flags: Some flags, as usual
5165 * Color: Clear color for the render target
5166 * Z: Clear value for the Z buffer
5167 * Stencil: Clear value to store in each stencil buffer entry
5168 *
5169 * Returns:
5170 * D3D_OK on success
5171 *
5172 *****************************************************************************/
5173static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count,
5175{
5176 const struct wined3d_color c =
5177 {
5178 ((color >> 16) & 0xff) / 255.0f,
5179 ((color >> 8) & 0xff) / 255.0f,
5180 (color & 0xff) / 255.0f,
5181 ((color >> 24) & 0xff) / 255.0f,
5182 };
5184 HRESULT hr;
5185
5186 TRACE("iface %p, count %lu, rects %p, flags %#lx, color 0x%08lx, z %.8e, stencil %#lx.\n",
5187 iface, count, rects, flags, color, z, stencil);
5188
5189 if (count && !rects)
5190 {
5191 WARN("count %lu with NULL rects.\n", count);
5192 count = 0;
5193 }
5194
5197 hr = wined3d_device_clear(device->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil);
5199
5200 return hr;
5201}
5202
5203static HRESULT WINAPI d3d_device7_Clear_FPUSetup(IDirect3DDevice7 *iface, DWORD count,
5205{
5206 return d3d_device7_Clear(iface, count, rects, flags, color, z, stencil);
5207}
5208
5211{
5212 HRESULT hr;
5213 WORD old_fpucw;
5214
5215 old_fpucw = d3d_fpu_setup();
5216 hr = d3d_device7_Clear(iface, count, rects, flags, color, z, stencil);
5217 set_fpu_control_word(old_fpucw);
5218
5219 return hr;
5220}
5221
5222static HRESULT d3d_device7_SetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5223{
5225 struct wined3d_sub_resource_desc rt_desc;
5226 struct wined3d_rendertarget_view *rtv;
5227 struct ddraw_surface *surface;
5228 struct wined3d_viewport vp;
5229
5230 TRACE("iface %p, viewport %p.\n", iface, viewport);
5231
5232 if (!viewport)
5233 return DDERR_INVALIDPARAMS;
5234
5236 rtv = device->target ? ddraw_surface_get_rendertarget_view(device->target) : NULL;
5237 if (!rtv)
5238 {
5240 return DDERR_INVALIDCAPS;
5241 }
5244
5245 if (!wined3d_bound_range(viewport->dwX, viewport->dwWidth, rt_desc.width)
5246 || !wined3d_bound_range(viewport->dwY, viewport->dwHeight, rt_desc.height))
5247 {
5248 WARN("Invalid viewport, returning E_INVALIDARG.\n");
5250 return E_INVALIDARG;
5251 }
5252
5253 vp.x = viewport->dwX;
5254 vp.y = viewport->dwY;
5255 vp.width = viewport->dwWidth;
5256 vp.height = viewport->dwHeight;
5257 vp.min_z = viewport->dvMinZ;
5258 vp.max_z = viewport->dvMaxZ;
5259
5260 wined3d_stateblock_set_viewport(device->update_state, &vp);
5262
5263 return D3D_OK;
5264}
5265
5266static HRESULT WINAPI d3d_device7_SetViewport_FPUSetup(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5267{
5268 return d3d_device7_SetViewport(iface, viewport);
5269}
5270
5271static HRESULT WINAPI d3d_device7_SetViewport_FPUPreserve(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5272{
5273 HRESULT hr;
5274 WORD old_fpucw;
5275
5276 old_fpucw = d3d_fpu_setup();
5277 hr = d3d_device7_SetViewport(iface, viewport);
5278 set_fpu_control_word(old_fpucw);
5279
5280 return hr;
5281}
5282
5283static HRESULT d3d_device7_GetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5284{
5287
5288 TRACE("iface %p, viewport %p.\n", iface, viewport);
5289
5290 if (!viewport)
5291 return DDERR_INVALIDPARAMS;
5292
5294 wined3d_viewport = device->stateblock_state->viewport;
5296
5297 viewport->dwX = wined3d_viewport.x;
5298 viewport->dwY = wined3d_viewport.y;
5299 viewport->dwWidth = wined3d_viewport.width;
5300 viewport->dwHeight = wined3d_viewport.height;
5301 viewport->dvMinZ = wined3d_viewport.min_z;
5302 viewport->dvMaxZ = wined3d_viewport.max_z;
5303
5304 return D3D_OK;
5305}
5306
5307static HRESULT WINAPI d3d_device7_GetViewport_FPUSetup(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5308{
5309 return d3d_device7_GetViewport(iface, viewport);
5310}
5311
5312static HRESULT WINAPI d3d_device7_GetViewport_FPUPreserve(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
5313{
5314 HRESULT hr;
5315 WORD old_fpucw;
5316
5317 old_fpucw = d3d_fpu_setup();
5318 hr = d3d_device7_GetViewport(iface, viewport);
5319 set_fpu_control_word(old_fpucw);
5320
5321 return hr;
5322}
5323
5324/*****************************************************************************
5325 * IDirect3DDevice7::SetMaterial
5326 *
5327 * Sets the Material
5328 *
5329 * Version 7
5330 *
5331 * Params:
5332 * Mat: The material to set
5333 *
5334 * Returns:
5335 * D3D_OK on success
5336 * DDERR_INVALIDPARAMS if Mat is NULL.
5337 *
5338 *****************************************************************************/
5339static HRESULT d3d_device7_SetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
5340{
5342
5343 TRACE("iface %p, material %p.\n", iface, material);
5344
5345 if (!material)
5346 return DDERR_INVALIDPARAMS;
5347
5349 /* Note: D3DMATERIAL7 is compatible with struct wined3d_material. */
5350 wined3d_stateblock_set_material(device->update_state, (const struct wined3d_material *)material);
5352
5353 return D3D_OK;
5354}
5355
5357{
5358 return d3d_device7_SetMaterial(iface, material);
5359}
5360
5362{
5363 HRESULT hr;
5364 WORD old_fpucw;
5365
5366 old_fpucw = d3d_fpu_setup();
5368 set_fpu_control_word(old_fpucw);
5369
5370 return hr;
5371}
5372
5373/*****************************************************************************
5374 * IDirect3DDevice7::GetMaterial
5375 *
5376 * Returns the current material
5377 *
5378 * Version 7
5379 *
5380 * Params:
5381 * Mat: D3DMATERIAL7 structure to write the material parameters to
5382 *
5383 * Returns:
5384 * D3D_OK on success
5385 * DDERR_INVALIDPARAMS if Mat is NULL
5386 *
5387 *****************************************************************************/
5388static HRESULT d3d_device7_GetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
5389{
5391
5392 TRACE("iface %p, material %p.\n", iface, material);
5393
5395 /* Note: D3DMATERIAL7 is compatible with struct wined3d_material. */
5396 memcpy(material, &device->stateblock_state->material, sizeof(*material));
5398
5399 return D3D_OK;
5400}
5401
5403{
5404 return d3d_device7_GetMaterial(iface, material);
5405}
5406
5408{
5409 HRESULT hr;
5410 WORD old_fpucw;
5411
5412 old_fpucw = d3d_fpu_setup();
5414 set_fpu_control_word(old_fpucw);
5415
5416 return hr;
5417}
5418
5419/*****************************************************************************
5420 * IDirect3DDevice7::SetLight
5421 *
5422 * Assigns a light to a light index, but doesn't activate it yet.
5423 *
5424 * Version 7, IDirect3DLight uses this method for older versions
5425 *
5426 * Params:
5427 * LightIndex: The index of the new light
5428 * Light: A D3DLIGHT7 structure describing the light
5429 *
5430 * Returns:
5431 * D3D_OK on success
5432 *
5433 *****************************************************************************/
5434static HRESULT d3d_device7_SetLight(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5435{
5437 HRESULT hr;
5438
5439 TRACE("iface %p, light_idx %lu, light %p.\n", iface, light_idx, light);
5440
5442 /* Note: D3DLIGHT7 is compatible with struct wined3d_light. */
5443 hr = wined3d_stateblock_set_light(device->update_state, light_idx, (const struct wined3d_light *)light);
5445
5446 return hr_ddraw_from_wined3d(hr);
5447}
5448
5449static HRESULT WINAPI d3d_device7_SetLight_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5450{
5451 return d3d_device7_SetLight(iface, light_idx, light);
5452}
5453
5454static HRESULT WINAPI d3d_device7_SetLight_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5455{
5456 HRESULT hr;
5457 WORD old_fpucw;
5458
5459 old_fpucw = d3d_fpu_setup();
5460 hr = d3d_device7_SetLight(iface, light_idx, light);
5461 set_fpu_control_word(old_fpucw);
5462
5463 return hr;
5464}
5465
5466/*****************************************************************************
5467 * IDirect3DDevice7::GetLight
5468 *
5469 * Returns the light assigned to a light index
5470 *
5471 * Params:
5472 * Light: Structure to write the light information to
5473 *
5474 * Returns:
5475 * D3D_OK on success
5476 * DDERR_INVALIDPARAMS if Light is NULL
5477 *
5478 *****************************************************************************/
5479static HRESULT d3d_device7_GetLight(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5480{
5482 BOOL enabled;
5483 HRESULT hr;
5484
5485 TRACE("iface %p, light_idx %lu, light %p.\n", iface, light_idx, light);
5486
5488 /* Note: D3DLIGHT7 is compatible with struct wined3d_light. */
5489 hr = wined3d_stateblock_get_light(device->state, light_idx, (struct wined3d_light *)light, &enabled);
5491
5492 return hr_ddraw_from_wined3d(hr);
5493}
5494
5495static HRESULT WINAPI d3d_device7_GetLight_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5496{
5497 return d3d_device7_GetLight(iface, light_idx, light);
5498}
5499
5500static HRESULT WINAPI d3d_device7_GetLight_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
5501{
5502 HRESULT hr;
5503 WORD old_fpucw;
5504
5505 old_fpucw = d3d_fpu_setup();
5506 hr = d3d_device7_GetLight(iface, light_idx, light);
5507 set_fpu_control_word(old_fpucw);
5508
5509 return hr;
5510}
5511
5512/*****************************************************************************
5513 * IDirect3DDevice7::BeginStateBlock
5514 *
5515 * Begins recording to a stateblock
5516 *
5517 * Version 7
5518 *
5519 * Returns:
5520 * D3D_OK on success
5521 *
5522 *****************************************************************************/
5523static HRESULT d3d_device7_BeginStateBlock(IDirect3DDevice7 *iface)
5524{
5526 struct wined3d_stateblock *stateblock;
5527 HRESULT hr;
5528
5529 TRACE("iface %p.\n", iface);
5530
5532 if (device->recording)
5533 {
5535 WARN("Trying to begin a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
5537 }
5538 if (SUCCEEDED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_RECORDED, &stateblock)))
5539 device->update_state = device->recording = stateblock;
5541
5542 return hr_ddraw_from_wined3d(hr);
5543}
5544
5546{
5547 return d3d_device7_BeginStateBlock(iface);
5548}
5549
5551{
5552 HRESULT hr;
5553 WORD old_fpucw;
5554
5555 old_fpucw = d3d_fpu_setup();
5557 set_fpu_control_word(old_fpucw);
5558
5559 return hr;
5560}
5561
5562/*****************************************************************************
5563 * IDirect3DDevice7::EndStateBlock
5564 *
5565 * Stops recording to a state block and returns the created stateblock
5566 * handle.
5567 *
5568 * Version 7
5569 *
5570 * Params:
5571 * BlockHandle: Address to store the stateblock's handle to
5572 *
5573 * Returns:
5574 * D3D_OK on success
5575 * DDERR_INVALIDPARAMS if BlockHandle is NULL
5576 *
5577 *****************************************************************************/
5578static HRESULT d3d_device7_EndStateBlock(IDirect3DDevice7 *iface, DWORD *stateblock)
5579{
5581 struct wined3d_stateblock *wined3d_sb;
5582 DWORD h;
5583
5584 TRACE("iface %p, stateblock %p.\n", iface, stateblock);
5585
5586 if (!stateblock)
5587 return DDERR_INVALIDPARAMS;
5588
5590 if (!device->recording)
5591 {
5593 WARN("Trying to end a stateblock, but no stateblock is being recorded.\n");
5595 }
5596 wined3d_sb = device->recording;
5598 device->recording = NULL;
5599 device->update_state = device->state;
5600
5601 h = ddraw_allocate_handle(&device->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK);
5602 if (h == DDRAW_INVALID_HANDLE)
5603 {
5604 ERR("Failed to allocate a stateblock handle.\n");
5605 wined3d_stateblock_decref(wined3d_sb);
5607 *stateblock = 0;
5608 return DDERR_OUTOFMEMORY;
5609 }
5610
5612 *stateblock = h + 1;
5613
5614 return D3D_OK;
5615}
5616
5617static HRESULT WINAPI d3d_device7_EndStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD *stateblock)
5618{
5619 return d3d_device7_EndStateBlock(iface, stateblock);
5620}
5621
5622static HRESULT WINAPI d3d_device7_EndStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD *stateblock)
5623{
5624 HRESULT hr;
5625 WORD old_fpucw;
5626
5627 old_fpucw = d3d_fpu_setup();
5628 hr = d3d_device7_EndStateBlock(iface, stateblock);
5629 set_fpu_control_word(old_fpucw);
5630
5631 return hr;
5632}
5633
5634/*****************************************************************************
5635 * IDirect3DDevice7::PreLoad
5636 *
5637 * Allows the app to signal that a texture will be used soon, to allow
5638 * the Direct3DDevice to load it to the video card in the meantime.
5639 *
5640 * Version 7
5641 *
5642 * Params:
5643 * Texture: The texture to preload
5644 *
5645 * Returns:
5646 * D3D_OK on success
5647 * DDERR_INVALIDPARAMS if Texture is NULL
5648 *
5649 *****************************************************************************/
5651{
5653
5654 TRACE("iface %p, texture %p.\n", iface, texture);
5655
5656 if (!texture)
5657 return DDERR_INVALIDPARAMS;
5658
5661 : surface->wined3d_texture));
5663
5664 return D3D_OK;
5665}
5666
5668{
5669 return d3d_device7_PreLoad(iface, texture);
5670}
5671
5673{
5674 HRESULT hr;
5675 WORD old_fpucw;
5676
5677 old_fpucw = d3d_fpu_setup();
5678 hr = d3d_device7_PreLoad(iface, texture);
5679 set_fpu_control_word(old_fpucw);
5680
5681 return hr;
5682}
5683
5684/*****************************************************************************
5685 * IDirect3DDevice7::ApplyStateBlock
5686 *
5687 * Activates the state stored in a state block handle.
5688 *
5689 * Params:
5690 * BlockHandle: The stateblock handle to activate
5691 *
5692 * Returns:
5693 * D3D_OK on success
5694 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
5695 *
5696 *****************************************************************************/
5697static HRESULT d3d_device7_ApplyStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
5698{
5700 struct wined3d_stateblock *wined3d_sb;
5701
5702 TRACE("iface %p, stateblock %#lx.\n", iface, stateblock);
5703
5705 if (device->recording)
5706 {
5708 WARN("Trying to apply a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
5710 }
5711 wined3d_sb = ddraw_get_object(&device->handle_table, stateblock - 1, DDRAW_HANDLE_STATEBLOCK);
5712 if (!wined3d_sb)
5713 {
5714 WARN("Invalid stateblock handle.\n");
5717 }
5718
5719 wined3d_stateblock_apply(wined3d_sb, device->state);
5721
5722 return D3D_OK;
5723}
5724
5725static HRESULT WINAPI d3d_device7_ApplyStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
5726{
5727 return d3d_device7_ApplyStateBlock(iface, stateblock);
5728}
5729
5730static HRESULT WINAPI d3d_device7_ApplyStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
5731{
5732 HRESULT hr;
5733 WORD old_fpucw;
5734
5735 old_fpucw = d3d_fpu_setup();
5736 hr = d3d_device7_ApplyStateBlock(iface, stateblock);
5737 set_fpu_control_word(old_fpucw);
5738
5739 return hr;
5740}
5741
5742/*****************************************************************************
5743 * IDirect3DDevice7::CaptureStateBlock
5744 *
5745 * Updates a stateblock's values to the values currently set for the device
5746 *
5747 * Version 7
5748 *
5749 * Params:
5750 * BlockHandle: Stateblock to update
5751 *
5752 * Returns:
5753 * D3D_OK on success
5754 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
5755 *
5756 *****************************************************************************/
5757static HRESULT d3d_device7_CaptureStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
5758{
5760 struct wined3d_stateblock *wined3d_sb;
5761
5762 TRACE("iface %p, stateblock %#lx.\n", iface, stateblock);
5763
5765 if (device->recording)
5766 {
5768 WARN("Trying to capture a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
5770 }
5771 wined3d_sb = ddraw_get_object(&device->handle_table, stateblock - 1, DDRAW_HANDLE_STATEBLOCK);
5772 if (!wined3d_sb)
5773 {
5774 WARN("Invalid stateblock handle.\n");
5777 }
5778
5779 wined3d_stateblock_capture(wined3d_sb, device->state);
5781
5782 return D3D_OK;
5783}
5784
5785static HRESULT WINAPI d3d_device7_CaptureStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
5786{
5787 return d3d_device7_CaptureStateBlock(iface, stateblock);
5788}
5789
5790static HRESULT WINAPI d3d_device7_CaptureStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
5791{
5792 HRESULT hr;
5793 WORD old_fpucw;
5794
5795 old_fpucw = d3d_fpu_setup();
5796 hr = d3d_device7_CaptureStateBlock(iface, stateblock);
5797 set_fpu_control_word(old_fpucw);
5798
5799 return hr;
5800}
5801
5802/*****************************************************************************
5803 * IDirect3DDevice7::DeleteStateBlock
5804 *
5805 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
5806 *
5807 * Version 7
5808 *
5809 * Params:
5810 * BlockHandle: Stateblock handle to delete
5811 *
5812 * Returns:
5813 * D3D_OK on success
5814 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
5815 *
5816 *****************************************************************************/
5817static HRESULT d3d_device7_DeleteStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
5818{
5820 struct wined3d_stateblock *wined3d_sb;
5821 ULONG ref;
5822
5823 TRACE("iface %p, stateblock %#lx.\n", iface, stateblock);
5824
5826
5827 wined3d_sb = ddraw_free_handle(&device->handle_table, stateblock - 1, DDRAW_HANDLE_STATEBLOCK);
5828 if (!wined3d_sb)
5829 {
5830 WARN("Invalid stateblock handle.\n");
5833 }
5834
5835 if ((ref = wined3d_stateblock_decref(wined3d_sb)))
5836 {
5837 ERR("Something is still holding stateblock %p (refcount %lu).\n", wined3d_sb, ref);
5838 }
5839
5841
5842 return D3D_OK;
5843}
5844
5845static HRESULT WINAPI d3d_device7_DeleteStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
5846{
5847 return d3d_device7_DeleteStateBlock(iface, stateblock);
5848}
5849
5850static HRESULT WINAPI d3d_device7_DeleteStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
5851{
5852 HRESULT hr;
5853 WORD old_fpucw;
5854
5855 old_fpucw = d3d_fpu_setup();
5856 hr = d3d_device7_DeleteStateBlock(iface, stateblock);
5857 set_fpu_control_word(old_fpucw);
5858
5859 return hr;
5860}
5861
5862/*****************************************************************************
5863 * IDirect3DDevice7::CreateStateBlock
5864 *
5865 * Creates a new state block handle.
5866 *
5867 * Version 7
5868 *
5869 * Params:
5870 * Type: The state block type
5871 * BlockHandle: Address to write the created handle to
5872 *
5873 * Returns:
5874 * D3D_OK on success
5875 * DDERR_INVALIDPARAMS if BlockHandle is NULL
5876 *
5877 *****************************************************************************/
5878static HRESULT d3d_device7_CreateStateBlock(IDirect3DDevice7 *iface,
5879 D3DSTATEBLOCKTYPE type, DWORD *stateblock)
5880{
5882 struct wined3d_stateblock *wined3d_sb;
5883 HRESULT hr;
5884 DWORD h;
5885
5886 TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock);
5887
5888 if (!stateblock)
5889 return DDERR_INVALIDPARAMS;
5890
5891 if (type != D3DSBT_ALL
5894 {
5895 WARN("Unexpected stateblock type, returning DDERR_INVALIDPARAMS\n");
5896 return DDERR_INVALIDPARAMS;
5897 }
5898
5900
5901 if (device->recording)
5902 {
5904 WARN("Trying to apply a stateblock while recording, returning D3DERR_INBEGINSTATEBLOCK.\n");
5906 }
5907
5908 if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device,
5909 device->state, wined3d_stateblock_type_from_ddraw(type), &wined3d_sb)))
5910 {
5911 WARN("Failed to create stateblock, hr %#lx.\n", hr);
5913 return hr_ddraw_from_wined3d(hr);
5914 }
5915
5916 h = ddraw_allocate_handle(&device->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK);
5917 if (h == DDRAW_INVALID_HANDLE)
5918 {
5919 ERR("Failed to allocate stateblock handle.\n");
5920 wined3d_stateblock_decref(wined3d_sb);
5922 return DDERR_OUTOFMEMORY;
5923 }
5924
5925 *stateblock = h + 1;
5927
5928 return hr_ddraw_from_wined3d(hr);
5929}
5930
5932 D3DSTATEBLOCKTYPE type, DWORD *stateblock)
5933{
5934 return d3d_device7_CreateStateBlock(iface, type, stateblock);
5935}
5936
5938 D3DSTATEBLOCKTYPE type, DWORD *stateblock)
5939{
5940 HRESULT hr;
5941 WORD old_fpucw;
5942
5943 old_fpucw = d3d_fpu_setup();
5944 hr = d3d_device7_CreateStateBlock(iface, type, stateblock);
5945 set_fpu_control_word(old_fpucw);
5946
5947 return hr;
5948}
5949
5951{
5952 struct ddraw_surface *src_level, *dest_level;
5954 DDSURFACEDESC2 ddsd;
5955 BOOL levelFound; /* at least one suitable sublevel in dest found */
5956
5957 /* To satisfy "destination is mip level subset of source" criteria (regular texture counts as 1 level),
5958 * 1) there must be at least one mip level in destination that matched dimensions of some mip level in source and
5959 * 2) there must be no destination levels that don't match any levels in source. Otherwise it's INVALIDPARAMS.
5960 */
5961 levelFound = FALSE;
5962
5963 src_level = src;
5964 dest_level = dest;
5965
5966 for (;src_level && dest_level;)
5967 {
5968 if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
5969 src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
5970 {
5971 levelFound = TRUE;
5972
5975 IDirectDrawSurface7_GetAttachedSurface(&dest_level->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
5976
5977 if (dest_level != dest) IDirectDrawSurface7_Release(&dest_level->IDirectDrawSurface7_iface);
5978
5980 }
5981
5984 IDirectDrawSurface7_GetAttachedSurface(&src_level->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
5985
5986 if (src_level != src) IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface);
5987
5989 }
5990
5991 if (src_level && src_level != src) IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface);
5992 if (dest_level && dest_level != dest) IDirectDrawSurface7_Release(&dest_level->IDirectDrawSurface7_iface);
5993
5994 return !dest_level && levelFound;
5995}
5996
5998 struct ddraw_surface *src, const POINT *DestPoint, const RECT *SrcRect)
5999{
6000 struct ddraw_surface *dst_level, *src_level;
6002 DDSURFACEDESC2 ddsd;
6003 POINT point;
6004 RECT src_rect;
6005 HRESULT hr;
6006 IDirectDrawPalette *pal = NULL, *pal_src = NULL;
6007 DWORD ckeyflag;
6008 DDCOLORKEY ddckey;
6009
6010 /* Copy palette, if possible. */
6011 IDirectDrawSurface7_GetPalette(&src->IDirectDrawSurface7_iface, &pal_src);
6012 IDirectDrawSurface7_GetPalette(&dst->IDirectDrawSurface7_iface, &pal);
6013
6014 if (pal_src != NULL && pal != NULL)
6015 {
6016 PALETTEENTRY palent[256];
6017
6018 IDirectDrawPalette_GetEntries(pal_src, 0, 0, 256, palent);
6019 IDirectDrawPalette_SetEntries(pal, 0, 0, 256, palent);
6020 }
6021
6022 if (pal) IDirectDrawPalette_Release(pal);
6023 if (pal_src) IDirectDrawPalette_Release(pal_src);
6024
6025 /* Copy colorkeys, if present. */
6026 for (ckeyflag = DDCKEY_DESTBLT; ckeyflag <= DDCKEY_SRCOVERLAY; ckeyflag <<= 1)
6027 {
6028 hr = IDirectDrawSurface7_GetColorKey(&src->IDirectDrawSurface7_iface, ckeyflag, &ddckey);
6029
6030 if (SUCCEEDED(hr))
6031 {
6032 IDirectDrawSurface7_SetColorKey(&dst->IDirectDrawSurface7_iface, ckeyflag, &ddckey);
6033 }
6034 }
6035
6036 src_level = src;
6037 dst_level = dst;
6038
6039 point = *DestPoint;
6040 src_rect = *SrcRect;
6041
6042 for (;src_level && dst_level;)
6043 {
6044 if (src_level->surface_desc.dwWidth == dst_level->surface_desc.dwWidth
6045 && src_level->surface_desc.dwHeight == dst_level->surface_desc.dwHeight)
6046 {
6047 UINT src_w = src_rect.right - src_rect.left;
6048 UINT src_h = src_rect.bottom - src_rect.top;
6049 RECT dst_rect = {point.x, point.y, point.x + src_w, point.y + src_h};
6050
6051 if (FAILED(hr = wined3d_device_context_blt(device->immediate_context,
6052 ddraw_surface_get_any_texture(dst_level, DDRAW_SURFACE_RW), dst_level->sub_resource_idx, &dst_rect,
6054 src_level->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT)))
6055 ERR("Blit failed, hr %#lx.\n", hr);
6056
6059 IDirectDrawSurface7_GetAttachedSurface(&dst_level->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
6060
6061 if (dst_level != dst)
6062 IDirectDrawSurface7_Release(&dst_level->IDirectDrawSurface7_iface);
6063
6065 }
6066
6069 IDirectDrawSurface7_GetAttachedSurface(&src_level->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
6070
6071 if (src_level != src) IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface);
6072
6074
6075 point.x /= 2;
6076 point.y /= 2;
6077
6078 src_rect.top /= 2;
6079 src_rect.left /= 2;
6080 src_rect.right = (src_rect.right + 1) / 2;
6081 src_rect.bottom = (src_rect.bottom + 1) / 2;
6082 }
6083
6084 if (src_level && src_level != src)
6085 IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface);
6086 if (dst_level && dst_level != dst)
6087 IDirectDrawSurface7_Release(&dst_level->IDirectDrawSurface7_iface);
6088}
6089
6090/*****************************************************************************
6091 * IDirect3DDevice7::Load
6092 *
6093 * Loads a rectangular area from the source into the destination texture.
6094 * It can also copy the source to the faces of a cubic environment map
6095 *
6096 * Version 7
6097 *
6098 * Params:
6099 * DestTex: Destination texture
6100 * DestPoint: Point in the destination where the source image should be
6101 * written to
6102 * SrcTex: Source texture
6103 * SrcRect: Source rectangle
6104 * Flags: Cubemap faces to load (DDSCAPS2_CUBEMAP_ALLFACES, DDSCAPS2_CUBEMAP_POSITIVEX,
6105 * DDSCAPS2_CUBEMAP_NEGATIVEX, DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY,
6106 * DDSCAPS2_CUBEMAP_POSITIVEZ, DDSCAPS2_CUBEMAP_NEGATIVEZ)
6107 *
6108 * Returns:
6109 * D3D_OK on success
6110 * DDERR_INVALIDPARAMS if dst_texture or src_texture is NULL, broken coordinates or anything unexpected.
6111 *
6112 *
6113 *****************************************************************************/
6114static HRESULT d3d_device7_Load(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture, POINT *dst_pos,
6115 IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
6116{
6120 POINT destpoint;
6121 RECT srcrect;
6122
6123 TRACE("iface %p, dst_texture %p, dst_pos %s, src_texture %p, src_rect %s, flags %#lx.\n",
6124 iface, dst_texture, wine_dbgstr_point(dst_pos), src_texture, wine_dbgstr_rect(src_rect), flags);
6125
6126 if( (!src) || (!dest) )
6127 return DDERR_INVALIDPARAMS;
6128
6130
6131 if (!src_rect)
6132 SetRect(&srcrect, 0, 0, src->surface_desc.dwWidth, src->surface_desc.dwHeight);
6133 else
6134 srcrect = *src_rect;
6135
6136 if (!dst_pos)
6137 destpoint.x = destpoint.y = 0;
6138 else
6139 destpoint = *dst_pos;
6140
6141 /* Check bad dimensions. dst_pos is validated against src, not dest, because
6142 * destination can be a subset of mip levels, in which case actual coordinates used
6143 * for it may be divided. If any dimension of dest is larger than source, it can't be
6144 * mip level subset, so an error can be returned early.
6145 */
6146 if (IsRectEmpty(&srcrect) || srcrect.right > src->surface_desc.dwWidth ||
6147 srcrect.bottom > src->surface_desc.dwHeight ||
6148 destpoint.x + srcrect.right - srcrect.left > src->surface_desc.dwWidth ||
6149 destpoint.y + srcrect.bottom - srcrect.top > src->surface_desc.dwHeight ||
6150 dest->surface_desc.dwWidth > src->surface_desc.dwWidth ||
6151 dest->surface_desc.dwHeight > src->surface_desc.dwHeight)
6152 {
6154 return DDERR_INVALIDPARAMS;
6155 }
6156
6157 /* Must be top level surfaces. */
6158 if (src->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL ||
6159 dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)
6160 {
6162 return DDERR_INVALIDPARAMS;
6163 }
6164
6165 if (src->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
6166 {
6167 struct ddraw_surface *src_face, *dest_face;
6168 DWORD src_face_flag, dest_face_flag;
6170 DDSURFACEDESC2 ddsd;
6171 int i;
6172
6173 if (!(dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP))
6174 {
6176 return DDERR_INVALIDPARAMS;
6177 }
6178
6179 /* Iterate through cube faces 2 times. First time is just to check INVALIDPARAMS conditions, second
6180 * time it's actual surface loading. */
6181 for (i = 0; i < 2; i++)
6182 {
6183 dest_face = dest;
6184 src_face = src;
6185
6186 for (;dest_face && src_face;)
6187 {
6188 src_face_flag = src_face->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES;
6189 dest_face_flag = dest_face->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES;
6190
6191 if (src_face_flag == dest_face_flag)
6192 {
6193 if (i == 0)
6194 {
6195 /* Destination mip levels must be subset of source mip levels. */
6196 if (!is_mip_level_subset(dest_face, src_face))
6197 {
6199 return DDERR_INVALIDPARAMS;
6200 }
6201 }
6202 else if (flags & dest_face_flag)
6203 {
6204 copy_mipmap_chain(device, dest_face, src_face, &destpoint, &srcrect);
6205 }
6206
6207 if (src_face_flag < DDSCAPS2_CUBEMAP_NEGATIVEZ)
6208 {
6210 ddsd.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | (src_face_flag << 1);
6211 IDirectDrawSurface7_GetAttachedSurface(&src->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
6212
6213 if (src_face != src) IDirectDrawSurface7_Release(&src_face->IDirectDrawSurface7_iface);
6214
6216 }
6217 else
6218 {
6219 if (src_face != src) IDirectDrawSurface7_Release(&src_face->IDirectDrawSurface7_iface);
6220
6221 src_face = NULL;
6222 }
6223 }
6224
6225 if (dest_face_flag < DDSCAPS2_CUBEMAP_NEGATIVEZ)
6226 {
6228 ddsd.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | (dest_face_flag << 1);
6229 IDirectDrawSurface7_GetAttachedSurface(&dest->IDirectDrawSurface7_iface, &ddsd.ddsCaps, &temp);
6230
6231 if (dest_face != dest) IDirectDrawSurface7_Release(&dest_face->IDirectDrawSurface7_iface);
6232
6234 }
6235 else
6236 {
6237 if (dest_face != dest) IDirectDrawSurface7_Release(&dest_face->IDirectDrawSurface7_iface);
6238
6239 dest_face = NULL;
6240 }
6241 }
6242
6243 if (i == 0)
6244 {
6245 /* Native returns error if src faces are not subset of dest faces. */
6246 if (src_face)
6247 {
6249 return DDERR_INVALIDPARAMS;
6250 }
6251 }
6252 }
6253
6255 return D3D_OK;
6256 }
6257 else if (dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
6258 {
6260 return DDERR_INVALIDPARAMS;
6261 }
6262
6263 /* Handle non cube map textures. */
6264
6265 /* Destination mip levels must be subset of source mip levels. */
6267 {
6269 return DDERR_INVALIDPARAMS;
6270 }
6271
6272 copy_mipmap_chain(device, dest, src, &destpoint, &srcrect);
6273
6275
6276 return D3D_OK;
6277}
6278
6279static HRESULT WINAPI d3d_device7_Load_FPUSetup(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture,
6280 POINT *dst_pos, IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
6281{
6282 return d3d_device7_Load(iface, dst_texture, dst_pos, src_texture, src_rect, flags);
6283}
6284
6285static HRESULT WINAPI d3d_device7_Load_FPUPreserve(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture,
6286 POINT *dst_pos, IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
6287{
6288 HRESULT hr;
6289 WORD old_fpucw;
6290
6291 old_fpucw = d3d_fpu_setup();
6292 hr = d3d_device7_Load(iface, dst_texture, dst_pos, src_texture, src_rect, flags);
6293 set_fpu_control_word(old_fpucw);
6294
6295 return hr;
6296}
6297
6298/*****************************************************************************
6299 * IDirect3DDevice7::LightEnable
6300 *
6301 * Enables or disables a light
6302 *
6303 * Version 7, IDirect3DLight uses this method too.
6304 *
6305 * Params:
6306 * LightIndex: The index of the light to enable / disable
6307 * Enable: Enable or disable the light
6308 *
6309 * Returns:
6310 * D3D_OK on success
6311 *
6312 *****************************************************************************/
6313static HRESULT d3d_device7_LightEnable(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
6314{
6316 HRESULT hr;
6317
6318 TRACE("iface %p, light_idx %lu, enabled %#x.\n", iface, light_idx, enabled);
6319
6321 hr = wined3d_stateblock_set_light_enable(device->update_state, light_idx, enabled);
6323
6324 return hr_ddraw_from_wined3d(hr);
6325}
6326
6327static HRESULT WINAPI d3d_device7_LightEnable_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
6328{
6329 return d3d_device7_LightEnable(iface, light_idx, enabled);
6330}
6331
6332static HRESULT WINAPI d3d_device7_LightEnable_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
6333{
6334 HRESULT hr;
6335 WORD old_fpucw;
6336
6337 old_fpucw = d3d_fpu_setup();
6338 hr = d3d_device7_LightEnable(iface, light_idx, enabled);
6339 set_fpu_control_word(old_fpucw);
6340
6341 return hr;
6342}
6343
6344/*****************************************************************************
6345 * IDirect3DDevice7::GetLightEnable
6346 *
6347 * Retrieves if the light with the given index is enabled or not
6348 *
6349 * Version 7
6350 *
6351 * Params:
6352 * LightIndex: Index of desired light
6353 * Enable: Pointer to a BOOL which contains the result
6354 *
6355 * Returns:
6356 * D3D_OK on success
6357 * DDERR_INVALIDPARAMS if Enable is NULL
6358 *
6359 *****************************************************************************/
6360static HRESULT d3d_device7_GetLightEnable(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
6361{
6363 struct wined3d_light light;
6364 HRESULT hr;
6365
6366 TRACE("iface %p, light_idx %lu, enabled %p.\n", iface, light_idx, enabled);
6367
6368 if (!enabled)
6369 return DDERR_INVALIDPARAMS;
6370
6372 hr = wined3d_stateblock_get_light(device->state, light_idx, &light, enabled);
6374
6375 return hr_ddraw_from_wined3d(hr);
6376}
6377
6378static HRESULT WINAPI d3d_device7_GetLightEnable_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
6379{
6380 return d3d_device7_GetLightEnable(iface, light_idx, enabled);
6381}
6382
6383static HRESULT WINAPI d3d_device7_GetLightEnable_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
6384{
6385 HRESULT hr;
6386 WORD old_fpucw;
6387
6388 old_fpucw = d3d_fpu_setup();
6389 hr = d3d_device7_GetLightEnable(iface, light_idx, enabled);
6390 set_fpu_control_word(old_fpucw);
6391
6392 return hr;
6393}
6394
6395/*****************************************************************************
6396 * IDirect3DDevice7::SetClipPlane
6397 *
6398 * Sets custom clipping plane
6399 *
6400 * Version 7
6401 *
6402 * Params:
6403 * Index: The index of the clipping plane
6404 * PlaneEquation: An equation defining the clipping plane
6405 *
6406 * Returns:
6407 * D3D_OK on success
6408 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
6409 *
6410 *****************************************************************************/
6411static HRESULT d3d_device7_SetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
6412{
6414 const struct wined3d_vec4 *wined3d_plane;
6415 HRESULT hr;
6416
6417 TRACE("iface %p, idx %lu, plane %p.\n", iface, idx, plane);
6418
6419 if (!plane)
6420 return DDERR_INVALIDPARAMS;
6421
6422 wined3d_plane = (struct wined3d_vec4 *)plane;
6423
6425 hr = wined3d_stateblock_set_clip_plane(device->update_state, idx, wined3d_plane);
6426 if (idx < ARRAY_SIZE(device->user_clip_planes))
6427 {
6428 device->user_clip_planes[idx] = *wined3d_plane;
6430 {
6431 WARN("Clip plane %lu is not supported.\n", idx);
6432 hr = D3D_OK;
6433 }
6434 }
6436
6437 return hr;
6438}
6439
6441{
6442 return d3d_device7_SetClipPlane(iface, idx, plane);
6443}
6444
6446{
6447 HRESULT hr;
6448 WORD old_fpucw;
6449
6450 old_fpucw = d3d_fpu_setup();
6452 set_fpu_control_word(old_fpucw);
6453
6454 return hr;
6455}
6456
6457/*****************************************************************************
6458 * IDirect3DDevice7::GetClipPlane
6459 *
6460 * Returns the clipping plane with a specific index
6461 *
6462 * Params:
6463 * Index: The index of the desired plane
6464 * PlaneEquation: Address to store the plane equation to
6465 *
6466 * Returns:
6467 * D3D_OK on success
6468 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
6469 *
6470 *****************************************************************************/
6471static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
6472{
6474
6475 TRACE("iface %p, idx %lu, plane %p.\n", iface, idx, plane);
6476
6477 if (!plane)
6478 return DDERR_INVALIDPARAMS;
6479
6482 memcpy(plane, &device->stateblock_state->clip_planes[idx], sizeof(struct wined3d_vec4));
6483 else
6484 {
6485 WARN("Clip plane %lu is not supported.\n", idx);
6486 if (idx < ARRAY_SIZE(device->user_clip_planes))
6487 memcpy(plane, &device->user_clip_planes[idx], sizeof(struct wined3d_vec4));
6488 }
6490
6491 return D3D_OK;
6492}
6493
6495{
6496 return d3d_device7_GetClipPlane(iface, idx, plane);
6497}
6498
6500{
6501 HRESULT hr;
6502 WORD old_fpucw;
6503
6504 old_fpucw = d3d_fpu_setup();
6506 set_fpu_control_word(old_fpucw);
6507
6508 return hr;
6509}
6510
6511/*****************************************************************************
6512 * IDirect3DDevice7::GetInfo
6513 *
6514 * Retrieves some information about the device. The DirectX sdk says that
6515 * this version returns S_FALSE for all retail builds of DirectX, that's what
6516 * this implementation does.
6517 *
6518 * Params:
6519 * DevInfoID: Information type requested
6520 * DevInfoStruct: Pointer to a structure to store the info to
6521 * Size: Size of the structure
6522 *
6523 * Returns:
6524 * S_FALSE, because it's a non-debug driver
6525 *
6526 *****************************************************************************/
6527static HRESULT WINAPI d3d_device7_GetInfo(IDirect3DDevice7 *iface, DWORD info_id, void *info, DWORD info_size)
6528{
6529 TRACE("iface %p, info_id %#lx, info %p, info_size %lu.\n",
6530 iface, info_id, info, info_size);
6531
6532 if (TRACE_ON(ddraw))
6533 {
6534 TRACE(" info requested : ");
6535 switch (info_id)
6536 {
6537 case D3DDEVINFOID_TEXTUREMANAGER: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
6538 case D3DDEVINFOID_D3DTEXTUREMANAGER: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
6539 case D3DDEVINFOID_TEXTURING: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
6540 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS;
6541 }
6542 }
6543
6544 return S_FALSE; /* According to MSDN, this is valid for a non-debug driver */
6545}
6546
6547/* For performance optimization, devices created in FPUSETUP and FPUPRESERVE modes
6548 * have separate vtables. Simple functions where this doesn't matter like GetDirect3D
6549 * are not duplicated.
6550
6551 * Device created with DDSCL_FPUSETUP (d3d7 default) - device methods assume that FPU
6552 * has already been setup for optimal d3d operation.
6553
6554 * Device created with DDSCL_FPUPRESERVE - resets and restores FPU mode when necessary in
6555 * d3d calls (FPU may be in a mode non-suitable for d3d when the app calls d3d). Required
6556 * by Sacrifice (game). */
6557static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_setup_vtbl =
6558{
6559 /*** IUnknown Methods ***/
6563 /*** IDirect3DDevice7 ***/
6610};
6611
6612static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_preserve_vtbl =
6613{
6614 /*** IUnknown Methods ***/
6618 /*** IDirect3DDevice7 ***/
6665};
6666
6667static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl =
6668{
6669 /*** IUnknown Methods ***/
6673 /*** IDirect3DDevice3 ***/
6713};
6714
6715static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl =
6716{
6717 /*** IUnknown Methods ***/
6721 /*** IDirect3DDevice2 ***/
6752};
6753
6754static const struct IDirect3DDeviceVtbl d3d_device1_vtbl =
6755{
6756 /*** IUnknown Methods ***/
6760 /*** IDirect3DDevice1 ***/
6780};
6781
6782static const struct IUnknownVtbl d3d_device_inner_vtbl =
6783{
6787};
6788
6789struct d3d_device *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
6790{
6791 if (!iface) return NULL;
6792 assert((iface->lpVtbl == &d3d_device7_fpu_preserve_vtbl) || (iface->lpVtbl == &d3d_device7_fpu_setup_vtbl));
6794}
6795
6796struct d3d_device *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
6797{
6798 if (!iface) return NULL;
6799 assert(iface->lpVtbl == &d3d_device3_vtbl);
6801}
6802
6803struct d3d_device *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
6804{
6805 if (!iface) return NULL;
6806 assert(iface->lpVtbl == &d3d_device2_vtbl);
6808}
6809
6810struct d3d_device *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface)
6811{
6812 if (!iface) return NULL;
6813 assert(iface->lpVtbl == &d3d_device1_vtbl);
6814 return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice_iface);
6815}
6816
6818{
6819 IDirectDrawSurface7 *depthStencil = NULL;
6820 IDirectDrawSurface7 *render_target;
6821 static DDSCAPS2 depthcaps = { DDSCAPS_ZBUFFER, 0, 0, {0} };
6822
6823 if (device->rt_iface && SUCCEEDED(IUnknown_QueryInterface(device->rt_iface,
6824 &IID_IDirectDrawSurface7, (void **)&render_target)))
6825 {
6826 IDirectDrawSurface7_GetAttachedSurface(render_target, &depthcaps, &depthStencil);
6827 IDirectDrawSurface7_Release(render_target);
6828 }
6829 if (!depthStencil)
6830 {
6831 TRACE("Setting wined3d depth stencil to NULL\n");
6834 device->target_ds = NULL;
6835 return WINED3D_ZB_FALSE;
6836 }
6837
6838 device->target_ds = impl_from_IDirectDrawSurface7(depthStencil);
6842
6843 IDirectDrawSurface7_Release(depthStencil);
6844 return WINED3D_ZB_TRUE;
6845}
6846
6848{
6849 struct wined3d_viewport vp;
6850 RECT rect;
6851
6852 wined3d_device_context_get_viewports(device->immediate_context, NULL, &vp);
6856}
6857
6859 struct ddraw_surface *target, IUnknown *rt_iface, UINT version, IUnknown *outer_unknown)
6860{
6861 static const struct wined3d_matrix ident =
6862 {
6863 1.0f, 0.0f, 0.0f, 0.0f,
6864 0.0f, 1.0f, 0.0f, 0.0f,
6865 0.0f, 0.0f, 1.0f, 0.0f,
6866 0.0f, 0.0f, 0.0f, 1.0f,
6867 };
6868 struct wined3d_rendertarget_view *rtv;
6869 HRESULT hr;
6870
6872 device->IDirect3DDevice7_iface.lpVtbl = &d3d_device7_fpu_preserve_vtbl;
6873 else
6874 device->IDirect3DDevice7_iface.lpVtbl = &d3d_device7_fpu_setup_vtbl;
6875
6876 device->IDirect3DDevice3_iface.lpVtbl = &d3d_device3_vtbl;
6877 device->IDirect3DDevice2_iface.lpVtbl = &d3d_device2_vtbl;
6878 device->IDirect3DDevice_iface.lpVtbl = &d3d_device1_vtbl;
6879 device->IUnknown_inner.lpVtbl = &d3d_device_inner_vtbl;
6880 device->ref = 1;
6881 device->version = version;
6882 device->hardware_device = IsEqualGUID(&IID_IDirect3DTnLHalDevice, guid)
6883 || IsEqualGUID(&IID_IDirect3DHALDevice, guid);
6884
6885 if (device->hardware_device && !(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
6886 {
6887 WARN("Surface %p is not in video memory.\n", target);
6889 }
6890
6891 if (outer_unknown)
6892 device->outer_unknown = outer_unknown;
6893 else
6894 device->outer_unknown = &device->IUnknown_inner;
6895
6896 device->ddraw = ddraw;
6897 list_init(&device->viewport_list);
6898
6899 if (!ddraw_handle_table_init(&device->handle_table, 64))
6900 {
6901 ERR("Failed to initialize handle table.\n");
6902 return DDERR_OUTOFMEMORY;
6903 }
6904
6905 device->legacyTextureBlending = FALSE;
6906 device->legacy_projection = ident;
6907 device->legacy_clipspace = ident;
6908
6910 {
6911 ERR("Failed to create the primary stateblock, hr %#lx.\n", hr);
6912 ddraw_handle_table_destroy(&device->handle_table);
6913 return hr;
6914 }
6915 device->stateblock_state = wined3d_stateblock_get_state(device->state);
6916 device->update_state = device->state;
6917
6918 /* This is for convenience. */
6919 device->wined3d_device = ddraw->wined3d_device;
6920 device->immediate_context = ddraw->immediate_context;
6922
6925
6926 /* Render to the back buffer */
6928 if (FAILED(hr = wined3d_device_context_set_rendertarget_views(device->immediate_context, 0, 1, &rtv, TRUE)))
6929 {
6930 ERR("Failed to set render target, hr %#lx.\n", hr);
6932 ddraw_handle_table_destroy(&device->handle_table);
6933 return hr;
6934 }
6935
6936 device->rt_iface = rt_iface;
6937 device->target = target;
6938 if (version != 1)
6939 IUnknown_AddRef(device->rt_iface);
6940
6941 list_add_head(&ddraw->d3ddevice_list, &device->ddraw_entry);
6942
6945 if (version == 1) /* Color keying is initially enabled for version 1 devices. */
6947 else if (version == 2)
6949 if (version < 7)
6950 {
6952 IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface,
6954 }
6956 return D3D_OK;
6957}
6958
6960 UINT version, struct d3d_device **device, IUnknown *outer_unknown)
6961{
6962 struct d3d_device *object;
6963 HRESULT hr;
6964
6965 TRACE("ddraw %p, guid %s, target %p, version %u, device %p, outer_unknown %p.\n",
6967
6968 if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
6969 || (target->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
6970 {
6971 WARN("Surface %p is not a render target.\n", target);
6972 return DDERR_INVALIDCAPS;
6973 }
6974
6976 {
6977 WARN("Surface %p has an indexed pixel format, but no palette.\n", target);
6979 }
6980
6981 if (ddraw->flags & DDRAW_NO3D)
6982 {
6983 ERR_(winediag)("The application wants to create a Direct3D device, "
6984 "but the current DirectDrawRenderer does not support this.\n");
6985
6986 return DDERR_OUTOFMEMORY;
6987 }
6988
6989 if (!(object = calloc(1, sizeof(*object))))
6990 {
6991 ERR("Failed to allocate device memory.\n");
6992 return DDERR_OUTOFMEMORY;
6993 }
6994
6996 {
6997 WARN("Failed to initialize device, hr %#lx.\n", hr);
6998 free(object);
6999 return hr;
7000 }
7001
7002 TRACE("Created device %p.\n", object);
7003 *device = object;
7004
7005 return D3D_OK;
7006}
_Tp _STLP_CALL norm(const complex< _Tp > &__z)
Definition: _complex.h:741
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
static int state
Definition: maze.c:121
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static const char * wine_dbgstr_point(const POINT *ppt)
Definition: atltest.h:138
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
r l[0]
Definition: byte_order.h:168
Definition: list.h:39
RECT rect
Definition: combotst.c:67
#define D3DFVF_DIFFUSE
Definition: d3d8types.h:122
enum _D3DTEXTURESTAGESTATETYPE D3DTEXTURESTAGESTATETYPE
#define D3DFVF_XYZRHW
Definition: d3d8types.h:114
@ D3DTSS_MAGFILTER
Definition: d3d8types.h:926
@ D3DTSS_MIPFILTER
Definition: d3d8types.h:928
@ D3DTSS_TEXTURETRANSFORMFLAGS
Definition: d3d8types.h:934
#define D3DFVF_NORMAL
Definition: d3d8types.h:120
@ D3DSBT_PIXELSTATE
Definition: d3d8types.h:831
@ D3DSBT_ALL
Definition: d3d8types.h:830
@ D3DSBT_VERTEXSTATE
Definition: d3d8types.h:832
enum _D3DTRANSFORMSTATETYPE D3DTRANSFORMSTATETYPE
#define D3DFVF_SPECULAR
Definition: d3d8types.h:123
#define D3DFVF_POSITION_MASK
Definition: d3d8types.h:112
enum _D3DSTATEBLOCKTYPE D3DSTATEBLOCKTYPE
#define IDirect3DDevice2_AddRef(p)
Definition: d3d.h:1063
#define D3DERR_INBEGINSTATEBLOCK
Definition: d3d.h:186
#define D3DERR_INVALIDSTATEBLOCK
Definition: d3d.h:185
#define D3DERR_SCENE_IN_SCENE
Definition: d3d.h:151
#define IDirect3DDevice_AddRef(p)
Definition: d3d.h:965
#define IDirect3DDevice3_SetRenderState(p, a, b)
Definition: d3d.h:1213
#define IDirect3DDevice7_DrawPrimitive(p, a, b, c, d, e)
Definition: d3d.h:1368
#define IDirect3DDevice3_AddRef(p)
Definition: d3d.h:1191
#define IDirect3DDevice7_AddRef(p)
Definition: d3d.h:1343
#define D3DERR_NOTINBEGINSTATEBLOCK
Definition: d3d.h:187
#define IDirect3DDevice7_GetRenderState(p, a, b)
Definition: d3d.h:1364
#define D3DERR_SURFACENOTINVIDMEM
Definition: d3d.h:147
#define IDirect3DDevice7_EndScene(p)
Definition: d3d.h:1349
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define IDirect3DDevice7_DrawPrimitiveVB(p, a, b, c, d, e)
Definition: d3d.h:1374
#define IDirect3DDevice7_GetClipPlane(p, a, b)
Definition: d3d.h:1390
#define D3DNEXT_NEXT
Definition: d3d.h:192
#define IDirect3DDevice3_DeleteViewport(p, a)
Definition: d3d.h:1197
#define IDirect3DDevice3_GetRenderState(p, a, b)
Definition: d3d.h:1212
#define IDirect3DDevice3_SetCurrentViewport(p, a)
Definition: d3d.h:1203
#define IDirect3DDevice7_SetClipStatus(p, a)
Definition: d3d.h:1370
#define IDirect3DDevice7_DrawIndexedPrimitive(p, a, b, c, d, e, f, g)
Definition: d3d.h:1369
#define D3DDP_DONOTLIGHT
Definition: d3d.h:200
#define IDirect3DViewport3_AddRef(p)
Definition: d3d.h:826
#define IDirect3D7_AddRef(p)
Definition: d3d.h:380
#define IDirect3DDevice7_BeginScene(p)
Definition: d3d.h:1348
#define IDirect3DDevice7_GetTextureStageState(p, a, b, c)
Definition: d3d.h:1379
#define IDirect3D3_AddRef(p)
Definition: d3d.h:329
#define IDirect3DDevice7_MultiplyTransform(p, a, b)
Definition: d3d.h:1357
#define IDirect3DDevice7_GetTexture(p, a, b)
Definition: d3d.h:1377
#define IDirect3DDevice7_DrawPrimitiveStrided(p, a, b, c, d, e)
Definition: d3d.h:1372
#define IDirect3DDevice7_ValidateDevice(p, a)
Definition: d3d.h:1381
#define D3DERR_SCENE_NOT_IN_SCENE
Definition: d3d.h:152
#define IDirect3DDevice2_SetRenderState(p, a, b)
Definition: d3d.h:1086
#define IDirect3DDevice7_GetClipStatus(p, a)
Definition: d3d.h:1371
#define IDirect3DDevice7_DrawIndexedPrimitiveStrided(p, a, b, c, d, e, f, g)
Definition: d3d.h:1373
#define IDirect3D_AddRef(p)
Definition: d3d.h:232
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice7_SetRenderState(p, a, b)
Definition: d3d.h:1363
#define IDirect3DDevice3_SetTransform(p, a, b)
Definition: d3d.h:1216
#define IDirect3DDevice7_EnumTextureFormats(p, a, b)
Definition: d3d.h:1347
#define IDirect3DDevice2_GetRenderState(p, a, b)
Definition: d3d.h:1085
#define D3DERR_NOCURRENTVIEWPORT
Definition: d3d.h:160
#define D3DERR_VERTEXBUFFERLOCKED
Definition: d3d.h:165
#define D3DNEXT_TAIL
Definition: d3d.h:194
#define IDirect3DDevice7_SetTransform(p, a, b)
Definition: d3d.h:1354
#define IDirect3D2_AddRef(p)
Definition: d3d.h:279
#define IDirect3DDevice7_DeleteStateBlock(p, a)
Definition: d3d.h:1384
#define IDirect3DDevice7_SetTextureStageState(p, a, b, c)
Definition: d3d.h:1380
#define IDirect3DDevice3_GetTransform(p, a, b)
Definition: d3d.h:1217
#define IDirect3DDevice3_SetTexture(p, a, b)
Definition: d3d.h:1229
#define IDirect3DDevice7_DrawIndexedPrimitiveVB(p, a, b, c, d, e, f, g)
Definition: d3d.h:1375
#define IDirect3DDevice7_GetTransform(p, a, b)
Definition: d3d.h:1355
#define IDirect3DDevice3_MultiplyTransform(p, a, b)
Definition: d3d.h:1218
#define D3DNEXT_HEAD
Definition: d3d.h:193
#define D3DVIS_INTERSECT_LEFT
Definition: d3dtypes.h:1354
HRESULT(CALLBACK * LPD3DENUMPIXELFORMATSCALLBACK)(DDPIXELFORMAT *format, void *ctx)
Definition: d3dtypes.h:85
D3DVERTEXTYPE
Definition: d3dtypes.h:813
@ D3DVT_TLVERTEX
Definition: d3dtypes.h:816
@ D3DVT_LVERTEX
Definition: d3dtypes.h:815
@ D3DVT_VERTEX
Definition: d3dtypes.h:814
float D3DVALUE
Definition: d3dtypes.h:89
@ D3DFILTER_MIPLINEAR
Definition: d3dtypes.h:707
@ D3DFILTER_LINEARMIPLINEAR
Definition: d3dtypes.h:709
@ D3DFILTER_MIPNEAREST
Definition: d3dtypes.h:706
@ D3DFILTER_LINEAR
Definition: d3dtypes.h:705
@ D3DFILTER_NEAREST
Definition: d3dtypes.h:704
@ D3DFILTER_LINEARMIPNEAREST
Definition: d3dtypes.h:708
D3DPRIMITIVETYPE
Definition: d3dtypes.h:822
#define D3DSTATUS_CLIPINTERSECTIONLEFT
Definition: d3dtypes.h:434
#define D3DCOLOR_MONO
Definition: d3dtypes.h:626
#define D3DCOLOR_RGB
Definition: d3dtypes.h:627
#define D3DSTATUS_CLIPUNIONLEFT
Definition: d3dtypes.h:421
@ D3DTSS_ADDRESS
Definition: d3dtypes.h:1077
#define D3DFVF_VERTEX
Definition: d3dtypes.h:1328
#define D3DVIS_OUTSIDE_FRUSTUM
Definition: d3dtypes.h:1352
@ D3DTFP_LINEAR
Definition: d3dtypes.h:1166
@ D3DTFP_POINT
Definition: d3dtypes.h:1165
@ D3DTFP_NONE
Definition: d3dtypes.h:1164
#define D3DDEVINFOID_TEXTUREMANAGER
Definition: d3dtypes.h:1383
#define D3DDEVINFOID_D3DTEXTUREMANAGER
Definition: d3dtypes.h:1384
#define D3DVIS_INTERSECT_FRUSTUM
Definition: d3dtypes.h:1351
D3DRENDERSTATETYPE
Definition: d3dtypes.h:874
@ D3DRENDERSTATE_BORDERCOLOR
Definition: d3dtypes.h:919
@ D3DRENDERSTATE_STIPPLEPATTERN31
Definition: d3dtypes.h:970
@ D3DRENDERSTATE_TEXTUREMAG
Definition: d3dtypes.h:891
@ D3DRENDERSTATE_TEXTUREMIN
Definition: d3dtypes.h:892
@ D3DRENDERSTATE_TEXTUREADDRESS
Definition: d3dtypes.h:877
@ D3DRENDERSTATE_TEXTUREHANDLE
Definition: d3dtypes.h:875
@ D3DRENDERSTATE_TEXTUREADDRESSU
Definition: d3dtypes.h:920
@ D3DRENDERSTATE_TEXTUREADDRESSV
Definition: d3dtypes.h:921
@ D3DRENDERSTATE_TEXTUREMAPBLEND
Definition: d3dtypes.h:895
@ D3DRENDERSTATE_STIPPLEPATTERN00
Definition: d3dtypes.h:939
#define D3DFVF_LVERTEX
Definition: d3dtypes.h:1329
HRESULT(CALLBACK * LPD3DENUMTEXTUREFORMATSCALLBACK)(DDSURFACEDESC *surface_desc, void *ctx)
Definition: d3dtypes.h:84
D3DLIGHTSTATETYPE
Definition: d3dtypes.h:860
@ D3DLIGHTSTATE_MATERIAL
Definition: d3dtypes.h:861
@ D3DLIGHTSTATE_FOGSTART
Definition: d3dtypes.h:865
@ D3DLIGHTSTATE_COLORMODEL
Definition: d3dtypes.h:863
@ D3DLIGHTSTATE_FOGMODE
Definition: d3dtypes.h:864
@ D3DLIGHTSTATE_FOGDENSITY
Definition: d3dtypes.h:867
@ D3DLIGHTSTATE_FOGEND
Definition: d3dtypes.h:866
@ D3DLIGHTSTATE_AMBIENT
Definition: d3dtypes.h:862
@ D3DLIGHTSTATE_COLORVERTEX
Definition: d3dtypes.h:868
@ D3DTBLEND_DECALALPHA
Definition: d3dtypes.h:738
@ D3DTBLEND_MODULATE
Definition: d3dtypes.h:737
@ D3DTBLEND_DECAL
Definition: d3dtypes.h:736
@ D3DTBLEND_MODULATEALPHA
Definition: d3dtypes.h:739
@ D3DTBLEND_ADD
Definition: d3dtypes.h:743
@ D3DTBLEND_COPY
Definition: d3dtypes.h:742
#define D3DSTATE_OVERRIDE_BIAS
Definition: d3dtypes.h:834
@ D3DTFG_GAUSSIANCUBIC
Definition: d3dtypes.h:1149
@ D3DTFG_POINT
Definition: d3dtypes.h:1146
@ D3DTFG_ANISOTROPIC
Definition: d3dtypes.h:1150
@ D3DTFG_FLATCUBIC
Definition: d3dtypes.h:1148
@ D3DTFG_LINEAR
Definition: d3dtypes.h:1147
#define D3DFVF_TLVERTEX
Definition: d3dtypes.h:1331
#define D3DVIS_OUTSIDE_LEFT
Definition: d3dtypes.h:1355
#define D3DCLIPSTATUS_EXTENTS2
Definition: d3dtypes.h:1244
#define D3DDEVINFOID_TEXTURING
Definition: d3dtypes.h:1385
DWORD D3DMATRIXHANDLE
Definition: d3dtypes.h:156
static struct wined3d_texture * ddraw_surface_get_any_texture(struct ddraw_surface *surface, unsigned int flags)
void * ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
Definition: main.c:184
void viewport_activate(struct d3d_viewport *viewport, BOOL ignore_lights)
Definition: viewport.c:51
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
Definition: utils.c:1153
void dump_D3DMATRIX(const D3DMATRIX *mat)
Definition: utils.c:906
void viewport_deactivate(struct d3d_viewport *viewport)
Definition: viewport.c:111
struct ddraw_surface * unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface)
Definition: surface.c:5966
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface)
Definition: viewport.c:1224
HRESULT d3d_execute_buffer_init(struct d3d_execute_buffer *execute_buffer, struct d3d_device *device, D3DEXECUTEBUFFERDESC *desc)
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:1209
void material_activate(struct d3d_material *material)
Definition: material.c:444
struct d3d_vertex_buffer * unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface)
Definition: vertexbuffer.c:510
void * ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
Definition: main.c:213
#define DDRAW_NO3D
Definition: ddraw_private.h:56
void ddraw_handle_table_destroy(struct ddraw_handle_table *t)
Definition: main.c:132
struct wined3d_rendertarget_view * ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface)
Definition: surface.c:7053
struct ddraw_handle_table global_handle_table
Definition: main.c:40
HRESULT hr_ddraw_from_wined3d(HRESULT hr)
Definition: utils.c:1183
#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num)
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface)
Definition: viewport.c:1216
static BOOL format_is_paletteindexed(const DDPIXELFORMAT *fmt)
HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *execute_buffer, struct d3d_device *device)
Definition: executebuffer.c:48
struct ddraw_surface * unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
Definition: surface.c:5950
static struct d3d_device * impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
#define DDRAW_SURFACE_RW
struct ddraw_surface * unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface)
Definition: surface.c:6037
BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size)
Definition: main.c:118
struct d3d_execute_buffer * unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface)
#define DDRAW_SURFACE_READ
#define DDRAW_INVALID_HANDLE
struct ddraw_surface * unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface)
Definition: surface.c:6014
#define DD_STRUCT_COPY_BYSIZE(to, from)
#define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType)
struct ddraw_surface * unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface)
Definition: surface.c:6030
static struct d3d_device * impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddraw_handle_type type)
Definition: main.c:138
@ DDRAW_HANDLE_STATEBLOCK
@ DDRAW_HANDLE_SURFACE
@ DDRAW_HANDLE_MATRIX
@ DDRAW_HANDLE_MATERIAL
@ DDRAW_HANDLE_FREE
static struct wined3d_texture * ddraw_surface_get_draw_texture(struct ddraw_surface *surface, unsigned int flags)
static struct d3d_device * impl_from_IDirect3DDevice(IDirect3DDevice *iface)
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
Definition: utils.c:915
void ddrawformat_from_wined3dformat(DDPIXELFORMAT *ddraw_format, enum wined3d_format_id wined3d_format)
Definition: utils.c:30
static struct d3d_device * impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
static struct ddraw_surface * impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
#define DDRAW_MAX_TEXTURES
Definition: ddraw_private.h:71
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static struct d2d_device_context * impl_from_IUnknown(IUnknown *iface)
Definition: device.c:207
void d3d_device_init(struct d3d_device *device, void *outer_unknown)
Definition: device.c:7756
static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
Definition: device.c:5124
static ULONG STDMETHODCALLTYPE d3d_device_inner_AddRef(IUnknown *iface)
Definition: device.c:5166
static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
Definition: device.c:5176
static void device_reset_viewport_state(struct d3d8_device *device)
Definition: device.c:559
struct wined3d_vertex_declaration * ddraw_find_decl(struct ddraw *This, DWORD fvf)
Definition: ddraw.c:4917
HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps)
Definition: ddraw.c:1287
void ddraw_d3dcaps1_from_7(D3DDEVICEDESC *caps1, D3DDEVICEDESC7 *caps7)
Definition: ddraw.c:1203
static HRESULT WINAPI d3d_device1_GetStats(IDirect3DDevice *iface, D3DSTATS *stats)
Definition: device.c:655
static HRESULT WINAPI d3d_device7_CreateStateBlock_FPUPreserve(IDirect3DDevice7 *iface, D3DSTATEBLOCKTYPE type, DWORD *stateblock)
Definition: device.c:5937
static enum wined3d_stateblock_type wined3d_stateblock_type_from_ddraw(D3DSTATEBLOCKTYPE type)
Definition: device.c:110
static HRESULT d3d_device7_SetRenderState(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: device.c:2543
static HRESULT WINAPI d3d_device7_ApplyStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5725
static HRESULT d3d_device7_EndStateBlock(IDirect3DDevice7 *iface, DWORD *stateblock)
Definition: device.c:5578
static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_preserve_vtbl
Definition: device.c:6612
static HRESULT WINAPI d3d_device1_GetPickRecords(IDirect3DDevice *iface, DWORD *count, D3DPICKRECORD *records)
Definition: device.c:1048
static HRESULT WINAPI d3d_device7_SetClipStatus(IDirect3DDevice7 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3780
static HRESULT WINAPI d3d_device3_SetLightState(IDirect3DDevice3 *iface, D3DLIGHTSTATETYPE state, DWORD value)
Definition: device.c:2918
struct d3d_device * unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
Definition: device.c:6789
static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD *value)
Definition: device.c:2332
static HRESULT d3d_device7_LightEnable(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
Definition: device.c:6313
static HRESULT WINAPI d3d_device7_GetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
Definition: device.c:4917
static HRESULT WINAPI d3d_device1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DMatHandle)
Definition: device.c:1313
void d3d_device_apply_state(struct d3d_device *device, BOOL clear_state)
Definition: device.c:3454
static HRESULT WINAPI d3d_device7_GetClipPlane_FPUPreserve(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6499
static BOOL check_d3ddevicedesc_size(DWORD size)
Definition: device.c:484
static HRESULT WINAPI d3d_device7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:3517
static HRESULT WINAPI d3d_device3_BeginScene(IDirect3DDevice3 *iface)
Definition: device.c:1536
static HRESULT d3d_device7_MultiplyTransform(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3303
static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, D3DDRAWPRIMITIVESTRIDEDDATA *strided_data, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:4027
static HRESULT WINAPI d3d_device7_GetTexture_FPUPreserve(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 **Texture)
Definition: device.c:4627
static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE primitive_type, IDirect3DVertexBuffer *vertex_buffer, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:4364
static HRESULT WINAPI d3d_device7_SetTextureStageState_FPUSetup(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value)
Definition: device.c:5050
static WORD d3d_fpu_setup(void)
Definition: device.c:52
static HRESULT WINAPI d3d_device3_DrawPrimitiveVB(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
Definition: device.c:4223
static HRESULT WINAPI d3d_device7_GetClipPlane_FPUSetup(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6494
static HRESULT WINAPI d3d_device7_ComputeSphereVisibility(IDirect3DDevice7 *iface, D3DVECTOR *centers, D3DVALUE *radii, DWORD sphere_count, DWORD flags, DWORD *return_values)
Definition: device.c:4503
static HRESULT WINAPI d3d_device7_MultiplyTransform_FPUSetup(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3319
static HRESULT WINAPI d3d_device7_Clear_FPUPreserve(IDirect3DDevice7 *iface, DWORD count, D3DRECT *rects, DWORD flags, D3DCOLOR color, D3DVALUE z, DWORD stencil)
Definition: device.c:5209
static HRESULT WINAPI d3d_device1_CreateExecuteBuffer(IDirect3DDevice *iface, D3DEXECUTEBUFFERDESC *buffer_desc, IDirect3DExecuteBuffer **ExecuteBuffer, IUnknown *outer_unknown)
Definition: device.c:684
static HRESULT WINAPI d3d_device7_Clear_FPUSetup(IDirect3DDevice7 *iface, DWORD count, D3DRECT *rects, DWORD flags, D3DCOLOR color, D3DVALUE z, DWORD stencil)
Definition: device.c:5203
static HRESULT WINAPI d3d_device7_GetTexture_FPUSetup(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 **Texture)
Definition: device.c:4621
static HRESULT WINAPI d3d_device7_GetMaterial_FPUSetup(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5402
static HRESULT WINAPI d3d_device7_GetInfo(IDirect3DDevice7 *iface, DWORD info_id, void *info, DWORD info_size)
Definition: device.c:6527
static HRESULT WINAPI d3d_device7_SetRenderState_FPUPreserve(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: device.c:2684
static ULONG WINAPI d3d_device3_Release(IDirect3DDevice3 *iface)
Definition: device.c:365
static HRESULT WINAPI d3d_device7_EnumTextureFormats_FPUSetup(IDirect3DDevice7 *iface, LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
Definition: device.c:1178
static HRESULT WINAPI d3d_device7_SetClipPlane_FPUPreserve(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6445
static HRESULT WINAPI d3d_device7_DrawPrimitiveVB_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
Definition: device.c:4204
static HRESULT WINAPI d3d_device2_SetRenderState(IDirect3DDevice2 *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: device.c:2890
static HRESULT WINAPI d3d_device2_BeginScene(IDirect3DDevice2 *iface)
Definition: device.c:1545
static HRESULT WINAPI d3d_device3_GetLightState(IDirect3DDevice3 *iface, D3DLIGHTSTATETYPE state, DWORD *value)
Definition: device.c:3034
static HRESULT WINAPI d3d_device2_AddViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport)
Definition: device.c:797
static enum wined3d_render_state wined3d_render_state_from_ddraw(D3DRENDERSTATETYPE state)
Definition: device.c:75
static HRESULT WINAPI d3d_device2_SetCurrentViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport)
Definition: device.c:1772
static HRESULT WINAPI d3d_device1_GetDirect3D(IDirect3DDevice *iface, IDirect3D **d3d)
Definition: device.c:1698
static HRESULT WINAPI d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface, LPD3DENUMTEXTUREFORMATSCALLBACK callback, void *context)
Definition: device.c:1217
static HRESULT WINAPI d3d_device7_Load_FPUSetup(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture, POINT *dst_pos, IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
Definition: device.c:6279
static HRESULT d3d_device7_SetRenderTarget(IDirect3DDevice7 *iface, IDirectDrawSurface7 *target, DWORD flags)
Definition: device.c:1866
static void prepare_clip_space_planes(struct d3d_device *device, struct wined3d_vec4 *plane)
Definition: device.c:4436
static HRESULT WINAPI d3d_device2_BeginIndexed(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE primitive_type, D3DVERTEXTYPE vertex_type, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:2206
static HRESULT WINAPI d3d_device7_ApplyStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5730
static HRESULT WINAPI d3d_device3_GetCaps(IDirect3DDevice3 *iface, D3DDEVICEDESC *HWDesc, D3DDEVICEDESC *HelDesc)
Definition: device.c:492
static HRESULT WINAPI d3d_device2_GetCurrentViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 **viewport)
Definition: device.c:1820
static HRESULT WINAPI d3d_device7_SetLight_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5454
static const struct IDirect3DDeviceVtbl d3d_device1_vtbl
Definition: device.c:6754
static HRESULT WINAPI d3d_device7_DrawPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
Definition: device.c:3981
static HRESULT WINAPI d3d_device1_DeleteViewport(IDirect3DDevice *iface, IDirect3DViewport *viewport)
Definition: device.c:886
static HRESULT d3d_device7_SetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6411
static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, IDirect3DVertexBuffer7 *vb, DWORD start_vertex, DWORD vertex_count, DWORD flags)
Definition: device.c:4139
static HRESULT WINAPI d3d_device2_SetLightState(IDirect3DDevice2 *iface, D3DLIGHTSTATETYPE state, DWORD value)
Definition: device.c:3006
static ULONG WINAPI d3d_device3_AddRef(IDirect3DDevice3 *iface)
Definition: device.c:233
static HRESULT WINAPI d3d_device7_SetRenderTarget_FPUPreserve(IDirect3DDevice7 *iface, IDirectDrawSurface7 *NewTarget, DWORD flags)
Definition: device.c:1921
static HRESULT WINAPI d3d_device7_SetTexture_FPUSetup(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 *texture)
Definition: device.c:4703
static HRESULT WINAPI d3d_device2_GetTransform(IDirect3DDevice2 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3276
static HRESULT WINAPI d3d_device3_GetTextureStageState(IDirect3DDevice3 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
Definition: device.c:4930
static HRESULT WINAPI d3d_device7_GetDirect3D(IDirect3DDevice7 *iface, IDirect3D7 **d3d)
Definition: device.c:1650
static HRESULT d3d_device7_GetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5388
static HRESULT WINAPI d3d_device7_EnumTextureFormats_FPUPreserve(IDirect3DDevice7 *iface, LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
Definition: device.c:1184
static HRESULT WINAPI d3d_device7_EndStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD *stateblock)
Definition: device.c:5622
static HRESULT WINAPI d3d_device2_Vertex(IDirect3DDevice2 *iface, void *vertex)
Definition: device.c:2277
static HRESULT WINAPI d3d_device7_ValidateDevice_FPUPreserve(IDirect3DDevice7 *iface, DWORD *pass_count)
Definition: device.c:5132
static HRESULT WINAPI d3d_device3_SetRenderTarget(IDirect3DDevice3 *iface, IDirectDrawSurface4 *target, DWORD flags)
Definition: device.c:1934
static HRESULT WINAPI d3d_device2_DeleteViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport)
Definition: device.c:875
static HRESULT d3d_device_set_render_target(struct d3d_device *device, struct ddraw_surface *target, IUnknown *rt_iface)
Definition: device.c:1836
static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl
Definition: device.c:6715
static void fixup_texture_alpha_op(struct d3d_device *device)
Definition: device.c:2697
static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD flags)
Definition: device.c:3531
static HRESULT WINAPI d3d_device2_End(IDirect3DDevice2 *iface, DWORD flags)
Definition: device.c:3755
static HRESULT d3d_device7_SetTextureStageState(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value)
Definition: device.c:4958
static HRESULT WINAPI d3d_device1_EnumTextureFormats(IDirect3DDevice *iface, LPD3DENUMTEXTUREFORMATSCALLBACK callback, void *context)
Definition: device.c:1287
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices, DWORD IndexCount, DWORD Flags)
Definition: device.c:4088
static HRESULT WINAPI d3d_device7_CreateStateBlock_FPUSetup(IDirect3DDevice7 *iface, D3DSTATEBLOCKTYPE type, DWORD *stateblock)
Definition: device.c:5931
static HRESULT WINAPI d3d_device2_NextViewport(IDirect3DDevice2 *iface, IDirect3DViewport2 *viewport, IDirect3DViewport2 **next, DWORD flags)
Definition: device.c:968
static HRESULT WINAPI d3d_device7_GetTransform_FPUSetup(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3236
static HRESULT WINAPI d3d_device1_NextViewport(IDirect3DDevice *iface, IDirect3DViewport *viewport, IDirect3DViewport **next, DWORD flags)
Definition: device.c:985
static HRESULT WINAPI d3d_device7_SetViewport_FPUSetup(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5266
static HRESULT WINAPI d3d_device2_DrawIndexedPrimitive(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE primitive_type, D3DVERTEXTYPE vertex_type, void *vertices, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:3702
static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6471
static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, D3DDRAWPRIMITIVESTRIDEDDATA *strided_data, DWORD vertex_count, DWORD flags)
Definition: device.c:3931
struct d3d_device * unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface)
Definition: device.c:6810
static HRESULT WINAPI d3d_device3_GetCurrentViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 **viewport)
Definition: device.c:1798
static HRESULT WINAPI d3d_device1_QueryInterface(IDirect3DDevice *iface, REFIID riid, void **out)
Definition: device.c:205
static HRESULT WINAPI d3d_device2_Index(IDirect3DDevice2 *iface, WORD index)
Definition: device.c:2306
static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 **texture)
Definition: device.c:4586
static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface, LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
Definition: device.c:1074
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitive_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:3663
static HRESULT WINAPI d3d_device1_Execute(IDirect3DDevice *iface, IDirect3DExecuteBuffer *ExecuteBuffer, IDirect3DViewport *viewport, DWORD flags)
Definition: device.c:734
static HRESULT WINAPI d3d_device3_QueryInterface(IDirect3DDevice3 *iface, REFIID riid, void **out)
Definition: device.c:187
static HRESULT WINAPI d3d_device3_GetClipStatus(IDirect3DDevice3 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3837
static HRESULT WINAPI d3d_device7_DrawPrimitive_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:3510
enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device)
Definition: device.c:6817
static enum wined3d_transform_state wined3d_transform_state_from_ddraw(D3DTRANSFORMSTATETYPE state)
Definition: device.c:88
static HRESULT d3d_device7_SetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5222
static HRESULT WINAPI d3d_device2_GetClipStatus(IDirect3DDevice2 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3846
static HRESULT WINAPI d3d_device7_GetLight_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5500
static HRESULT WINAPI d3d_device3_AddViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
Definition: device.c:776
static DWORD in_plane(UINT idx, struct wined3d_vec4 p, D3DVECTOR center, D3DVALUE radius, BOOL equality)
Definition: device.c:4412
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitiveVB_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, WORD *Indices, DWORD IndexCount, DWORD Flags)
Definition: device.c:4341
static ULONG WINAPI d3d_device1_Release(IDirect3DDevice *iface)
Definition: device.c:383
static HRESULT WINAPI d3d_device7_SetViewport_FPUPreserve(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5271
static HRESULT WINAPI d3d_device2_QueryInterface(IDirect3DDevice2 *iface, REFIID riid, void **out)
Definition: device.c:196
static HRESULT WINAPI d3d_device7_BeginStateBlock_FPUPreserve(IDirect3DDevice7 *iface)
Definition: device.c:5550
static HRESULT WINAPI d3d_device7_GetRenderTarget(IDirect3DDevice7 *iface, IDirectDrawSurface7 **RenderTarget)
Definition: device.c:2058
static HRESULT WINAPI d3d_device3_ValidateDevice(IDirect3DDevice3 *iface, DWORD *pass_count)
Definition: device.c:5144
static void pack_strided_data(BYTE *dst, DWORD count, const D3DDRAWPRIMITIVESTRIDEDDATA *src, DWORD fvf)
Definition: device.c:3875
static ULONG WINAPI d3d_device2_Release(IDirect3DDevice2 *iface)
Definition: device.c:374
static HRESULT d3d_device7_GetTransform(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3218
static HRESULT d3d_device7_BeginStateBlock(IDirect3DDevice7 *iface)
Definition: device.c:5523
void d3d_device_sync_surfaces(struct d3d_device *device)
Definition: device.c:3427
static void d3d_device_sync_rendertarget(struct d3d_device *device)
Definition: device.c:3392
static HRESULT WINAPI d3d_device7_SetTransform_FPUSetup(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3147
static HRESULT WINAPI d3d_device1_SwapTextureHandles(IDirect3DDevice *iface, IDirect3DTexture *tex1, IDirect3DTexture *tex2)
Definition: device.c:597
static const struct IUnknownVtbl d3d_device_inner_vtbl
Definition: device.c:6782
static HRESULT WINAPI d3d_device7_GetLightEnable_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
Definition: device.c:6378
static HRESULT d3d_device7_CaptureStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5757
static HRESULT WINAPI d3d_device3_GetStats(IDirect3DDevice3 *iface, D3DSTATS *Stats)
Definition: device.c:629
static HRESULT d3d_device7_EndScene(IDirect3DDevice7 *iface)
Definition: device.c:1577
static enum wined3d_primitive_type wined3d_primitive_type_from_ddraw(D3DPRIMITIVETYPE type)
Definition: device.c:105
static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices, DWORD IndexCount, DWORD Flags)
Definition: device.c:4104
static HRESULT WINAPI d3d_device1_GetMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE D3DMatHandle, D3DMATRIX *D3DMatrix)
Definition: device.c:1426
static HRESULT WINAPI d3d_device3_DrawIndexedPrimitive(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:3686
static HRESULT WINAPI d3d_device7_GetCaps_FPUPreserve(IDirect3DDevice7 *iface, D3DDEVICEDESC7 *desc)
Definition: device.c:442
static HRESULT WINAPI d3d_device7_GetCaps_FPUSetup(IDirect3DDevice7 *iface, D3DDEVICEDESC7 *desc)
Definition: device.c:437
static HRESULT WINAPI d3d_device7_GetRenderState_FPUPreserve(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD *value)
Definition: device.c:2460
static HRESULT WINAPI d3d_device3_SetTextureStageState(IDirect3DDevice3 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value)
Definition: device.c:5069
static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: device.c:2724
static HRESULT d3d_device7_GetLight(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5479
static HRESULT WINAPI d3d_device7_MultiplyTransform_FPUPreserve(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3325
static HRESULT WINAPI d3d_device2_GetCaps(IDirect3DDevice2 *iface, D3DDEVICEDESC *hw_desc, D3DDEVICEDESC *hel_desc)
Definition: device.c:532
static HRESULT WINAPI d3d_device2_SetRenderTarget(IDirect3DDevice2 *iface, IDirectDrawSurface *target, DWORD flags)
Definition: device.c:1988
static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface, D3DRENDERSTATETYPE state, DWORD *value)
Definition: device.c:2473
static HRESULT WINAPI d3d_device7_GetLight_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5495
static HRESULT WINAPI d3d_device7_GetClipStatus(IDirect3DDevice7 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3817
static HRESULT WINAPI d3d_device3_End(IDirect3DDevice3 *iface, DWORD flags)
Definition: device.c:3745
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d_device7_EndScene_FPUSetup(IDirect3DDevice7 *iface)
Definition: device.c:1592
static HRESULT WINAPI d3d_device2_GetLightState(IDirect3DDevice2 *iface, D3DLIGHTSTATETYPE state, DWORD *value)
Definition: device.c:3098
static HRESULT WINAPI d3d_device7_DrawPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, DWORD Flags)
Definition: device.c:4210
static HRESULT WINAPI d3d_device2_SetClipStatus(IDirect3DDevice2 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3796
static HRESULT WINAPI d3d_device1_Pick(IDirect3DDevice *iface, IDirect3DExecuteBuffer *buffer, IDirect3DViewport *viewport, DWORD flags, D3DRECT *rect)
Definition: device.c:1023
static HRESULT WINAPI d3d_device3_SetTransform(IDirect3DDevice3 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3166
static ULONG WINAPI d3d_device1_AddRef(IDirect3DDevice *iface)
Definition: device.c:251
static HRESULT WINAPI d3d_device7_GetTextureStageState_FPUSetup(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
Definition: device.c:4911
static HRESULT WINAPI d3d_device7_GetRenderState_FPUSetup(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD *value)
Definition: device.c:2454
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer7 *D3DVertexBuf, DWORD StartVertex, DWORD NumVertices, WORD *Indices, DWORD IndexCount, DWORD Flags)
Definition: device.c:4349
static HRESULT WINAPI d3d_device7_GetLightEnable_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
Definition: device.c:6383
static HRESULT WINAPI d3d_device7_SetMaterial_FPUSetup(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5356
static HRESULT WINAPI d3d_device2_Begin(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE primitive_type, D3DVERTEXTYPE vertex_type, DWORD flags)
Definition: device.c:2154
static HRESULT WINAPI d3d_device7_LightEnable_FPUPreserve(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
Definition: device.c:6332
static HRESULT WINAPI d3d_device1_AddViewport(IDirect3DDevice *iface, IDirect3DViewport *viewport)
Definition: device.c:808
static HRESULT d3d_device7_BeginScene(IDirect3DDevice7 *iface)
Definition: device.c:1504
static HRESULT WINAPI d3d_device7_GetTransform_FPUPreserve(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3242
static HRESULT d3d_device7_GetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5283
static HRESULT WINAPI d3d_device7_BeginScene_FPUPreserve(IDirect3DDevice7 *iface)
Definition: device.c:1524
static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:3543
static HRESULT d3d_device7_ValidateDevice(IDirect3DDevice7 *iface, DWORD *pass_count)
Definition: device.c:5113
static HRESULT WINAPI d3d_device3_GetTexture(IDirect3DDevice3 *iface, DWORD stage, IDirect3DTexture2 **Texture2)
Definition: device.c:4640
static HRESULT d3d_device7_DeleteStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5817
static HRESULT d3d_device7_PreLoad(IDirect3DDevice7 *iface, IDirectDrawSurface7 *texture)
Definition: device.c:5650
static HRESULT WINAPI d3d_device7_SetClipPlane_FPUSetup(IDirect3DDevice7 *iface, DWORD idx, D3DVALUE *plane)
Definition: device.c:6440
static BOOL validate_surface_palette(struct ddraw_surface *surface)
Definition: device.c:1830
struct d3d_device * unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
Definition: device.c:6803
static HRESULT WINAPI d3d_device7_BeginScene_FPUSetup(IDirect3DDevice7 *iface)
Definition: device.c:1519
static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:3605
static HRESULT WINAPI d3d_device3_GetTransform(IDirect3DDevice3 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3255
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitive_FPUPreserve(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:3671
static HRESULT WINAPI d3d_device1_SetMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE matrix_handle, D3DMATRIX *matrix)
Definition: device.c:1367
static HRESULT WINAPI d3d_device2_SetTransform(IDirect3DDevice2 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3192
static HRESULT WINAPI d3d_device3_Begin(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, DWORD flags)
Definition: device.c:2135
static HRESULT WINAPI d3d_device7_GetViewport_FPUPreserve(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5312
static HRESULT WINAPI d3d_device3_ComputeSphereVisibility(IDirect3DDevice3 *iface, D3DVECTOR *centers, D3DVALUE *radii, DWORD sphere_count, DWORD flags, DWORD *return_values)
Definition: device.c:4525
static BOOL is_mip_level_subset(struct ddraw_surface *dest, struct ddraw_surface *src)
Definition: device.c:5950
static HRESULT WINAPI d3d_device7_GetMaterial_FPUPreserve(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5407
static HRESULT WINAPI d3d_device7_PreLoad_FPUPreserve(IDirect3DDevice7 *iface, IDirectDrawSurface7 *texture)
Definition: device.c:5672
static HRESULT WINAPI d3d_device3_NextViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *Viewport3, IDirect3DViewport3 **lplpDirect3DViewport3, DWORD flags)
Definition: device.c:915
static HRESULT WINAPI d3d_device3_DrawPrimitiveStrided(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
Definition: device.c:3996
static HRESULT WINAPI d3d_device7_BeginStateBlock_FPUSetup(IDirect3DDevice7 *iface)
Definition: device.c:5545
static void compute_sphere_visibility(const struct wined3d_vec4 *planes, DWORD enabled_planes, BOOL equality, const D3DVECTOR *centres, const D3DVALUE *radii, unsigned int sphere_count, DWORD *return_values)
Definition: device.c:4486
static HRESULT WINAPI d3d_device7_EndStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD *stateblock)
Definition: device.c:5617
static HRESULT WINAPI d3d_device2_GetDirect3D(IDirect3DDevice2 *iface, IDirect3D2 **d3d)
Definition: device.c:1682
static HRESULT d3d_device7_SetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5339
static HRESULT WINAPI d3d_device1_GetCaps(IDirect3DDevice *iface, D3DDEVICEDESC *hw_desc, D3DDEVICEDESC *hel_desc)
Definition: device.c:542
static HRESULT WINAPI d3d_device7_SetMaterial_FPUPreserve(IDirect3DDevice7 *iface, D3DMATERIAL7 *material)
Definition: device.c:5361
static HRESULT WINAPI d3d_device3_GetRenderTarget(IDirect3DDevice3 *iface, IDirectDrawSurface4 **RenderTarget)
Definition: device.c:2075
static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface, DWORD stage, IDirect3DTexture2 *texture)
Definition: device.c:4722
static HRESULT d3d_device7_CreateStateBlock(IDirect3DDevice7 *iface, D3DSTATEBLOCKTYPE type, DWORD *stateblock)
Definition: device.c:5878
static HRESULT WINAPI d3d_device7_SetTexture_FPUPreserve(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 *texture)
Definition: device.c:4709
static HRESULT WINAPI d3d_device2_GetStats(IDirect3DDevice2 *iface, D3DSTATS *stats)
Definition: device.c:646
static HRESULT WINAPI d3d_device7_LightEnable_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, BOOL enabled)
Definition: device.c:6327
static HRESULT WINAPI d3d_device2_SwapTextureHandles(IDirect3DDevice2 *iface, IDirect3DTexture2 *tex1, IDirect3DTexture2 *tex2)
Definition: device.c:564
static HRESULT WINAPI d3d_device3_Vertex(IDirect3DDevice3 *iface, void *vertex)
Definition: device.c:2247
static HRESULT WINAPI d3d_device7_Load_FPUPreserve(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture, POINT *dst_pos, IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
Definition: device.c:6285
static HRESULT WINAPI d3d_device7_QueryInterface(IDirect3DDevice7 *iface, REFIID riid, void **out)
Definition: device.c:178
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d_device3_EndScene(IDirect3DDevice3 *iface)
Definition: device.c:1609
struct d3d_device * unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
Definition: device.c:6796
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d_device1_EndScene(IDirect3DDevice *iface)
Definition: device.c:1627
static HRESULT WINAPI d3d_device7_CaptureStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5785
static HRESULT WINAPI d3d_device3_SetClipStatus(IDirect3DDevice3 *iface, D3DCLIPSTATUS *clip_status)
Definition: device.c:3787
static HRESULT WINAPI d3d_device7_DeleteStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5850
static HRESULT WINAPI d3d_device7_SetRenderState_FPUSetup(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: device.c:2678
static HRESULT WINAPI d3d_device7_PreLoad_FPUSetup(IDirect3DDevice7 *iface, IDirectDrawSurface7 *texture)
Definition: device.c:5667
static HRESULT d3d_device7_SetTransform(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3128
static HRESULT WINAPI d3d_device3_BeginIndexed(IDirect3DDevice3 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:2195
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d_device2_EndScene(IDirect3DDevice2 *iface)
Definition: device.c:1618
static HRESULT WINAPI d3d_device7_DrawIndexedPrimitiveStrided_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices, DWORD IndexCount, DWORD Flags)
Definition: device.c:4079
static void set_fpu_control_word(WORD fpucw)
Definition: device.c:43
static HRESULT WINAPI d3d_device1_Initialize(IDirect3DDevice *iface, IDirect3D *d3d, GUID *guid, D3DDEVICEDESC *device_desc)
Definition: device.c:410
static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count, D3DRECT *rects, DWORD flags, D3DCOLOR color, D3DVALUE z, DWORD stencil)
Definition: device.c:5173
static ULONG WINAPI d3d_device7_Release(IDirect3DDevice7 *iface)
Definition: device.c:356
static HRESULT WINAPI d3d_device7_SetTransform_FPUPreserve(IDirect3DDevice7 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3153
static HRESULT WINAPI d3d_device7_CaptureStateBlock_FPUPreserve(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5790
static HRESULT WINAPI d3d_device1_BeginScene(IDirect3DDevice *iface)
Definition: device.c:1554
static HRESULT d3d_device7_SetLight(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5434
static HRESULT WINAPI d3d_device7_GetViewport_FPUSetup(IDirect3DDevice7 *iface, D3DVIEWPORT7 *viewport)
Definition: device.c:5307
static HRESULT WINAPI d3d_device7_DrawPrimitiveStrided_FPUSetup(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
Definition: device.c:3973
static HRESULT WINAPI d3d_device2_MultiplyTransform(IDirect3DDevice2 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3362
static HRESULT WINAPI d3d_device2_GetRenderTarget(IDirect3DDevice2 *iface, IDirectDrawSurface **RenderTarget)
Definition: device.c:2096
static HRESULT WINAPI d3d_device1_DeleteMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE D3DMatHandle)
Definition: device.c:1467
static HRESULT d3d_device7_Load(IDirect3DDevice7 *iface, IDirectDrawSurface7 *dst_texture, POINT *dst_pos, IDirectDrawSurface7 *src_texture, RECT *src_rect, DWORD flags)
Definition: device.c:6114
static HRESULT d3d_device7_GetCaps(IDirect3DDevice7 *iface, D3DDEVICEDESC7 *device_desc)
Definition: device.c:421
static HRESULT WINAPI d3d_device7_DeleteStateBlock_FPUSetup(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5845
static HRESULT WINAPI d3d_device7_SetLight_FPUSetup(IDirect3DDevice7 *iface, DWORD light_idx, D3DLIGHT7 *light)
Definition: device.c:5449
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d_device7_EndScene_FPUPreserve(IDirect3DDevice7 *iface)
Definition: device.c:1597
static HRESULT WINAPI d3d_device7_SetRenderTarget_FPUSetup(IDirect3DDevice7 *iface, IDirectDrawSurface7 *NewTarget, DWORD flags)
Definition: device.c:1915
static HRESULT WINAPI d3d_device2_GetRenderState(IDirect3DDevice2 *iface, D3DRENDERSTATETYPE state, DWORD *value)
Definition: device.c:2520
static ULONG WINAPI d3d_device7_AddRef(IDirect3DDevice7 *iface)
Definition: device.c:224
HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, struct d3d_device **device, IUnknown *outer_unknown)
Definition: device.c:6959
static HRESULT d3d_device7_GetLightEnable(IDirect3DDevice7 *iface, DWORD light_idx, BOOL *enabled)
Definition: device.c:6360
static HRESULT d3d_device7_ApplyStateBlock(IDirect3DDevice7 *iface, DWORD stateblock)
Definition: device.c:5697
static HRESULT WINAPI d3d_device7_ValidateDevice_FPUSetup(IDirect3DDevice7 *iface, DWORD *pass_count)
Definition: device.c:5127
static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_setup_vtbl
Definition: device.c:6557
static HRESULT WINAPI d3d_device3_GetDirect3D(IDirect3DDevice3 *iface, IDirect3D3 **d3d)
Definition: device.c:1666
static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl
Definition: device.c:6667
static HRESULT WINAPI d3d_device2_DrawPrimitive(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE primitive_type, D3DVERTEXTYPE vertex_type, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:3558
static HRESULT WINAPI d3d_device3_Index(IDirect3DDevice3 *iface, WORD index)
Definition: device.c:2299
static HRESULT WINAPI d3d_device3_MultiplyTransform(IDirect3DDevice3 *iface, D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix)
Definition: device.c:3338
static void copy_mipmap_chain(struct d3d_device *device, struct ddraw_surface *dst, struct ddraw_surface *src, const POINT *DestPoint, const RECT *SrcRect)
Definition: device.c:5997
static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, IDirect3DVertexBuffer7 *vb, DWORD start_vertex, DWORD vertex_count, WORD *indices, DWORD index_count, DWORD flags)
Definition: device.c:4255
static HRESULT WINAPI d3d_device3_SetCurrentViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
Definition: device.c:1730
const GUID IID_D3DDEVICE_WineD3D
Definition: device.c:36
static HRESULT WINAPI d3d_device7_SetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD value)
Definition: device.c:5056
static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface, D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count, DWORD flags)
Definition: device.c:3468
static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
Definition: device.c:4809
static HRESULT WINAPI d3d_device3_DeleteViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
Definition: device.c:834
static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface, DWORD stage, IDirectDrawSurface7 *texture)
Definition: device.c:4674
static ULONG WINAPI d3d_device2_AddRef(IDirect3DDevice2 *iface)
Definition: device.c:242
static HRESULT WINAPI d3d_device3_EnumTextureFormats(IDirect3DDevice3 *iface, LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
Definition: device.c:1197
HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, const void *data, unsigned int size, unsigned int stride, unsigned int *ret_pos)
Definition: buffer.c:1422
struct wined3d_resource *CDECL wined3d_buffer_get_resource(struct wined3d_buffer *buffer)
Definition: buffer.c:520
void CDECL wined3d_streaming_buffer_unmap(struct wined3d_streaming_buffer *buffer)
Definition: buffer.c:1417
HRESULT CDECL wined3d_streaming_buffer_map(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, unsigned int size, unsigned int stride, unsigned int *ret_pos, void **ret_data)
Definition: buffer.c:1375
void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, unsigned int start_vertex, unsigned int vertex_count, unsigned int start_instance, unsigned int instance_count)
Definition: device.c:2635
void CDECL wined3d_device_context_set_primitive_type(struct wined3d_device_context *context, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count)
Definition: device.c:3779
HRESULT CDECL wined3d_device_context_set_rendertarget_views(struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, struct wined3d_rendertarget_view *const *views, BOOL set_viewport)
Definition: device.c:2377
ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
Definition: device.c:251
void CDECL wined3d_device_context_get_scissor_rects(const struct wined3d_device_context *context, unsigned int *rect_count, RECT *rects)
Definition: device.c:1890
HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, unsigned int rect_count, const RECT *rects, uint32_t flags, const struct wined3d_color *color, float depth, unsigned int stencil)
Definition: device.c:3729
HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
Definition: device.c:3715
void CDECL wined3d_device_context_get_viewports(const struct wined3d_device_context *context, unsigned int *viewport_count, struct wined3d_viewport *viewports)
Definition: device.c:1844
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, const struct wined3d_stateblock_state *state, DWORD *num_passes)
Definition: device.c:3963
void CDECL wined3d_device_context_draw_indexed(struct wined3d_device_context *context, int base_vertex_index, unsigned int start_index, unsigned int index_count, unsigned int start_instance, unsigned int instance_count)
Definition: device.c:2649
ULONG CDECL wined3d_device_incref(struct wined3d_device *device)
Definition: device.c:161
HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device)
Definition: device.c:3700
HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_device_context *context, struct wined3d_rendertarget_view *view)
Definition: device.c:2453
void CDECL wined3d_resource_preload(struct wined3d_resource *resource)
Definition: resource.c:311
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: resource.c:304
void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc)
Definition: resource.c:280
HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags)
Definition: resource.c:295
void *CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
Definition: texture.c:1690
HRESULT CDECL wined3d_texture_get_sub_resource_desc(const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
Definition: texture.c:4055
void *CDECL wined3d_texture_get_sub_resource_parent(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:4033
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1649
HRESULT CDECL wined3d_device_context_blt(struct wined3d_device_context *context, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const RECT *src_rect, unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: texture.c:3854
unsigned int idx
Definition: utils.c:40
void *CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view)
Definition: view.c:400
void *CDECL wined3d_rendertarget_view_get_sub_resource_parent(const struct wined3d_rendertarget_view *view)
Definition: view.c:407
#define TRACE_ON(x)
Definition: compat.h:75
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
static const WCHAR version[]
Definition: asmname.c:66
GUID guid
Definition: version.c:147
#define assert(_expr)
Definition: assert.h:32
#define USHRT_MAX
Definition: limits.h:23
_ACRTIMP double __cdecl fabs(double)
#define DDSCAPS2_CUBEMAP
Definition: ddsformat.c:64
return ret
Definition: mutex.c:147
r parent
Definition: btrfs.c:3010
#define D3DRENDERSTATE_ZBIAS
Definition: dx7todx8.h:78
#define D3DRENDERSTATE_EDGEANTIALIAS
Definition: dx7todx8.h:39
#define D3DTRANSFORMSTATE_WORLD2
Definition: dx7todx8.h:24
#define D3DTRANSFORMSTATE_WORLD1
Definition: dx7todx8.h:23
#define D3DRENDERSTATE_FOGVERTEXMODE
Definition: dx7todx8.h:49
#define D3DRENDERSTATE_COLORVERTEX
Definition: dx7todx8.h:34
#define D3DRENDERSTATE_LIGHTING
Definition: dx7todx8.h:51
#define D3DRENDERSTATE_NORMALIZENORMALS
Definition: dx7todx8.h:54
#define D3DTRANSFORMSTATE_WORLD
Definition: dx7todx8.h:22
#define D3DTRANSFORMSTATE_WORLD3
Definition: dx7todx8.h:25
#define D3DRENDERSTATE_FOGSTART
Definition: dx7todx8.h:47
#define D3DRENDERSTATE_FOGDENSITY
Definition: dx7todx8.h:44
#define D3DTRANSFORMSTATE_PROJECTION
Definition: dx7todx8.h:12
#define D3DRENDERSTATE_AMBIENT
Definition: dx7todx8.h:30
#define D3DRENDERSTATE_LOCALVIEWER
Definition: dx7todx8.h:53
#define D3DRENDERSTATE_CLIPPLANEENABLE
Definition: dx7todx8.h:33
#define D3DRENDERSTATE_FOGEND
Definition: dx7todx8.h:46
POINTL point
Definition: edittest.c:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
GLenum GLuint texture
Definition: glext.h:6295
GLsizei stride
Definition: glext.h:5848
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLsizei GLsizei GLfloat distance
Definition: glext.h:11755
GLuint GLenum matrix
Definition: glext.h:9407
GLenum mode
Definition: glext.h:6217
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean enable
Definition: glext.h:11120
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLdouble GLdouble z
Definition: glext.h:5874
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum light
Definition: glfuncs.h:170
unsigned int UINT
Definition: sysinfo.c:13
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IPrintDialogCallback callback
Definition: printdlg.c:325
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
int vertex_count
Definition: d3drm.c:3528
static ULONG * old_value
Definition: directory.c:54
static char * dest
Definition: rtl.c:149
static float(__cdecl *square_half_float)(float x
#define min(a, b)
Definition: monoChain.cc:55
#define sqrtf(x)
Definition: mymath.h:59
#define DWORD
Definition: nt_native.h:44
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
DWORD IDirectDrawSurface7
Definition: vmrender.idl:20
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tpush %rbx\n" "\t.seh_pushreg %rbx\n" "\tpush %rdi\n" "\t.seh_pushreg %rdi\n" "\tpush %rsi\n" "\t.seh_pushreg %rsi\n" "\tpush %r12\n" "\t.seh_pushreg %r12\n" "\tpush %r13\n" "\t.seh_pushreg %r13\n" "\tpush %r14\n" "\t.seh_pushreg %r14\n" "\tpush %r15\n" "\t.seh_pushreg %r15\n" "\tsub $40, %rsp\n" "\t.seh_stackalloc 40\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $40, %rsp\n" "\tpop %r15\n" "\tpop %r14\n" "\tpop %r13\n" "\tpop %r12\n" "\tpop %rsi\n" "\tpop %rdi\n" "\tpop %rbx\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
static calc_node_t temp
Definition: rpn_ieee.c:38
#define DDSCL_FPUPRESERVE
Definition: ddraw.h:545
#define DDSCAPS2_CUBEMAP_NEGATIVEZ
Definition: ddraw.h:298
#define DDSCAPS_ZBUFFER
Definition: ddraw.h:269
#define DDSCAPS2_CUBEMAP_ALLFACES
Definition: ddraw.h:299
#define DDSD_PIXELFORMAT
Definition: ddraw.h:218
#define DDENUMRET_OK
Definition: ddraw.h:191
#define DDERR_INVALIDPIXELFORMAT
Definition: ddraw.h:82
#define DDERR_INVALIDCAPS
Definition: ddraw.h:77
#define DDSCAPS2_MIPMAPSUBLEVEL
Definition: ddraw.h:306
#define DDCKEY_SRCOVERLAY
Definition: ddraw.h:481
#define DDERR_OUTOFMEMORY
Definition: ddraw.h:113
#define DDERR_NOPALETTEATTACHED
Definition: ddraw.h:148
#define DDCKEY_DESTBLT
Definition: ddraw.h:478
#define DD_OK
Definition: ddraw.h:188
#define DDSCAPS_3DDEVICE
Definition: ddraw.h:265
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:81
#define DDSCAPS_TEXTURE
Definition: ddraw.h:264
#define DDSCAPS_VIDEOMEMORY
Definition: ddraw.h:266
#define DDSD_CAPS
Definition: ddraw.h:210
#define ERR_(ch,...)
Definition: debug.h:156
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:117
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:230
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:139
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwTrianglesDrawn
Definition: d3dtypes.h:1249
DWORD dwLinesDrawn
Definition: d3dtypes.h:1250
DWORD dwVerticesProcessed
Definition: d3dtypes.h:1253
DWORD dwPointsDrawn
Definition: d3dtypes.h:1251
DWORD dwSpansDrawn
Definition: d3dtypes.h:1252
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
DWORD dwStatus
Definition: d3dtypes.h:1237
DWORD dwSize
Definition: d3dcaps.h:318
D3DVALUE dvMinZ
Definition: d3dtypes.h:395
DWORD dwWidth
Definition: d3dtypes.h:393
D3DVALUE dvMaxZ
Definition: d3dtypes.h:396
DWORD dwHeight
Definition: d3dtypes.h:394
DWORD dwSize
Definition: ddraw.h:1072
DWORD dwRGBAlphaBitMask
Definition: ddraw.h:1115
DWORD dwCaps2
Definition: ddraw.h:735
DWORD dwCaps
Definition: ddraw.h:734
DWORD dwWidth
Definition: ddraw.h:1157
DWORD dwHeight
Definition: ddraw.h:1156
DDSCAPS2 ddsCaps
Definition: ddraw.h:1190
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1187
LONG y
Definition: windef.h:130
LONG x
Definition: windef.h:129
Definition: http.c:7252
IUnknown * outer_unknown
D3DPRIMITIVETYPE primitive_type
IDirect3DDevice3 IDirect3DDevice3_iface
IUnknown * rt_iface
DWORD vertex_type
IUnknown IUnknown_inner
IDirect3DDevice2 IDirect3DDevice2_iface
DWORD material
IDirect3DDevice IDirect3DDevice_iface
IDirect3DDevice7 IDirect3DDevice7_iface
struct wined3d_vertex_declaration * wined3d_declaration
struct wined3d_buffer * wined3d_buffer
IDirect3DVertexBuffer7 IDirect3DVertexBuffer7_iface
struct d3d_device * active_device
IDirect3DViewport3 IDirect3DViewport3_iface
struct list entry
IDirectDrawSurface IDirectDrawSurface_iface
struct wined3d_texture * draw_texture
DDSURFACEDESC2 surface_desc
unsigned int sub_resource_idx
struct ddraw_palette * palette
IDirectDrawSurface7 IDirectDrawSurface7_iface
IDirectDrawSurface4 IDirectDrawSurface4_iface
struct wined3d_texture * wined3d_texture
IDirect3DTexture2 IDirect3DTexture2_iface
struct ddraw_surface * root
DWORD flags
struct wined3d_device * wined3d_device
Definition: ddraw_private.h:99
struct wined3d_device_context * immediate_context
DWORD cooperative_level
struct list d3ddevice_list
Definition: devices.h:37
Definition: list.h:15
Definition: send.c:48
Definition: tools.h:99
union tss_lookup::@266 u
enum wined3d_texture_stage_state texture_state
Definition: device.c:2329
BOOL sampler_state
Definition: device.c:2326
Definition: mesh.c:4665
UINT left
Definition: wined3d.h:1873
UINT right
Definition: wined3d.h:1875
#define max(a, b)
Definition: svc.c:63
#define LIST_ENTRY(type)
Definition: queue.h:175
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:64
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define WINAPI
Definition: msvc.h:6
HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, const struct wined3d_adapter *adapter, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, uint32_t usage, unsigned int bind_flags, enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
Definition: directx.c:1972
HRESULT CDECL wined3d_output_get_display_mode(const struct wined3d_output *output, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:1515
void CDECL wined3d_stateblock_set_vertex_declaration(struct wined3d_stateblock *stateblock, struct wined3d_vertex_declaration *declaration)
Definition: stateblock.c:1571
HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
Definition: stateblock.c:2508
void CDECL wined3d_stateblock_set_material(struct wined3d_stateblock *stateblock, const struct wined3d_material *material)
Definition: stateblock.c:1891
void CDECL wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock, UINT stage, struct wined3d_texture *texture)
Definition: stateblock.c:1816
void CDECL wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:393
HRESULT CDECL wined3d_stateblock_set_light(struct wined3d_stateblock *stateblock, UINT light_idx, const struct wined3d_light *light)
Definition: stateblock.c:1996
void CDECL wined3d_stateblock_depth_buffer_changed(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:4043
HRESULT CDECL wined3d_stateblock_set_clip_plane(struct wined3d_stateblock *stateblock, UINT plane_idx, const struct wined3d_vec4 *plane)
Definition: stateblock.c:1875
HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *stateblock, UINT light_idx, BOOL enable)
Definition: stateblock.c:2042
void CDECL wined3d_stateblock_primary_dirtify_all_states(struct wined3d_device *device, struct wined3d_stateblock *stateblock)
Definition: stateblock.c:313
void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock, UINT sampler_idx, enum wined3d_sampler_state state, unsigned int value)
Definition: stateblock.c:1702
const struct wined3d_stateblock_state *CDECL wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock)
Definition: stateblock.c:2064
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:670
void CDECL wined3d_stateblock_set_transform(struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: stateblock.c:1840
void CDECL wined3d_stateblock_multiply_transform(struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: stateblock.c:1859
void CDECL wined3d_stateblock_set_index_buffer(struct wined3d_stateblock *stateblock, struct wined3d_buffer *buffer, enum wined3d_format_id format_id)
Definition: stateblock.c:1918
void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateblock, enum wined3d_render_state state, unsigned int value)
Definition: stateblock.c:1623
void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, struct wined3d_stateblock *device_state)
Definition: stateblock.c:1156
void CDECL wined3d_stateblock_set_scissor_rect(struct wined3d_stateblock *stateblock, const RECT *rect)
Definition: stateblock.c:1910
void CDECL wined3d_stateblock_apply_clear_state(struct wined3d_stateblock *stateblock, struct wined3d_device *device)
Definition: stateblock.c:2917
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state)
Definition: stateblock.c:893
HRESULT CDECL wined3d_stateblock_set_stream_source(struct wined3d_stateblock *stateblock, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride)
Definition: stateblock.c:1939
HRESULT CDECL wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock, UINT light_idx, struct wined3d_light *light, BOOL *enabled)
Definition: stateblock.c:2069
void CDECL wined3d_stateblock_set_texture_stage_state(struct wined3d_stateblock *stateblock, UINT stage, enum wined3d_texture_stage_state state, unsigned int value)
Definition: stateblock.c:1718
void CDECL wined3d_stateblock_set_viewport(struct wined3d_stateblock *stateblock, const struct wined3d_viewport *viewport)
Definition: stateblock.c:1900
void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock)
Definition: stateblock.c:3038
wined3d_stateblock_type
Definition: wined3d.h:786
@ WINED3D_SBT_PRIMARY
Definition: wined3d.h:791
@ WINED3D_SBT_RECORDED
Definition: wined3d.h:790
#define WINED3DUSAGE_QUERY_LEGACYBUMPMAP
Definition: wined3d.h:942
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:683
wined3d_render_state
Definition: wined3d.h:288
@ WINED3D_RS_COLORKEYENABLE
Definition: wined3d.h:323
@ WINED3D_RS_LIGHTING
Definition: wined3d.h:347
@ WINED3D_RS_ZENABLE
Definition: wined3d.h:293
@ WINED3D_RS_ANTIALIASEDLINEENABLE
Definition: wined3d.h:383
@ WINED3D_RS_DEPTHBIAS
Definition: wined3d.h:401
@ WINED3D_RS_NORMALIZENORMALS
Definition: wined3d.h:353
@ WINED3D_RS_SPECULARENABLE
Definition: wined3d.h:312
wined3d_primitive_type
Definition: wined3d.h:74
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982
#define WINED3D_OK
Definition: wined3d.h:33
#define WINED3D_BIND_VERTEX_BUFFER
Definition: wined3d.h:909
wined3d_sampler_state
Definition: wined3d.h:554
@ WINED3D_SAMP_MAX_ANISOTROPY
Definition: wined3d.h:564
@ WINED3D_SAMP_MIPMAP_LOD_BIAS
Definition: wined3d.h:562
@ WINED3D_SAMP_MIN_FILTER
Definition: wined3d.h:560
@ WINED3D_SAMP_MIP_FILTER
Definition: wined3d.h:561
@ WINED3D_SAMP_MAG_FILTER
Definition: wined3d.h:559
@ WINED3D_SAMP_BORDER_COLOR
Definition: wined3d.h:558
@ WINED3D_SAMP_ADDRESS_V
Definition: wined3d.h:556
@ WINED3D_SAMP_ADDRESS_U
Definition: wined3d.h:555
@ WINED3D_SAMP_MAX_MIP_LEVEL
Definition: wined3d.h:563
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
static void wined3d_streaming_buffer_init(struct wined3d_streaming_buffer *buffer, unsigned int bind_flags)
Definition: wined3d.h:2937
wined3d_texture_filter_type
Definition: wined3d.h:704
@ WINED3D_TEXF_GAUSSIAN_CUBIC
Definition: wined3d.h:710
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705
@ WINED3D_TEXF_FLAT_CUBIC
Definition: wined3d.h:709
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
@ WINED3D_TEXF_ANISOTROPIC
Definition: wined3d.h:708
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:707
wined3d_texture_stage_state
Definition: wined3d.h:593
@ WINED3D_TSS_COLOR_ARG2
Definition: wined3d.h:596
@ WINED3D_TSS_BUMPENV_LOFFSET
Definition: wined3d.h:606
@ WINED3D_TSS_ALPHA_OP
Definition: wined3d.h:597
@ WINED3D_TSS_BUMPENV_MAT11
Definition: wined3d.h:603
@ WINED3D_TSS_COLOR_OP
Definition: wined3d.h:594
@ WINED3D_TSS_INVALID
Definition: wined3d.h:612
@ WINED3D_TSS_BUMPENV_MAT10
Definition: wined3d.h:602
@ WINED3D_TSS_TEXCOORD_INDEX
Definition: wined3d.h:604
@ WINED3D_TSS_ALPHA_ARG2
Definition: wined3d.h:599
@ WINED3D_TSS_BUMPENV_MAT01
Definition: wined3d.h:601
@ WINED3D_TSS_BUMPENV_LSCALE
Definition: wined3d.h:605
@ WINED3D_TSS_COLOR_ARG1
Definition: wined3d.h:595
@ WINED3D_TSS_ALPHA_ARG1
Definition: wined3d.h:598
@ WINED3D_TSS_BUMPENV_MAT00
Definition: wined3d.h:600
@ WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
Definition: wined3d.h:607
#define WINED3D_MAP_READ
Definition: wined3d.h:957
#define WINED3D_BIND_SHADER_RESOURCE
Definition: wined3d.h:912
#define WINED3DTA_CURRENT
Definition: wined3d.h:882
wined3d_format_id
Definition: wined3d.h:126
@ WINED3DFMT_B2G3R3_UNORM
Definition: wined3d.h:131
@ WINED3DFMT_B4G4R4A4_UNORM
Definition: wined3d.h:130
@ WINED3DFMT_DXT2
Definition: wined3d.h:261
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:244
@ WINED3DFMT_R10G11B11_SNORM
Definition: wined3d.h:143
@ WINED3DFMT_B8G8R8X8_UNORM
Definition: wined3d.h:245
@ WINED3DFMT_B5G5R5X1_UNORM
Definition: wined3d.h:129
@ WINED3DFMT_R8G8_SNORM
Definition: wined3d.h:208
@ WINED3DFMT_R5G5_SNORM_L6_UNORM
Definition: wined3d.h:141
@ WINED3DFMT_DXT1
Definition: wined3d.h:260
@ WINED3DFMT_B5G5R5A1_UNORM
Definition: wined3d.h:243
@ WINED3DFMT_R10G10B10_SNORM_A2_UNORM
Definition: wined3d.h:147
@ WINED3DFMT_DXT3
Definition: wined3d.h:262
@ WINED3DFMT_DXT4
Definition: wined3d.h:263
@ WINED3DFMT_R8G8_SNORM_L8X8_UNORM
Definition: wined3d.h:142
@ WINED3DFMT_B5G6R5_UNORM
Definition: wined3d.h:242
@ WINED3DFMT_DXT5
Definition: wined3d.h:264
@ WINED3DFMT_P8_UINT
Definition: wined3d.h:137
@ WINED3DFMT_R16_UINT
Definition: wined3d.h:214
@ WINED3D_TOP_SELECT_ARG1
Definition: wined3d.h:629
@ WINED3D_TOP_ADD
Definition: wined3d.h:634
@ WINED3D_TOP_MODULATE
Definition: wined3d.h:631
@ WINED3D_TOP_SELECT_ARG2
Definition: wined3d.h:630
@ WINED3D_TOP_BLEND_TEXTURE_ALPHA
Definition: wined3d.h:640
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995
#define WINED3D_MAX_CLIP_DISTANCES
Definition: wined3d.h:1601
wined3d_depth_buffer_type
Definition: wined3d.h:472
@ WINED3D_ZB_TRUE
Definition: wined3d.h:474
@ WINED3D_ZB_FALSE
Definition: wined3d.h:473
static void wined3d_streaming_buffer_cleanup(struct wined3d_streaming_buffer *buffer)
Definition: wined3d.h:2943
wined3d_transform_state
Definition: wined3d.h:666
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:668
@ WINED3D_TS_VIEW
Definition: wined3d.h:667
@ WINED3D_TS_WORLD
Definition: wined3d.h:677
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44
@ WINED3D_DEVICE_TYPE_HAL
Definition: wined3d.h:91
#define WINED3D_BIND_INDEX_BUFFER
Definition: wined3d.h:910
#define WINED3DTA_TEXTURE
Definition: wined3d.h:883
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
unsigned char BYTE
Definition: xxhash.c:193