ReactOS 0.4.17-dev-966-gf06eace
device.c
Go to the documentation of this file.
1/*
2 * Copyright 2002 Lionel Ulmer
3 * Copyright 2002-2005 Jason Edmeades
4 * Copyright 2003-2004 Raphael Junqueira
5 * Copyright 2004 Christian Costa
6 * Copyright 2005 Oliver Stieber
7 * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
8 * Copyright 2006-2008 Henri Verbeet
9 * Copyright 2007 Andrew Riedi
10 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
11 * Copyright 2016, 2018 Józef Kucia for CodeWeavers
12 * Copyright 2020 Zebediah Figura
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 */
28
29#include "wined3d_private.h"
30#include "wined3d_gl.h"
31#include "wined3d_vk.h"
32
36
38{
39 struct wined3d_color diffuse, specular, ambient;
43};
44
46{
52
54
66};
67
68/* Define the default light parameters as specified by MSDN. */
70{
72 { 1.0f, 1.0f, 1.0f, 0.0f }, /* Diffuse r,g,b,a */
73 { 0.0f, 0.0f, 0.0f, 0.0f }, /* Specular r,g,b,a */
74 { 0.0f, 0.0f, 0.0f, 0.0f }, /* Ambient r,g,b,a, */
75 { 0.0f, 0.0f, 0.0f }, /* Position x,y,z */
76 { 0.0f, 0.0f, 1.0f }, /* Direction x,y,z */
77 0.0f, /* Range */
78 0.0f, /* Falloff */
79 0.0f, 0.0f, 0.0f, /* Attenuation 0,1,2 */
80 0.0f, /* Theta */
81 0.0f /* Phi */
82};
83
85{
86 struct wined3d_context **new_array;
87
88 TRACE("Adding context %p.\n", context);
89
90 if (!device->shader_backend->shader_allocate_context_data(context))
91 {
92 ERR("Failed to allocate shader backend context data.\n");
93 return FALSE;
94 }
95 device->shader_backend->shader_init_context_state(context);
96
97 if (!device->adapter->fragment_pipe->allocate_context_data(context))
98 {
99 ERR("Failed to allocate fragment pipeline context data.\n");
100 device->shader_backend->shader_free_context_data(context);
101 return FALSE;
102 }
103
104 if (!(new_array = realloc(device->contexts, sizeof(*new_array) * (device->context_count + 1))))
105 {
106 ERR("Failed to grow the context array.\n");
107 device->adapter->fragment_pipe->free_context_data(context);
108 device->shader_backend->shader_free_context_data(context);
109 return FALSE;
110 }
111
112 new_array[device->context_count++] = context;
113 device->contexts = new_array;
114
115 return TRUE;
116}
117
119{
120 struct wined3d_context **new_array;
121 BOOL found = FALSE;
122 UINT i;
123
124 TRACE("Removing context %p.\n", context);
125
126 device->adapter->fragment_pipe->free_context_data(context);
127 device->shader_backend->shader_free_context_data(context);
128
129 for (i = 0; i < device->context_count; ++i)
130 {
131 if (device->contexts[i] == context)
132 {
133 found = TRUE;
134 break;
135 }
136 }
137
138 if (!found)
139 {
140 ERR("Context %p doesn't exist in context array.\n", context);
141 return;
142 }
143
144 if (!--device->context_count)
145 {
146 free(device->contexts);
147 device->contexts = NULL;
148 return;
149 }
150
151 memmove(&device->contexts[i], &device->contexts[i + 1], (device->context_count - i) * sizeof(*device->contexts));
152 if (!(new_array = realloc(device->contexts, device->context_count * sizeof(*device->contexts))))
153 {
154 ERR("Failed to shrink context array. Oh well.\n");
155 return;
156 }
157
158 device->contexts = new_array;
159}
160
162{
163 unsigned int refcount = InterlockedIncrement(&device->ref);
164
165 TRACE("%p increasing refcount to %u.\n", device, refcount);
166
167 return refcount;
168}
169
171{
173
174 free(s);
175}
176
178{
180
181 ERR("Leftover sampler %p.\n", sampler);
182}
183
185{
187
188 ERR("Leftover rasterizer state %p.\n", state);
189}
190
192{
194
195 ERR("Leftover blend state %p.\n", blend_state);
196}
197
199{
201
202 ERR("Leftover depth/stencil state %p.\n", state);
203}
204
206{
207 unsigned int i;
208
209 if (device->swapchain_count)
211
213
214 for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
215 {
216 free(device->multistate_funcs[i]);
217 device->multistate_funcs[i] = NULL;
218 }
219
220 if (!list_empty(&device->resources))
221 {
223
224 ERR("Device released with resources still bound.\n");
225
227 {
228 ERR("Leftover resource %p with type %s (%#x).\n",
230 }
231 }
232
233 if (device->contexts)
234 ERR("Context array not freed!\n");
235 if (device->hardwareCursor)
236 DestroyCursor(device->hardwareCursor);
237 device->hardwareCursor = 0;
238
244
245 wined3d_lock_cleanup(&device->bo_map_lock);
246
247 wined3d_decref(device->wined3d);
248 device->wined3d = NULL;
249}
250
252{
253 unsigned int refcount = InterlockedDecrement(&device->ref);
254
255 TRACE("%p decreasing refcount to %u.\n", device, refcount);
256
257 if (!refcount)
258 {
260 device->adapter->adapter_ops->adapter_destroy_device(device);
261 TRACE("Destroyed device %p.\n", device);
263 }
264
265 return refcount;
266}
267
269{
270 unsigned int refcount = InterlockedIncrement(&state->refcount);
271
272 TRACE("%p increasing refcount to %u.\n", state, refcount);
273
274 return refcount;
275}
276
277static void wined3d_blend_state_destroy_object(void *object)
278{
279 TRACE("object %p.\n", object);
280
281 free(object);
282}
283
285{
286 unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount);
287 struct wined3d_device *device = state->device;
288
289 TRACE("%p decreasing refcount to %u.\n", state, refcount);
290
291 if (!refcount)
292 {
293 state->parent_ops->wined3d_object_destroyed(state->parent);
296 }
297
298 return refcount;
299}
300
302{
303 TRACE("state %p.\n", state);
304
305 return state->parent;
306}
307
309{
311}
312
314 const struct wined3d_blend_state_desc *desc, void *parent,
315 const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state)
316{
318
319 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
321
322 if (!(object = calloc(1, sizeof(*object))))
323 return E_OUTOFMEMORY;
324
325 object->refcount = 1;
326 object->desc = *desc;
327 object->parent = parent;
328 object->parent_ops = parent_ops;
329 object->device = device;
330
331 object->dual_source = desc->rt[0].enable
332 && (is_dual_source(desc->rt[0].src)
333 || is_dual_source(desc->rt[0].dst)
334 || is_dual_source(desc->rt[0].src_alpha)
335 || is_dual_source(desc->rt[0].dst_alpha));
336
337 TRACE("Created blend state %p.\n", object);
338 *state = object;
339
340 return WINED3D_OK;
341}
342
344{
345 unsigned int refcount = InterlockedIncrement(&state->refcount);
346
347 TRACE("%p increasing refcount to %u.\n", state, refcount);
348
349 return refcount;
350}
351
353{
354 TRACE("object %p.\n", object);
355
356 free(object);
357}
358
360{
361 unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount);
362 struct wined3d_device *device = state->device;
363
364 TRACE("%p decreasing refcount to %u.\n", state, refcount);
365
366 if (!refcount)
367 {
368 state->parent_ops->wined3d_object_destroyed(state->parent);
371 }
372
373 return refcount;
374}
375
377{
378 TRACE("state %p.\n", state);
379
380 return state->parent;
381}
382
384{
385 return desc->fail_op != WINED3D_STENCIL_OP_KEEP
386 || desc->depth_fail_op != WINED3D_STENCIL_OP_KEEP
387 || desc->pass_op != WINED3D_STENCIL_OP_KEEP;
388}
389
391{
392 if (desc->depth && desc->depth_write)
393 return true;
394
395 if (desc->stencil && desc->stencil_write_mask)
396 {
397 if (stencil_op_writes_ds(&desc->front) || stencil_op_writes_ds(&desc->back))
398 return true;
399 }
400
401 return false;
402}
403
405 const struct wined3d_depth_stencil_state_desc *desc, void *parent,
406 const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state)
407{
409
410 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
412
413 if (!(object = calloc(1, sizeof(*object))))
414 return E_OUTOFMEMORY;
415
416 object->refcount = 1;
417 object->desc = *desc;
418 object->parent = parent;
419 object->parent_ops = parent_ops;
420 object->device = device;
421
422 object->writes_ds = depth_stencil_state_desc_writes_ds(desc);
423
424 TRACE("Created depth/stencil state %p.\n", object);
425 *state = object;
426
427 return WINED3D_OK;
428}
429
431{
432 unsigned int refcount = InterlockedIncrement(&state->refcount);
433
434 TRACE("%p increasing refcount to %u.\n", state, refcount);
435
436 return refcount;
437}
438
440{
441 TRACE("object %p.\n", object);
442
443 free(object);
444}
445
447{
448 unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount);
449 struct wined3d_device *device = state->device;
450
451 TRACE("%p decreasing refcount to %u.\n", state, refcount);
452
453 if (!refcount)
454 {
455 state->parent_ops->wined3d_object_destroyed(state->parent);
458 }
459
460 return refcount;
461}
462
464{
465 TRACE("rasterizer_state %p.\n", state);
466
467 return state->parent;
468}
469
471 const struct wined3d_rasterizer_state_desc *desc, void *parent,
472 const struct wined3d_parent_ops *parent_ops, struct wined3d_rasterizer_state **state)
473{
475
476 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
478
479 if (!(object = calloc(1, sizeof(*object))))
480 return E_OUTOFMEMORY;
481
482 object->refcount = 1;
483 object->desc = *desc;
484 object->parent = parent;
485 object->parent_ops = parent_ops;
486 object->device = device;
487
488 TRACE("Created rasterizer state %p.\n", object);
489 *state = object;
490
491 return WINED3D_OK;
492}
493
495{
496 TRACE("device %p.\n", device);
497
498 return device->swapchain_count;
499}
500
502{
503 TRACE("device %p, swapchain_idx %u.\n", device, swapchain_idx);
504
505 if (swapchain_idx >= device->swapchain_count)
506 {
507 WARN("swapchain_idx %u >= swapchain_count %u.\n",
508 swapchain_idx, device->swapchain_count);
509 return NULL;
510 }
511
512 return device->swapchains[swapchain_idx];
513}
514
515static void device_load_logo(struct wined3d_device *device, const char *filename)
516{
519 HBITMAP hbm;
520 BITMAP bm;
521 HRESULT hr;
522 HDC dcb = NULL, dcs = NULL;
523
525 {
526 ERR_(winediag)("Failed to load logo %s.\n", wine_dbgstr_a(filename));
527 return;
528 }
529 GetObjectA(hbm, sizeof(BITMAP), &bm);
530
531 if (!(dcb = CreateCompatibleDC(NULL)))
532 goto out;
533 SelectObject(dcb, hbm);
534
535 desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
537 desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
538 desc.multisample_quality = 0;
540 desc.bind_flags = 0;
542 desc.width = bm.bmWidth;
543 desc.height = bm.bmHeight;
544 desc.depth = 1;
545 desc.size = 0;
547 NULL, NULL, &wined3d_null_parent_ops, &device->logo_texture)))
548 {
549 ERR("Wine logo requested, but failed to create texture, hr %#lx.\n", hr);
550 goto out;
551 }
552
553 if (FAILED(hr = wined3d_texture_get_dc(device->logo_texture, 0, &dcs)))
554 {
555 wined3d_texture_decref(device->logo_texture);
556 device->logo_texture = NULL;
557 goto out;
558 }
559 BitBlt(dcs, 0, 0, bm.bmWidth, bm.bmHeight, dcb, 0, 0, SRCCOPY);
560 wined3d_texture_release_dc(device->logo_texture, 0, dcs);
561
562 color_key.color_space_low_value = 0;
563 color_key.color_space_high_value = 0;
565
566out:
567 if (dcb) DeleteDC(dcb);
568 if (hbm) DeleteObject(hbm);
569}
570
571/* Context activation is done by the caller. */
573 struct wined3d_context_gl *context_gl)
574{
575 struct wined3d_dummy_textures *textures = &device_gl->dummy_textures;
576 const struct wined3d_d3d_info *d3d_info = context_gl->c.d3d_info;
577 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
578 unsigned int i;
579 DWORD color;
580
582 color = 0x000000ff;
583 else
584 color = 0x00000000;
585
586 /* Under DirectX you can sample even if no texture is bound, whereas
587 * OpenGL will only allow that when a valid texture is bound.
588 * We emulate this by creating dummy textures and binding them
589 * to each texture stage when the currently set D3D texture is NULL. */
590 wined3d_context_gl_active_texture(context_gl, gl_info, 0);
591
592 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_1d);
593 TRACE("Dummy 1D texture given name %u.\n", textures->tex_1d);
594 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, textures->tex_1d);
595 gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, 1, 0,
597
598 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_2d);
599 TRACE("Dummy 2D texture given name %u.\n", textures->tex_2d);
600 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, textures->tex_2d);
601 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0,
603
604 if (gl_info->supported[EXT_TEXTURE3D])
605 {
606 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_3d);
607 TRACE("Dummy 3D texture given name %u.\n", textures->tex_3d);
608 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, textures->tex_3d);
611 }
612
613 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
614 {
615 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_cube);
616 TRACE("Dummy cube texture given name %u.\n", textures->tex_cube);
617 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP, textures->tex_cube);
619 {
620 gl_info->gl_ops.gl.p_glTexImage2D(i, 0, GL_RGBA8, 1, 1, 0,
622 }
623 }
624
626 {
627 DWORD cube_array_data[6];
628
629 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_cube_array);
630 TRACE("Dummy cube array texture given name %u.\n", textures->tex_cube_array);
631 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textures->tex_cube_array);
632 for (i = 0; i < ARRAY_SIZE(cube_array_data); ++i)
633 cube_array_data[i] = color;
635 GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, cube_array_data));
636 }
637
638 if (gl_info->supported[EXT_TEXTURE_ARRAY])
639 {
640 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_1d_array);
641 TRACE("Dummy 1D array texture given name %u.\n", textures->tex_1d_array);
642 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, textures->tex_1d_array);
643 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA8, 1, 1, 0,
645
646 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_2d_array);
647 TRACE("Dummy 2D array texture given name %u.\n", textures->tex_2d_array);
648 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, textures->tex_2d_array);
651 }
652
654 {
656
657 GL_EXTCALL(glGenBuffers(1, &buffer));
658 GL_EXTCALL(glBindBuffer(GL_TEXTURE_BUFFER, buffer));
659 GL_EXTCALL(glBufferData(GL_TEXTURE_BUFFER, sizeof(color), &color, GL_STATIC_DRAW));
660 GL_EXTCALL(glBindBuffer(GL_TEXTURE_BUFFER, 0));
661
662 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_buffer);
663 TRACE("Dummy buffer texture given name %u.\n", textures->tex_buffer);
664 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, textures->tex_buffer);
666 GL_EXTCALL(glDeleteBuffers(1, &buffer));
667 }
668
670 {
671 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_2d_ms);
672 TRACE("Dummy multisample texture given name %u.\n", textures->tex_2d_ms);
673 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures->tex_2d_ms);
674 GL_EXTCALL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, GL_TRUE));
675
676 gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_2d_ms_array);
677 TRACE("Dummy multisample array texture given name %u.\n", textures->tex_2d_ms_array);
678 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures->tex_2d_ms_array);
679 GL_EXTCALL(glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, GL_RGBA8, 1, 1, 1, GL_TRUE));
680
681 if (gl_info->supported[ARB_CLEAR_TEXTURE])
682 {
683 GL_EXTCALL(glClearTexImage(textures->tex_2d_ms, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color));
684 GL_EXTCALL(glClearTexImage(textures->tex_2d_ms_array, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color));
685 }
686 else
687 {
688 WARN("ARB_clear_texture is currently required to clear dummy multisample textures.\n");
689 }
690 }
691
692 checkGLcall("create dummy textures");
693
695}
696
697/* Context activation is done by the caller. */
699 struct wined3d_context_gl *context_gl)
700{
701 struct wined3d_dummy_textures *dummy_textures = &device_gl->dummy_textures;
702 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
703
705 {
706 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_2d_ms);
707 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_2d_ms_array);
708 }
709
711 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_buffer);
712
713 if (gl_info->supported[EXT_TEXTURE_ARRAY])
714 {
715 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_2d_array);
716 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_1d_array);
717 }
718
720 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_cube_array);
721
722 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
723 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_cube);
724
725 if (gl_info->supported[EXT_TEXTURE3D])
726 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_3d);
727
728 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_2d);
729 gl_info->gl_ops.gl.p_glDeleteTextures(1, &dummy_textures->tex_1d);
730
731 checkGLcall("delete dummy textures");
732
733 memset(dummy_textures, 0, sizeof(*dummy_textures));
734}
735
736/* Context activation is done by the caller. */
738{
740 HRESULT hr;
741
742 desc.address_u = WINED3D_TADDRESS_WRAP;
743 desc.address_v = WINED3D_TADDRESS_WRAP;
744 desc.address_w = WINED3D_TADDRESS_WRAP;
745 memset(desc.border_color, 0, sizeof(desc.border_color));
746 desc.mag_filter = WINED3D_TEXF_POINT;
747 desc.min_filter = WINED3D_TEXF_POINT;
748 desc.mip_filter = WINED3D_TEXF_NONE;
749 desc.lod_bias = 0.0f;
750 desc.min_lod = -1000.0f;
751 desc.max_lod = 1000.0f;
752 desc.mip_base_level = 0;
753 desc.max_anisotropy = 1;
754 desc.compare = FALSE;
755 desc.comparison_func = WINED3D_CMP_NEVER;
756 desc.srgb_decode = TRUE;
757
758 /* In SM4+ shaders there is a separation between resources and samplers. Some shader
759 * instructions allow access to resources without using samplers.
760 * In GLSL, resources are always accessed through sampler or image variables. The default
761 * sampler object is used to emulate the direct resource access when there is no sampler state
762 * to use.
763 */
765 {
766 ERR("Failed to create default sampler, hr %#lx.\n", hr);
767 device->default_sampler = NULL;
768 }
769
770 /* In D3D10+, a NULL sampler maps to the default sampler state. */
771 desc.address_u = WINED3D_TADDRESS_CLAMP;
772 desc.address_v = WINED3D_TADDRESS_CLAMP;
773 desc.address_w = WINED3D_TADDRESS_CLAMP;
774 desc.mag_filter = WINED3D_TEXF_LINEAR;
775 desc.min_filter = WINED3D_TEXF_LINEAR;
776 desc.mip_filter = WINED3D_TEXF_LINEAR;
778 {
779 ERR("Failed to create null sampler, hr %#lx.\n", hr);
780 device->null_sampler = NULL;
781 }
782}
783
785{
786 wined3d_sampler_decref(device->default_sampler);
787 device->default_sampler = NULL;
788 wined3d_sampler_decref(device->null_sampler);
789 device->null_sampler = NULL;
790}
791
793 VkCommandBuffer vk_command_buffer, VkImageType type, unsigned int layer_count, unsigned int sample_count)
794{
795 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
797 uint32_t flags = 0;
798
799 static const VkClearColorValue colour = {{0}};
800
801 TRACE("image %p, context_vk %p, vk_command_buffer %p, type %#x, layer_count %u, sample_count %u.\n",
802 image, context_vk, vk_command_buffer, type, layer_count, sample_count);
803
804 if (type == VK_IMAGE_TYPE_2D && layer_count >= 6)
806
807 if (!wined3d_context_vk_create_image(context_vk, type,
809 1, 1, 1, sample_count, 1, layer_count, flags, image))
810 {
811 return false;
812 }
813
815
816 range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
817 range.baseMipLevel = 0;
818 range.levelCount = 1;
819 range.baseArrayLayer = 0;
820 range.layerCount = layer_count;
821
822 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
825
826 VK_CALL(vkCmdClearColorImage(vk_command_buffer, image->vk_image,
828
829 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
832
833 TRACE("Created NULL image 0x%s, memory 0x%s.\n",
834 wine_dbgstr_longlong(image->vk_image), wine_dbgstr_longlong(image->vk_memory));
835
836 return true;
837}
838
840 struct wined3d_context_vk *context_vk)
841{
842 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
843 const struct wined3d_vk_info *vk_info;
844 const struct wined3d_format *format;
845 VkMemoryPropertyFlags memory_type;
846 VkCommandBuffer vk_command_buffer;
847 unsigned int sample_count = 2;
849
851 while (sample_count && !(sample_count & format->multisample_types))
852 sample_count <<= 1;
853
854 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
855 {
856 ERR("Failed to get command buffer.\n");
857 return false;
858 }
859
860 vk_info = context_vk->vk_info;
861
865 if (!wined3d_context_vk_create_bo(context_vk, 16, usage, memory_type, &r->bo))
866 return false;
867 VK_CALL(vkCmdFillBuffer(vk_command_buffer, r->bo.vk_buffer, r->bo.b.buffer_offset, r->bo.size, 0x00000000u));
868 r->buffer_info.buffer = r->bo.vk_buffer;
869 r->buffer_info.offset = r->bo.b.buffer_offset;
870 r->buffer_info.range = r->bo.size;
871
872 if (!wined3d_null_image_vk_init(&r->image_1d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_1D, 1, 1))
873 {
874 ERR("Failed to create 1D image.\n");
875 goto fail;
876 }
877
878 if (!wined3d_null_image_vk_init(&r->image_2d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_2D, 6, 1))
879 {
880 ERR("Failed to create 2D image.\n");
881 goto fail;
882 }
883
884 if (!wined3d_null_image_vk_init(&r->image_2dms, context_vk, vk_command_buffer, VK_IMAGE_TYPE_2D, 1, sample_count))
885 {
886 ERR("Failed to create 2D MSAA image.\n");
887 goto fail;
888 }
889
890 if (!wined3d_null_image_vk_init(&r->image_3d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_3D, 1, 1))
891 {
892 ERR("Failed to create 3D image.\n");
893 goto fail;
894 }
895
896 return true;
897
898fail:
899 if (r->image_2dms.vk_image)
900 wined3d_context_vk_destroy_image(context_vk, &r->image_2dms);
901 if (r->image_2d.vk_image)
902 wined3d_context_vk_destroy_image(context_vk, &r->image_2d);
903 if (r->image_1d.vk_image)
904 wined3d_context_vk_destroy_image(context_vk, &r->image_1d);
905 wined3d_context_vk_reference_bo(context_vk, &r->bo);
906 wined3d_context_vk_destroy_bo(context_vk, &r->bo);
907 return false;
908}
909
911 struct wined3d_context_vk *context_vk)
912{
913 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
914
915 /* We don't track command buffer references to NULL resources. We easily
916 * could, but it doesn't seem worth it. */
917 wined3d_context_vk_reference_image(context_vk, &r->image_3d);
918 wined3d_context_vk_destroy_image(context_vk, &r->image_3d);
919 wined3d_context_vk_reference_image(context_vk, &r->image_2dms);
920 wined3d_context_vk_destroy_image(context_vk, &r->image_2dms);
921 wined3d_context_vk_reference_image(context_vk, &r->image_2d);
922 wined3d_context_vk_destroy_image(context_vk, &r->image_2d);
923 wined3d_context_vk_reference_image(context_vk, &r->image_1d);
924 wined3d_context_vk_destroy_image(context_vk, &r->image_1d);
925 wined3d_context_vk_reference_bo(context_vk, &r->bo);
926 wined3d_context_vk_destroy_bo(context_vk, &r->bo);
927}
928
930{
931 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
932 struct wined3d_null_views_vk *v = &device_vk->null_views_vk;
933 VkBufferViewCreateInfo buffer_create_info;
935 const struct wined3d_vk_info *vk_info;
936 VkImageViewCreateInfo view_desc;
937 VkResult vr;
938
939 vk_info = context_vk->vk_info;
940
942 buffer_create_info.pNext = NULL;
943 buffer_create_info.flags = 0;
944 buffer_create_info.buffer = r->bo.vk_buffer;
945 buffer_create_info.format = VK_FORMAT_R32_UINT;
946 buffer_create_info.offset = r->bo.b.buffer_offset;
947 buffer_create_info.range = r->bo.size;
948
949 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
950 &buffer_create_info, NULL, &v->vk_view_buffer_uint))) < 0)
951 {
952 ERR("Failed to create buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
953 return false;
954 }
955 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(v->vk_view_buffer_uint));
956
957 buffer_create_info.format = VK_FORMAT_R32G32B32A32_SFLOAT;
958 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
959 &buffer_create_info, NULL, &v->vk_view_buffer_float))) < 0)
960 {
961 ERR("Failed to create buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
962 goto fail;
963 }
964 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(v->vk_view_buffer_float));
965
967 view_desc.pNext = NULL;
968 view_desc.flags = 0;
969 view_desc.image = r->image_1d.vk_image;
977 view_desc.subresourceRange.baseMipLevel = 0;
978 view_desc.subresourceRange.levelCount = 1;
979 view_desc.subresourceRange.baseArrayLayer = 0;
980 view_desc.subresourceRange.layerCount = 1;
981
983 {
985 usage_desc.pNext = NULL;
987
988 view_desc.pNext = &usage_desc;
989 }
990
991 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_1d.imageView))) < 0)
992 {
993 ERR("Failed to create 1D image view, vr %s.\n", wined3d_debug_vkresult(vr));
994 goto fail;
995 }
996 v->vk_info_1d.sampler = VK_NULL_HANDLE;
997 v->vk_info_1d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
998 TRACE("Created 1D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_1d.imageView));
999
1001 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_1d_array.imageView))) < 0)
1002 {
1003 ERR("Failed to create 1D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1004 goto fail;
1005 }
1006 v->vk_info_1d_array.sampler = VK_NULL_HANDLE;
1007 v->vk_info_1d_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1008 TRACE("Created 1D array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_1d_array.imageView));
1009
1010 view_desc.image = r->image_2d.vk_image;
1011 view_desc.viewType = VK_IMAGE_VIEW_TYPE_2D;
1012 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2d.imageView))) < 0)
1013 {
1014 ERR("Failed to create 2D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1015 goto fail;
1016 }
1017 v->vk_info_2d.sampler = VK_NULL_HANDLE;
1018 v->vk_info_2d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1019 TRACE("Created 2D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2d.imageView));
1020
1021 view_desc.image = r->image_2dms.vk_image;
1022 view_desc.viewType = VK_IMAGE_VIEW_TYPE_2D;
1023 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2dms.imageView))) < 0)
1024 {
1025 ERR("Failed to create 2D MSAA image view, vr %s.\n", wined3d_debug_vkresult(vr));
1026 goto fail;
1027 }
1028 v->vk_info_2dms.sampler = VK_NULL_HANDLE;
1029 v->vk_info_2dms.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1030 TRACE("Created 2D MSAA image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2dms.imageView));
1031
1032 view_desc.image = r->image_3d.vk_image;
1033 view_desc.viewType = VK_IMAGE_VIEW_TYPE_3D;
1034 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_3d.imageView))) < 0)
1035 {
1036 ERR("Failed to create 3D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1037 goto fail;
1038 }
1039 v->vk_info_3d.sampler = VK_NULL_HANDLE;
1040 v->vk_info_3d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1041 TRACE("Created 3D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_3d.imageView));
1042
1043 view_desc.image = r->image_2d.vk_image;
1044 view_desc.subresourceRange.layerCount = 6;
1046 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_cube.imageView))) < 0)
1047 {
1048 ERR("Failed to create cube image view, vr %s.\n", wined3d_debug_vkresult(vr));
1049 goto fail;
1050 }
1051 v->vk_info_cube.sampler = VK_NULL_HANDLE;
1052 v->vk_info_cube.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1053 TRACE("Created cube image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_cube.imageView));
1054
1055 view_desc.subresourceRange.layerCount = 1;
1057 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2d_array.imageView))) < 0)
1058 {
1059 ERR("Failed to create 2D array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1060 goto fail;
1061 }
1062 v->vk_info_2d_array.sampler = VK_NULL_HANDLE;
1063 v->vk_info_2d_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1064 TRACE("Created 2D array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2d_array.imageView));
1065
1066 view_desc.image = r->image_2dms.vk_image;
1068 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2dms_array.imageView))) < 0)
1069 {
1070 ERR("Failed to create 2D MSAA array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1071 goto fail;
1072 }
1073 v->vk_info_2dms_array.sampler = VK_NULL_HANDLE;
1074 v->vk_info_2dms_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1075 TRACE("Created 2D MSAA array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2dms_array.imageView));
1076
1077 view_desc.image = r->image_2d.vk_image;
1078 view_desc.subresourceRange.layerCount = 6;
1080 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_cube_array.imageView))) < 0)
1081 {
1082 ERR("Failed to create cube array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1083 goto fail;
1084 }
1085 v->vk_info_cube_array.sampler = VK_NULL_HANDLE;
1086 v->vk_info_cube_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1087 TRACE("Created cube array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_cube_array.imageView));
1088
1089 return true;
1090
1091fail:
1092 if (v->vk_info_cube_array.imageView)
1093 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_cube_array.imageView, NULL));
1094 if (v->vk_info_2d_array.imageView)
1095 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2d_array.imageView, NULL));
1096 if (v->vk_info_cube.imageView)
1097 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_cube.imageView, NULL));
1098 if (v->vk_info_3d.imageView)
1099 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_3d.imageView, NULL));
1100 if (v->vk_info_2dms.imageView)
1101 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2dms.imageView, NULL));
1102 if (v->vk_info_2d.imageView)
1103 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2d.imageView, NULL));
1104 if (v->vk_info_1d_array.imageView)
1105 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_1d_array.imageView, NULL));
1106 if (v->vk_info_1d.imageView)
1107 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_1d.imageView, NULL));
1108 if (v->vk_view_buffer_float)
1109 VK_CALL(vkDestroyBufferView(device_vk->vk_device, v->vk_view_buffer_float, NULL));
1110 VK_CALL(vkDestroyBufferView(device_vk->vk_device, v->vk_view_buffer_uint, NULL));
1111 return false;
1112}
1113
1115{
1116 struct wined3d_null_views_vk *v = &device_vk->null_views_vk;
1117 uint64_t id = context_vk->current_command_buffer.id;
1118
1119 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_cube_array.imageView, id);
1120 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2dms_array.imageView, id);
1121 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2d_array.imageView, id);
1122 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_cube.imageView, id);
1123 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_3d.imageView, id);
1124 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2dms.imageView, id);
1125 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2d.imageView, id);
1126 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_1d_array.imageView, id);
1127 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_1d.imageView, id);
1128
1129 wined3d_context_vk_destroy_vk_buffer_view(context_vk, v->vk_view_buffer_float, id);
1130 wined3d_context_vk_destroy_vk_buffer_view(context_vk, v->vk_view_buffer_uint, id);
1131}
1132
1134{
1135 unsigned int screensaver_active;
1136
1137 TRACE("device %p, window %p.\n", device, window);
1138
1140 {
1141 ERR("Failed to register window %p.\n", window);
1142 return E_FAIL;
1143 }
1144
1145 InterlockedExchangePointer((void **)&device->focus_window, window);
1146 SetWindowPos(window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
1147 SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_active, 0);
1148 if ((device->restore_screensaver = !!screensaver_active))
1150
1151 return WINED3D_OK;
1152}
1153
1155{
1156 TRACE("device %p.\n", device);
1157
1158 if (device->focus_window) wined3d_unregister_window(device->focus_window);
1159 InterlockedExchangePointer((void **)&device->focus_window, NULL);
1160 if (device->restore_screensaver)
1161 {
1163 device->restore_screensaver = FALSE;
1164 }
1165}
1166
1168{
1170 BOOL ds_enable = swapchain->state.desc.enable_auto_depth_stencil;
1171 struct wined3d_device_context *context = &device->cs->c;
1172
1173 if (device->back_buffer_view)
1174 views[0] = device->back_buffer_view;
1176 device->adapter->d3d_info.limits.max_rt_count, views, !!device->back_buffer_view);
1177
1178 wined3d_device_context_set_depth_stencil_view(context, ds_enable ? device->auto_depth_stencil_view : NULL);
1179}
1180
1182 struct wined3d_context *context, unsigned int memory_type, size_t chunk_size)
1183{
1184 struct wined3d_allocator_chunk_gl *chunk_gl;
1185 struct wined3d_context_gl *context_gl;
1186
1187 TRACE("allocator %p, context %p, memory_type %u, chunk_size %Iu.\n", allocator, context, memory_type, chunk_size);
1188
1189 if (!context)
1190 return NULL;
1191 context_gl = wined3d_context_gl(context);
1192
1193 if (!(chunk_gl = malloc(sizeof(*chunk_gl))))
1194 return NULL;
1195
1196 if (!wined3d_allocator_chunk_init(&chunk_gl->c, allocator))
1197 {
1198 free(chunk_gl);
1199 return NULL;
1200 }
1201
1202 chunk_gl->memory_type = memory_type;
1203 if (!(chunk_gl->gl_buffer = wined3d_context_gl_allocate_vram_chunk_buffer(context_gl, memory_type, chunk_size)))
1204 {
1206 free(chunk_gl);
1207 return NULL;
1208 }
1209 list_add_head(&allocator->pools[memory_type].chunks, &chunk_gl->c.entry);
1210
1211 return &chunk_gl->c;
1212}
1213
1215{
1216 struct wined3d_device_gl *device_gl = wined3d_device_gl_from_allocator(chunk->allocator);
1218 const struct wined3d_gl_info *gl_info;
1219 struct wined3d_context_gl *context_gl;
1220
1221 TRACE("chunk %p.\n", chunk);
1222
1223 context_gl = wined3d_context_gl(context_acquire(&device_gl->d, NULL, 0));
1224 gl_info = context_gl->gl_info;
1225
1227 if (chunk_gl->c.map_ptr)
1228 GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
1229 GL_EXTCALL(glDeleteBuffers(1, &chunk_gl->gl_buffer));
1230 TRACE("Freed buffer %u.\n", chunk_gl->gl_buffer);
1232 free(chunk_gl);
1233
1234 context_release(&context_gl->c);
1235}
1236
1238{
1239 .allocator_create_chunk = wined3d_allocator_gl_create_chunk,
1240 .allocator_destroy_chunk = wined3d_allocator_gl_destroy_chunk,
1241};
1242
1243static const struct
1244{
1246}
1248{
1249 {0},
1253
1259
1261{
1262 unsigned int i;
1263
1264 for (i = 0; i < ARRAY_SIZE(gl_memory_types); ++i)
1265 {
1266 if (gl_memory_types[i].flags == flags)
1267 return i;
1268 }
1269
1270 assert(0);
1271 return 0;
1272}
1273
1275{
1276 return gl_memory_types[memory_type_idx].flags;
1277}
1278
1280 struct wined3d_context_gl *context_gl, unsigned int memory_type, GLsizeiptr size, GLuint *id)
1281{
1282 struct wined3d_allocator *allocator = &device_gl->allocator;
1284
1286
1288 {
1289 if (context_gl)
1290 *id = wined3d_context_gl_allocate_vram_chunk_buffer(context_gl, memory_type, size);
1292 return NULL;
1293 }
1294
1295 if (!(block = wined3d_allocator_allocate(allocator, context_gl ? &context_gl->c : NULL, memory_type, size)))
1296 {
1298 *id = 0;
1299 return NULL;
1300 }
1301
1303
1305 TRACE("Allocated offset %#Ix from chunk %p.\n", block->offset, block->chunk);
1306 return block;
1307}
1308
1310 const struct wined3d_gl_info *gl_info, GLenum binding)
1311{
1312 switch (binding)
1313 {
1314 case GL_ARRAY_BUFFER:
1318 case GL_UNIFORM_BUFFER:
1319 return true;
1320
1322 /* There is no way to specify an element array buffer offset for
1323 * indirect draws in OpenGL. */
1324 return device_gl->d.wined3d->flags & WINED3D_NO_DRAW_INDIRECT
1325 || !gl_info->supported[ARB_DRAW_INDIRECT];
1326
1327 case GL_TEXTURE_BUFFER:
1328 return gl_info->supported[ARB_TEXTURE_BUFFER_RANGE];
1329
1330 default:
1331 return false;
1332 }
1333}
1334
1335bool wined3d_device_gl_create_bo(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl,
1336 GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo)
1337{
1338 const struct wined3d_gl_info *gl_info = &wined3d_adapter_gl(device_gl->d.adapter)->gl_info;
1339 unsigned int memory_type_idx = wined3d_device_gl_find_memory_type(flags);
1341 GLsizeiptr buffer_offset = 0;
1342 GLuint id = 0;
1343
1344 TRACE("device_gl %p, context_gl %p, size %Iu, binding %#x, usage %#x, coherent %#x, flags %#x, bo %p.\n",
1345 device_gl, context_gl, size, binding, usage, coherent, flags, bo);
1346
1347 if (gl_info->supported[ARB_BUFFER_STORAGE])
1348 {
1349 /* Only suballocate dynamic buffers.
1350 *
1351 * We only need suballocation so that we can allocate GL buffers from
1352 * the client thread and thereby accelerate DISCARD maps.
1353 *
1354 * For other buffer types, suballocating means that a whole-buffer
1355 * upload won't be replacing the whole buffer anymore. If the driver
1356 * isn't smart enough to track individual buffer ranges then it'll
1357 * force synchronizing that BO with the GPU. Even using ARB_sync
1358 * ourselves won't help here, because glBufferSubData() is still
1359 * implicitly synchronized. */
1361 {
1362 if (use_buffer_chunk_suballocation(device_gl, gl_info, binding))
1363 {
1364 if ((memory = wined3d_device_gl_allocate_memory(device_gl, context_gl, memory_type_idx, size, &id)))
1365 buffer_offset = memory->offset;
1366 else if (!context_gl)
1367 WARN_(d3d_perf)("Failed to suballocate buffer from the client thread.\n");
1368 }
1369 else if (context_gl)
1370 {
1371 WARN_(d3d_perf)("Not allocating chunk memory for binding type %#x.\n", binding);
1372 id = wined3d_context_gl_allocate_vram_chunk_buffer(context_gl, memory_type_idx, size);
1373 }
1374 }
1375 else
1376 {
1377 id = wined3d_context_gl_allocate_vram_chunk_buffer(context_gl, memory_type_idx, size);
1378 }
1379
1380 if (!id)
1381 {
1382 if (context_gl)
1383 WARN("Failed to allocate buffer.\n");
1384 return false;
1385 }
1386 }
1387 else
1388 {
1389 if (!context_gl)
1390 return false;
1391
1392 GL_EXTCALL(glGenBuffers(1, &id));
1393 if (!id)
1394 {
1395 checkGLcall("buffer object creation");
1396 return false;
1397 }
1398 TRACE("Created buffer object %u.\n", id);
1399 wined3d_context_gl_bind_bo(context_gl, binding, id);
1400
1401 if (!coherent && gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
1402 {
1403 GL_EXTCALL(glBufferParameteriAPPLE(binding, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE));
1405 }
1406
1407 GL_EXTCALL(glBufferData(binding, size, NULL, usage));
1408
1409 wined3d_context_gl_bind_bo(context_gl, binding, 0);
1410 checkGLcall("buffer object creation");
1411 }
1412
1413 bo->id = id;
1414 bo->memory = memory;
1415 bo->size = size;
1416 bo->binding = binding;
1417 bo->usage = usage;
1418 bo->flags = flags;
1419 bo->b.coherent = coherent;
1420 list_init(&bo->b.users);
1421 bo->command_fence_id = 0;
1422 bo->b.buffer_offset = buffer_offset;
1423 bo->b.memory_offset = bo->b.buffer_offset;
1424 bo->b.map_ptr = NULL;
1425 bo->b.client_map_count = 0;
1426 bo->b.refcount = 1;
1427
1428 return true;
1429}
1430
1432{
1433 struct wined3d_device_gl *device_gl = object;
1434 struct wined3d_context_gl *context_gl;
1435 struct wined3d_context *context;
1436 struct wined3d_device *device;
1437 struct wined3d_shader *shader;
1438
1439 TRACE("device %p.\n", device_gl);
1440
1441 device = &device_gl->d;
1442
1444 {
1445 device->shader_backend->shader_destroy(shader);
1446 }
1447
1449 context_gl = wined3d_context_gl(context);
1450 device->blitter->ops->blitter_destroy(device->blitter, context);
1451 device->shader_backend->shader_free_private(device, context);
1452 wined3d_device_gl_destroy_dummy_textures(device_gl, context_gl);
1453
1454 if (context_gl->c.d3d_info->fences)
1455 {
1458 wined3d_device_gl(context_gl->c.device)->current_fence_id - 1);
1459 }
1461
1463
1464 while (device->context_count)
1466
1467 if (device_gl->backup_dc)
1468 {
1469 TRACE("Destroying backup wined3d window %p, dc %p.\n", device_gl->backup_wnd, device_gl->backup_dc);
1470
1471 wined3d_release_dc(device_gl->backup_wnd, device_gl->backup_dc);
1472 DestroyWindow(device_gl->backup_wnd);
1473 }
1474}
1475
1477{
1478 struct wined3d_device_gl *device_gl = object;
1479 struct wined3d_context_gl *context_gl;
1480 struct wined3d_swapchain *swapchain;
1481 struct wined3d_context *context;
1482 struct wined3d_texture *target;
1483 struct wined3d_device *device;
1484 HRESULT hr;
1485
1486 TRACE("device %p.\n", device_gl);
1487
1488 device = &device_gl->d;
1489 swapchain = device->swapchains[0];
1490 target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer;
1491 if (!(context = context_acquire(device, target, 0)))
1492 {
1493 WARN("Failed to acquire context.\n");
1494 return;
1495 }
1496
1497 context_gl = wined3d_context_gl(context);
1498
1500 {
1501 WARN("Failed to initialise allocator.\n");
1504 return;
1505 }
1506
1507 if (FAILED(hr = device->shader_backend->shader_alloc_private(device,
1508 device->adapter->vertex_pipe, device->adapter->fragment_pipe)))
1509 {
1510 ERR("Failed to allocate shader private data, hr %#lx.\n", hr);
1514 return;
1515 }
1516
1517 if (!(device->blitter = wined3d_cpu_blitter_create()))
1518 {
1519 ERR("Failed to create CPU blitter.\n");
1520 device->shader_backend->shader_free_private(device, NULL);
1524 return;
1525 }
1526
1527 wined3d_ffp_blitter_create(&device->blitter, context_gl->gl_info);
1529 wined3d_fbo_blitter_create(&device->blitter, context_gl->gl_info);
1530 wined3d_raw_blitter_create(&device->blitter, context_gl->gl_info);
1531
1532 wined3d_device_gl_create_dummy_textures(device_gl, context_gl);
1535}
1536
1538{
1539 static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f};
1540 const struct wined3d_swapchain_desc *swapchain_desc;
1541 struct wined3d_fb_state *fb = &device->cs->c.state->fb;
1542 DWORD clear_flags = 0;
1543 unsigned int i;
1544 HRESULT hr;
1545
1546 TRACE("device %p, swapchain %p.\n", device, swapchain);
1547
1548 if (device->d3d_initialized)
1550
1551 device->swapchain_count = 1;
1552 if (!(device->swapchains = calloc(device->swapchain_count, sizeof(*device->swapchains))))
1553 {
1554 ERR("Failed to allocate swapchain array.\n");
1555 hr = E_OUTOFMEMORY;
1556 goto err_out;
1557 }
1558 device->swapchains[0] = swapchain;
1559
1560 for (i = 0; i < ARRAY_SIZE(fb->render_targets); ++i)
1561 {
1562 if (fb->render_targets[i])
1564 }
1565 memset(fb->render_targets, 0, sizeof(fb->render_targets));
1566
1567 if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device)))
1568 goto err_out;
1569 device->d3d_initialized = TRUE;
1570
1571 swapchain_desc = &swapchain->state.desc;
1572 if (swapchain_desc->backbuffer_count && swapchain_desc->backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
1573 {
1574 struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
1575 struct wined3d_view_desc view_desc;
1576
1577 view_desc.format_id = back_buffer->format->id;
1578 view_desc.flags = 0;
1579 view_desc.u.texture.level_idx = 0;
1580 view_desc.u.texture.level_count = 1;
1581 view_desc.u.texture.layer_idx = 0;
1582 view_desc.u.texture.layer_count = 1;
1583 if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc, back_buffer,
1584 NULL, &wined3d_null_parent_ops, &device->back_buffer_view)))
1585 {
1586 ERR("Failed to create rendertarget view, hr %#lx.\n", hr);
1587 device->adapter->adapter_ops->adapter_uninit_3d(device);
1588 device->d3d_initialized = FALSE;
1589 goto err_out;
1590 }
1591 }
1592
1594
1595 TRACE("All defaults now set up.\n");
1596
1597 /* Clear the screen. */
1598 if (device->back_buffer_view)
1599 clear_flags |= WINED3DCLEAR_TARGET;
1600 if (swapchain_desc->enable_auto_depth_stencil)
1602 if (clear_flags)
1603 wined3d_device_clear(device, 0, NULL, clear_flags, &black, 1.0f, 0);
1604
1607
1608 return WINED3D_OK;
1609
1610err_out:
1611 free(device->swapchains);
1612 device->swapchains = NULL;
1613 device->swapchain_count = 0;
1614
1615 return hr;
1616}
1617
1619{
1621
1623}
1624
1626{
1628
1630}
1631
1633{
1635
1636 wined3d_blend_state_decref(blend_state);
1637}
1638
1640{
1642
1644}
1645
1647{
1649
1650 wined3d_shader_decref(vs->shader);
1651 free(vs);
1652}
1653
1655{
1657
1659 free(ps);
1660}
1661
1663{
1664 struct wined3d_state *state = device->cs->c.state;
1667 struct wined3d_texture *texture;
1668 struct wined3d_buffer *buffer;
1669 unsigned int i;
1670
1671 TRACE("device %p.\n", device);
1672
1673 if (!device->d3d_initialized)
1674 {
1675 ERR("Called while 3D support was not initialised.\n");
1676 return;
1677 }
1678
1680
1681 device->swapchain_count = 0;
1682
1683 if ((texture = device->logo_texture))
1684 {
1685 device->logo_texture = NULL;
1687 }
1688
1689 if ((texture = device->cursor_texture))
1690 {
1691 device->cursor_texture = NULL;
1693 }
1694
1695 for (i = 0; i < ARRAY_SIZE(device->push_constants); ++i)
1696 {
1697 if ((buffer = device->push_constants[i]))
1699 }
1700 memset(device->push_constants, 0, sizeof(device->push_constants));
1701
1704
1711
1712 LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
1713 {
1714 TRACE("Unloading resource %p.\n", resource);
1716 }
1717
1718 device->adapter->adapter_ops->adapter_uninit_3d(device);
1719 device->d3d_initialized = FALSE;
1720
1721 if ((view = device->auto_depth_stencil_view))
1722 {
1723 device->auto_depth_stencil_view = NULL;
1725 ERR("Something's still holding the auto depth/stencil view (%p).\n", view);
1726 }
1727
1728 if ((view = device->back_buffer_view))
1729 {
1730 device->back_buffer_view = NULL;
1732 }
1733
1734 free(device->swapchains);
1735 device->swapchains = NULL;
1736
1737 wined3d_state_reset(state, &device->adapter->d3d_info);
1738}
1739
1740/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw
1741 * from SetCooperativeLevel if DDSCL_MULTITHREADED is specified, and by d3d8/9 from
1742 * CreateDevice if D3DCREATE_MULTITHREADED is passed.
1743 *
1744 * There is no way to deactivate thread safety once it is enabled.
1745 */
1747{
1748 TRACE("device %p.\n", device);
1749
1750 /* For now just store the flag (needed in case of ddraw). */
1751 device->create_parms.flags |= WINED3DCREATE_MULTITHREADED;
1752}
1753
1755{
1756 const struct wined3d_driver_info *driver_info;
1757
1758 TRACE("device %p.\n", device);
1759
1760 driver_info = &device->adapter->driver_info;
1761
1762 TRACE("Emulating 0x%s bytes. 0x%s used, returning 0x%s left.\n",
1763 wine_dbgstr_longlong(driver_info->vram_bytes),
1764 wine_dbgstr_longlong(device->adapter->vram_bytes_used),
1765 wine_dbgstr_longlong(driver_info->vram_bytes - device->adapter->vram_bytes_used));
1766
1767 return min(UINT_MAX, driver_info->vram_bytes) - device->adapter->vram_bytes_used;
1768}
1769
1771 unsigned int idx, unsigned int *offset)
1772{
1773 TRACE("context %p, idx %u, offset %p.\n", context, idx, offset);
1774
1776 {
1777 WARN("Invalid stream output %u.\n", idx);
1778 return NULL;
1779 }
1780
1781 if (offset)
1782 *offset = context->state->stream_output[idx].offset;
1783 return context->state->stream_output[idx].buffer;
1784}
1785
1787 unsigned int stream_idx, struct wined3d_buffer **buffer, unsigned int *offset, unsigned int *stride)
1788{
1789 const struct wined3d_stream_state *stream;
1790
1791 TRACE("context %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
1792 context, stream_idx, buffer, offset, stride);
1793
1794 if (stream_idx >= WINED3D_MAX_STREAMS)
1795 {
1796 WARN("Stream index %u out of range.\n", stream_idx);
1798 }
1799
1800 stream = &context->state->streams[stream_idx];
1801 *buffer = stream->buffer;
1802 if (offset)
1803 *offset = stream->offset;
1804 *stride = stream->stride;
1805
1806 return WINED3D_OK;
1807}
1808
1810 const struct wined3d_clip_status *clip_status)
1811{
1812 FIXME("device %p, clip_status %p stub!\n", device, clip_status);
1813
1814 if (!clip_status)
1816
1817 return WINED3D_OK;
1818}
1819
1821 struct wined3d_clip_status *clip_status)
1822{
1823 FIXME("device %p, clip_status %p stub!\n", device, clip_status);
1824
1825 if (!clip_status)
1827
1828 return WINED3D_OK;
1829}
1830
1832 enum wined3d_format_id *format, unsigned int *offset)
1833{
1834 const struct wined3d_state *state = context->state;
1835
1836 TRACE("context %p, format %p, offset %p.\n", context, format, offset);
1837
1838 *format = state->index_format;
1839 if (offset)
1840 *offset = state->index_offset;
1841 return state->index_buffer;
1842}
1843
1845 unsigned int *viewport_count, struct wined3d_viewport *viewports)
1846{
1847 const struct wined3d_state *state = context->state;
1848 unsigned int count;
1849
1850 TRACE("context %p, viewport_count %p, viewports %p.\n", context, viewport_count, viewports);
1851
1852 count = viewport_count ? min(*viewport_count, state->viewport_count) : 1;
1853 if (count && viewports)
1854 memcpy(viewports, state->viewports, count * sizeof(*viewports));
1855 if (viewport_count)
1856 *viewport_count = state->viewport_count;
1857}
1858
1860 struct wined3d_color *blend_factor, unsigned int *sample_mask)
1861{
1862 const struct wined3d_state *state = context->state;
1863
1864 TRACE("context %p, blend_factor %p, sample_mask %p.\n", context, blend_factor, sample_mask);
1865
1866 *blend_factor = state->blend_factor;
1867 *sample_mask = state->sample_mask;
1868 return state->blend_state;
1869}
1870
1872 const struct wined3d_device_context *context, unsigned int *stencil_ref)
1873{
1874 const struct wined3d_state *state = context->state;
1875
1876 TRACE("context %p, stencil_ref %p.\n", context, stencil_ref);
1877
1878 *stencil_ref = state->stencil_ref;
1879 return state->depth_stencil_state;
1880}
1881
1884{
1885 TRACE("context %p.\n", context);
1886
1887 return context->state->rasterizer_state;
1888}
1889
1891 unsigned int *rect_count, RECT *rects)
1892{
1893 const struct wined3d_state *state = context->state;
1894 unsigned int count;
1895
1896 TRACE("context %p, rect_count %p, rects %p.\n", context, rect_count, rects);
1897
1898 if (rects && (count = rect_count ? min(*rect_count, state->scissor_rect_count) : 1))
1899 memcpy(rects, state->scissor_rects, count * sizeof(*rects));
1900 if (rect_count)
1901 *rect_count = state->scissor_rect_count;
1902}
1903
1905{
1906 TRACE("context %p.\n", context);
1907
1909 state_cleanup(context->state);
1910 wined3d_state_reset(context->state, &context->device->adapter->d3d_info);
1913}
1914
1916{
1917 unsigned int i;
1918
1919 TRACE("context %p, state %p.\n", context, state);
1920
1922 context->state = state;
1924
1926 ARRAY_SIZE(state->fb.render_targets), state->fb.render_targets);
1927
1930
1932
1934
1936 state->index_format, state->index_offset);
1937
1938 wined3d_device_context_emit_set_predication(context, state->predicate, state->predicate_value);
1939
1940 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
1941 {
1946 MAX_SHADER_RESOURCE_VIEWS, state->shader_resource_view[i]);
1947 }
1948
1949 for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
1951 state->unordered_access_view[i], NULL);
1952
1953 wined3d_device_context_emit_set_viewports(context, state->viewport_count, state->viewports);
1954 wined3d_device_context_emit_set_scissor_rects(context, state->scissor_rect_count, state->scissor_rects);
1955
1956 wined3d_device_context_emit_set_blend_state(context, state->blend_state, &state->blend_factor, state->sample_mask);
1957 wined3d_device_context_emit_set_depth_stencil_state(context, state->depth_stencil_state, state->stencil_ref);
1960}
1961
1963{
1964 TRACE("device %p.\n", device);
1965
1966 return device->cs->c.state;
1967}
1968
1970{
1971 TRACE("device %p.\n", device);
1972
1973 return &device->cs->c;
1974}
1975
1977 const struct wined3d_device_context *context)
1978{
1979 TRACE("context %p.\n", context);
1980
1981 return context->state->vertex_declaration;
1982}
1983
1986{
1987 struct wined3d_state *state = context->state;
1988 struct wined3d_shader *prev;
1989
1990 TRACE("context %p, type %#x, shader %p.\n", context, type, shader);
1991
1993 prev = state->shader[type];
1994 if (shader == prev)
1995 goto out;
1996
1997 if (shader)
1999 state->shader[type] = shader;
2001 if (prev)
2003out:
2005}
2006
2009{
2010 TRACE("context %p, type %#x.\n", context, type);
2011
2012 return context->state->shader[type];
2013}
2014
2016 enum wined3d_shader_type type, unsigned int start_idx, unsigned int count,
2018{
2019 struct wined3d_state *state = context->state;
2020 unsigned int i;
2021
2022 TRACE("context %p, type %#x, start_idx %u, count %u, buffers %p.\n", context, type, start_idx, count, buffers);
2023
2025 {
2026 WARN("Invalid constant buffer index %u, count %u.\n", start_idx, count);
2027 return;
2028 }
2029
2031 if (!memcmp(buffers, &state->cb[type][start_idx], count * sizeof(*buffers)))
2032 goto out;
2033
2035 for (i = 0; i < count; ++i)
2036 {
2037 struct wined3d_buffer *prev = state->cb[type][start_idx + i].buffer;
2038 struct wined3d_buffer *buffer = buffers[i].buffer;
2039
2040 if (buffer)
2042 state->cb[type][start_idx + i] = buffers[i];
2043 if (prev)
2045 }
2046out:
2048}
2049
2051 struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
2052{
2053 struct wined3d_state *state = context->state;
2054 struct wined3d_blend_state *prev;
2055
2056 TRACE("context %p, blend_state %p, blend_factor %p, sample_mask %#x.\n",
2057 context, blend_state, blend_factor, sample_mask);
2058
2060 prev = state->blend_state;
2061 if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor))
2062 && sample_mask == state->sample_mask)
2063 goto out;
2064
2065 if (blend_state)
2066 wined3d_blend_state_incref(blend_state);
2067 state->blend_state = blend_state;
2068 state->blend_factor = *blend_factor;
2069 state->sample_mask = sample_mask;
2070 wined3d_device_context_emit_set_blend_state(context, blend_state, blend_factor, sample_mask);
2071 if (prev)
2073out:
2075}
2076
2078 struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref)
2079{
2080 struct wined3d_state *state = context->state;
2081 struct wined3d_depth_stencil_state *prev;
2082
2083 TRACE("context %p, depth_stencil_state %p, stencil_ref %u.\n", context, depth_stencil_state, stencil_ref);
2084
2086 prev = state->depth_stencil_state;
2087 if (prev == depth_stencil_state && state->stencil_ref == stencil_ref)
2088 goto out;
2089
2090 if (depth_stencil_state)
2091 wined3d_depth_stencil_state_incref(depth_stencil_state);
2092 state->depth_stencil_state = depth_stencil_state;
2093 state->stencil_ref = stencil_ref;
2094 wined3d_device_context_emit_set_depth_stencil_state(context, depth_stencil_state, stencil_ref);
2095 if (prev)
2097out:
2099}
2100
2102 struct wined3d_rasterizer_state *rasterizer_state)
2103{
2104 struct wined3d_state *state = context->state;
2105 struct wined3d_rasterizer_state *prev;
2106
2107 TRACE("context %p, rasterizer_state %p.\n", context, rasterizer_state);
2108
2110 prev = state->rasterizer_state;
2111 if (prev == rasterizer_state)
2112 goto out;
2113
2114 if (rasterizer_state)
2115 wined3d_rasterizer_state_incref(rasterizer_state);
2116 state->rasterizer_state = rasterizer_state;
2118 if (prev)
2120out:
2122}
2123
2125 const struct wined3d_viewport *viewports)
2126{
2127 struct wined3d_state *state = context->state;
2128 unsigned int i;
2129
2130 TRACE("context %p, viewport_count %u, viewports %p.\n", context, viewport_count, viewports);
2131
2132 for (i = 0; i < viewport_count; ++i)
2133 {
2134 TRACE("%u: x %.8e, y %.8e, w %.8e, h %.8e, min_z %.8e, max_z %.8e.\n", i, viewports[i].x, viewports[i].y,
2135 viewports[i].width, viewports[i].height, viewports[i].min_z, viewports[i].max_z);
2136 }
2137
2139 if (viewport_count)
2140 memcpy(state->viewports, viewports, viewport_count * sizeof(*viewports));
2141 else
2142 memset(state->viewports, 0, sizeof(state->viewports));
2143 state->viewport_count = viewport_count;
2144
2147}
2148
2150 const RECT *rects)
2151{
2152 struct wined3d_state *state = context->state;
2153 unsigned int i;
2154
2155 TRACE("context %p, rect_count %u, rects %p.\n", context, rect_count, rects);
2156
2157 for (i = 0; i < rect_count; ++i)
2158 {
2159 TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i]));
2160 }
2161
2163 if (state->scissor_rect_count == rect_count
2164 && !memcmp(state->scissor_rects, rects, rect_count * sizeof(*rects)))
2165 {
2166 TRACE("App is setting the old scissor rectangles over, nothing to do.\n");
2167 goto out;
2168 }
2169
2170 if (rect_count)
2171 memcpy(state->scissor_rects, rects, rect_count * sizeof(*rects));
2172 else
2173 memset(state->scissor_rects, 0, sizeof(state->scissor_rects));
2174 state->scissor_rect_count = rect_count;
2175
2177out:
2179}
2180
2182 enum wined3d_shader_type type, unsigned int start_idx, unsigned int count,
2183#ifdef __REACTOS__ /* MSVC C4028: the wined3d.h declaration omits the top-level const */
2184 struct wined3d_shader_resource_view *const *views)
2185#else
2186 struct wined3d_shader_resource_view *const *const views)
2187#endif
2188{
2190 struct wined3d_state *state = context->state;
2191 const struct wined3d_rendertarget_view *dsv = state->fb.depth_stencil;
2192 unsigned int i;
2193
2194 TRACE("context %p, type %#x, start_idx %u, count %u, views %p.\n", context, type, start_idx, count, views);
2195
2197 {
2198 WARN("Invalid view index %u, count %u.\n", start_idx, count);
2199 return;
2200 }
2201
2203 if (!memcmp(views, &state->shader_resource_view[type][start_idx], count * sizeof(*views)))
2204 goto out;
2205
2206 memcpy(real_views, views, count * sizeof(*views));
2207
2208 for (i = 0; i < count; ++i)
2209 {
2210 struct wined3d_shader_resource_view *view = real_views[i];
2211
2213 || (dsv && dsv->resource == view->resource && wined3d_dsv_srv_conflict(dsv, view->format))))
2214 {
2215 WARN("Application is trying to bind resource which is attached as render target.\n");
2216 real_views[i] = NULL;
2217 }
2218 }
2219
2221 for (i = 0; i < count; ++i)
2222 {
2223 struct wined3d_shader_resource_view *prev = state->shader_resource_view[type][start_idx + i];
2224 struct wined3d_shader_resource_view *view = real_views[i];
2225
2226 if (view)
2227 {
2230 }
2231
2232 state->shader_resource_view[type][start_idx + i] = view;
2233 if (prev)
2234 {
2237 }
2238 }
2239out:
2241}
2242
2244 unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
2245{
2246 struct wined3d_state *state = context->state;
2247 unsigned int i;
2248
2249 TRACE("context %p, type %#x, start_idx %u, count %u, samplers %p.\n", context, type, start_idx, count, samplers);
2250
2252 {
2253 WARN("Invalid sampler index %u, count %u.\n", start_idx, count);
2254 return;
2255 }
2256
2258 if (!memcmp(samplers, &state->sampler[type][start_idx], count * sizeof(*samplers)))
2259 goto out;
2260
2262 for (i = 0; i < count; ++i)
2263 {
2264 struct wined3d_sampler *prev = state->sampler[type][start_idx + i];
2265 struct wined3d_sampler *sampler = samplers[i];
2266
2267 if (sampler)
2269 state->sampler[type][start_idx + i] = sampler;
2270 if (prev)
2272 }
2273out:
2275}
2276
2278 enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count,
2279 struct wined3d_unordered_access_view *const *uavs, const unsigned int *initial_counts)
2280{
2281 struct wined3d_state *state = context->state;
2282 unsigned int i;
2283
2284 TRACE("context %p, pipeline %#x, start_idx %u, count %u, uavs %p, initial_counts %p.\n",
2285 context, pipeline, start_idx, count, uavs, initial_counts);
2286
2288 {
2289 WARN("Invalid UAV index %u, count %u.\n", start_idx, count);
2290 return;
2291 }
2292
2294 if (!memcmp(uavs, &state->unordered_access_view[pipeline][start_idx], count * sizeof(*uavs)) && !initial_counts)
2295 goto out;
2296
2297 wined3d_device_context_emit_set_unordered_access_views(context, pipeline, start_idx, count, uavs, initial_counts);
2298 for (i = 0; i < count; ++i)
2299 {
2300 struct wined3d_unordered_access_view *prev = state->unordered_access_view[pipeline][start_idx + i];
2301 struct wined3d_unordered_access_view *uav = uavs[i];
2302
2303 if (uav)
2305 state->unordered_access_view[pipeline][start_idx + i] = uav;
2306 if (prev)
2308 }
2309out:
2311}
2312
2314 unsigned int rtv_count, struct wined3d_rendertarget_view *const *render_target_views,
2315 struct wined3d_rendertarget_view *depth_stencil_view, UINT uav_count,
2316 struct wined3d_unordered_access_view *const *unordered_access_views, const unsigned int *initial_counts)
2317{
2319 if (rtv_count != ~0u)
2320 {
2321 if (depth_stencil_view && !(depth_stencil_view->resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL))
2322 {
2323 WARN("View resource %p has incompatible %s bind flags.\n",
2324 depth_stencil_view->resource, wined3d_debug_bind_flags(depth_stencil_view->resource->bind_flags));
2325 goto out;
2326 }
2327
2329 render_target_views, FALSE)))
2330 goto out;
2331
2333 }
2334
2335 if (uav_count != ~0u)
2336 {
2338 unordered_access_views, initial_counts);
2339 }
2340out:
2342}
2343
2345 const struct wined3d_rendertarget_view *view, BOOL dsv)
2346{
2347 const struct wined3d_state *state = context->state;
2348 const struct wined3d_resource *resource;
2349
2350 if (!view)
2351 return;
2352 resource = view->resource;
2353
2354 if (resource->srv_bind_count_device)
2355 {
2356 const struct wined3d_shader_resource_view *srv;
2357 unsigned int i, j;
2358
2359 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
2360 {
2361 for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
2362 {
2363 if ((srv = state->shader_resource_view[i][j]) && srv->resource == resource
2364 && ((!dsv && wined3d_is_srv_rtv_bound(state, srv))
2365 || (dsv && wined3d_dsv_srv_conflict(view, srv->format))))
2366 {
2367 static struct wined3d_shader_resource_view *const null_srv;
2368
2369 WARN("Application sets bound resource as render target.\n");
2371 }
2372 }
2373 }
2374 }
2375}
2376
2378 unsigned int start_idx, unsigned int count, struct wined3d_rendertarget_view *const *views, BOOL set_viewport)
2379{
2380 struct wined3d_state *state = context->state;
2381 unsigned int i, max_rt_count;
2382
2383 TRACE("context %p, start_idx %u, count %u, views %p, set_viewport %#x.\n",
2384 context, start_idx, count, views, set_viewport);
2385
2386 max_rt_count = context->device->adapter->d3d_info.limits.max_rt_count;
2387 if (start_idx >= max_rt_count)
2388 {
2389 WARN("Only %u render targets are supported.\n", max_rt_count);
2391 }
2392 count = min(count, max_rt_count - start_idx);
2393
2394 for (i = 0; i < count; ++i)
2395 {
2396 if (views[i] && !(views[i]->resource->bind_flags & WINED3D_BIND_RENDER_TARGET))
2397 {
2398 WARN("View resource %p doesn't have render target bind flags.\n", views[i]->resource);
2400 }
2401 }
2402
2404 /* Set the viewport and scissor rectangles, if requested. Tests show that
2405 * stateblock recording is ignored, the change goes directly into the
2406 * primary stateblock. */
2407 if (!start_idx && set_viewport)
2408 {
2409 state->viewports[0].x = 0;
2410 state->viewports[0].y = 0;
2411 state->viewports[0].width = views[0]->width;
2412 state->viewports[0].height = views[0]->height;
2413 state->viewports[0].min_z = 0.0f;
2414 state->viewports[0].max_z = 1.0f;
2415 state->viewport_count = 1;
2417
2418 SetRect(&state->scissor_rects[0], 0, 0, views[0]->width, views[0]->height);
2419 state->scissor_rect_count = 1;
2421 }
2422
2423 if (!memcmp(views, &state->fb.render_targets[start_idx], count * sizeof(*views)))
2424 goto out;
2425
2427 for (i = 0; i < count; ++i)
2428 {
2429 struct wined3d_rendertarget_view *prev = state->fb.render_targets[start_idx + i];
2430 struct wined3d_rendertarget_view *view = views[i];
2431
2432 if (view)
2433 {
2436 }
2437 state->fb.render_targets[start_idx + i] = view;
2438 /* Release after the assignment, to prevent device_resource_released()
2439 * from seeing the resource as still in use. */
2440 if (prev)
2441 {
2444 }
2445
2447 }
2448out:
2450 return WINED3D_OK;
2451}
2452
2455{
2456 struct wined3d_fb_state *fb = &context->state->fb;
2457 struct wined3d_rendertarget_view *prev;
2458
2459 TRACE("context %p, view %p.\n", context, view);
2460
2461 if (view && !(view->resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL))
2462 {
2463 WARN("View resource %p has incompatible %s bind flags.\n",
2464 view->resource, wined3d_debug_bind_flags(view->resource->bind_flags));
2466 }
2467
2469 prev = fb->depth_stencil;
2470 if (prev == view)
2471 {
2472 TRACE("Trying to do a NOP SetRenderTarget operation.\n");
2473 goto out;
2474 }
2475
2476 if ((fb->depth_stencil = view))
2479 if (prev)
2482out:
2484 return WINED3D_OK;
2485}
2486
2488 struct wined3d_query *predicate, BOOL value)
2489{
2490 struct wined3d_state *state = context->state;
2491 struct wined3d_query *prev;
2492
2493 TRACE("context %p, predicate %p, value %#x.\n", context, predicate, value);
2494
2496 prev = state->predicate;
2497 if (predicate)
2498 {
2499 FIXME("Predicated rendering not implemented.\n");
2500 wined3d_query_incref(predicate);
2501 }
2502 state->predicate = predicate;
2503 state->predicate_value = value;
2505 if (prev)
2508}
2509
2511 unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
2512{
2513 struct wined3d_state *state = context->state;
2514 unsigned int i;
2515
2516 TRACE("context %p, start_idx %u, count %u, streams %p.\n", context, start_idx, count, streams);
2517
2518 if (start_idx >= WINED3D_MAX_STREAMS)
2519 {
2520 WARN("Start index %u is out of range.\n", start_idx);
2522 }
2523
2524 count = min(count, WINED3D_MAX_STREAMS - start_idx);
2525
2526 for (i = 0; i < count; ++i)
2527 {
2528 if (streams[i].offset & 0x3)
2529 {
2530 WARN("Offset %u is not 4 byte aligned.\n", streams[i].offset);
2532 }
2533 }
2534
2536 if (!memcmp(streams, &state->streams[start_idx], count * sizeof(*streams)))
2537 goto out;
2538
2540 for (i = 0; i < count; ++i)
2541 {
2542 struct wined3d_buffer *prev = state->streams[start_idx + i].buffer;
2543 struct wined3d_buffer *buffer = streams[i].buffer;
2544
2545 state->streams[start_idx + i] = streams[i];
2546
2547 if (buffer)
2549 if (prev)
2551 }
2552out:
2554 return WINED3D_OK;
2555}
2556
2558 struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
2559{
2560 struct wined3d_state *state = context->state;
2561 enum wined3d_format_id prev_format;
2562 struct wined3d_buffer *prev_buffer;
2563 unsigned int prev_offset;
2564
2565 TRACE("context %p, buffer %p, format %s, offset %u.\n",
2567
2569 prev_buffer = state->index_buffer;
2570 prev_format = state->index_format;
2571 prev_offset = state->index_offset;
2572
2573 if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset)
2574 goto out;
2575
2576 if (buffer)
2578 state->index_buffer = buffer;
2579 state->index_format = format_id;
2580 state->index_offset = offset;
2582 if (prev_buffer)
2583 wined3d_buffer_decref(prev_buffer);
2584out:
2586}
2587
2590{
2591 struct wined3d_state *state = context->state;
2592 struct wined3d_vertex_declaration *prev;
2593
2594 TRACE("context %p, declaration %p.\n", context, declaration);
2595
2597 prev = state->vertex_declaration;
2598 if (declaration == prev)
2599 goto out;
2600
2601 if (declaration)
2603 state->vertex_declaration = declaration;
2605 if (prev)
2607out:
2609}
2610
2613{
2614 struct wined3d_state *state = context->state;
2615 unsigned int i;
2616
2617 TRACE("context %p, outputs %p.\n", context, outputs);
2618
2621 for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
2622 {
2623 struct wined3d_buffer *prev_buffer = state->stream_output[i].buffer;
2624 struct wined3d_buffer *buffer = outputs[i].buffer;
2625
2626 if (buffer)
2628 state->stream_output[i] = outputs[i];
2629 if (prev_buffer)
2630 wined3d_buffer_decref(prev_buffer);
2631 }
2633}
2634
2635void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, unsigned int start_vertex,
2636 unsigned int vertex_count, unsigned int start_instance, unsigned int instance_count)
2637{
2638 struct wined3d_state *state = context->state;
2639
2640 TRACE("context %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n",
2641 context, start_vertex, vertex_count, start_instance, instance_count);
2642
2644 wined3d_device_context_emit_draw(context, state->primitive_type, state->patch_vertex_count,
2645 0, start_vertex, vertex_count, start_instance, instance_count, false);
2647}
2648
2650 unsigned int start_index, unsigned int index_count, unsigned int start_instance, unsigned int instance_count)
2651{
2652 struct wined3d_state *state = context->state;
2653
2654 TRACE("context %p, base_vertex_index %d, start_index %u, index_count %u, start_instance %u, instance_count %u.\n",
2655 context, base_vertex_index, start_index, index_count, start_instance, instance_count);
2656
2658 wined3d_device_context_emit_draw(context, state->primitive_type, state->patch_vertex_count,
2659 base_vertex_index, start_index, index_count, start_instance, instance_count, true);
2661}
2662
2665{
2666 TRACE("context %p, shader_type %#x, idx %u.\n", context, shader_type, idx);
2667
2669 {
2670 WARN("Invalid constant buffer index %u.\n", idx);
2671 return;
2672 }
2673
2674 *state = context->state->cb[shader_type][idx];
2675}
2676
2678 const struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int idx)
2679{
2681 {
2682 WARN("Invalid view index %u.\n", idx);
2683 return NULL;
2684 }
2685
2686 return context->state->shader_resource_view[shader_type][idx];
2687}
2688
2690 enum wined3d_shader_type shader_type, unsigned int idx)
2691{
2692 TRACE("context %p, shader_type %#x, idx %u.\n", context, shader_type, idx);
2693
2694 if (idx >= MAX_SAMPLER_OBJECTS)
2695 {
2696 WARN("Invalid sampler index %u.\n", idx);
2697 return NULL;
2698 }
2699
2700 return context->state->sampler[shader_type][idx];
2701}
2702
2704 const struct wined3d_device_context *context, enum wined3d_pipeline pipeline, unsigned int idx)
2705{
2706 TRACE("context %p, pipeline %#x, idx %u.\n", context, pipeline, idx);
2707
2709 {
2710 WARN("Invalid UAV index %u.\n", idx);
2711 return NULL;
2712 }
2713
2714 return context->state->unordered_access_view[pipeline][idx];
2715}
2716
2718{
2719 unsigned int i;
2720
2721 if (!latency)
2722 latency = 3;
2723
2724 device->max_frame_latency = latency;
2725 for (i = 0; i < device->swapchain_count; ++i)
2727}
2728
2730{
2731 return device->max_frame_latency;
2732}
2733
2735{
2736 unsigned int texcoord_count = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
2737 unsigned int i, size = 0;
2738
2739 if (fvf & WINED3DFVF_NORMAL) size += 3 * sizeof(float);
2740 if (fvf & WINED3DFVF_DIFFUSE) size += sizeof(DWORD);
2741 if (fvf & WINED3DFVF_SPECULAR) size += sizeof(DWORD);
2742 if (fvf & WINED3DFVF_PSIZE) size += sizeof(DWORD);
2743 switch (fvf & WINED3DFVF_POSITION_MASK)
2744 {
2745 case WINED3DFVF_XYZ: size += 3 * sizeof(float); break;
2746 case WINED3DFVF_XYZRHW: size += 4 * sizeof(float); break;
2747 case WINED3DFVF_XYZB1: size += 4 * sizeof(float); break;
2748 case WINED3DFVF_XYZB2: size += 5 * sizeof(float); break;
2749 case WINED3DFVF_XYZB3: size += 6 * sizeof(float); break;
2750 case WINED3DFVF_XYZB4: size += 7 * sizeof(float); break;
2751 case WINED3DFVF_XYZB5: size += 8 * sizeof(float); break;
2752 case WINED3DFVF_XYZW: size += 4 * sizeof(float); break;
2753 default: FIXME("Unexpected position mask %#x.\n", fvf & WINED3DFVF_POSITION_MASK);
2754 }
2755 for (i = 0; i < texcoord_count; ++i)
2756 {
2757 size += GET_TEXCOORD_SIZE_FROM_FVF(fvf, i) * sizeof(float);
2758 }
2759
2760 return size;
2761}
2762
2764 const void *data, struct wined3d_color *colour)
2765{
2766 float *output = &colour->r;
2767 const uint32_t *u32_data;
2768 const uint16_t *u16_data;
2769 const float *f32_data;
2770 unsigned int i;
2771
2772 static const struct wined3d_color default_colour = {0.0f, 0.0f, 0.0f, 1.0f};
2773 static unsigned int warned;
2774
2775 switch (format->id)
2776 {
2778 u32_data = data;
2779 wined3d_color_from_d3dcolor(colour, *u32_data);
2780 break;
2781
2783 u32_data = data;
2784 colour->r = (*u32_data & 0xffu) / 255.0f;
2785 colour->g = ((*u32_data >> 8) & 0xffu) / 255.0f;
2786 colour->b = ((*u32_data >> 16) & 0xffu) / 255.0f;
2787 colour->a = ((*u32_data >> 24) & 0xffu) / 255.0f;
2788 break;
2789
2792 u16_data = data;
2793 *colour = default_colour;
2794 for (i = 0; i < format->component_count; ++i)
2795 output[i] = u16_data[i] / 65535.0f;
2796 break;
2797
2802 f32_data = data;
2803 *colour = default_colour;
2804 for (i = 0; i < format->component_count; ++i)
2805 output[i] = f32_data[i];
2806 break;
2807
2808 default:
2809 *colour = default_colour;
2810 if (!warned++)
2811 FIXME("Unhandled colour format conversion, format %s.\n", debug_d3dformat(format->id));
2812 break;
2813 }
2814}
2815
2817 const struct wined3d_color *material_colour, unsigned int index,
2818 const struct wined3d_stream_info *stream_info)
2819{
2821
2822 switch (mcs)
2823 {
2825 *colour = *material_colour;
2826 return;
2827
2828 case WINED3D_MCS_COLOR1:
2829 if (!(stream_info->use_map & (1u << WINED3D_FFP_DIFFUSE)))
2830 {
2831 colour->r = colour->g = colour->b = colour->a = 1.0f;
2832 return;
2833 }
2835 break;
2836
2837 case WINED3D_MCS_COLOR2:
2838 if (!(stream_info->use_map & (1u << WINED3D_FFP_SPECULAR)))
2839 {
2840 colour->r = colour->g = colour->b = colour->a = 0.0f;
2841 return;
2842 }
2844 break;
2845
2846 default:
2847 colour->r = colour->g = colour->b = colour->a = 0.0f;
2848 ERR("Invalid material colour source %#x.\n", mcs);
2849 return;
2850 }
2851
2852 wined3d_format_get_colour(element->format, &element->data.addr[index * element->stride], colour);
2853}
2854
2855static float wined3d_clamp(float value, float min_value, float max_value)
2856{
2857 return value < min_value ? min_value : value > max_value ? max_value : value;
2858}
2859
2860static float wined3d_vec3_dot(const struct wined3d_vec3 *v0, const struct wined3d_vec3 *v1)
2861{
2862 return v0->x * v1->x + v0->y * v1->y + v0->z * v1->z;
2863}
2864
2865static void wined3d_vec3_subtract(struct wined3d_vec3 *v0, const struct wined3d_vec3 *v1)
2866{
2867 v0->x -= v1->x;
2868 v0->y -= v1->y;
2869 v0->z -= v1->z;
2870}
2871
2872static void wined3d_vec3_scale(struct wined3d_vec3 *v, float s)
2873{
2874 v->x *= s;
2875 v->y *= s;
2876 v->z *= s;
2877}
2878
2880{
2881 float rnorm = 1.0f / sqrtf(wined3d_vec3_dot(v, v));
2882
2883 if (isfinite(rnorm))
2884 wined3d_vec3_scale(v, rnorm);
2885}
2886
2888 const struct wined3d_vec3 *v, const struct wined3d_matrix *m)
2889{
2890 struct wined3d_vec3 tmp;
2891
2892 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31;
2893 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32;
2894 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33;
2895
2896 *dst = tmp;
2897}
2898
2899static void wined3d_color_clamp(struct wined3d_color *dst, const struct wined3d_color *src,
2900 float min_value, float max_value)
2901{
2902 dst->r = wined3d_clamp(src->r, min_value, max_value);
2903 dst->g = wined3d_clamp(src->g, min_value, max_value);
2904 dst->b = wined3d_clamp(src->b, min_value, max_value);
2905 dst->a = wined3d_clamp(src->a, min_value, max_value);
2906}
2907
2908static void wined3d_color_rgb_mul_add(struct wined3d_color *dst, const struct wined3d_color *src, float c)
2909{
2910 dst->r += src->r * c;
2911 dst->g += src->g * c;
2912 dst->b += src->b * c;
2913}
2914
2916 const struct wined3d_stateblock_state *state, BOOL legacy_lighting, BOOL compute_lighting)
2917{
2919 const struct wined3d_light_info *light_info;
2920 struct wined3d_light_info *light_iter;
2921 struct light_transformed *light;
2922 struct wined3d_vec4 vec4;
2923 unsigned int light_count;
2924 unsigned int i, index;
2925
2926 memset(ls, 0, sizeof(*ls));
2927
2928 ls->lighting = !!compute_lighting;
2929 ls->fog_mode = state->rs[WINED3D_RS_FOGVERTEXMODE];
2930 ls->fog_coord_mode = state->rs[WINED3D_RS_RANGEFOGENABLE]
2932 ls->fog_start = int_to_float(state->rs[WINED3D_RS_FOGSTART]);
2933 ls->fog_end = int_to_float(state->rs[WINED3D_RS_FOGEND]);
2934 ls->fog_density = int_to_float(state->rs[WINED3D_RS_FOGDENSITY]);
2935
2936 if (ls->fog_mode == WINED3D_FOG_NONE && !compute_lighting)
2937 return;
2938
2939 multiply_matrix(&ls->modelview_matrix, &state->transforms[WINED3D_TS_VIEW],
2940 &state->transforms[WINED3D_TS_WORLD_MATRIX(0)]);
2941
2942 if (!compute_lighting)
2943 return;
2944
2945 compute_normal_matrix(&ls->normal_matrix, legacy_lighting, &ls->modelview_matrix);
2946
2948 ls->legacy_lighting = !!legacy_lighting;
2949 ls->normalise = !!state->rs[WINED3D_RS_NORMALIZENORMALS];
2950 ls->localviewer = !!state->rs[WINED3D_RS_LOCALVIEWER];
2951
2952 index = 0;
2953 RB_FOR_EACH_ENTRY(light_iter, &state->light_state->lights_tree, struct wined3d_light_info, entry)
2954 {
2955 if (!light_iter->enabled)
2956 continue;
2957
2958 switch (light_iter->OriginalParms.type)
2959 {
2961 ++ls->directional_light_count;
2962 break;
2963
2965 ++ls->point_light_count;
2966 break;
2967
2968 case WINED3D_LIGHT_SPOT:
2969 ++ls->spot_light_count;
2970 break;
2971
2973 ++ls->parallel_point_light_count;
2974 break;
2975
2976 default:
2977 FIXME("Unhandled light type %#x.\n", light_iter->OriginalParms.type);
2978 continue;
2979 }
2980 lights[index++] = light_iter;
2982 break;
2983 }
2984
2985 light_count = index;
2986 for (i = 0, index = 0; i < light_count; ++i)
2987 {
2988 light_info = lights[i];
2989 if (light_info->OriginalParms.type != WINED3D_LIGHT_DIRECTIONAL)
2990 continue;
2991
2992 light = &ls->lights[index];
2993 wined3d_vec4_transform(&vec4, &light_info->constants.direction, &state->transforms[WINED3D_TS_VIEW]);
2994 light->direction = *(struct wined3d_vec3 *)&vec4;
2995 wined3d_vec3_normalise(&light->direction);
2996
2997 light->diffuse = light_info->OriginalParms.diffuse;
2998 light->ambient = light_info->OriginalParms.ambient;
2999 light->specular = light_info->OriginalParms.specular;
3000 ++index;
3001 }
3002
3003 for (i = 0; i < light_count; ++i)
3004 {
3005 light_info = lights[i];
3006 if (light_info->OriginalParms.type != WINED3D_LIGHT_POINT)
3007 continue;
3008
3009 light = &ls->lights[index];
3010
3011 wined3d_vec4_transform(&light->position, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]);
3012 light->range = light_info->OriginalParms.range;
3013 light->c_att = light_info->OriginalParms.attenuation0;
3014 light->l_att = light_info->OriginalParms.attenuation1;
3015 light->q_att = light_info->OriginalParms.attenuation2;
3016
3017 light->diffuse = light_info->OriginalParms.diffuse;
3018 light->ambient = light_info->OriginalParms.ambient;
3019 light->specular = light_info->OriginalParms.specular;
3020 ++index;
3021 }
3022
3023 for (i = 0; i < light_count; ++i)
3024 {
3025 light_info = lights[i];
3026 if (light_info->OriginalParms.type != WINED3D_LIGHT_SPOT)
3027 continue;
3028
3029 light = &ls->lights[index];
3030
3031 wined3d_vec4_transform(&light->position, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]);
3032 wined3d_vec4_transform(&vec4, &light_info->constants.direction, &state->transforms[WINED3D_TS_VIEW]);
3033 light->direction = *(struct wined3d_vec3 *)&vec4;
3034 wined3d_vec3_normalise(&light->direction);
3035 light->range = light_info->OriginalParms.range;
3036 light->falloff = light_info->OriginalParms.falloff;
3037 light->c_att = light_info->OriginalParms.attenuation0;
3038 light->l_att = light_info->OriginalParms.attenuation1;
3039 light->q_att = light_info->OriginalParms.attenuation2;
3040 light->cos_htheta = cosf(light_info->OriginalParms.theta / 2.0f);
3041 light->cos_hphi = cosf(light_info->OriginalParms.phi / 2.0f);
3042
3043 light->diffuse = light_info->OriginalParms.diffuse;
3044 light->ambient = light_info->OriginalParms.ambient;
3045 light->specular = light_info->OriginalParms.specular;
3046 ++index;
3047 }
3048
3049 for (i = 0; i < light_count; ++i)
3050 {
3051 light_info = lights[i];
3052 if (light_info->OriginalParms.type != WINED3D_LIGHT_PARALLELPOINT)
3053 continue;
3054
3055 light = &ls->lights[index];
3056
3057 wined3d_vec4_transform(&vec4, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]);
3058 *(struct wined3d_vec3 *)&light->position = *(struct wined3d_vec3 *)&vec4;
3059 wined3d_vec3_normalise((struct wined3d_vec3 *)&light->position);
3060 light->diffuse = light_info->OriginalParms.diffuse;
3061 light->ambient = light_info->OriginalParms.ambient;
3062 light->specular = light_info->OriginalParms.specular;
3063 ++index;
3064 }
3065}
3066
3068 const struct wined3d_vec3 *dir, float att, float material_shininess,
3069 const struct wined3d_vec3 *normal_transformed,
3070 const struct wined3d_vec3 *position_transformed_normalised,
3071 const struct light_transformed *light, const struct lights_settings *ls)
3072{
3073 struct wined3d_vec3 vec3;
3074 float t, c;
3075
3076 c = wined3d_clamp(wined3d_vec3_dot(dir, normal_transformed), 0.0f, 1.0f);
3077 wined3d_color_rgb_mul_add(diffuse, &light->diffuse, c * att);
3078
3079 vec3 = *dir;
3080 if (ls->localviewer)
3081 wined3d_vec3_subtract(&vec3, position_transformed_normalised);
3082 else
3083 vec3.z -= 1.0f;
3085 t = wined3d_vec3_dot(normal_transformed, &vec3);
3086 if (t > 0.0f && (!ls->legacy_lighting || material_shininess > 0.0f)
3087 && wined3d_vec3_dot(dir, normal_transformed) > 0.0f)
3088 wined3d_color_rgb_mul_add(specular, &light->specular, att * powf(t, material_shininess));
3089}
3090
3092 const struct wined3d_vec4 *position)
3093{
3094 if (ls->fog_mode == WINED3D_FOG_NONE && !ls->lighting)
3095 return;
3096
3097 wined3d_vec4_transform(&ls->position_transformed, position, &ls->modelview_matrix);
3098 wined3d_vec3_scale((struct wined3d_vec3 *)&ls->position_transformed, 1.0f / ls->position_transformed.w);
3099}
3100
3101static void compute_light(struct wined3d_color *ambient, struct wined3d_color *diffuse,
3102 struct wined3d_color *specular, struct lights_settings *ls, const struct wined3d_vec3 *normal,
3103 float material_shininess)
3104{
3105 struct wined3d_vec3 position_transformed_normalised;
3106 struct wined3d_vec3 normal_transformed = {0.0f};
3107 const struct light_transformed *light;
3108 struct wined3d_vec3 dir, dst;
3109 unsigned int i, index;
3110 float att;
3111
3112 position_transformed_normalised = *(const struct wined3d_vec3 *)&ls->position_transformed;
3113 wined3d_vec3_normalise(&position_transformed_normalised);
3114
3115 if (normal)
3116 {
3117 wined3d_vec3_transform(&normal_transformed, normal, &ls->normal_matrix);
3118 if (ls->normalise)
3119 wined3d_vec3_normalise(&normal_transformed);
3120 }
3121
3122 diffuse->r = diffuse->g = diffuse->b = diffuse->a = 0.0f;
3123 *specular = *diffuse;
3124 *ambient = ls->ambient_light;
3125
3126 index = 0;
3127 for (i = 0; i < ls->directional_light_count; ++i, ++index)
3128 {
3129 light = &ls->lights[index];
3130
3131 wined3d_color_rgb_mul_add(ambient, &light->ambient, 1.0f);
3132 if (normal)
3133 update_light_diffuse_specular(diffuse, specular, &light->direction, 1.0f, material_shininess,
3134 &normal_transformed, &position_transformed_normalised, light, ls);
3135 }
3136
3137 for (i = 0; i < ls->point_light_count; ++i, ++index)
3138 {
3139 light = &ls->lights[index];
3140 dir.x = light->position.x - ls->position_transformed.x;
3141 dir.y = light->position.y - ls->position_transformed.y;
3142 dir.z = light->position.z - ls->position_transformed.z;
3143
3144 dst.z = wined3d_vec3_dot(&dir, &dir);
3145 dst.y = sqrtf(dst.z);
3146 dst.x = 1.0f;
3147 if (ls->legacy_lighting)
3148 {
3149 dst.y = (light->range - dst.y) / light->range;
3150 if (!(dst.y > 0.0f))
3151 continue;
3152 dst.z = dst.y * dst.y;
3153 }
3154 else
3155 {
3156 if (!(dst.y <= light->range))
3157 continue;
3158 }
3159 att = dst.x * light->c_att + dst.y * light->l_att + dst.z * light->q_att;
3160 if (!ls->legacy_lighting)
3161 att = 1.0f / att;
3162
3163 wined3d_color_rgb_mul_add(ambient, &light->ambient, att);
3164 if (normal)
3165 {
3167 update_light_diffuse_specular(diffuse, specular, &dir, att, material_shininess,
3168 &normal_transformed, &position_transformed_normalised, light, ls);
3169 }
3170 }
3171
3172 for (i = 0; i < ls->spot_light_count; ++i, ++index)
3173 {
3174 float t;
3175
3176 light = &ls->lights[index];
3177
3178 dir.x = light->position.x - ls->position_transformed.x;
3179 dir.y = light->position.y - ls->position_transformed.y;
3180 dir.z = light->position.z - ls->position_transformed.z;
3181
3182 dst.z = wined3d_vec3_dot(&dir, &dir);
3183 dst.y = sqrtf(dst.z);
3184 dst.x = 1.0f;
3185
3186 if (ls->legacy_lighting)
3187 {
3188 dst.y = (light->range - dst.y) / light->range;
3189 if (!(dst.y > 0.0f))
3190 continue;
3191 dst.z = dst.y * dst.y;
3192 }
3193 else
3194 {
3195 if (!(dst.y <= light->range))
3196 continue;
3197 }
3199 t = -wined3d_vec3_dot(&dir, &light->direction);
3200 if (t > light->cos_htheta)
3201 att = 1.0f;
3202 else if (t <= light->cos_hphi)
3203 att = 0.0f;
3204 else
3205 att = powf((t - light->cos_hphi) / (light->cos_htheta - light->cos_hphi), light->falloff);
3206
3207 t = dst.x * light->c_att + dst.y * light->l_att + dst.z * light->q_att;
3208 if (ls->legacy_lighting)
3209 att *= t;
3210 else
3211 att /= t;
3212
3213 wined3d_color_rgb_mul_add(ambient, &light->ambient, att);
3214
3215 if (normal)
3216 update_light_diffuse_specular(diffuse, specular, &dir, att, material_shininess,
3217 &normal_transformed, &position_transformed_normalised, light, ls);
3218 }
3219
3220 for (i = 0; i < ls->parallel_point_light_count; ++i, ++index)
3221 {
3222 light = &ls->lights[index];
3223
3224 wined3d_color_rgb_mul_add(ambient, &light->ambient, 1.0f);
3225 if (normal)
3226 update_light_diffuse_specular(diffuse, specular, (const struct wined3d_vec3 *)&light->position,
3227 1.0f, material_shininess, &normal_transformed, &position_transformed_normalised, light, ls);
3228 }
3229}
3230
3231static float wined3d_calculate_fog_factor(float fog_coord, const struct lights_settings *ls)
3232{
3233 switch (ls->fog_mode)
3234 {
3235 case WINED3D_FOG_NONE:
3236 return fog_coord;
3237 case WINED3D_FOG_LINEAR:
3238 return (ls->fog_end - fog_coord) / (ls->fog_end - ls->fog_start);
3239 case WINED3D_FOG_EXP:
3240 return expf(-fog_coord * ls->fog_density);
3241 case WINED3D_FOG_EXP2:
3242 return expf(-fog_coord * fog_coord * ls->fog_density * ls->fog_density);
3243 default:
3244 ERR("Unhandled fog mode %#x.\n", ls->fog_mode);
3245 return 0.0f;
3246 }
3247}
3248
3249static void update_fog_factor(float *fog_factor, struct lights_settings *ls)
3250{
3251 float fog_coord;
3252
3253 if (ls->fog_mode == WINED3D_FOG_NONE)
3254 return;
3255
3256 switch (ls->fog_coord_mode)
3257 {
3259 fog_coord = sqrtf(wined3d_vec3_dot((const struct wined3d_vec3 *)&ls->position_transformed,
3260 (const struct wined3d_vec3 *)&ls->position_transformed));
3261 break;
3262
3264 fog_coord = fabsf(ls->position_transformed.z);
3265 break;
3266
3267 default:
3268 ERR("Unhandled fog coordinate mode %#x.\n", ls->fog_coord_mode);
3269 return;
3270 }
3271 *fog_factor = wined3d_calculate_fog_factor(fog_coord, ls);
3272}
3273
3274/* Context activation is done by the caller. */
3275#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
3277 const struct wined3d_stateblock_state *state, DWORD dwDestIndex, DWORD dwCount,
3278 const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, uint32_t flags, uint32_t dst_fvf)
3279{
3280 enum wined3d_material_color_source diffuse_source, specular_source, ambient_source, emissive_source;
3281 const struct wined3d_state *device_state = device->cs->c.state;
3282 const struct wined3d_matrix *proj_mat, *view_mat, *world_mat;
3283 const struct wined3d_color *material_specular_state_colour;
3284 const struct wined3d_format *output_colour_format;
3285 static const struct wined3d_color black;
3286 struct wined3d_map_desc map_desc;
3287 struct wined3d_box box = {0};
3288 struct wined3d_viewport vp;
3289 unsigned int texture_count;
3290 struct lights_settings ls;
3291 struct wined3d_matrix mat;
3292 unsigned int vertex_size;
3293 BOOL do_clip, lighting;
3294 float min_z, max_z;
3295 unsigned int i;
3296 BYTE *dest_ptr;
3297 HRESULT hr;
3298
3299 if (!(stream_info->use_map & (1u << WINED3D_FFP_POSITION)))
3300 {
3301 ERR("Source has no position mask.\n");
3303 }
3304
3305 if (state->rs[WINED3D_RS_CLIPPING])
3306 {
3307 static BOOL warned = FALSE;
3308 /*
3309 * The clipping code is not quite correct. Some things need
3310 * to be checked against IDirect3DDevice3 (!), d3d8 and d3d9,
3311 * so disable clipping for now.
3312 * (The graphics in Half-Life are broken, and my processvertices
3313 * test crashes with IDirect3DDevice3)
3314 do_clip = TRUE;
3315 */
3316 do_clip = FALSE;
3317 if (!warned)
3318 {
3319 warned = TRUE;
3320 FIXME("Clipping is broken and disabled for now\n");
3321 }
3322 }
3323 else
3324 do_clip = FALSE;
3325
3326 vertex_size = wined3d_get_flexible_vertex_size(dst_fvf);
3327 box.left = dwDestIndex * vertex_size;
3328 box.right = box.left + dwCount * vertex_size;
3329 if (FAILED(hr = wined3d_resource_map(&dest->resource, 0, &map_desc, &box, WINED3D_MAP_WRITE)))
3330 {
3331 WARN("Failed to map buffer, hr %#lx.\n", hr);
3332 return hr;
3333 }
3334 dest_ptr = map_desc.data;
3335
3336 view_mat = &state->transforms[WINED3D_TS_VIEW];
3337 proj_mat = &state->transforms[WINED3D_TS_PROJECTION];
3338 world_mat = &state->transforms[WINED3D_TS_WORLD];
3339
3340 TRACE("View mat:\n");
3341 TRACE("%.8e %.8e %.8e %.8e\n", view_mat->_11, view_mat->_12, view_mat->_13, view_mat->_14);
3342 TRACE("%.8e %.8e %.8e %.8e\n", view_mat->_21, view_mat->_22, view_mat->_23, view_mat->_24);
3343 TRACE("%.8e %.8e %.8e %.8e\n", view_mat->_31, view_mat->_32, view_mat->_33, view_mat->_34);
3344 TRACE("%.8e %.8e %.8e %.8e\n", view_mat->_41, view_mat->_42, view_mat->_43, view_mat->_44);
3345
3346 TRACE("Proj mat:\n");
3347 TRACE("%.8e %.8e %.8e %.8e\n", proj_mat->_11, proj_mat->_12, proj_mat->_13, proj_mat->_14);
3348 TRACE("%.8e %.8e %.8e %.8e\n", proj_mat->_21, proj_mat->_22, proj_mat->_23, proj_mat->_24);
3349 TRACE("%.8e %.8e %.8e %.8e\n", proj_mat->_31, proj_mat->_32, proj_mat->_33, proj_mat->_34);
3350 TRACE("%.8e %.8e %.8e %.8e\n", proj_mat->_41, proj_mat->_42, proj_mat->_43, proj_mat->_44);
3351
3352 TRACE("World mat:\n");
3353 TRACE("%.8e %.8e %.8e %.8e\n", world_mat->_11, world_mat->_12, world_mat->_13, world_mat->_14);
3354 TRACE("%.8e %.8e %.8e %.8e\n", world_mat->_21, world_mat->_22, world_mat->_23, world_mat->_24);
3355 TRACE("%.8e %.8e %.8e %.8e\n", world_mat->_31, world_mat->_32, world_mat->_33, world_mat->_34);
3356 TRACE("%.8e %.8e %.8e %.8e\n", world_mat->_41, world_mat->_42, world_mat->_43, world_mat->_44);
3357
3358 /* Get the viewport */
3360 TRACE("viewport x %.8e, y %.8e, width %.8e, height %.8e, min_z %.8e, max_z %.8e.\n",
3361 vp.x, vp.y, vp.width, vp.height, vp.min_z, vp.max_z);
3362
3363 multiply_matrix(&mat, view_mat, world_mat);
3364 multiply_matrix(&mat, proj_mat, &mat);
3365
3366 texture_count = (dst_fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
3367
3368 lighting = state->rs[WINED3D_RS_LIGHTING]
3369 && (dst_fvf & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR));
3370 wined3d_get_material_colour_source(&diffuse_source, &emissive_source,
3371 &ambient_source, &specular_source, device_state);
3372 output_colour_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, 0);
3373 material_specular_state_colour = state->rs[WINED3D_RS_SPECULARENABLE]
3374 ? &state->material.specular : &black;
3375 init_transformed_lights(&ls, state, device->adapter->d3d_info.wined3d_creation_flags
3376 & WINED3D_LEGACY_FFP_LIGHTING, lighting);
3377
3378 wined3d_viewport_get_z_range(&vp, &min_z, &max_z);
3379
3380 for (i = 0; i < dwCount; ++i)
3381 {
3382 const struct wined3d_stream_info_element *position_element = &stream_info->elements[WINED3D_FFP_POSITION];
3383 const float *p = (const float *)&position_element->data.addr[i * position_element->stride];
3384 struct wined3d_color ambient, diffuse, specular;
3385 struct wined3d_vec4 position;
3386 unsigned int tex_index;
3387
3388 position.x = p[0];
3389 position.y = p[1];
3390 position.z = p[2];
3391 position.w = 1.0f;
3392
3393 light_set_vertex_data(&ls, &position);
3394
3395 if ( ((dst_fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
3396 ((dst_fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
3397 /* The position first */
3398 float x, y, z, rhw;
3399 TRACE("In: ( %06.2f %06.2f %06.2f )\n", p[0], p[1], p[2]);
3400
3401 /* Multiplication with world, view and projection matrix. */
3402 x = (p[0] * mat._11) + (p[1] * mat._21) + (p[2] * mat._31) + mat._41;
3403 y = (p[0] * mat._12) + (p[1] * mat._22) + (p[2] * mat._32) + mat._42;
3404 z = (p[0] * mat._13) + (p[1] * mat._23) + (p[2] * mat._33) + mat._43;
3405 rhw = (p[0] * mat._14) + (p[1] * mat._24) + (p[2] * mat._34) + mat._44;
3406
3407 TRACE("x=%f y=%f z=%f rhw=%f\n", x, y, z, rhw);
3408
3409 /* WARNING: The following things are taken from d3d7 and were not yet checked
3410 * against d3d8 or d3d9!
3411 */
3412
3413 /* Clipping conditions: From msdn
3414 *
3415 * A vertex is clipped if it does not match the following requirements
3416 * -rhw < x <= rhw
3417 * -rhw < y <= rhw
3418 * 0 < z <= rhw
3419 * 0 < rhw ( Not in d3d7, but tested in d3d7)
3420 *
3421 * If clipping is on is determined by the D3DVOP_CLIP flag in D3D7, and
3422 * by the D3DRS_CLIPPING in D3D9(according to the msdn, not checked)
3423 *
3424 */
3425
3426 if (!do_clip || (-rhw - eps < x && -rhw - eps < y && -eps < z && x <= rhw + eps
3427 && y <= rhw + eps && z <= rhw + eps && rhw > eps))
3428 {
3429 /* "Normal" viewport transformation (not clipped)
3430 * 1) The values are divided by rhw
3431 * 2) The y axis is negative, so multiply it with -1
3432 * 3) Screen coordinates go from -(Width/2) to +(Width/2) and
3433 * -(Height/2) to +(Height/2). The z range is MinZ to MaxZ
3434 * 4) Multiply x with Width/2 and add Width/2
3435 * 5) The same for the height
3436 * 6) Add the viewpoint X and Y to the 2D coordinates and
3437 * The minimum Z value to z
3438 * 7) rhw = 1 / rhw Reciprocal of Homogeneous W....
3439 *
3440 * Well, basically it's simply a linear transformation into viewport
3441 * coordinates
3442 */
3443
3444 x /= rhw;
3445 y /= rhw;
3446 z /= rhw;
3447
3448 y *= -1;
3449
3450 x *= vp.width / 2;
3451 y *= vp.height / 2;
3452 z *= max_z - min_z;
3453
3454 x += vp.width / 2 + vp.x;
3455 y += vp.height / 2 + vp.y;
3456 z += min_z;
3457
3458 rhw = 1 / rhw;
3459 } else {
3460 /* That vertex got clipped
3461 * Contrary to OpenGL it is not dropped completely, it just
3462 * undergoes a different calculation.
3463 */
3464 TRACE("Vertex got clipped\n");
3465 x += rhw;
3466 y += rhw;
3467
3468 x /= 2;
3469 y /= 2;
3470
3471 /* Msdn mentions that Direct3D9 keeps a list of clipped vertices
3472 * outside of the main vertex buffer memory. That needs some more
3473 * investigation...
3474 */
3475 }
3476
3477 TRACE("Writing (%f %f %f) %f\n", x, y, z, rhw);
3478
3479
3480 ( (float *) dest_ptr)[0] = x;
3481 ( (float *) dest_ptr)[1] = y;
3482 ( (float *) dest_ptr)[2] = z;
3483 ( (float *) dest_ptr)[3] = rhw; /* SIC, see ddraw test! */
3484
3485 dest_ptr += 3 * sizeof(float);
3486
3488 dest_ptr += sizeof(float);
3489 }
3490
3491 if (dst_fvf & WINED3DFVF_PSIZE)
3492 dest_ptr += sizeof(DWORD);
3493
3494 if (dst_fvf & WINED3DFVF_NORMAL)
3495 {
3497 const float *normal = (const float *)(element->data.addr + i * element->stride);
3498 /* AFAIK this should go into the lighting information */
3499 FIXME("Didn't expect the destination to have a normal\n");
3500 copy_and_next(dest_ptr, normal, 3 * sizeof(float));
3501 }
3502
3503 if (lighting)
3504 {
3506 struct wined3d_vec3 *normal;
3507
3508 if (stream_info->use_map & (1u << WINED3D_FFP_NORMAL))
3509 {
3511 normal = (struct wined3d_vec3 *)&element->data.addr[i * element->stride];
3512 }
3513 else
3514 {
3515 normal = NULL;
3516 }
3517 compute_light(&ambient, &diffuse, &specular, &ls, normal,
3518 state->rs[WINED3D_RS_SPECULARENABLE] ? state->material.power : 0.0f);
3519 }
3520
3521 if (dst_fvf & WINED3DFVF_DIFFUSE)
3522 {
3523 struct wined3d_color material_diffuse, material_ambient, material_emissive, diffuse_colour;
3524
3525 wined3d_colour_from_mcs(&material_diffuse, diffuse_source,
3526 &state->material.diffuse, i, stream_info);
3527
3528 if (lighting)
3529 {
3530 wined3d_colour_from_mcs(&material_ambient, ambient_source,
3531 &state->material.ambient, i, stream_info);
3532 wined3d_colour_from_mcs(&material_emissive, emissive_source,
3533 &state->material.emissive, i, stream_info);
3534
3535 diffuse_colour.r = ambient.r * material_ambient.r
3536 + diffuse.r * material_diffuse.r + material_emissive.r;
3537 diffuse_colour.g = ambient.g * material_ambient.g
3538 + diffuse.g * material_diffuse.g + material_emissive.g;
3539 diffuse_colour.b = ambient.b * material_ambient.b
3540 + diffuse.b * material_diffuse.b + material_emissive.b;
3541 diffuse_colour.a = material_diffuse.a;
3542 }
3543 else
3544 {
3545 diffuse_colour = material_diffuse;
3546 }
3547 wined3d_color_clamp(&diffuse_colour, &diffuse_colour, 0.0f, 1.0f);
3548 wined3d_format_convert_from_float(output_colour_format, &diffuse_colour, dest_ptr);
3549 dest_ptr += sizeof(DWORD);
3550 }
3551
3552 if (dst_fvf & WINED3DFVF_SPECULAR)
3553 {
3554 struct wined3d_color material_specular, specular_colour;
3555
3556 wined3d_colour_from_mcs(&material_specular, specular_source,
3557 material_specular_state_colour, i, stream_info);
3558
3559 if (lighting)
3560 {
3561 specular_colour.r = specular.r * material_specular.r;
3562 specular_colour.g = specular.g * material_specular.g;
3563 specular_colour.b = specular.b * material_specular.b;
3564 specular_colour.a = ls.legacy_lighting ? 0.0f : material_specular.a;
3565 }
3566 else
3567 {
3568 specular_colour = material_specular;
3569 }
3570 update_fog_factor(&specular_colour.a, &ls);
3571 wined3d_color_clamp(&specular_colour, &specular_colour, 0.0f, 1.0f);
3572 wined3d_format_convert_from_float(output_colour_format, &specular_colour, dest_ptr);
3573 dest_ptr += sizeof(DWORD);
3574 }
3575
3576 for (tex_index = 0; tex_index < texture_count; ++tex_index)
3577 {
3578 const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_TEXCOORD0 + tex_index];
3579 const float *tex_coord = (const float *)(element->data.addr + i * element->stride);
3580 if (!(stream_info->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + tex_index))))
3581 {
3582 ERR("No source texture, but destination requests one\n");
3583 dest_ptr += GET_TEXCOORD_SIZE_FROM_FVF(dst_fvf, tex_index) * sizeof(float);
3584 }
3585 else
3586 {
3587 copy_and_next(dest_ptr, tex_coord, GET_TEXCOORD_SIZE_FROM_FVF(dst_fvf, tex_index) * sizeof(float));
3588 }
3589 }
3590 }
3591
3592 wined3d_resource_unmap(&dest->resource, 0);
3593
3594 return WINED3D_OK;
3595}
3596#undef copy_and_next
3597
3599 UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
3601{
3603 struct wined3d_state *device_state = device->cs->c.state;
3605 struct wined3d_resource *resource;
3606 struct wined3d_box box = {0};
3607 struct wined3d_shader *vs;
3608 unsigned int i, j;
3609 uint32_t map;
3610 HRESULT hr;
3611
3612 TRACE("device %p, src_start_idx %u, dst_idx %u, vertex_count %u, "
3613 "dst_buffer %p, declaration %p, flags %#x, dst_fvf %#x.\n",
3614 device, src_start_idx, dst_idx, vertex_count,
3615 dst_buffer, declaration, flags, dst_fvf);
3616
3617 if (declaration)
3618 FIXME("Output vertex declaration not implemented yet.\n");
3619
3621
3626
3627 /* We can't convert FROM a VBO, and vertex buffers used to source into
3628 * process_vertices() are unlikely to ever be used for drawing. Release
3629 * VBOs in those buffers and fix up the stream_info structure.
3630 *
3631 * Also apply the start index. */
3632 map = stream_info.use_map;
3633 while (map)
3634 {
3636 struct wined3d_map_desc map_desc;
3637
3639 e = &stream_info.elements[i];
3640 resource = &state->streams[e->stream_idx].buffer->resource;
3641 box.left = src_start_idx * e->stride;
3642 box.right = box.left + vertex_count * e->stride;
3644 {
3645 ERR("Failed to map resource.\n");
3646 map = stream_info.use_map;
3647 while (map)
3648 {
3650 if (j >= i)
3651 break;
3652
3653 e = &stream_info.elements[j];
3654 resource = &state->streams[e->stream_idx].buffer->resource;
3656 ERR("Failed to unmap resource.\n");
3657 }
3659 }
3660 e->data.buffer_object = 0;
3661 e->data.addr += (ULONG_PTR)map_desc.data;
3662 }
3663
3665 &stream_info, dst_buffer, flags, dst_fvf);
3666
3667 map = stream_info.use_map;
3668 while (map)
3669 {
3671 resource = &state->streams[stream_info.elements[i].stream_idx].buffer->resource;
3673 ERR("Failed to unmap resource.\n");
3674 }
3675
3676 return hr;
3677}
3678
3680{
3681 TRACE("device %p, caps %p.\n", device, caps);
3682
3683 return wined3d_get_device_caps(device->adapter, device->create_parms.device_type, caps);
3684}
3685
3687 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
3688{
3689 struct wined3d_swapchain *swapchain;
3690
3691 TRACE("device %p, swapchain_idx %u, mode %p, rotation %p.\n",
3692 device, swapchain_idx, mode, rotation);
3693
3694 if (!(swapchain = wined3d_device_get_swapchain(device, swapchain_idx)))
3696
3697 return wined3d_swapchain_get_display_mode(swapchain, mode, rotation);
3698}
3699
3701{
3702 /* At the moment we have no need for any functionality at the beginning
3703 * of a scene. */
3704 TRACE("device %p.\n", device);
3705
3706 if (device->inScene)
3707 {
3708 WARN("Already in scene, returning WINED3DERR_INVALIDCALL.\n");
3710 }
3711 device->inScene = TRUE;
3712 return WINED3D_OK;
3713}
3714
3716{
3717 TRACE("device %p.\n", device);
3718
3719 if (!device->inScene)
3720 {
3721 WARN("Not in scene, returning WINED3DERR_INVALIDCALL.\n");
3723 }
3724
3725 device->inScene = FALSE;
3726 return WINED3D_OK;
3727}
3728
3729HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, unsigned int rect_count,
3730 const RECT *rects, uint32_t flags, const struct wined3d_color *color, float depth, unsigned int stencil)
3731{
3732 struct wined3d_fb_state *fb = &device->cs->c.state->fb;
3733
3734 TRACE("device %p, rect_count %u, rects %p, flags %#x, color %s, depth %.8e, stencil %u.\n",
3735 device, rect_count, rects, flags, debug_color(color), depth, stencil);
3736
3737 if (!rect_count && rects)
3738 {
3739 WARN("Rects is %p, but rect_count is 0, ignoring clear\n", rects);
3740 return WINED3D_OK;
3741 }
3742
3744 {
3746 if (!ds)
3747 {
3748 WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
3749 /* TODO: What about depth stencil buffers without stencil bits? */
3751 }
3752 else if (flags & WINED3DCLEAR_TARGET)
3753 {
3754 if (ds->width < fb->render_targets[0]->width
3755 || ds->height < fb->render_targets[0]->height)
3756 {
3757 WARN("Silently ignoring depth and target clear with mismatching sizes\n");
3758 return WINED3D_OK;
3759 }
3760 }
3761 }
3762
3763 wined3d_cs_emit_clear(device->cs, rect_count, rects, flags, color, depth, stencil);
3764
3765 return WINED3D_OK;
3766}
3767
3769{
3770 struct wined3d_state *state = context->state;
3771
3772 TRACE("context %p, value %p.\n", context, value);
3773
3774 if (value)
3775 *value = state->predicate_value;
3776 return state->predicate;
3777}
3778
3781{
3782 struct wined3d_state *state = context->state;
3783
3784 TRACE("context %p, primitive_type %s, patch_vertex_count %u.\n",
3786
3788 state->primitive_type = primitive_type;
3789 state->patch_vertex_count = patch_vertex_count;
3791}
3792
3795{
3796 const struct wined3d_state *state = context->state;
3797
3798 TRACE("context %p, primitive_type %p, patch_vertex_count %p.\n",
3800
3801 *primitive_type = state->primitive_type;
3803 *patch_vertex_count = state->patch_vertex_count;
3804
3805 TRACE("Returning %s.\n", debug_d3dprimitivetype(*primitive_type));
3806}
3807
3809 struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture)
3810{
3811 unsigned int src_size, dst_size, src_skip_levels = 0;
3812 unsigned int src_level_count, dst_level_count;
3813 const struct wined3d_dirty_regions *regions;
3814 unsigned int layer_count, level_count, i, j;
3816 BOOL entire_texture = TRUE;
3817 struct wined3d_box box;
3818
3819 TRACE("device %p, src_texture %p, dst_texture %p.\n", device, src_texture, dst_texture);
3820
3821 /* Verify that the source and destination textures are non-NULL. */
3822 if (!src_texture || !dst_texture)
3823 {
3824 WARN("Source and destination textures must be non-NULL, returning WINED3DERR_INVALIDCALL.\n");
3826 }
3827
3828 if (src_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU
3829 || src_texture->resource.usage & WINED3DUSAGE_SCRATCH)
3830 {
3831 WARN("Source resource is GPU accessible or a scratch resource.\n");
3833 }
3834 if (dst_texture->resource.access & WINED3D_RESOURCE_ACCESS_CPU)
3835 {
3836 WARN("Destination resource is CPU accessible.\n");
3838 }
3839
3840 /* Verify that the source and destination textures are the same type. */
3841 type = src_texture->resource.type;
3842 if (dst_texture->resource.type != type)
3843 {
3844 WARN("Source and destination have different types, returning WINED3DERR_INVALIDCALL.\n");
3846 }
3847
3848 layer_count = src_texture->layer_count;
3849 if (layer_count != dst_texture->layer_count)
3850 {
3851 WARN("Source and destination have different layer counts.\n");
3853 }
3854
3855 if (src_texture->resource.format != dst_texture->resource.format)
3856 {
3857 WARN("Source and destination formats do not match.\n");
3859 }
3860
3861 src_level_count = src_texture->level_count;
3862 dst_level_count = dst_texture->level_count;
3863 level_count = min(src_level_count, dst_level_count);
3864
3865 src_size = max(src_texture->resource.width, src_texture->resource.height);
3866 src_size = max(src_size, src_texture->resource.depth);
3867 dst_size = max(dst_texture->resource.width, dst_texture->resource.height);
3868 dst_size = max(dst_size, dst_texture->resource.depth);
3869 while (src_size > dst_size)
3870 {
3871 src_size >>= 1;
3872 ++src_skip_levels;
3873 }
3874
3875 if (wined3d_texture_get_level_width(src_texture, src_skip_levels) != dst_texture->resource.width
3876 || wined3d_texture_get_level_height(src_texture, src_skip_levels) != dst_texture->resource.height
3877 || wined3d_texture_get_level_depth(src_texture, src_skip_levels) != dst_texture->resource.depth)
3878 {
3879 WARN("Source and destination dimensions do not match.\n");
3881 }
3882
3883 if ((regions = src_texture->dirty_regions))
3884 {
3885 for (i = 0; i < layer_count && entire_texture; ++i)
3886 {
3888 continue;
3889
3890 entire_texture = FALSE;
3891 break;
3892 }
3893 }
3894
3895 /* Update every surface level of the texture. */
3896 if (entire_texture)
3897 {
3898 for (i = 0; i < level_count; ++i)
3899 {
3900 wined3d_texture_get_level_box(dst_texture, i, &box);
3901 for (j = 0; j < layer_count; ++j)
3902 {
3904 &dst_texture->resource, j * dst_level_count + i, &box,
3905 &src_texture->resource, j * src_level_count + i + src_skip_levels, &box,
3907 }
3908 }
3909 }
3910 else
3911 {
3912 unsigned int src_level, box_count, k;
3913 const struct wined3d_box *boxes;
3914 struct wined3d_box b;
3915
3916 for (i = 0; i < layer_count; ++i)
3917 {
3918 boxes = regions[i].boxes;
3919 box_count = regions[i].box_count;
3921 {
3922 boxes = &b;
3923 box_count = 1;
3924 wined3d_texture_get_level_box(dst_texture, i, &b);
3925 }
3926
3927 for (j = 0; j < level_count; ++j)
3928 {
3929 src_level = j + src_skip_levels;
3930
3931 /* TODO: We could pass an array of boxes here to avoid
3932 * multiple context acquisitions for the same resource. */
3933 for (k = 0; k < box_count; ++k)
3934 {
3935 box = boxes[k];
3936 if (src_level)
3937 {
3938 box.left >>= src_level;
3939 box.top >>= src_level;
3940 box.right = min((box.right + (1u << src_level) - 1) >> src_level,
3941 wined3d_texture_get_level_width(src_texture, src_level));
3942 box.bottom = min((box.bottom + (1u << src_level) - 1) >> src_level,
3943 wined3d_texture_get_level_height(src_texture, src_level));
3944 box.front >>= src_level;
3945 box.back = min((box.back + (1u << src_level) - 1) >> src_level,
3946 wined3d_texture_get_level_depth(src_texture, src_level));
3947 }
3948
3950 &dst_texture->resource, i * dst_level_count + j, &box,
3951 &src_texture->resource, i * src_level_count + src_level, &box,
3953 }
3954 }
3955 }
3956 }
3957
3959
3960 return WINED3D_OK;
3961}
3962
3964{
3965 const struct wined3d_state *device_state = device->cs->c.state;
3966 struct wined3d_texture *texture;
3967 unsigned i;
3968
3969 TRACE("device %p, num_passes %p.\n", device, num_passes);
3970
3971 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
3972 {
3973 if (state->sampler_states[i][WINED3D_SAMP_MIN_FILTER] == WINED3D_TEXF_NONE)
3974 {
3975 WARN("Sampler state %u has minfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
3977 }
3978 if (state->sampler_states[i][WINED3D_SAMP_MAG_FILTER] == WINED3D_TEXF_NONE)
3979 {
3980 WARN("Sampler state %u has magfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
3982 }
3983
3984 texture = state->textures[i];
3985 if (!texture || texture->resource.format_caps & WINED3D_FORMAT_CAP_FILTERING)
3986 continue;
3987
3988 if (state->sampler_states[i][WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_POINT)
3989 {
3990 WARN("Non-filterable texture and mag filter enabled on sampler %u, returning E_FAIL\n", i);
3991 return E_FAIL;
3992 }
3993 if (state->sampler_states[i][WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_POINT)
3994 {
3995 WARN("Non-filterable texture and min filter enabled on sampler %u, returning E_FAIL\n", i);
3996 return E_FAIL;
3997 }
3998 if (state->sampler_states[i][WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_NONE
3999 && state->sampler_states[i][WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_POINT)
4000 {
4001 WARN("Non-filterable texture and mip filter enabled on sampler %u, returning E_FAIL\n", i);
4002 return E_FAIL;
4003 }
4004 }
4005
4007 {
4010
4011 if (ds && rt && (ds->width < rt->width || ds->height < rt->height))
4012 {
4013 WARN("Depth stencil is smaller than the color buffer, returning D3DERR_CONFLICTINGRENDERSTATE\n");
4015 }
4016 }
4017
4018 /* return a sensible default */
4019 *num_passes = 1;
4020
4021 TRACE("returning D3D_OK\n");
4022 return WINED3D_OK;
4023}
4024
4026{
4027 static BOOL warned;
4028
4029 TRACE("device %p, software %#x.\n", device, software);
4030
4031 if (!warned)
4032 {
4033 FIXME("device %p, software %#x stub!\n", device, software);
4034 warned = TRUE;
4035 }
4036
4037 device->softwareVertexProcessing = software;
4038}
4039
4041{
4042 static BOOL warned;
4043
4044 TRACE("device %p.\n", device);
4045
4046 if (!warned)
4047 {
4048 TRACE("device %p stub!\n", device);
4049 warned = TRUE;
4050 }
4051
4052 return device->softwareVertexProcessing;
4053}
4054
4056 UINT swapchain_idx, struct wined3d_raster_status *raster_status)
4057{
4058 struct wined3d_swapchain *swapchain;
4059
4060 TRACE("device %p, swapchain_idx %u, raster_status %p.\n",
4061 device, swapchain_idx, raster_status);
4062
4063 if (!(swapchain = wined3d_device_get_swapchain(device, swapchain_idx)))
4065
4066 return wined3d_swapchain_get_raster_status(swapchain, raster_status);
4067}
4068
4070{
4071 static BOOL warned;
4072
4073 TRACE("device %p, segments %.8e.\n", device, segments);
4074
4075 if (segments != 0.0f)
4076 {
4077 if (!warned)
4078 {
4079 FIXME("device %p, segments %.8e stub!\n", device, segments);
4080 warned = TRUE;
4081 }
4082 }
4083
4084 return WINED3D_OK;
4085}
4086
4088{
4089 static BOOL warned;
4090
4091 TRACE("device %p.\n", device);
4092
4093 if (!warned)
4094 {
4095 FIXME("device %p stub!\n", device);
4096 warned = TRUE;
4097 }
4098
4099 return 0.0f;
4100}
4101
4103 struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav)
4104{
4105 TRACE("context %p, dst_buffer %p, offset %u, uav %p.\n",
4106 context, dst_buffer, offset, uav);
4107
4111}
4112
4113static bool resources_format_compatible(const struct wined3d_resource *src_resource,
4114 const struct wined3d_resource *dst_resource)
4115{
4116 if (src_resource->format->id == dst_resource->format->id)
4117 return true;
4118 if (src_resource->format->typeless_id && src_resource->format->typeless_id == dst_resource->format->typeless_id)
4119 return true;
4120 if (src_resource->device->cs->c.state->feature_level < WINED3D_FEATURE_LEVEL_10_1)
4121 return false;
4122 if ((src_resource->format_attrs & WINED3D_FORMAT_ATTR_BLOCKS)
4124 return src_resource->format->block_byte_count == dst_resource->format->byte_count;
4126 && (dst_resource->format_attrs & WINED3D_FORMAT_ATTR_BLOCKS))
4127 return src_resource->format->byte_count == dst_resource->format->block_byte_count;
4128 return false;
4129}
4130
4132 struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource)
4133{
4134 unsigned int src_row_block_count, dst_row_block_count;
4135 struct wined3d_texture *dst_texture, *src_texture;
4136 unsigned int src_row_count, dst_row_count;
4137 struct wined3d_box src_box, dst_box;
4138 unsigned int i, j;
4139
4140 TRACE("context %p, dst_resource %p, src_resource %p.\n", context, dst_resource, src_resource);
4141
4142 if (src_resource == dst_resource)
4143 {
4144 WARN("Source and destination are the same resource.\n");
4145 return;
4146 }
4147
4148 if (src_resource->type != dst_resource->type)
4149 {
4150 WARN("Resource types (%s / %s) don't match.\n",
4151 debug_d3dresourcetype(dst_resource->type),
4152 debug_d3dresourcetype(src_resource->type));
4153 return;
4154 }
4155
4156 if (!resources_format_compatible(src_resource, dst_resource))
4157 {
4158 WARN("Resource formats %s and %s are incompatible.\n",
4159 debug_d3dformat(dst_resource->format->id),
4160 debug_d3dformat(src_resource->format->id));
4161 return;
4162 }
4163
4164 src_row_block_count = (src_resource->width + (src_resource->format->block_width - 1))
4165 / src_resource->format->block_width;
4166 dst_row_block_count = (dst_resource->width + (dst_resource->format->block_width - 1))
4167 / dst_resource->format->block_width;
4168 src_row_count = (src_resource->height + (src_resource->format->block_height - 1))
4169 / src_resource->format->block_height;
4170 dst_row_count = (dst_resource->height + (dst_resource->format->block_height - 1))
4171 / dst_resource->format->block_height;
4172
4173 if (src_row_block_count != dst_row_block_count || src_row_count != dst_row_count
4174 || src_resource->depth != dst_resource->depth)
4175 {
4176 WARN("Resource block dimensions (%ux%ux%u / %ux%ux%u) don't match.\n",
4177 dst_row_block_count, dst_row_count, dst_resource->depth,
4178 src_row_block_count, src_row_count, src_resource->depth);
4179 return;
4180 }
4181
4182 if (dst_resource->type == WINED3D_RTYPE_BUFFER)
4183 {
4184 wined3d_box_set(&src_box, 0, 0, src_resource->size, 1, 0, 1);
4186 wined3d_device_context_emit_blt_sub_resource(context, dst_resource, 0, &src_box,
4187 src_resource, 0, &src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
4189 return;
4190 }
4191
4192 dst_texture = texture_from_resource(dst_resource);
4193 src_texture = texture_from_resource(src_resource);
4194
4195 if (src_texture->layer_count != dst_texture->layer_count
4196 || src_texture->level_count != dst_texture->level_count)
4197 {
4198 WARN("Subresource layouts (%ux%u / %ux%u) don't match.\n",
4199 dst_texture->layer_count, dst_texture->level_count,
4200 src_texture->layer_count, src_texture->level_count);
4201 return;
4202 }
4203
4205 for (i = 0; i < dst_texture->level_count; ++i)
4206 {
4207 wined3d_texture_get_level_box(src_texture, i, &src_box);
4208 wined3d_texture_get_level_box(dst_texture, i, &dst_box);
4209 for (j = 0; j < dst_texture->layer_count; ++j)
4210 {
4211 unsigned int idx = j * dst_texture->level_count + i;
4212
4214 src_resource, idx, &src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
4215 }
4216 }
4218}
4219
4221 struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x,
4222 unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource,
4223 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags)
4224{
4225 struct wined3d_box dst_box, b;
4226
4227 TRACE("context %p, dst_resource %p, dst_sub_resource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
4228 "src_resource %p, src_sub_resource_idx %u, src_box %s, flags %#x.\n",
4229 context, dst_resource, dst_sub_resource_idx, dst_x, dst_y, dst_z,
4230 src_resource, src_sub_resource_idx, debug_box(src_box), flags);
4231
4232 if (flags)
4233 FIXME("Ignoring flags %#x.\n", flags);
4234
4235 if (src_resource == dst_resource && src_sub_resource_idx == dst_sub_resource_idx)
4236 {
4237 WARN("Source and destination are the same sub-resource.\n");
4239 }
4240
4241 if (!resources_format_compatible(src_resource, dst_resource))
4242 {
4243 WARN("Resource formats %s and %s are incompatible.\n",
4244 debug_d3dformat(dst_resource->format->id),
4245 debug_d3dformat(src_resource->format->id));
4247 }
4248
4249 if (dst_resource->type == WINED3D_RTYPE_BUFFER)
4250 {
4251 if (src_resource->type != WINED3D_RTYPE_BUFFER)
4252 {
4253 WARN("Resource types (%s / %s) don't match.\n",
4254 debug_d3dresourcetype(dst_resource->type),
4255 debug_d3dresourcetype(src_resource->type));
4257 }
4258
4259 if (dst_sub_resource_idx)
4260 {
4261 WARN("Invalid dst_sub_resource_idx %u.\n", dst_sub_resource_idx);
4263 }
4264
4265 if (src_sub_resource_idx)
4266 {
4267 WARN("Invalid src_sub_resource_idx %u.\n", src_sub_resource_idx);
4269 }
4270
4271 if (!src_box)
4272 {
4273 unsigned int dst_w;
4274
4275 dst_w = dst_resource->size - dst_x;
4276 wined3d_box_set(&b, 0, 0, min(src_resource->size, dst_w), 1, 0, 1);
4277 src_box = &b;
4278 }
4279 else if ((src_box->left >= src_box->right
4280 || src_box->top >= src_box->bottom
4281 || src_box->front >= src_box->back))
4282 {
4283 WARN("Invalid box %s specified.\n", debug_box(src_box));
4285 }
4286
4287 if (src_box->right > src_resource->size || dst_x >= dst_resource->size
4288 || src_box->right - src_box->left > dst_resource->size - dst_x)
4289 {
4290 WARN("Invalid range specified, dst_offset %u, src_offset %u, size %u.\n",
4291 dst_x, src_box->left, src_box->right - src_box->left);
4293 }
4294
4295 wined3d_box_set(&dst_box, dst_x, 0, dst_x + (src_box->right - src_box->left), 1, 0, 1);
4296 }
4297 else
4298 {
4299 struct wined3d_texture *dst_texture = texture_from_resource(dst_resource);
4300 struct wined3d_texture *src_texture = texture_from_resource(src_resource);
4301 unsigned int src_level = src_sub_resource_idx % src_texture->level_count;
4302 unsigned int src_row_block_count, src_row_count;
4303
4304 if (!wined3d_texture_validate_sub_resource_idx(dst_texture, dst_sub_resource_idx))
4306
4307 if (!wined3d_texture_validate_sub_resource_idx(src_texture, src_sub_resource_idx))
4309
4310 if (dst_texture->sub_resources[dst_sub_resource_idx].map_count)
4311 {
4312 WARN("Destination sub-resource %u is mapped.\n", dst_sub_resource_idx);
4314 }
4315
4316 if (src_texture->sub_resources[src_sub_resource_idx].map_count)
4317 {
4318 WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx);
4320 }
4321
4322 if (!src_box)
4323 {
4324 unsigned int src_w, src_h, src_d, dst_w, dst_h, dst_d, dst_level;
4325
4326 src_w = wined3d_texture_get_level_width(src_texture, src_level);
4327 src_h = wined3d_texture_get_level_height(src_texture, src_level);
4328 src_d = wined3d_texture_get_level_depth(src_texture, src_level);
4329
4330 dst_level = dst_sub_resource_idx % dst_texture->level_count;
4331 dst_w = wined3d_texture_get_level_width(dst_texture, dst_level) - dst_x;
4332 dst_h = wined3d_texture_get_level_height(dst_texture, dst_level) - dst_y;
4333 dst_d = wined3d_texture_get_level_depth(dst_texture, dst_level) - dst_z;
4334
4335 wined3d_box_set(&b, 0, 0, min(src_w, dst_w), min(src_h, dst_h), 0, min(src_d, dst_d));
4336 src_box = &b;
4337 }
4338 else if (FAILED(wined3d_resource_check_box_dimensions(src_resource, src_sub_resource_idx, src_box)))
4339 {
4340 WARN("Invalid source box %s.\n", debug_box(src_box));
4342 }
4343
4344 if (src_resource->format->block_width == dst_resource->format->block_width
4345 && src_resource->format->block_height == dst_resource->format->block_height)
4346 {
4347 wined3d_box_set(&dst_box, dst_x, dst_y, dst_x + (src_box->right - src_box->left),
4348 dst_y + (src_box->bottom - src_box->top), dst_z, dst_z + (src_box->back - src_box->front));
4349 }
4350 else
4351 {
4352 src_row_block_count = (src_box->right - src_box->left + src_resource->format->block_width - 1)
4353 / src_resource->format->block_width;
4354 src_row_count = (src_box->bottom - src_box->top + src_resource->format->block_height - 1)
4355 / src_resource->format->block_height;
4356 wined3d_box_set(&dst_box, dst_x, dst_y,
4357 dst_x + (src_row_block_count * dst_resource->format->block_width),
4358 dst_y + (src_row_count * dst_resource->format->block_height),
4359 dst_z, dst_z + (src_box->back - src_box->front));
4360 }
4361 if (FAILED(wined3d_resource_check_box_dimensions(dst_resource, dst_sub_resource_idx, &dst_box)))
4362 {
4363 WARN("Invalid destination box %s.\n", debug_box(&dst_box));
4365 }
4366 }
4367
4369 wined3d_device_context_emit_blt_sub_resource(context, dst_resource, dst_sub_resource_idx, &dst_box,
4370 src_resource, src_sub_resource_idx, src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
4372
4373 return WINED3D_OK;
4374}
4375
4377 struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
4378 const void *data, unsigned int row_pitch, unsigned int depth_pitch, unsigned int flags)
4379{
4381 struct wined3d_box b;
4382
4383 TRACE("context %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n",
4384 context, resource, sub_resource_idx, debug_box(box), data, row_pitch, depth_pitch, flags);
4385
4386 if (flags)
4387 FIXME("Ignoring flags %#x.\n", flags);
4388
4389 if (!(resource->access & WINED3D_RESOURCE_ACCESS_GPU))
4390 {
4391 WARN("Resource %p is not GPU accessible.\n", resource);
4392 return;
4393 }
4394
4396 return;
4397
4398 if (!box)
4399 {
4400 wined3d_box_set(&b, 0, 0, desc.width, desc.height, 0, desc.depth);
4401 box = &b;
4402 }
4403 else if (box->left >= box->right || box->right > desc.width
4404 || box->top >= box->bottom || box->bottom > desc.height
4405 || box->front >= box->back || box->back > desc.depth)
4406 {
4407 WARN("Invalid box %s specified.\n", debug_box(box));
4408 return;
4409 }
4410
4413 sub_resource_idx, box, data, row_pitch, depth_pitch);
4415}
4416
4418 struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx,
4419 struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx,
4421{
4422 struct wined3d_texture *dst_texture, *src_texture;
4423 unsigned int dst_level, src_level;
4424 struct wined3d_blt_fx fx = {0};
4425 RECT dst_rect, src_rect;
4426
4427 TRACE("context %p, dst_resource %p, dst_sub_resource_idx %u, "
4428 "src_resource %p, src_sub_resource_idx %u, format %s.\n",
4429 context, dst_resource, dst_sub_resource_idx,
4430 src_resource, src_sub_resource_idx, debug_d3dformat(format_id));
4431
4432 if (wined3d_format_is_typeless(dst_resource->format)
4433 || wined3d_format_is_typeless(src_resource->format))
4434 {
4435 FIXME("Multisample resolve is not fully supported for typeless formats "
4436 "(dst_format %s, src_format %s, format %s).\n",
4437 debug_d3dformat(dst_resource->format->id), debug_d3dformat(src_resource->format->id),
4439 }
4440 if (dst_resource->type != WINED3D_RTYPE_TEXTURE_2D)
4441 {
4442 WARN("Invalid destination resource type %s.\n", debug_d3dresourcetype(dst_resource->type));
4443 return;
4444 }
4445 if (src_resource->type != WINED3D_RTYPE_TEXTURE_2D)
4446 {
4447 WARN("Invalid source resource type %s.\n", debug_d3dresourcetype(src_resource->type));
4448 return;
4449 }
4450
4452 fx.resolve_format_id = format_id;
4453
4454 dst_texture = texture_from_resource(dst_resource);
4455 src_texture = texture_from_resource(src_resource);
4456
4457 dst_level = dst_sub_resource_idx % dst_texture->level_count;
4458 SetRect(&dst_rect, 0, 0, wined3d_texture_get_level_width(dst_texture, dst_level),
4459 wined3d_texture_get_level_height(dst_texture, dst_level));
4460 src_level = src_sub_resource_idx % src_texture->level_count;
4461 SetRect(&src_rect, 0, 0, wined3d_texture_get_level_width(src_texture, src_level),
4462 wined3d_texture_get_level_height(src_texture, src_level));
4463 wined3d_device_context_blt(context, dst_texture, dst_sub_resource_idx, &dst_rect,
4464 src_texture, src_sub_resource_idx, &src_rect, 0, &fx, WINED3D_TEXF_POINT);
4466}
4467
4469 struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags,
4470 const struct wined3d_color *color, float depth, unsigned int stencil)
4471{
4472 struct wined3d_resource *resource;
4473 RECT r;
4474
4475 TRACE("context %p, view %p, rect %s, flags %#x, color %s, depth %.8e, stencil %u.\n",
4477
4478 if (!flags)
4479 return WINED3D_OK;
4480
4481 resource = view->resource;
4482 if (resource->type == WINED3D_RTYPE_BUFFER)
4483 {
4484 FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
4486 }
4487
4488 if (!rect)
4489 {
4490 SetRect(&r, 0, 0, view->width, view->height);
4491 rect = &r;
4492 }
4493 else
4494 {
4495 struct wined3d_box b = {rect->left, rect->top, rect->right, rect->bottom, 0, 1};
4496 HRESULT hr;
4497
4498 if (FAILED(hr = wined3d_resource_check_box_dimensions(resource, view->sub_resource_idx, &b)))
4499 return hr;
4500 }
4501
4505
4506 return WINED3D_OK;
4507}
4508
4510 struct wined3d_unordered_access_view *view, const struct wined3d_vec4 *clear_value)
4511{
4512 TRACE("context %p, view %p, clear_value %s.\n", context, view, debug_vec4(clear_value));
4513
4515 {
4516 WARN("Not supported for view format %s.\n", debug_d3dformat(view->format->id));
4517 return;
4518 }
4519
4521 wined3d_device_context_emit_clear_uav(context, view, (const struct wined3d_uvec4 *)clear_value, true);
4523}
4524
4526 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value)
4527{
4528 TRACE("context %p, view %p, clear_value %s.\n", context, view, debug_uvec4(clear_value));
4529
4533}
4534
4535static unsigned int sanitise_map_flags(const struct wined3d_resource *resource, unsigned int flags)
4536{
4537 /* Not all flags make sense together, but Windows never returns an error.
4538 * Catch the cases that could cause issues. */
4539 if (flags & WINED3D_MAP_READ)
4540 {
4542 {
4543 WARN("WINED3D_MAP_READ combined with WINED3D_MAP_DISCARD, ignoring flags.\n");
4545 }
4547 {
4548 WARN("WINED3D_MAP_READ combined with WINED3D_MAP_NOOVERWRITE, ignoring flags.\n");
4550 }
4551 }
4553 {
4554 if (!(resource->access & WINED3D_RESOURCE_ACCESS_GPU) || !(resource->usage & WINED3DUSAGE_DYNAMIC))
4555 {
4556 WARN("DISCARD or NOOVERWRITE map not on dynamic GPU-accessible buffer, ignoring.\n");
4558 }
4561 {
4562 WARN("WINED3D_MAP_NOOVERWRITE used with WINED3D_MAP_DISCARD, ignoring WINED3D_MAP_DISCARD.\n");
4563 flags &= ~WINED3D_MAP_DISCARD;
4564 }
4565 }
4566
4567 return flags;
4568}
4569
4571 struct wined3d_resource *resource, unsigned int sub_resource_idx,
4572 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
4573{
4575 struct wined3d_box b;
4576 HRESULT hr;
4577
4578 TRACE("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
4579 context, resource, sub_resource_idx, map_desc, debug_box(box), flags);
4580
4582 {
4583 WARN("No read/write flags specified.\n");
4584 return E_INVALIDARG;
4585 }
4586
4588 {
4589 WARN("Resource does not have MAP_R access.\n");
4590 return E_INVALIDARG;
4591 }
4592
4594 {
4595 WARN("Resource does not have MAP_W access.\n");
4596 return E_INVALIDARG;
4597 }
4598
4600
4602 return E_INVALIDARG;
4603
4604 if (!box)
4605 {
4606 wined3d_box_set(&b, 0, 0, desc.width, desc.height, 0, desc.depth);
4607 box = &b;
4608 }
4609 else if (FAILED(wined3d_resource_check_box_dimensions(resource, sub_resource_idx, box)))
4610 {
4611 WARN("Map box is invalid.\n");
4612
4615
4616 if ((resource->format_attrs & WINED3D_FORMAT_ATTR_BLOCKS) &&
4619 }
4620
4622 hr = wined3d_device_context_emit_map(context, resource, sub_resource_idx, map_desc, box, flags);
4624 return hr;
4625}
4626
4628 struct wined3d_resource *resource, unsigned int sub_resource_idx)
4629{
4630 HRESULT hr;
4631 TRACE("context %p, resource %p, sub_resource_idx %u.\n", context, resource, sub_resource_idx);
4632
4636 return hr;
4637}
4638
4640 struct wined3d_query *query, unsigned int flags)
4641{
4642 TRACE("context %p, query %p, flags %#x.\n", context, query, flags);
4643
4645 context->ops->issue_query(context, query, flags);
4647}
4648
4650 struct wined3d_command_list *list, bool restore_state)
4651{
4652 TRACE("context %p, list %p, restore_state %d.\n", context, list, restore_state);
4653
4657}
4658
4660 const struct wined3d_device_context *context, unsigned int view_idx)
4661{
4662 unsigned int max_rt_count;
4663
4664 TRACE("context %p, view_idx %u.\n", context, view_idx);
4665
4666 max_rt_count = context->device->adapter->d3d_info.limits.max_rt_count;
4667 if (view_idx >= max_rt_count)
4668 {
4669 WARN("Only %u render targets are supported.\n", max_rt_count);
4670 return NULL;
4671 }
4672
4673 return context->state->fb.render_targets[view_idx];
4674}
4675
4677 const struct wined3d_device_context *context)
4678{
4679 TRACE("context %p.\n", context);
4680
4681 return context->state->fb.depth_stencil;
4682}
4683
4686{
4687 struct wined3d_texture *texture;
4688
4689 TRACE("context %p, view %p.\n", context, view);
4690
4691 if (view->resource->type == WINED3D_RTYPE_BUFFER)
4692 {
4693 WARN("Called on buffer resource %p.\n", view->resource);
4694 return;
4695 }
4696
4697 texture = texture_from_resource(view->resource);
4699 {
4700 WARN("Texture without the WINED3D_TEXTURE_GENERATE_MIPMAPS flag, ignoring.\n");
4701 return;
4702 }
4703
4707}
4708
4710 struct wined3d_texture *cursor_image, unsigned int sub_resource_idx)
4711{
4712 unsigned int texture_level = sub_resource_idx % cursor_image->level_count;
4715 struct wined3d_map_desc map_desc;
4716 struct wined3d_texture *texture;
4717 HRESULT hr;
4718
4719 if (FAILED(wined3d_resource_map(&cursor_image->resource, sub_resource_idx, &map_desc, NULL, WINED3D_MAP_READ)))
4720 {
4721 ERR("Failed to map source texture.\n");
4722 return NULL;
4723 }
4724
4725 data.data = map_desc.data;
4726 data.row_pitch = map_desc.row_pitch;
4727 data.slice_pitch = map_desc.slice_pitch;
4728
4729 desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
4731 desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
4732 desc.multisample_quality = 0;
4733 desc.usage = WINED3DUSAGE_DYNAMIC;
4734 desc.bind_flags = 0;
4736 desc.width = wined3d_texture_get_level_width(cursor_image, texture_level);
4737 desc.height = wined3d_texture_get_level_height(cursor_image, texture_level);
4738 desc.depth = 1;
4739 desc.size = 0;
4740
4742 wined3d_resource_unmap(&cursor_image->resource, sub_resource_idx);
4743 if (FAILED(hr))
4744 {
4745 ERR("Failed to create cursor texture.\n");
4746 return NULL;
4747 }
4748
4749 return texture;
4750}
4751
4753 UINT x_hotspot, UINT y_hotspot, struct wined3d_texture *texture, unsigned int sub_resource_idx)
4754{
4755 unsigned int texture_level = sub_resource_idx % texture->level_count;
4756 unsigned int cursor_width, cursor_height;
4757 struct wined3d_map_desc map_desc;
4758
4759 TRACE("device %p, x_hotspot %u, y_hotspot %u, texture %p, sub_resource_idx %u.\n",
4760 device, x_hotspot, y_hotspot, texture, sub_resource_idx);
4761
4763 || texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
4765
4766 if (device->cursor_texture)
4767 {
4768 wined3d_texture_decref(device->cursor_texture);
4769 device->cursor_texture = NULL;
4770 }
4771
4772 if (texture->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM)
4773 {
4774 WARN("Texture %p has invalid format %s.\n",
4775 texture, debug_d3dformat(texture->resource.format->id));
4777 }
4778
4779 /* Cursor width and height must all be powers of two */
4780 cursor_width = wined3d_texture_get_level_width(texture, texture_level);
4781 cursor_height = wined3d_texture_get_level_height(texture, texture_level);
4782 if ((cursor_width & (cursor_width - 1)) || (cursor_height & (cursor_height - 1)))
4783 {
4784 WARN("Cursor size %ux%u are not all powers of two.\n", cursor_width, cursor_height);
4786 }
4787
4788 /* Do not store the surface's pointer because the application may
4789 * release it after setting the cursor image. Windows doesn't
4790 * addref the set surface, so we can't do this either without
4791 * creating circular refcount dependencies. */
4792 if (!(device->cursor_texture = wined3d_device_create_cursor_texture(device, texture, sub_resource_idx)))
4793 {
4794 ERR("Failed to create cursor texture.\n");
4796 }
4797
4798 if (cursor_width == 32 && cursor_height == 32)
4799 {
4800 UINT mask_size = cursor_width * cursor_height / 8;
4801 ICONINFO cursor_info;
4802 DWORD *mask_bits;
4804
4805 /* 32-bit user32 cursors ignore the alpha channel if it's all
4806 * zeroes, and use the mask instead. Fill the mask with all ones
4807 * to ensure we still get a fully transparent cursor. */
4808 if (!(mask_bits = malloc(mask_size)))
4809 return E_OUTOFMEMORY;
4810 memset(mask_bits, 0xff, mask_size);
4811
4812 wined3d_resource_map(&texture->resource, sub_resource_idx, &map_desc, NULL,
4814 cursor_info.fIcon = FALSE;
4815 cursor_info.xHotspot = x_hotspot;
4816 cursor_info.yHotspot = y_hotspot;
4817 cursor_info.hbmMask = CreateBitmap(cursor_width, cursor_height, 1, 1, mask_bits);
4818 cursor_info.hbmColor = CreateBitmap(cursor_width, cursor_height, 1, 32, map_desc.data);
4819 wined3d_resource_unmap(&texture->resource, sub_resource_idx);
4820
4821 /* Create our cursor and clean up. */
4822 cursor = CreateIconIndirect(&cursor_info);
4823 if (cursor_info.hbmMask)
4824 DeleteObject(cursor_info.hbmMask);
4825 if (cursor_info.hbmColor)
4826 DeleteObject(cursor_info.hbmColor);
4827 if (device->hardwareCursor)
4828 DestroyCursor(device->hardwareCursor);
4829 device->hardwareCursor = cursor;
4830 if (device->bCursorVisible)
4832
4833 free(mask_bits);
4834 }
4835
4836 TRACE("New cursor dimensions are %ux%u.\n", cursor_width, cursor_height);
4837 device->cursorWidth = cursor_width;
4838 device->cursorHeight = cursor_height;
4839 device->xHotSpot = x_hotspot;
4840 device->yHotSpot = y_hotspot;
4841
4842 return WINED3D_OK;
4843}
4844
4846 int x_screen_space, int y_screen_space, uint32_t flags)
4847{
4848 TRACE("device %p, x %d, y %d, flags %#x.\n",
4849 device, x_screen_space, y_screen_space, flags);
4850
4851 device->xScreenSpace = x_screen_space;
4852 device->yScreenSpace = y_screen_space;
4853
4854 if (device->hardwareCursor)
4855 {
4856 POINT pt;
4857
4858 GetCursorPos( &pt );
4859 if (x_screen_space == pt.x && y_screen_space == pt.y)
4860 return;
4861 SetCursorPos( x_screen_space, y_screen_space );
4862
4863 /* Switch to the software cursor if position diverges from the hardware one. */
4864 GetCursorPos( &pt );
4865 if (x_screen_space != pt.x || y_screen_space != pt.y)
4866 {
4867 if (device->bCursorVisible) SetCursor( NULL );
4868 DestroyCursor( device->hardwareCursor );
4869 device->hardwareCursor = 0;
4870 }
4871 }
4872}
4873
4875{
4876 BOOL oldVisible = device->bCursorVisible;
4877
4878 TRACE("device %p, show %#x.\n", device, show);
4879
4880 /*
4881 * When ShowCursor is first called it should make the cursor appear at the OS's last
4882 * known cursor position.
4883 */
4884 if (show && !oldVisible)
4885 {
4886 POINT pt;
4887 GetCursorPos(&pt);
4888 device->xScreenSpace = pt.x;
4889 device->yScreenSpace = pt.y;
4890 }
4891
4892 if (device->hardwareCursor)
4893 {
4894 device->bCursorVisible = show;
4895 if (show)
4896 SetCursor(device->hardwareCursor);
4897 else
4898 SetCursor(NULL);
4899 }
4900 else if (device->cursor_texture)
4901 {
4902 device->bCursorVisible = show;
4903 }
4904
4905 return oldVisible;
4906}
4907
4909{
4910 if (resource->type != WINED3D_RTYPE_BUFFER)
4911 {
4913 unsigned int i;
4914
4915 if (texture->dirty_regions)
4916 {
4917 for (i = 0; i < texture->layer_count; ++i)
4919 }
4920 }
4921}
4922
4924{
4926
4927 TRACE("device %p.\n", device);
4928
4930 {
4931 TRACE("Checking resource %p for eviction.\n", resource);
4932
4933 if ((resource->usage & WINED3DUSAGE_MANAGED) && !resource->map_count)
4934 {
4936 {
4937 TRACE("Evicting %p.\n", resource);
4939 }
4940
4942 }
4943 }
4944}
4945
4947{
4948 TRACE("context %p.\n", context);
4949
4951 context->ops->flush(context);
4953}
4954
4956{
4957 unsigned int flags = texture->swapchain->state.desc.flags;
4958
4961 else
4963
4966 else
4967 texture->flags &= ~WINED3D_TEXTURE_GET_DC;
4968}
4969
4971 const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode,
4973{
4974 static struct wined3d_rendertarget_view *const views[WINED3D_MAX_RENDER_TARGETS];
4975 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
4976 struct wined3d_device_context *context = &device->cs->c;
4977 struct wined3d_swapchain_state *swapchain_state;
4978 struct wined3d_state *state = context->state;
4979 struct wined3d_swapchain_desc *current_desc;
4982 struct wined3d_swapchain *swapchain;
4983 struct wined3d_view_desc view_desc;
4984 BOOL backbuffer_resized, windowed;
4986 HWND device_window;
4987 unsigned int i;
4988
4989 TRACE("device %p, swapchain_desc %p, mode %p, callback %p, reset_state %#x.\n",
4990 device, swapchain_desc, mode, callback, reset_state);
4991
4993
4994 if (!(swapchain = wined3d_device_get_swapchain(device, 0)))
4995 {
4996 ERR("Failed to get the first implicit swapchain.\n");
4998 }
4999 swapchain_state = &swapchain->state;
5000 current_desc = &swapchain_state->desc;
5001
5002 if (reset_state)
5003 {
5004 if (device->logo_texture)
5005 {
5006 wined3d_texture_decref(device->logo_texture);
5007 device->logo_texture = NULL;
5008 }
5009 if (device->cursor_texture)
5010 {
5011 wined3d_texture_decref(device->cursor_texture);
5012 device->cursor_texture = NULL;
5013 }
5014 for (unsigned int i = 0; i < ARRAY_SIZE(device->push_constants); ++i)
5015 {
5016 if (device->push_constants[i])
5017 wined3d_buffer_decref(device->push_constants[i]);
5018 device->push_constants[i] = NULL;
5019 }
5021 }
5022
5023 wined3d_device_context_set_rendertarget_views(context, 0, d3d_info->limits.max_rt_count, views, FALSE);
5025
5026 if (reset_state)
5027 {
5028 LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
5029 {
5030 TRACE("Enumerating resource %p.\n", resource);
5031 if (FAILED(hr = callback(resource)))
5032 return hr;
5033 }
5034 }
5035
5036 TRACE("New params:\n");
5037 TRACE("output %p\n", swapchain_desc->output);
5038 TRACE("backbuffer_width %u\n", swapchain_desc->backbuffer_width);
5039 TRACE("backbuffer_height %u\n", swapchain_desc->backbuffer_height);
5040 TRACE("backbuffer_format %s\n", debug_d3dformat(swapchain_desc->backbuffer_format));
5041 TRACE("backbuffer_count %u\n", swapchain_desc->backbuffer_count);
5042 TRACE("multisample_type %#x\n", swapchain_desc->multisample_type);
5043 TRACE("multisample_quality %u\n", swapchain_desc->multisample_quality);
5044 TRACE("swap_effect %#x\n", swapchain_desc->swap_effect);
5045 TRACE("device_window %p\n", swapchain_desc->device_window);
5046 TRACE("windowed %#x\n", swapchain_desc->windowed);
5047 TRACE("enable_auto_depth_stencil %#x\n", swapchain_desc->enable_auto_depth_stencil);
5048 if (swapchain_desc->enable_auto_depth_stencil)
5049 TRACE("auto_depth_stencil_format %s\n", debug_d3dformat(swapchain_desc->auto_depth_stencil_format));
5050 TRACE("flags %#x\n", swapchain_desc->flags);
5051 TRACE("refresh_rate %u\n", swapchain_desc->refresh_rate);
5052 TRACE("auto_restore_display_mode %#x\n", swapchain_desc->auto_restore_display_mode);
5053
5054 if (swapchain_desc->backbuffer_bind_flags && swapchain_desc->backbuffer_bind_flags != WINED3D_BIND_RENDER_TARGET)
5055 FIXME("Got unexpected backbuffer bind flags %#x.\n", swapchain_desc->backbuffer_bind_flags);
5056
5057 if (swapchain_desc->swap_effect != WINED3D_SWAP_EFFECT_DISCARD
5058 && swapchain_desc->swap_effect != WINED3D_SWAP_EFFECT_SEQUENTIAL
5059 && swapchain_desc->swap_effect != WINED3D_SWAP_EFFECT_COPY)
5060 FIXME("Unimplemented swap effect %#x.\n", swapchain_desc->swap_effect);
5061
5062 /* No special treatment of these parameters. Just store them */
5063 current_desc->swap_effect = swapchain_desc->swap_effect;
5064 current_desc->enable_auto_depth_stencil = swapchain_desc->enable_auto_depth_stencil;
5065 current_desc->auto_depth_stencil_format = swapchain_desc->auto_depth_stencil_format;
5066 current_desc->refresh_rate = swapchain_desc->refresh_rate;
5067 current_desc->auto_restore_display_mode = swapchain_desc->auto_restore_display_mode;
5068
5069 device_window = swapchain_desc->device_window ? swapchain_desc->device_window : device->create_parms.focus_window;
5070 if (device_window && device_window != current_desc->device_window)
5071 {
5072 TRACE("Changing the device window from %p to %p.\n",
5073 current_desc->device_window, device_window);
5074 current_desc->device_window = device_window;
5075 swapchain_state->device_window = device_window;
5077 }
5078
5079 backbuffer_resized = swapchain_desc->backbuffer_width != current_desc->backbuffer_width
5080 || swapchain_desc->backbuffer_height != current_desc->backbuffer_height;
5081 windowed = current_desc->windowed;
5082
5083 if (!swapchain_desc->windowed != !windowed || swapchain->reapply_mode
5084 || mode || (!swapchain_desc->windowed && backbuffer_resized))
5085 {
5086 /* Switch from windowed to fullscreen. */
5087 if (windowed && !swapchain_desc->windowed)
5088 {
5089 HWND focus_window = device->create_parms.focus_window;
5090
5091 if (!focus_window)
5092 focus_window = swapchain->state.device_window;
5094 {
5095 ERR("Failed to acquire focus window, hr %#lx.\n", hr);
5096 return hr;
5097 }
5098 }
5099
5101 swapchain_desc, mode)))
5102 return hr;
5103
5104 /* Switch from fullscreen to windowed. */
5105 if (!windowed && swapchain_desc->windowed)
5107 }
5108 else if (!swapchain_desc->windowed)
5109 {
5110 DWORD style = swapchain_state->style;
5111 DWORD exstyle = swapchain_state->exstyle;
5112 struct wined3d_output_desc output_desc;
5113
5114 /* If we're in fullscreen, and the mode wasn't changed, we have to get
5115 * the window back into the right position. Some applications
5116 * (Battlefield 2, Guild Wars) move it and then call Reset() to clean
5117 * up their mess. Guild Wars also loses the device during that. */
5118 if (FAILED(hr = wined3d_output_get_desc(swapchain_desc->output, &output_desc)))
5119 {
5120 ERR("Failed to get output description, hr %#lx.\n", hr);
5121 return hr;
5122 }
5123
5124 swapchain_state->style = 0;
5125 swapchain_state->exstyle = 0;
5126 wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain_state->device_window,
5127 output_desc.desktop_rect.left, output_desc.desktop_rect.top,
5128 swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height);
5129 swapchain_state->style = style;
5130 swapchain_state->exstyle = exstyle;
5131 }
5132
5133 if (FAILED(hr = wined3d_swapchain_resize_buffers(swapchain, swapchain_desc->backbuffer_count,
5134 swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height, swapchain_desc->backbuffer_format,
5135 swapchain_desc->multisample_type, swapchain_desc->multisample_quality)))
5136 return hr;
5137
5138 if (swapchain_desc->flags != current_desc->flags)
5139 {
5140 current_desc->flags = swapchain_desc->flags;
5141
5143 for (i = 0; i < current_desc->backbuffer_count; ++i)
5144 {
5146 }
5147 }
5148
5149 if ((view = device->auto_depth_stencil_view))
5150 {
5151 device->auto_depth_stencil_view = NULL;
5153 }
5154 if (current_desc->enable_auto_depth_stencil)
5155 {
5156 struct wined3d_resource_desc texture_desc;
5157 struct wined3d_texture *texture;
5158
5159 TRACE("Creating the depth stencil buffer.\n");
5160
5162 texture_desc.format = current_desc->auto_depth_stencil_format;
5163 texture_desc.multisample_type = current_desc->multisample_type;
5164 texture_desc.multisample_quality = current_desc->multisample_quality;
5165 texture_desc.usage = 0;
5167 texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
5168 texture_desc.width = current_desc->backbuffer_width;
5169 texture_desc.height = current_desc->backbuffer_height;
5170 texture_desc.depth = 1;
5171 texture_desc.size = 0;
5172
5173 if (FAILED(hr = wined3d_texture_create(device, &texture_desc, 1, 1, 0,
5175 {
5176 ERR("Failed to create the auto depth/stencil surface, hr %#lx.\n", hr);
5178 }
5179
5180 view_desc.format_id = texture->resource.format->id;
5181 view_desc.flags = 0;
5182 view_desc.u.texture.level_idx = 0;
5183 view_desc.u.texture.level_count = 1;
5184 view_desc.u.texture.layer_idx = 0;
5185 view_desc.u.texture.layer_count = 1;
5186 hr = wined3d_rendertarget_view_create(&view_desc, &texture->resource,
5187 NULL, &wined3d_null_parent_ops, &device->auto_depth_stencil_view);
5189 if (FAILED(hr))
5190 {
5191 ERR("Failed to create rendertarget view, hr %#lx.\n", hr);
5192 return hr;
5193 }
5194 }
5195
5196 if ((view = device->back_buffer_view))
5197 {
5198 device->back_buffer_view = NULL;
5200 }
5201 if (current_desc->backbuffer_count && current_desc->backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
5202 {
5203 struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
5204
5205 view_desc.format_id = back_buffer->format->id;
5206 view_desc.flags = 0;
5207 view_desc.u.texture.level_idx = 0;
5208 view_desc.u.texture.level_count = 1;
5209 view_desc.u.texture.layer_idx = 0;
5210 view_desc.u.texture.layer_count = 1;
5211 if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc, back_buffer,
5212 NULL, &wined3d_null_parent_ops, &device->back_buffer_view)))
5213 {
5214 ERR("Failed to create rendertarget view, hr %#lx.\n", hr);
5215 return hr;
5216 }
5217 }
5218
5223
5224 if (reset_state)
5225 {
5226 TRACE("Resetting state.\n");
5227 if (device->inScene)
5231
5233 {
5234 TRACE("Unloading resource %p.\n", resource);
5236
5237 if (resource->usage & WINED3DUSAGE_MANAGED)
5239 }
5240
5241 device->adapter->adapter_ops->adapter_uninit_3d(device);
5242
5243 wined3d_state_reset(state, &device->adapter->d3d_info);
5244
5248
5249 hr = device->adapter->adapter_ops->adapter_init_3d(device);
5250 }
5251 else
5252 {
5253 if ((view = device->back_buffer_view))
5255 if ((view = device->auto_depth_stencil_view))
5257 }
5258
5259 /* All done. There is no need to reload resources or shaders, this will
5260 * happen automatically on the first use. */
5261 return hr;
5262}
5263
5265{
5266 TRACE("device %p, enable_dialogs %#x.\n", device, enable_dialogs);
5267
5268 if (!enable_dialogs) FIXME("Dialogs cannot be disabled yet.\n");
5269
5270 return WINED3D_OK;
5271}
5272
5273
5276{
5277 TRACE("device %p, parameters %p.\n", device, parameters);
5278
5279 *parameters = device->create_parms;
5280}
5281
5283{
5284 TRACE("device %p.\n", device);
5285
5286 return device->wined3d;
5287}
5288
5290 UINT swapchain_idx, uint32_t flags, const struct wined3d_gamma_ramp *ramp)
5291{
5292 struct wined3d_swapchain *swapchain;
5293
5294 TRACE("device %p, swapchain_idx %u, flags %#x, ramp %p.\n",
5295 device, swapchain_idx, flags, ramp);
5296
5297 if ((swapchain = wined3d_device_get_swapchain(device, swapchain_idx)))
5299}
5300
5302 UINT swapchain_idx, struct wined3d_gamma_ramp *ramp)
5303{
5304 struct wined3d_swapchain *swapchain;
5305
5306 TRACE("device %p, swapchain_idx %u, ramp %p.\n",
5307 device, swapchain_idx, ramp);
5308
5309 if ((swapchain = wined3d_device_get_swapchain(device, swapchain_idx)))
5311}
5312
5314{
5315 TRACE("device_gl %p.\n", device_gl);
5316
5317 if (!device_gl->backup_dc)
5318 {
5319 TRACE("Creating the backup window for device %p.\n", device_gl);
5320
5321 if (!(device_gl->backup_wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
5322 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL)))
5323 {
5324 ERR("Failed to create a window.\n");
5325 return NULL;
5326 }
5327
5328 if (!(device_gl->backup_dc = GetDC(device_gl->backup_wnd)))
5329 {
5330 ERR("Failed to get a DC.\n");
5331 DestroyWindow(device_gl->backup_wnd);
5332 device_gl->backup_wnd = NULL;
5333 return NULL;
5334 }
5335 }
5336
5337 return device_gl->backup_dc;
5338}
5339
5341{
5342 TRACE("device %p, resource %p.\n", device, resource);
5343
5345
5346 list_add_head(&device->resources, &resource->resource_list_entry);
5347}
5348
5350{
5351 TRACE("device %p, resource %p.\n", device, resource);
5352
5354
5355 list_remove(&resource->resource_list_entry);
5356}
5357
5359{
5360 enum wined3d_resource_type type = resource->type;
5361 struct wined3d_state *state = device->cs->c.state;
5362 struct wined3d_rendertarget_view *rtv;
5363 unsigned int i;
5364
5365 TRACE("device %p, resource %p, type %s.\n", device, resource, debug_d3dresourcetype(type));
5366
5367 for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
5368 {
5369 if ((rtv = state->fb.render_targets[i]) && rtv->resource == resource)
5370 ERR("Resource %p is still in use as render target %u.\n", resource, i);
5371 }
5372
5373 if ((rtv = state->fb.depth_stencil) && rtv->resource == resource)
5374 ERR("Resource %p is still in use as depth/stencil buffer.\n", resource);
5375
5376 switch (type)
5377 {
5379 for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
5380 {
5381 if (&state->streams[i].buffer->resource == resource)
5382 {
5383 ERR("Buffer resource %p is still in use, stream %u.\n", resource, i);
5384 state->streams[i].buffer = NULL;
5385 }
5386 }
5387
5388 if (&state->index_buffer->resource == resource)
5389 {
5390 ERR("Buffer resource %p is still in use as index buffer.\n", resource);
5391 state->index_buffer = NULL;
5392 }
5393 break;
5394
5395 default:
5396 break;
5397 }
5398
5399 /* Remove the resource from the resourceStore */
5401
5402 TRACE("Resource released.\n");
5403}
5404
5405static int wined3d_so_desc_compare(const void *key, const struct wine_rb_entry *entry)
5406{
5408 struct wined3d_so_desc_entry, entry)->desc;
5409 const struct wined3d_stream_output_desc *k = key;
5410 unsigned int i;
5411 int ret;
5412
5413 if ((ret = wined3d_uint32_compare(k->element_count, desc->element_count)))
5414 return ret;
5415 if ((ret = wined3d_uint32_compare(k->buffer_stride_count, desc->buffer_stride_count)))
5416 return ret;
5417 if ((ret = wined3d_uint32_compare(k->rasterizer_stream_idx, desc->rasterizer_stream_idx)))
5418 return ret;
5419
5420 for (i = 0; i < k->element_count; ++i)
5421 {
5422 const struct wined3d_stream_output_element *b = &desc->elements[i];
5423 const struct wined3d_stream_output_element *a = &k->elements[i];
5424
5425 if ((ret = wined3d_uint32_compare(a->stream_idx, b->stream_idx)))
5426 return ret;
5427 if ((ret = (!a->semantic_name - !b->semantic_name)))
5428 return ret;
5429 if (a->semantic_name && (ret = strcmp(a->semantic_name, b->semantic_name)))
5430 return ret;
5431 if ((ret = wined3d_uint32_compare(a->semantic_idx, b->semantic_idx)))
5432 return ret;
5433 if ((ret = wined3d_uint32_compare(a->component_idx, b->component_idx)))
5434 return ret;
5435 if ((ret = wined3d_uint32_compare(a->component_count, b->component_count)))
5436 return ret;
5437 if ((ret = wined3d_uint32_compare(a->output_slot, b->output_slot)))
5438 return ret;
5439 }
5440
5441 for (i = 0; i < k->buffer_stride_count; ++i)
5442 {
5443 if ((ret = wined3d_uint32_compare(k->buffer_strides[i], desc->buffer_strides[i])))
5444 return ret;
5445 }
5446
5447 return 0;
5448}
5449
5450static int wined3d_sampler_compare(const void *key, const struct wine_rb_entry *entry)
5451{
5453
5454 return memcmp(&sampler->desc, key, sizeof(sampler->desc));
5455}
5456
5457static int wined3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
5458{
5460
5461 return memcmp(&state->desc, key, sizeof(state->desc));
5462}
5463
5464static int wined3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
5465{
5467
5468 return memcmp(&state->desc, key, sizeof(state->desc));
5469}
5470
5471static int wined3d_depth_stencil_state_compare(const void *key, const struct wine_rb_entry *entry)
5472{
5475
5476 return memcmp(&state->desc, key, sizeof(state->desc));
5477}
5478
5480 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
5481 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
5482 const BOOL *supported_extensions, struct wined3d_device_parent *device_parent)
5483{
5484 struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx];
5485 const struct wined3d_fragment_pipe_ops *fragment_pipeline;
5486 const struct wined3d_vertex_pipe_ops *vertex_pipeline;
5487 unsigned int i;
5488 HRESULT hr;
5489
5490 device->ref = 1;
5491 device->wined3d = wined3d;
5492 wined3d_incref(device->wined3d);
5493 device->adapter = adapter;
5494 device->device_parent = device_parent;
5495 list_init(&device->resources);
5496 list_init(&device->shaders);
5497 device->surface_alignment = surface_alignment;
5498
5499 /* Save the creation parameters. */
5500 device->create_parms.adapter_idx = adapter_idx;
5501 device->create_parms.device_type = device_type;
5502 device->create_parms.focus_window = focus_window;
5503 device->create_parms.flags = flags;
5504
5505 device->shader_backend = adapter->shader_backend;
5506
5507 vertex_pipeline = adapter->vertex_pipe;
5508
5509 fragment_pipeline = adapter->fragment_pipe;
5510
5518
5519 if (vertex_pipeline->vp_states && fragment_pipeline->states
5520 && FAILED(hr = compile_state_table(device->state_table, device->multistate_funcs,
5521 &adapter->d3d_info, supported_extensions, vertex_pipeline,
5522 fragment_pipeline, adapter->misc_state_template)))
5523 {
5524 ERR("Failed to compile state table, hr %#lx.\n", hr);
5525 wine_rb_destroy(&device->samplers, NULL, NULL);
5526 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
5527 wine_rb_destroy(&device->blend_states, NULL, NULL);
5528 wine_rb_destroy(&device->depth_stencil_states, NULL, NULL);
5529 wine_rb_destroy(&device->so_descs, NULL, NULL);
5530 wine_rb_destroy(&device->ffp_vertex_shaders, NULL, NULL);
5531 wine_rb_destroy(&device->ffp_pixel_shaders, NULL, NULL);
5532 wined3d_decref(device->wined3d);
5533 return hr;
5534 }
5535
5536 device->max_frame_latency = 3;
5537
5538 if (!(device->cs = wined3d_cs_create(device, levels, level_count)))
5539 {
5540 WARN("Failed to create command stream.\n");
5541 hr = E_FAIL;
5542 goto err;
5543 }
5544
5545 wined3d_lock_init(&device->bo_map_lock, "wined3d_device.bo_map_lock");
5546
5547 return WINED3D_OK;
5548
5549err:
5550 for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
5551 {
5552 free(device->multistate_funcs[i]);
5553 }
5554 wine_rb_destroy(&device->samplers, NULL, NULL);
5555 wine_rb_destroy(&device->rasterizer_states, NULL, NULL);
5556 wine_rb_destroy(&device->blend_states, NULL, NULL);
5557 wine_rb_destroy(&device->depth_stencil_states, NULL, NULL);
5558 wine_rb_destroy(&device->so_descs, NULL, NULL);
5559 wine_rb_destroy(&device->ffp_vertex_shaders, NULL, NULL);
5560 wine_rb_destroy(&device->ffp_pixel_shaders, NULL, NULL);
5561 wined3d_decref(device->wined3d);
5562 return hr;
5563}
5564
5565void device_invalidate_state(const struct wined3d_device *device, unsigned int state_id)
5566{
5567 unsigned int representative, i, idx, shift;
5568 struct wined3d_context *context;
5569
5571
5572 if (STATE_IS_COMPUTE(state_id))
5573 {
5574 for (i = 0; i < device->context_count; ++i)
5575 context_invalidate_compute_state(device->contexts[i], state_id);
5576 return;
5577 }
5578
5579 representative = device->state_table[state_id].representative;
5580 idx = representative / (sizeof(*context->dirty_graphics_states) * CHAR_BIT);
5581 shift = representative & ((sizeof(*context->dirty_graphics_states) * CHAR_BIT) - 1);
5582 for (i = 0; i < device->context_count; ++i)
5583 {
5584 device->contexts[i]->dirty_graphics_states[idx] |= (1u << shift);
5585 }
5586}
5587
5590{
5591 if (message == WM_DESTROY)
5592 {
5593 TRACE("unregister window %p.\n", window);
5595
5596 if (InterlockedCompareExchangePointer((void **)&device->focus_window, NULL, window) != window)
5597 ERR("Window %p is not the focus window for device %p.\n", window, device);
5598 }
5599 else if (message == WM_DISPLAYCHANGE)
5600 {
5601 device->device_parent->ops->mode_changed(device->device_parent);
5602 }
5603 else if (message == WM_ACTIVATEAPP)
5604 {
5605 unsigned int i = device->swapchain_count;
5606
5607 /* Deactivating the implicit swapchain may cause the application
5608 * (e.g. Deus Ex: GOTY) to destroy the device, so take care to
5609 * deactivate the implicit swapchain last, and to avoid accessing the
5610 * "device" pointer afterwards. */
5611 while (i--)
5613 }
5614 else if (message == WM_SYSCOMMAND)
5615 {
5616 if (wparam == SC_RESTORE && device->wined3d->flags & WINED3D_HANDLE_RESTORE)
5617 {
5618 if (unicode)
5620 else
5622 }
5623 }
5624
5625 if (unicode)
5627 else
5629}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
static struct myctx * mcs
Definition: adnstest.c:53
static int state
Definition: maze.c:121
unsigned int dir
Definition: maze.c:112
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
void ls(int argc, const char *argv[])
Definition: cmds.c:1136
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
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
Definition: list.h:39
Definition: _map.h:48
RECT rect
Definition: combotst.c:67
void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name)
Definition: context_gl.c:2497
void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl)
Definition: context_gl.c:1790
void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2653
void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id)
Definition: context_gl.c:2629
GLuint wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl *context_gl, unsigned int pool, size_t size)
Definition: context_gl.c:2707
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2308
void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context_gl.c:2489
BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
Definition: context_vk.c:528
void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk, VkBufferView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:931
void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk, VkImageView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:956
void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image)
Definition: context_vk.c:1092
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1805
void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const struct wined3d_bo_vk *bo)
Definition: context_vk.c:1106
BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type, VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, struct wined3d_image_vk *image)
Definition: context_vk.c:610
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range)
Definition: context_vk.c:2022
void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_shader_resource_view *const *views)
Definition: cs.c:1659
void wined3d_cs_destroy(struct wined3d_cs *cs)
Definition: cs.c:3657
void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context *context, struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav)
Definition: cs.c:2881
void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context *context, enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, struct wined3d_unordered_access_view *const *views, const unsigned int *initial_counts)
Definition: cs.c:1701
void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context, struct wined3d_shader_resource_view *view)
Definition: cs.c:2908
void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, struct wined3d_rendertarget_view *const *views)
Definition: cs.c:1343
void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration)
Definition: cs.c:1414
void wined3d_device_context_emit_clear_uav(struct wined3d_device_context *context, struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value, bool fp)
Definition: cs.c:2854
void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: cs.c:2766
void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context, const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS])
Definition: cs.c:1481
void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context *context, enum wined3d_feature_level level)
Definition: cs.c:2129
void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource)
Definition: cs.c:2440
void wined3d_device_context_emit_draw(struct wined3d_device_context *context, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count, int base_vertex_idx, unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count, bool indexed)
Definition: cs.c:1166
void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state)
Definition: cs.c:1849
void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context *context, struct wined3d_depth_stencil_state *state, unsigned int stencil_ref)
Definition: cs.c:1828
void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: cs.c:2703
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2299
void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
Definition: cs.c:1446
void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects, uint32_t flags, const struct wined3d_color *color, float depth, DWORD stencil)
Definition: cs.c:804
void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
Definition: cs.c:1511
void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, const struct wined3d_constant_buffer_state *buffers)
Definition: cs.c:1546
void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, const struct wined3d_viewport *viewports)
Definition: cs.c:1270
void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context *context, struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags, const struct wined3d_color *color, float depth, unsigned int stencil)
Definition: cs.c:844
HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: cs.c:2541
void wined3d_device_context_emit_set_predication(struct wined3d_device_context *context, struct wined3d_query *predicate, BOOL value)
Definition: cs.c:1245
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate)
Definition: cs.c:2269
void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context, struct wined3d_blend_state *state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
Definition: cs.c:1800
void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context, struct wined3d_rendertarget_view *view)
Definition: cs.c:1394
struct wined3d_cs * wined3d_cs_create(struct wined3d_device *device, const enum wined3d_feature_level *levels, unsigned int level_count)
Definition: cs.c:3561
HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
Definition: cs.c:2488
void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader)
Definition: cs.c:1768
void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, const RECT *rects)
Definition: cs.c:1296
void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
Definition: cs.c:1737
void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context *context, struct wined3d_command_list *list, bool restore_state)
Definition: cs.c:2994
range
Definition: d3dx9_private.h:58
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
Definition: utils.c:1153
#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
device_type
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
static void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_colour, D3DCOLOR d3d_colour)
Definition: device.c:34
ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
Definition: buffer.c:248
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
Definition: buffer.c:459
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:66
void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info, const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
Definition: context.c:160
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
static struct wined3d_texture * wined3d_device_create_cursor_texture(struct wined3d_device *device, struct wined3d_texture *cursor_image, unsigned int sub_resource_idx)
Definition: device.c:4709
void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state)
Definition: device.c:2101
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
void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_context *context, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref)
Definition: device.c:2077
static void device_leftover_rasterizer_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:184
static bool depth_stencil_state_desc_writes_ds(const struct wined3d_depth_stencil_state_desc *desc)
Definition: device.c:390
void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software)
Definition: device.c:4025
static void wined3d_vec3_normalise(struct wined3d_vec3 *v)
Definition: device.c:2879
struct wined3d_depth_stencil_state *CDECL wined3d_device_context_get_depth_stencil_state(const struct wined3d_device_context *context, unsigned int *stencil_ref)
Definition: device.c:1871
void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader)
Definition: device.c:1984
void CDECL wined3d_device_context_clear_uav_uint(struct wined3d_device_context *context, struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value)
Definition: device.c:4525
struct wined3d_shader *CDECL wined3d_device_context_get_shader(const struct wined3d_device_context *context, enum wined3d_shader_type type)
Definition: device.c:2007
HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
Definition: device.c:1537
#define copy_and_next(dest, src, size)
Definition: device.c:3275
void CDECL wined3d_device_get_creation_parameters(const struct wined3d_device *device, struct wined3d_device_creation_parameters *parameters)
Definition: device.c:5274
BOOL CDECL wined3d_device_get_software_vertex_processing(const struct wined3d_device *device)
Definition: device.c:4040
ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state)
Definition: device.c:268
ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state *state)
Definition: device.c:359
static unsigned int wined3d_get_flexible_vertex_size(uint32_t fvf)
Definition: device.c:2734
static void update_swapchain_flags(struct wined3d_texture *texture)
Definition: device.c:4955
void CDECL wined3d_device_set_max_frame_latency(struct wined3d_device *device, unsigned int latency)
Definition: device.c:2717
HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
Definition: device.c:1133
HRESULT CDECL wined3d_device_get_clip_status(const struct wined3d_device *device, struct wined3d_clip_status *clip_status)
Definition: device.c:1820
static struct wined3d_allocator_block * wined3d_device_gl_allocate_memory(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl, unsigned int memory_type, GLsizeiptr size, GLuint *id)
Definition: device.c:1279
struct wined3d_sampler *CDECL wined3d_device_context_get_sampler(const struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int idx)
Definition: device.c:2689
GLbitfield wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx)
Definition: device.c:1274
void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context *context, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
Definition: device.c:2050
struct wined3d_rasterizer_state *CDECL wined3d_device_context_get_rasterizer_state(struct wined3d_device_context *context)
Definition: device.c:1882
HDC wined3d_device_gl_get_backup_dc(struct wined3d_device_gl *device_gl)
Definition: device.c:5313
struct wined3d_buffer *CDECL wined3d_device_context_get_index_buffer(const struct wined3d_device_context *context, enum wined3d_format_id *format, unsigned int *offset)
Definition: device.c:1831
static unsigned int wined3d_device_gl_find_memory_type(GLbitfield flags)
Definition: device.c:1260
static struct wined3d_allocator_chunk * wined3d_allocator_gl_create_chunk(struct wined3d_allocator *allocator, struct wined3d_context *context, unsigned int memory_type, size_t chunk_size)
Definition: device.c:1181
static void device_free_so_desc(struct wine_rb_entry *entry, void *context)
Definition: device.c:170
void wined3d_device_gl_delete_opengl_contexts_cs(void *object)
Definition: device.c:1431
static void device_leftover_depth_stencil_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:198
HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: device.c:4627
static void wined3d_color_clamp(struct wined3d_color *dst, const struct wined3d_color *src, float min_value, float max_value)
Definition: device.c:2899
void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, enum wined3d_format_id format_id)
Definition: device.c:4417
static bool is_dual_source(enum wined3d_blend state)
Definition: device.c:308
static void wined3d_blend_state_destroy_object(void *object)
Definition: device.c:277
static void device_free_ffp_vertex_shader(struct wine_rb_entry *entry, void *context)
Definition: device.c:1646
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
void CDECL wined3d_device_set_cursor_position(struct wined3d_device *device, int x_screen_space, int y_screen_space, uint32_t flags)
Definition: device.c:4845
void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device)
Definition: device.c:4923
void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration)
Definition: device.c:2588
void CDECL wined3d_device_context_clear_uav_float(struct wined3d_device_context *context, struct wined3d_unordered_access_view *view, const struct wined3d_vec4 *clear_value)
Definition: device.c:4509
static void device_free_blend_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:1632
struct wined3d_rendertarget_view *CDECL wined3d_device_context_get_depth_stencil_view(const struct wined3d_device_context *context)
Definition: device.c:4676
HRESULT CDECL wined3d_device_set_clip_status(struct wined3d_device *device, const struct wined3d_clip_status *clip_status)
Definition: device.c:1809
HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
Definition: device.c:4570
void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_shader_resource_view *const *const views)
Definition: device.c:2181
struct wined3d_query *CDECL wined3d_device_context_get_predication(struct wined3d_device_context *context, BOOL *value)
Definition: device.c:3768
static void wined3d_format_get_colour(const struct wined3d_format *format, const void *data, struct wined3d_color *colour)
Definition: device.c:2763
HRESULT CDECL wined3d_device_context_copy_sub_resource_region(struct wined3d_device_context *context, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags)
Definition: device.c:4220
HRESULT CDECL wined3d_rasterizer_state_create(struct wined3d_device *device, const struct wined3d_rasterizer_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rasterizer_state **state)
Definition: device.c:470
struct wined3d_state *CDECL wined3d_device_get_state(struct wined3d_device *device)
Definition: device.c:1962
static void mark_managed_resource_dirty(struct wined3d_resource *resource)
Definition: device.c:4908
bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
Definition: device.c:839
void wined3d_device_destroy_default_samplers(struct wined3d_device *device)
Definition: device.c:784
UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device *device)
Definition: device.c:1754
static float wined3d_clamp(float value, float min_value, float max_value)
Definition: device.c:2855
HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
Definition: device.c:2510
static void update_fog_factor(float *fog_factor, struct lights_settings *ls)
Definition: device.c:3249
HRESULT CDECL wined3d_device_context_get_stream_source(const struct wined3d_device_context *context, unsigned int stream_idx, struct wined3d_buffer **buffer, unsigned int *offset, unsigned int *stride)
Definition: device.c:1786
static HRESULT process_vertices_strided(const struct wined3d_device *device, const struct wined3d_stateblock_state *state, DWORD dwDestIndex, DWORD dwCount, const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, uint32_t flags, uint32_t dst_fvf)
Definition: device.c:3276
struct wined3d_unordered_access_view *CDECL wined3d_device_context_get_unordered_access_view(const struct wined3d_device_context *context, enum wined3d_pipeline pipeline, unsigned int idx)
Definition: device.c:2703
void CDECL wined3d_device_context_execute_command_list(struct wined3d_device_context *context, struct wined3d_command_list *list, bool restore_state)
Definition: device.c:4649
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
static void update_light_diffuse_specular(struct wined3d_color *diffuse, struct wined3d_color *specular, const struct wined3d_vec3 *dir, float att, float material_shininess, const struct wined3d_vec3 *normal_transformed, const struct wined3d_vec3 *position_transformed_normalised, const struct light_transformed *light, const struct lights_settings *ls)
Definition: device.c:3067
void *CDECL wined3d_blend_state_get_parent(const struct wined3d_blend_state *state)
Definition: device.c:301
static void wined3d_depth_stencil_state_destroy_object(void *object)
Definition: device.c:352
void CDECL wined3d_device_context_generate_mipmaps(struct wined3d_device_context *context, struct wined3d_shader_resource_view *view)
Definition: device.c:4684
HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d, unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count, const BOOL *supported_extensions, struct wined3d_device_parent *device_parent)
Definition: device.c:5479
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
BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:84
HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode, wined3d_device_reset_cb callback, BOOL reset_state)
Definition: device.c:4970
HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device, UINT x_hotspot, UINT y_hotspot, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: device.c:4752
void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, const struct wined3d_constant_buffer_state *buffers)
Definition: device.c:2015
HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device, struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture)
Definition: device.c:3808
struct wined3d_rendertarget_view *CDECL wined3d_device_context_get_rendertarget_view(const struct wined3d_device_context *context, unsigned int view_idx)
Definition: device.c:4659
void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, const struct wined3d_viewport *viewports)
Definition: device.c:2124
unsigned int CDECL wined3d_device_get_max_frame_latency(const struct wined3d_device *device)
Definition: device.c:2729
void CDECL wined3d_device_context_get_primitive_type(const struct wined3d_device_context *context, enum wined3d_primitive_type *primitive_type, unsigned int *patch_vertex_count)
Definition: device.c:3793
void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource)
Definition: device.c:5340
HRESULT CDECL wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs)
Definition: device.c:5264
void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device)
Definition: device.c:1746
void device_invalidate_state(const struct wined3d_device *device, unsigned int state_id)
Definition: device.c:5565
float CDECL wined3d_device_get_npatch_mode(const struct wined3d_device *device)
Definition: device.c:4087
static void wined3d_vec3_transform(struct wined3d_vec3 *dst, const struct wined3d_vec3 *v, const struct wined3d_matrix *m)
Definition: device.c:2887
void CDECL wined3d_device_context_flush(struct wined3d_device_context *context)
Definition: device.c:4946
void wined3d_device_uninit_3d(struct wined3d_device *device)
Definition: device.c:1662
void CDECL wined3d_device_set_gamma_ramp(const struct wined3d_device *device, UINT swapchain_idx, uint32_t flags, const struct wined3d_gamma_ramp *ramp)
Definition: device.c:5289
static void light_set_vertex_data(struct lights_settings *ls, const struct wined3d_vec4 *position)
Definition: device.c:3091
HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
Definition: device.c:3715
static void wined3d_device_gl_create_dummy_textures(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl)
Definition: device.c:572
void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
Definition: device.c:1114
HRESULT CDECL wined3d_device_context_clear_rendertarget_view(struct wined3d_device_context *context, struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags, const struct wined3d_color *color, float depth, unsigned int stencil)
Definition: device.c:4468
static void wined3d_rasterizer_state_destroy_object(void *object)
Definition: device.c:439
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
void CDECL wined3d_device_context_update_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int depth_pitch, unsigned int flags)
Definition: device.c:4376
void CDECL wined3d_device_context_copy_uav_counter(struct wined3d_device_context *context, struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav)
Definition: device.c:4102
struct wined3d_device_context *CDECL wined3d_device_get_immediate_context(struct wined3d_device *device)
Definition: device.c:1969
void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
Definition: device.c:910
BOOL CDECL wined3d_device_show_cursor(struct wined3d_device *device, BOOL show)
Definition: device.c:4874
static int wined3d_depth_stencil_state_compare(const void *key, const struct wine_rb_entry *entry)
Definition: device.c:5471
void *CDECL wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_stencil_state *state)
Definition: device.c:376
ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state)
Definition: device.c:284
static unsigned int sanitise_map_flags(const struct wined3d_resource *resource, unsigned int flags)
Definition: device.c:4535
void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context, enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, struct wined3d_unordered_access_view *const *uavs, const unsigned int *initial_counts)
Definition: device.c:2277
static float wined3d_calculate_fog_factor(float fog_coord, const struct lights_settings *ls)
Definition: device.c:3231
void wined3d_device_cleanup(struct wined3d_device *device)
Definition: device.c:205
void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
Definition: device.c:1154
void device_context_remove(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:118
void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
Definition: device.c:2243
HRESULT CDECL wined3d_blend_state_create(struct wined3d_device *device, const struct wined3d_blend_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state)
Definition: device.c:313
ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *state)
Definition: device.c:430
static int wined3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry)
Definition: device.c:5464
static void wined3d_color_rgb_mul_add(struct wined3d_color *dst, const struct wined3d_color *src, float c)
Definition: device.c:2908
static void wined3d_vec3_subtract(struct wined3d_vec3 *v0, const struct wined3d_vec3 *v1)
Definition: device.c:2865
bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
Definition: device.c:929
HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device, const struct wined3d_depth_stencil_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state)
Definition: device.c:404
static void device_resource_remove(struct wined3d_device *device, struct wined3d_resource *resource)
Definition: device.c:5349
const struct wined3d_light WINED3D_default_light
Definition: device.c:69
ULONG CDECL wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state *state)
Definition: device.c:343
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, const struct wined3d_stateblock_state *state, DWORD *num_passes)
Definition: device.c:3963
ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state)
Definition: device.c:446
static int wined3d_so_desc_compare(const void *key, const struct wine_rb_entry *entry)
Definition: device.c:5405
static void device_free_depth_stencil_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:1639
void CDECL wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state)
Definition: device.c:1915
static bool use_buffer_chunk_suballocation(struct wined3d_device_gl *device_gl, const struct wined3d_gl_info *gl_info, GLenum binding)
Definition: device.c:1309
struct wined3d_swapchain *CDECL wined3d_device_get_swapchain(const struct wined3d_device *device, UINT swapchain_idx)
Definition: device.c:501
static void device_free_ffp_pixel_shader(struct wine_rb_entry *entry, void *context)
Definition: device.c:1654
static void device_free_sampler(struct wine_rb_entry *entry, void *context)
Definition: device.c:1618
struct wined3d_buffer *CDECL wined3d_device_context_get_stream_output(struct wined3d_device_context *context, unsigned int idx, unsigned int *offset)
Definition: device.c:1770
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
bool wined3d_device_gl_create_bo(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo)
Definition: device.c:1335
struct wined3d *CDECL wined3d_device_get_wined3d(const struct wined3d_device *device)
Definition: device.c:5282
static void device_leftover_sampler(struct wine_rb_entry *entry, void *context)
Definition: device.c:177
void CDECL wined3d_device_context_reset_state(struct wined3d_device_context *context)
Definition: device.c:1904
static void wined3d_device_gl_destroy_dummy_textures(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl)
Definition: device.c:698
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource)
Definition: device.c:5358
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps)
Definition: device.c:3679
void CDECL wined3d_device_context_issue_query(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags)
Definition: device.c:4639
struct wined3d_vertex_declaration *CDECL wined3d_device_context_get_vertex_declaration(const struct wined3d_device_context *context)
Definition: device.c:1976
static const struct @334 gl_memory_types[]
void CDECL wined3d_device_context_set_render_targets_and_unordered_access_views(struct wined3d_device_context *context, unsigned int rtv_count, struct wined3d_rendertarget_view *const *render_target_views, struct wined3d_rendertarget_view *depth_stencil_view, UINT uav_count, struct wined3d_unordered_access_view *const *unordered_access_views, const unsigned int *initial_counts)
Definition: device.c:2313
static void device_load_logo(struct wined3d_device *device, const char *filename)
Definition: device.c:515
void CDECL wined3d_device_context_copy_resource(struct wined3d_device_context *context, struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource)
Definition: device.c:4131
static bool wined3d_null_image_vk_init(struct wined3d_image_vk *image, struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkImageType type, unsigned int layer_count, unsigned int sample_count)
Definition: device.c:792
void CDECL wined3d_device_get_gamma_ramp(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_gamma_ramp *ramp)
Definition: device.c:5301
static bool resources_format_compatible(const struct wined3d_resource *src_resource, const struct wined3d_resource *dst_resource)
Definition: device.c:4113
static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
Definition: device.c:1167
void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_context *context, const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS])
Definition: device.c:2611
static void wined3d_device_context_unbind_srv_for_rtv(struct wined3d_device_context *context, const struct wined3d_rendertarget_view *view, BOOL dsv)
Definition: device.c:2344
LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc)
Definition: device.c:5588
struct wined3d_shader_resource_view *CDECL wined3d_device_context_get_shader_resource_view(const struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int idx)
Definition: device.c:2677
void *CDECL wined3d_rasterizer_state_get_parent(const struct wined3d_rasterizer_state *state)
Definition: device.c:463
static const struct wined3d_allocator_ops wined3d_allocator_gl_ops
Definition: device.c:1237
ULONG CDECL wined3d_device_incref(struct wined3d_device *device)
Definition: device.c:161
struct wined3d_blend_state *CDECL wined3d_device_context_get_blend_state(const struct wined3d_device_context *context, struct wined3d_color *blend_factor, unsigned int *sample_mask)
Definition: device.c:1859
void CDECL wined3d_device_context_set_predication(struct wined3d_device_context *context, struct wined3d_query *predicate, BOOL value)
Definition: device.c:2487
static void wined3d_colour_from_mcs(struct wined3d_color *colour, enum wined3d_material_color_source mcs, const struct wined3d_color *material_colour, unsigned int index, const struct wined3d_stream_info *stream_info)
Definition: device.c:2816
static void init_transformed_lights(struct lights_settings *ls, const struct wined3d_stateblock_state *state, BOOL legacy_lighting, BOOL compute_lighting)
Definition: device.c:2915
static void wined3d_vec3_scale(struct wined3d_vec3 *v, float s)
Definition: device.c:2872
static int wined3d_sampler_compare(const void *key, const struct wine_rb_entry *entry)
Definition: device.c:5450
HRESULT CDECL wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: device.c:3686
HRESULT CDECL wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments)
Definition: device.c:4069
static void wined3d_allocator_gl_destroy_chunk(struct wined3d_allocator_chunk *chunk)
Definition: device.c:1214
static void device_free_rasterizer_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:1625
static int wined3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
Definition: device.c:5457
UINT CDECL wined3d_device_get_swapchain_count(const struct wined3d_device *device)
Definition: device.c:494
HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device)
Definition: device.c:3700
static void compute_light(struct wined3d_color *ambient, struct wined3d_color *diffuse, struct wined3d_color *specular, struct lights_settings *ls, const struct wined3d_vec3 *normal, float material_shininess)
Definition: device.c:3101
HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_device_context *context, struct wined3d_rendertarget_view *view)
Definition: device.c:2453
HRESULT CDECL wined3d_device_get_raster_status(const struct wined3d_device *device, UINT swapchain_idx, struct wined3d_raster_status *raster_status)
Definition: device.c:4055
void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, const RECT *rects)
Definition: device.c:2149
static float wined3d_vec3_dot(const struct wined3d_vec3 *v0, const struct wined3d_vec3 *v1)
Definition: device.c:2860
HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, struct wined3d_stateblock *stateblock, UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer, const struct wined3d_vertex_declaration *declaration, uint32_t flags, uint32_t dst_fvf)
Definition: device.c:3598
static void device_leftover_blend_state(struct wine_rb_entry *entry, void *context)
Definition: device.c:191
void wined3d_device_gl_create_primary_opengl_context_cs(void *object)
Definition: device.c:1476
static bool stencil_op_writes_ds(const struct wined3d_stencil_op_desc *desc)
Definition: device.c:383
void CDECL wined3d_device_context_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
Definition: device.c:2557
void wined3d_device_create_default_samplers(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:737
void CDECL wined3d_device_context_get_constant_buffer(const struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int idx, struct wined3d_constant_buffer_state *state)
Definition: device.c:2663
ULONG CDECL wined3d_query_incref(struct wined3d_query *query)
Definition: query.c:413
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
Definition: query.c:432
HRESULT wined3d_resource_check_box_dimensions(struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box)
Definition: resource.c:488
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: resource.c:304
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
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:2535
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:2588
struct wined3d_blitter * wined3d_cpu_blitter_create(void)
Definition: surface.c:1300
HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc)
Definition: texture.c:4243
HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture, uint32_t flags, const struct wined3d_color_key *color_key)
Definition: texture.c:1753
void wined3d_fbo_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
Definition: texture.c:6105
void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture)
Definition: texture.c:753
HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, uint32_t flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
Definition: texture.c:4158
HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture, UINT layer, const struct wined3d_box *dirty_region)
Definition: texture.c:2132
bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:50
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1606
HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC dc)
Definition: texture.c:4291
void wined3d_raw_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
Definition: texture.c:6262
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
void wined3d_ffp_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
Definition: texture.c:5995
struct wined3d_allocator_block * wined3d_allocator_allocate(struct wined3d_allocator *allocator, struct wined3d_context *context, unsigned int memory_type, size_t size)
Definition: utils.c:7234
bool wined3d_allocator_init(struct wined3d_allocator *allocator, size_t pool_count, const struct wined3d_allocator_ops *allocator_ops)
Definition: utils.c:7265
void wined3d_allocator_cleanup(struct wined3d_allocator *allocator)
Definition: utils.c:7163
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6658
const char * wined3d_debug_bind_flags(uint32_t bind_flags)
Definition: utils.c:4845
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:4552
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
void compute_normal_matrix(struct wined3d_matrix *normal_matrix, BOOL legacy_lighting, const struct wined3d_matrix *modelview)
Definition: utils.c:7042
unsigned int idx
Definition: utils.c:40
const char * debug_vec4(const struct wined3d_vec4 *v)
Definition: utils.c:4585
const char * debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type)
Definition: utils.c:5009
const char * wined3d_debug_vkresult(VkResult vr)
Definition: utils.c:5463
void wined3d_format_convert_from_float(const struct wined3d_format *format, const struct wined3d_color *color, void *ret)
Definition: utils.c:5817
const char * debug_uvec4(const struct wined3d_uvec4 *v)
Definition: utils.c:4577
int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry)
Definition: utils.c:6436
bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk *chunk, struct wined3d_allocator *allocator)
Definition: utils.c:7141
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4992
const struct wined3d_format * wined3d_get_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id, unsigned int bind_flags)
Definition: utils.c:4428
void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk *chunk)
Definition: utils.c:7117
const char * debug_color(const struct wined3d_color *color)
Definition: utils.c:4561
int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry)
Definition: utils.c:6579
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
Definition: view.c:1536
ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view)
Definition: view.c:965
HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
Definition: view.c:933
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
Definition: view.c:365
ULONG CDECL wined3d_unordered_access_view_incref(struct wined3d_unordered_access_view *view)
Definition: view.c:1522
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
Definition: view.c:379
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
Definition: view.c:990
#define CHAR_BIT
Definition: cabinet.h:45
#define CDECL
Definition: compat.h:29
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define UINT_MAX
Definition: limits.h:27
_ACRTIMP float __cdecl powf(float, float)
Definition: powf.c:14
#define isfinite(x)
Definition: math.h:363
_ACRTIMP float __cdecl cosf(float)
Definition: cosf.c:13
_ACRTIMP float __cdecl fabsf(float)
_ACRTIMP float __cdecl expf(float)
unsigned short uint16_t
Definition: stdint.h:35
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static unsigned int box_count(struct histogram *h, struct box *b)
Definition: palette.c:512
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
return ret
Definition: mutex.c:147
r parent
Definition: btrfs.c:3010
#define ULONG_PTR
Definition: config.h:101
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs, const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions, const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment, const struct wined3d_state_entry_template *misc)
Definition: ffp_gl.c:1666
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
return adapter
pKey DeleteObject()
#define GL_TRUE
Definition: gl.h:174
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
Definition: gl.h:1795
#define GL_RGBA8
Definition: gl.h:762
unsigned int GLbitfield
Definition: gl.h:152
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int GLenum
Definition: gl.h:150
GLdouble s
Definition: gl.h:2039
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_3D
Definition: gl.h:1515
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLAPI void GLAPIENTRY glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_RGBA
Definition: gl.h:503
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X
Definition: gl.h:1790
#define GL_FALSE
Definition: gl.h:173
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GL_UNSIGNED_INT_8_8_8_8
Definition: gl.h:1494
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_MAP_READ_BIT
Definition: glext.h:1793
GLenum GLuint texture
Definition: glext.h:6295
GLsizei stride
Definition: glext.h:5848
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glext.h:2297
#define GL_BUFFER_SERIALIZED_MODIFY_APPLE
Definition: glext.h:4547
#define GL_UNIFORM_BUFFER
Definition: glext.h:1846
GLuint * samplers
Definition: glext.h:7280
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 GLuint * textures
Definition: glext.h:8098
const GLubyte * c
Definition: glext.h:8905
GLuint sampler
Definition: glext.h:7283
GLuint shader
Definition: glext.h:6030
GLuint index
Definition: glext.h:6031
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define GL_ARRAY_BUFFER
Definition: glext.h:336
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
GLenum mode
Definition: glext.h:6217
GLenum GLenum dst
Definition: glext.h:6340
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
GLbitfield flags
Definition: glext.h:7161
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define GL_MAP_WRITE_BIT
Definition: glext.h:1794
GLsizei levels
Definition: glext.h:7884
GLfloat v0
Definition: glext.h:6061
ptrdiff_t GLsizeiptr
Definition: glext.h:5499
GLfloat GLfloat p
Definition: glext.h:8902
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_BUFFER_FLUSHING_UNMAP_APPLE
Definition: glext.h:4548
#define GL_STATIC_DRAW
Definition: glext.h:350
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
const GLuint * buffers
Definition: glext.h:5916
GLfloat GLfloat v1
Definition: glext.h:6062
#define GL_ELEMENT_ARRAY_BUFFER
Definition: glext.h:337
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
GLuint id
Definition: glext.h:5910
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLdouble GLdouble z
Definition: glext.h:5874
#define GL_DRAW_INDIRECT_BUFFER
Definition: glext.h:2046
const GLfloat * m
Definition: glext.h:10848
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
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 * u
Definition: glfuncs.h:240
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 light
Definition: glfuncs.h:170
struct wined3d_blitter * wined3d_glsl_blitter_create(struct wined3d_blitter **next, const struct wined3d_device *device)
unsigned int UINT
Definition: sysinfo.c:13
#define ds
Definition: i386-dis.c:443
const char cursor[]
Definition: icontest.c:13
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
uint32_t entry
Definition: isohybrid.c:63
#define e
Definition: ke_i.h:82
#define c
Definition: ke_i.h:80
#define b
Definition: ke_i.h:79
#define resource
Definition: kernel32.h:9
if(dx< 0)
Definition: linetemp.h:194
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static IPrintDialogCallback callback
Definition: printdlg.c:325
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
float specular[3]
Definition: d3drm.c:3534
int vertex_count
Definition: d3drm.c:3528
static const BYTE ramp[17]
Definition: dib.c:2957
static const MAT2 mat
Definition: font.c:51
static char memory[1024 *256]
Definition: process.c:122
static IHTMLWindow2 * window
Definition: events.c:77
static char * dest
Definition: rtl.c:149
static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
static RPC_BINDING_HANDLE binding
Definition: server.c:166
static vector_t * vs
Definition: server.c:146
static float(__cdecl *square_half_float)(float x
static UINT format_id
Definition: clipboard.c:1455
#define shift
Definition: input.c:3280
static BYTE parameters[]
Definition: asn.c:558
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define sqrtf(x)
Definition: mymath.h:59
direction
Definition: netio.c:882
#define DWORD
Definition: nt_native.h:44
@ normal
Definition: optimize.h:166
static HANDLE proc()
Definition: pdb.c:32
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define WM_SYSCOMMAND
Definition: winuser.h:1769
#define IMAGE_BITMAP
Definition: winuser.h:211
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2985
BOOL WINAPI DestroyCursor(_In_ HCURSOR)
Definition: cursoricon.c:3093
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LR_LOADFROMFILE
Definition: winuser.h:1103
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define LR_CREATEDIBSECTION
Definition: winuser.h:1109
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SPI_SETSCREENSAVEACTIVE
Definition: winuser.h:1377
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3074
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SWP_NOSIZE
Definition: winuser.h:1256
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:3066
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2547
#define WM_ACTIVATEAPP
Definition: winuser.h:1660
#define WM_DESTROY
Definition: winuser.h:1637
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SC_RESTORE
Definition: winuser.h:2634
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SPI_GETSCREENSAVEACTIVE
Definition: winuser.h:1376
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define err(...)
#define calloc
Definition: rosglue.h:14
ULONG CDECL wined3d_sampler_incref(struct wined3d_sampler *sampler)
Definition: sampler.c:26
HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler)
Definition: sampler.c:287
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:35
#define ERR_(ch,...)
Definition: debug.h:156
#define WARN_(ch,...)
Definition: debug.h:157
int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:160
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
#define wine_rb_entry
Definition: rbtree.h:404
#define WINE_RB_ENTRY_VALUE
Definition: rbtree.h:414
#define RB_FOR_EACH_ENTRY(elem, tree, type, field)
Definition: rbtree.h:148
#define wine_rb_init
Definition: rbtree.h:406
#define wine_rb_destroy
Definition: rbtree.h:408
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
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
const void * pNext
Definition: vulkan.h:7684
VkBufferViewCreateFlags flags
Definition: vulkan.h:7685
VkStructureType sType
Definition: vulkan.h:7683
VkComponentSwizzle r
Definition: vulkan.h:7880
VkComponentSwizzle a
Definition: vulkan.h:7883
VkComponentSwizzle g
Definition: vulkan.h:7881
VkComponentSwizzle b
Definition: vulkan.h:7882
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:9118
VkComponentMapping components
Definition: vulkan.h:9117
VkImageViewType viewType
Definition: vulkan.h:9115
VkStructureType sType
Definition: vulkan.h:9111
const void * pNext
Definition: vulkan.h:9112
VkImageViewCreateFlags flags
Definition: vulkan.h:9113
VkImageUsageFlags usage
Definition: vulkan.h:9149
VkStructureType sType
Definition: vulkan.h:9147
DWORD yHotspot
Definition: winuser.h:3233
BOOL fIcon
Definition: winuser.h:3231
DWORD xHotspot
Definition: winuser.h:3232
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234
Definition: palette.c:466
Definition: http.c:7252
IDirect3DSurface9 * depth_stencil
Definition: render.c:29
IDirect3DSurface9 ** render_targets
Definition: render.c:28
Definition: devices.h:37
Definition: image.c:84
Definition: copy.c:22
float cos_hphi
Definition: device.c:42
struct wined3d_color diffuse specular ambient
Definition: device.c:39
float cos_htheta
Definition: device.c:42
struct wined3d_vec4 position
Definition: device.c:40
float falloff
Definition: device.c:42
float fog_end
Definition: device.c:53
uint32_t parallel_point_light_count
Definition: device.c:58
uint32_t directional_light_count
Definition: device.c:57
float fog_density
Definition: device.c:53
float fog_start
Definition: device.c:53
uint32_t fog_mode
Definition: device.c:64
struct light_transformed lights[WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS]
Definition: device.c:47
struct wined3d_matrix modelview_matrix
Definition: device.c:49
uint32_t legacy_lighting
Definition: device.c:60
struct wined3d_color ambient_light
Definition: device.c:48
uint32_t lighting
Definition: device.c:59
uint32_t spot_light_count
Definition: device.c:56
uint32_t point_light_count
Definition: device.c:55
struct wined3d_vec4 position_transformed
Definition: device.c:51
uint32_t normalise
Definition: device.c:61
uint32_t fog_coord_mode
Definition: device.c:63
uint32_t localviewer
Definition: device.c:62
struct wined3d_matrix normal_matrix
Definition: device.c:50
uint32_t padding
Definition: device.c:65
Definition: tftpd.h:60
Definition: parse.h:23
Definition: style.c:91
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
Definition: tools.h:99
Definition: shader.c:383
float z
Definition: shader.c:384
enum view_type type
struct wined3d_gl_info gl_info
Definition: wined3d_gl.h:800
struct wined3d_allocator_chunk c
Definition: wined3d_gl.h:820
struct wined3d_device * device
const struct wined3d_parent_ops * parent_ops
struct wined3d_allocator_block * memory
Definition: wined3d_gl.h:419
GLenum binding
Definition: wined3d_gl.h:422
uint64_t command_fence_id
Definition: wined3d_gl.h:426
GLsizeiptr size
Definition: wined3d_gl.h:421
GLbitfield flags
Definition: wined3d_gl.h:425
GLenum usage
Definition: wined3d_gl.h:423
struct wined3d_bo b
Definition: wined3d_gl.h:415
UINT left
Definition: wined3d.h:1873
UINT right
Definition: wined3d.h:1875
UINT back
Definition: wined3d.h:1878
UINT front
Definition: wined3d.h:1877
UINT bottom
Definition: wined3d.h:1876
UINT top
Definition: wined3d.h:1874
struct wined3d_context c
Definition: wined3d_gl.h:601
const struct wined3d_gl_info * gl_info
Definition: wined3d_gl.h:603
struct wined3d_command_buffer_vk current_command_buffer
Definition: wined3d_vk.h:617
const struct wined3d_vk_info * vk_info
Definition: wined3d_vk.h:590
struct wined3d_d3d_limits limits
uint32_t wined3d_creation_flags
struct wined3d_device * device
const struct wined3d_parent_ops * parent_ops
struct wined3d_device d
Definition: wined3d_gl.h:847
uint64_t current_fence_id
Definition: wined3d_gl.h:855
struct wined3d_dummy_textures dummy_textures
Definition: wined3d_gl.h:850
struct wined3d_allocator allocator
Definition: wined3d_gl.h:853
struct wined3d_device d
Definition: wined3d_vk.h:821
VkDevice vk_device
Definition: wined3d_vk.h:825
struct wined3d_null_resources_vk null_resources_vk
Definition: wined3d_vk.h:832
struct wined3d_null_views_vk null_views_vk
Definition: wined3d_vk.h:833
struct wined3d_rendertarget_view * depth_stencil
struct wined3d_rendertarget_view * render_targets[WINED3D_MAX_RENDER_TARGETS]
struct wined3d_shader * shader
const struct wined3d_state_entry_template * states
BOOL supported[WINED3D_GL_EXT_COUNT]
Definition: wined3d_gl.h:347
struct opengl_funcs gl_ops
Definition: wined3d_gl.h:353
struct wined3d_light_constants constants
struct wined3d_light OriginalParms
struct wined3d_device * device
const struct wined3d_parent_ops * parent_ops
struct wined3d_resource * resource
unsigned int size
Definition: wined3d.h:1801
enum wined3d_resource_type resource_type
Definition: wined3d.h:1791
unsigned int width
Definition: wined3d.h:1798
unsigned int height
Definition: wined3d.h:1799
enum wined3d_multisample_type multisample_type
Definition: wined3d.h:1793
unsigned int multisample_quality
Definition: wined3d.h:1794
unsigned int bind_flags
Definition: wined3d.h:1796
unsigned int usage
Definition: wined3d.h:1795
unsigned int depth
Definition: wined3d.h:1800
enum wined3d_format_id format
Definition: wined3d.h:1792
unsigned int access
Definition: wined3d.h:1797
unsigned int format_attrs
enum wined3d_resource_type type
struct wined3d_device * device
struct list resource_list_entry
const struct wined3d_format * format
struct wined3d_resource * resource
const struct wined3d_format * format
struct list shader_list_entry
enum wined3d_primitive_type primitive_type
unsigned int patch_vertex_count
unsigned int viewport_count
unsigned int stencil_ref
struct wined3d_color blend_factor
struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS]
uint32_t sample_mask
struct wined3d_stream_state streams[WINED3D_MAX_STREAMS]
struct wined3d_bo_address data
struct wined3d_buffer * buffer
Definition: wined3d.h:2160
unsigned int multisample_quality
Definition: wined3d.h:1778
unsigned int backbuffer_height
Definition: wined3d.h:1773
BOOL auto_restore_display_mode
Definition: wined3d.h:1786
enum wined3d_multisample_type multisample_type
Definition: wined3d.h:1777
enum wined3d_format_id auto_depth_stencil_format
Definition: wined3d.h:1783
struct wined3d_output * output
Definition: wined3d.h:1771
unsigned int backbuffer_width
Definition: wined3d.h:1772
unsigned int backbuffer_count
Definition: wined3d.h:1775
enum wined3d_format_id backbuffer_format
Definition: wined3d.h:1774
enum wined3d_swap_effect swap_effect
Definition: wined3d.h:1779
BOOL enable_auto_depth_stencil
Definition: wined3d.h:1782
unsigned int refresh_rate
Definition: wined3d.h:1785
unsigned int backbuffer_bind_flags
Definition: wined3d.h:1776
struct wined3d_swapchain_desc desc
struct wined3d_texture ** back_buffers
struct wined3d_texture * front_buffer
struct wined3d_swapchain_state state
struct wined3d_texture::wined3d_texture_sub_resource * sub_resources
unsigned int row_pitch
struct wined3d_resource resource
struct wined3d_texture::wined3d_dirty_regions * dirty_regions
unsigned int level_count
const struct wined3d_state_entry_template * vp_states
unsigned int flags
Definition: wined3d.h:2131
enum wined3d_format_id format_id
Definition: wined3d.h:2130
struct wined3d_view_desc::@4822::@4824 texture
union wined3d_view_desc::@4822 u
unsigned int api_version
Definition: wined3d_vk.h:259
BOOL supported[WINED3D_VK_EXT_COUNT]
Definition: wined3d_vk.h:261
struct wined3d_adapter * adapters[1]
#define max(a, b)
Definition: svc.c:63
GLfixed fx
Definition: tritemp.h:484
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:64
VkFlags VkMemoryPropertyFlags
Definition: vulkan.h:1063
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan.h:3456
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan.h:3458
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
Definition: vulkan.h:3770
void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
@ VK_IMAGE_VIEW_TYPE_1D
Definition: vulkan.h:3548
@ VK_IMAGE_VIEW_TYPE_2D_ARRAY
Definition: vulkan.h:3553
@ VK_IMAGE_VIEW_TYPE_1D_ARRAY
Definition: vulkan.h:3552
@ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
Definition: vulkan.h:3554
@ VK_IMAGE_VIEW_TYPE_3D
Definition: vulkan.h:3550
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan.h:3549
@ VK_IMAGE_VIEW_TYPE_CUBE
Definition: vulkan.h:3551
@ VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
Definition: vulkan.h:3424
void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan.h:3365
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:3511
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan.h:3512
@ VK_COMPONENT_SWIZZLE_ZERO
Definition: vulkan.h:2189
void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
VkImageType
Definition: vulkan.h:3501
@ VK_IMAGE_TYPE_2D
Definition: vulkan.h:3503
@ VK_IMAGE_TYPE_3D
Definition: vulkan.h:3504
@ VK_IMAGE_TYPE_1D
Definition: vulkan.h:3502
VkFlags VkBufferUsageFlags
Definition: vulkan.h:965
@ VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
Definition: vulkan.h:1917
@ VK_BUFFER_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:1916
@ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
Definition: vulkan.h:1919
@ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
Definition: vulkan.h:1922
VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
VkResult
Definition: vulkan.h:4639
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
#define VK_NULL_HANDLE
Definition: vulkan.h:861
VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
@ VK_FORMAT_R32G32B32A32_SFLOAT
Definition: vulkan.h:2925
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan.h:2853
@ VK_FORMAT_R32_UINT
Definition: vulkan.h:2914
void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan.h:4288
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
#define VK_API_VERSION_1_1
Definition: vulkan.h:843
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR
Definition: vulkan.h:5896
@ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO
Definition: vulkan.h:4977
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan.h:4979
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define GL_CLIENT_STORAGE_BIT
Definition: wgl.h:399
HICON HCURSOR
Definition: windef.h:99
ULONG CDECL wined3d_decref(struct wined3d *wined3d)
Definition: directx.c:198
HRESULT CDECL wined3d_output_get_desc(const struct wined3d_output *output, struct wined3d_output_desc *desc)
Definition: directx.c:1256
ULONG CDECL wined3d_incref(struct wined3d *wined3d)
Definition: directx.c:189
HRESULT CDECL wined3d_get_device_caps(const struct wined3d_adapter *adapter, enum wined3d_device_type device_type, struct wined3d_caps *caps)
Definition: directx.c:2366
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:3472
void state_cleanup(struct wined3d_state *state)
Definition: stateblock.c:648
const struct wined3d_stateblock_state *CDECL wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock)
Definition: stateblock.c:2064
void state_unbind_resources(struct wined3d_state *state)
Definition: stateblock.c:475
void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock)
Definition: stateblock.c:3038
HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain, struct wined3d_raster_status *raster_status)
Definition: swapchain.c:294
void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window)
Definition: swapchain.c:177
HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapchain, unsigned int buffer_count, unsigned int width, unsigned int height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, unsigned int multisample_quality)
Definition: swapchain.c:1923
HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state, HWND window, int x, int y, int width, int height)
Definition: swapchain.c:2225
HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain, struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:381
HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_state *state, const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode)
Definition: swapchain.c:2344
HRESULT CDECL wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: swapchain.c:316
void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain, const struct wined3d_device *device)
Definition: swapchain.c:1374
HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain, uint32_t flags, const struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:353
void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)
Definition: swapchain.c:1826
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
#define WINED3DFVF_XYZB4
Definition: wined3d.h:976
#define WINED3DERR_UNSUPPORTEDTEXTUREFILTER
Definition: wined3d.h:41
#define WINED3DFVF_PSIZE
Definition: wined3d.h:980
#define WINED3DCLEAR_TARGET
Definition: wined3d.h:1008
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:683
@ WINED3D_MULTISAMPLE_NONE
Definition: wined3d.h:573
@ WINED3D_FOG_LINEAR
Definition: wined3d.h:483
@ WINED3D_FOG_EXP
Definition: wined3d.h:481
@ WINED3D_FOG_NONE
Definition: wined3d.h:480
@ WINED3D_FOG_EXP2
Definition: wined3d.h:482
#define WINED3DFVF_XYZB5
Definition: wined3d.h:977
#define WINED3D_MAX_COMBINED_SAMPLERS
Definition: wined3d.h:1600
#define WINED3DFVF_SPECULAR
Definition: wined3d.h:982
@ WINED3D_RS_LIGHTING
Definition: wined3d.h:347
@ WINED3D_RS_STENCILENABLE
Definition: wined3d.h:329
@ WINED3D_RS_ZENABLE
Definition: wined3d.h:293
@ WINED3D_RS_FOGEND
Definition: wined3d.h:320
@ WINED3D_RS_RANGEFOGENABLE
Definition: wined3d.h:325
@ WINED3D_RS_LOCALVIEWER
Definition: wined3d.h:352
@ WINED3D_RS_FOGSTART
Definition: wined3d.h:319
@ WINED3D_RS_ZWRITEENABLE
Definition: wined3d.h:300
@ WINED3D_RS_NORMALIZENORMALS
Definition: wined3d.h:353
@ WINED3D_RS_SPECULARENABLE
Definition: wined3d.h:312
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:346
@ WINED3D_RS_FOGVERTEXMODE
Definition: wined3d.h:350
@ WINED3D_RS_AMBIENT
Definition: wined3d.h:349
@ WINED3D_RS_FOGDENSITY
Definition: wined3d.h:321
#define WINED3D_MAP_NO_DIRTY_UPDATE
Definition: wined3d.h:955
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 WINED3DFVF_TEXCOUNT_SHIFT
Definition: wined3d.h:984
@ WINED3D_SWAP_EFFECT_COPY
Definition: wined3d.h:538
@ WINED3D_SWAP_EFFECT_SEQUENTIAL
Definition: wined3d.h:535
@ WINED3D_SWAP_EFFECT_DISCARD
Definition: wined3d.h:534
wined3d_material_color_source
Definition: wined3d.h:520
@ WINED3D_MCS_COLOR2
Definition: wined3d.h:523
@ WINED3D_MCS_MATERIAL
Definition: wined3d.h:521
@ WINED3D_MCS_COLOR1
Definition: wined3d.h:522
@ WINED3D_SAMP_MIN_FILTER
Definition: wined3d.h:560
@ WINED3D_SAMP_MIP_FILTER
Definition: wined3d.h:561
@ WINED3D_SAMP_MAG_FILTER
Definition: wined3d.h:559
#define WINED3D_MAX_STREAM_OUTPUT_BUFFERS
Definition: wined3d.h:1576
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:51
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:52
#define WINED3DFVF_DIFFUSE
Definition: wined3d.h:981
#define WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
Definition: wined3d.h:1331
wined3d_resource_type
Definition: wined3d.h:716
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:718
#define WINED3DFVF_XYZW
Definition: wined3d.h:978
#define WINED3DFVF_POSITION_MASK
Definition: wined3d.h:970
#define WINED3D_MAX_RENDER_TARGETS
Definition: wined3d.h:1606
@ WINED3D_LIGHT_SPOT
Definition: wined3d.h:67
@ WINED3D_LIGHT_PARALLELPOINT
Definition: wined3d.h:69
@ WINED3D_LIGHT_POINT
Definition: wined3d.h:66
@ WINED3D_LIGHT_DIRECTIONAL
Definition: wined3d.h:68
#define WINED3D_HANDLE_RESTORE
Definition: wined3d.h:1327
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:707
#define WINED3D_SWAPCHAIN_GDI_COMPATIBLE
Definition: wined3d.h:900
#define WINED3DFVF_XYZ
Definition: wined3d.h:971
#define WINED3D_MAP_READ
Definition: wined3d.h:957
#define WINED3DFVF_XYZB1
Definition: wined3d.h:973
#define WINED3D_CKEY_SRC_BLT
Definition: wined3d.h:1341
#define WINED3DFVF_TEXCOUNT_MASK
Definition: wined3d.h:983
#define WINED3D_BIND_SHADER_RESOURCE
Definition: wined3d.h:912
@ WINED3D_TADDRESS_WRAP
Definition: wined3d.h:658
@ WINED3D_TADDRESS_CLAMP
Definition: wined3d.h:660
#define WINED3DFVF_XYZRHW
Definition: wined3d.h:972
#define WINED3DFVF_NORMAL
Definition: wined3d.h:979
wined3d_format_id
Definition: wined3d.h:126
@ WINED3DFMT_R16G16_UNORM
Definition: wined3d.h:192
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:171
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:244
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:161
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:185
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:166
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:198
@ WINED3DFMT_B5G6R5_UNORM
Definition: wined3d.h:242
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:157
#define WINED3DFVF_XYZB3
Definition: wined3d.h:975
#define WINED3D_MAX_STREAMS
Definition: wined3d.h:1596
wined3d_pipeline
Definition: wined3d.h:854
@ WINED3D_PIPELINE_COUNT
Definition: wined3d.h:857
@ WINED3D_PIPELINE_GRAPHICS
Definition: wined3d.h:855
#define WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER
Definition: wined3d.h:891
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
static void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
Definition: wined3d.h:3006
#define WINED3DCLEAR_STENCIL
Definition: wined3d.h:1010
@ WINED3D_CMP_NEVER
Definition: wined3d.h:461
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:53
#define WINED3DUSAGE_MANAGED
Definition: wined3d.h:938
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:953
#define WINED3D_MAP_WRITE
Definition: wined3d.h:956
#define WINED3DFVF_XYZB2
Definition: wined3d.h:974
wined3d_blend
Definition: wined3d.h:418
@ WINED3D_BLEND_SRC1COLOR
Definition: wined3d.h:434
@ WINED3D_BLEND_INVSRC1ALPHA
Definition: wined3d.h:437
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:932
wined3d_feature_level
Definition: wined3d.h:98
@ WINED3D_FEATURE_LEVEL_10_1
Definition: wined3d.h:108
#define WINED3DCLEAR_ZBUFFER
Definition: wined3d.h:1009
wined3d_shader_type
Definition: wined3d.h:840
@ WINED3D_SHADER_TYPE_VERTEX
Definition: wined3d.h:842
@ WINED3D_SHADER_TYPE_COUNT
Definition: wined3d.h:849
#define WINED3D_MAP_NOOVERWRITE
Definition: wined3d.h:952
#define WINED3D_BIND_RENDER_TARGET
Definition: wined3d.h:914
#define WINED3D_NO_DRAW_INDIRECT
Definition: wined3d.h:1335
wined3d_display_rotation
Definition: wined3d.h:831
#define WINED3D_LEGACY_FFP_LIGHTING
Definition: wined3d.h:1329
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:924
@ 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
#define WINED3D_TEXTURE_CREATE_GET_DC
Definition: wined3d.h:1565
@ WINED3D_STENCIL_OP_KEEP
Definition: wined3d.h:509
wined3d_device_type
Definition: wined3d.h:90
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:54
HRESULT(CDECL * wined3d_device_reset_cb)(struct wined3d_resource *resource)
Definition: wined3d.h:2289
#define WINED3DERR_CONFLICTINGRENDERSTATE
Definition: wined3d.h:40
#define WINED3D_BLT_RAW
Definition: wined3d.h:1371
@ ARB_TEXTURE_BUFFER_OBJECT
Definition: wined3d_gl.h:125
@ ARB_TEXTURE_CUBE_MAP
Definition: wined3d_gl.h:130
@ ARB_CLEAR_TEXTURE
Definition: wined3d_gl.h:57
@ APPLE_FLUSH_BUFFER_RANGE
Definition: wined3d_gl.h:48
@ ARB_BUFFER_STORAGE
Definition: wined3d_gl.h:55
@ EXT_TEXTURE3D
Definition: wined3d_gl.h:190
@ ARB_DRAW_INDIRECT
Definition: wined3d_gl.h:73
@ ARB_TEXTURE_MULTISAMPLE
Definition: wined3d_gl.h:139
@ EXT_TEXTURE_ARRAY
Definition: wined3d_gl.h:191
@ ARB_TEXTURE_BUFFER_RANGE
Definition: wined3d_gl.h:126
@ ARB_TEXTURE_CUBE_MAP_ARRAY
Definition: wined3d_gl.h:131
static void wined3d_device_gl_allocator_lock(struct wined3d_device_gl *device_gl)
Definition: wined3d_gl.h:880
#define GL_EXTCALL(f)
Definition: wined3d_gl.h:360
static void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl *device_gl)
Definition: wined3d_gl.h:885
#define checkGLcall(A)
Definition: wined3d_gl.h:402
static struct wined3d_device_gl * wined3d_device_gl_from_allocator(struct wined3d_allocator *allocator)
Definition: wined3d_gl.h:875
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
BOOL CDECL wined3d_register_window(struct wined3d *wined3d, HWND window, struct wined3d_device *device, unsigned int flags)
Definition: wined3d_main.c:715
void wined3d_unregister_window(HWND window)
Definition: wined3d_main.c:790
static ULONG wined3d_atomic_decrement_mutex_lock(volatile LONG *refcount)
static BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
#define WINED3D_FORMAT_ATTR_FLOAT
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
#define MAX_SAMPLER_OBJECTS
#define WINED3D_TEXTURE_GENERATE_MIPMAPS
#define WINED3D_OPENGL_WINDOW_CLASS_NAME
@ WINED3D_FFP_SPECULAR
@ WINED3D_FFP_POSITION
@ WINED3D_FFP_NORMAL
@ WINED3D_FFP_DIFFUSE
@ WINED3D_FFP_TEXCOORD0
static void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv)
#define MAX_CONSTANT_BUFFERS
static bool wined3d_is_srv_rtv_bound(const struct wined3d_state *state, const struct wined3d_shader_resource_view *srv)
static void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static void wined3d_vec4_transform(struct wined3d_vec4 *dst, const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
static void wined3d_not_from_cs(const struct wined3d_cs *cs)
static void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
static HRESULT wined3d_resource_get_sub_resource_desc(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
static BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view *dsv, const struct wined3d_format *srv_format)
#define MAX_UNORDERED_ACCESS_VIEWS
static int wined3d_uint32_compare(uint32_t x, uint32_t y)
static void context_release(struct wined3d_context *context)
static void wined3d_device_context_unlock(struct wined3d_device_context *context)
#define STATE_IS_COMPUTE(a)
#define WINED3D_FORMAT_CAP_FILTERING
#define WINED3D_ALLOCATOR_CHUNK_SIZE
static void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv)
#define WINED3D_TEXTURE_GET_DC
static void wined3d_state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
#define wined3d_lock_init(lock, name)
static void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse, enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient, enum wined3d_material_color_source *specular, const struct wined3d_state *state)
static void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv)
#define WINED3D_FORMAT_ATTR_NORMALISED
#define eps
static void wined3d_device_context_lock(struct wined3d_device_context *context)
#define WINED3D_MAX_DIRTY_REGION_COUNT
@ WINED3D_FFP_VS_FOG_DEPTH
@ WINED3D_FFP_VS_FOG_RANGE
static void wined3d_from_cs(const struct wined3d_cs *cs)
static void wined3d_texture_get_level_box(const struct wined3d_texture *texture, unsigned int level, struct wined3d_box *box)
#define WINED3DCREATE_MULTITHREADED
static void wined3d_lock_cleanup(CRITICAL_SECTION *lock)
#define MAX_SHADER_RESOURCE_VIEWS
static void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
static float int_to_float(uint32_t i)
#define WINED3D_FORMAT_ATTR_BLOCKS
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
@ WINED3D_CS_QUEUE_DEFAULT
#define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
#define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
static void wined3d_context_vk_reference_image(const struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image)
Definition: wined3d_vk.h:1097
#define VK_CALL(f)
Definition: wined3d_vk.h:272
@ WINED3D_VK_KHR_MAINTENANCE2
Definition: wined3d_vk.h:247
static void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk, struct wined3d_bo_vk *bo)
Definition: wined3d_vk.h:1091
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
static unsigned int block
Definition: xmlmemory.c:101
unsigned char BYTE
Definition: xxhash.c:193