ReactOS 0.4.17-dev-923-g4c9a150
state.c
Go to the documentation of this file.
1/*
2 * Copyright 2016 Józef Kucia for CodeWeavers
3 * Copyright 2016 Henri Verbeet for CodeWeavers
4 * Copyright 2021 Conor McCarthy for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "vkd3d_private.h"
22#include "vkd3d_shaders.h"
23#include "vkd3d_shader_utils.h"
24
25/* ID3D12RootSignature */
27{
29}
30
32 REFIID riid, void **object)
33{
34 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
35
36 if (IsEqualGUID(riid, &IID_ID3D12RootSignature)
37 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
38 || IsEqualGUID(riid, &IID_ID3D12Object)
40 {
41 ID3D12RootSignature_AddRef(iface);
42 *object = iface;
43 return S_OK;
44 }
45
46 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
47
48 *object = NULL;
49 return E_NOINTERFACE;
50}
51
53{
54 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
55 unsigned int refcount = vkd3d_atomic_increment_u32(&root_signature->refcount);
56
57 TRACE("%p increasing refcount to %u.\n", root_signature, refcount);
58
59 return refcount;
60}
61
63 struct d3d12_descriptor_set_layout *layout, struct d3d12_device *device)
64{
65 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
66
68}
69
70static void d3d12_root_signature_cleanup(struct d3d12_root_signature *root_signature,
71 struct d3d12_device *device)
72{
73 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
74 unsigned int i;
75
76 if (root_signature->vk_pipeline_layout)
77 VK_CALL(vkDestroyPipelineLayout(device->vk_device, root_signature->vk_pipeline_layout, NULL));
78 for (i = 0; i < root_signature->vk_set_count; ++i)
79 {
81 }
82
83 if (root_signature->parameters)
84 {
85 for (i = 0; i < root_signature->parameter_count; ++i)
86 {
87 if (root_signature->parameters[i].parameter_type == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
88 vkd3d_free(root_signature->parameters[i].u.descriptor_table.ranges);
89 }
90 vkd3d_free(root_signature->parameters);
91 }
92
93 if (root_signature->descriptor_mapping)
94 vkd3d_free(root_signature->descriptor_mapping);
95 vkd3d_free(root_signature->descriptor_offsets);
96 vkd3d_free(root_signature->uav_counter_mapping);
97 vkd3d_free(root_signature->uav_counter_offsets);
98 if (root_signature->root_constants)
99 vkd3d_free(root_signature->root_constants);
100
101 for (i = 0; i < root_signature->static_sampler_count; ++i)
102 {
103 if (root_signature->static_samplers[i])
104 VK_CALL(vkDestroySampler(device->vk_device, root_signature->static_samplers[i], NULL));
105 }
106 if (root_signature->static_samplers)
107 vkd3d_free(root_signature->static_samplers);
108}
109
111{
112 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
113 unsigned int refcount = vkd3d_atomic_decrement_u32(&root_signature->refcount);
114
115 TRACE("%p decreasing refcount to %u.\n", root_signature, refcount);
116
117 if (!refcount)
118 {
119 struct d3d12_device *device = root_signature->device;
121 d3d12_root_signature_cleanup(root_signature, device);
122 vkd3d_free(root_signature);
124 }
125
126 return refcount;
127}
128
130 REFGUID guid, UINT *data_size, void *data)
131{
132 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
133
134 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
135
136 return vkd3d_get_private_data(&root_signature->private_store, guid, data_size, data);
137}
138
140 REFGUID guid, UINT data_size, const void *data)
141{
142 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
143
144 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
145
146 return vkd3d_set_private_data(&root_signature->private_store, guid, data_size, data);
147}
148
150 REFGUID guid, const IUnknown *data)
151{
152 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
153
154 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
155
156 return vkd3d_set_private_data_interface(&root_signature->private_store, guid, data);
157}
158
160{
161 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
162
163 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, root_signature->device->wchar_size));
164
165 return name ? S_OK : E_INVALIDARG;
166}
167
169 REFIID iid, void **device)
170{
171 struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
172
173 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
174
175 return d3d12_device_query_interface(root_signature->device, iid, device);
176}
177
178static const struct ID3D12RootSignatureVtbl d3d12_root_signature_vtbl =
179{
180 /* IUnknown methods */
184 /* ID3D12Object methods */
189 /* ID3D12DeviceChild methods */
191};
192
194{
195 if (!iface)
196 return NULL;
197 VKD3D_ASSERT(iface->lpVtbl == &d3d12_root_signature_vtbl);
198 return impl_from_ID3D12RootSignature(iface);
199}
200
202{
203 switch (visibility)
204 {
206 return VK_SHADER_STAGE_ALL;
217 default:
218 return 0;
219 }
220}
221
223{
224 switch (visibility)
225 {
227 return VK_SHADER_STAGE_ALL;
240 default:
241 FIXME("Unhandled visibility %#x.\n", visibility);
243 }
244}
245
247{
248 switch (visibility)
249 {
262 default:
263 FIXME("Unhandled visibility %#x.\n", visibility);
265 }
266}
267
269 bool is_buffer)
270{
271 switch (type)
272 {
281 default:
282 FIXME("Unhandled descriptor range type type %#x.\n", type);
284 }
285}
286
289{
290 switch (type)
291 {
300 default:
301 FIXME("Unhandled descriptor range type type %#x.\n", type);
303 }
304}
305
308{
309 switch (type)
310 {
317 default:
318 FIXME("Unhandled descriptor root parameter type %#x.\n", type);
320 }
321}
322
324{
327
330
331 unsigned int cbv_count;
332 unsigned int srv_count;
333 unsigned int uav_count;
334 unsigned int sampler_count;
339
340 size_t cost;
341
343 {
345 unsigned int space;
346 unsigned int base_idx;
347 unsigned int count;
351};
352
355 unsigned int space, unsigned int base_idx, unsigned int count)
356{
357 struct d3d12_root_signature_info_range *range;
358
359 if (!vkd3d_array_reserve((void **)&info->ranges, &info->range_capacity, info->range_count + 1,
360 sizeof(*info->ranges)))
361 return E_OUTOFMEMORY;
362
363 range = &info->ranges[info->range_count++];
364 range->type = type;
365 range->space = space;
366 range->base_idx = base_idx;
367 range->count = count;
368 range->visibility = visibility;
369
370 return S_OK;
371}
372
373static int d3d12_root_signature_info_range_compare(const void *a, const void *b)
374{
375 const struct d3d12_root_signature_info_range *range_a = a, *range_b = b;
376 int ret;
377
378 if ((ret = vkd3d_u32_compare(range_a->type, range_b->type)))
379 return ret;
380
381 if ((ret = vkd3d_u32_compare(range_a->space, range_b->space)))
382 return ret;
383
384 return vkd3d_u32_compare(range_a->base_idx, range_b->base_idx);
385}
386
387static HRESULT d3d12_root_signature_info_range_validate(const struct d3d12_root_signature_info_range *ranges,
388 unsigned int count, D3D12_SHADER_VISIBILITY visibility)
389{
390 const struct d3d12_root_signature_info_range *range, *next;
391 unsigned int i = 0, j;
392
393 while (i < count)
394 {
395 range = &ranges[i];
396
397 for (j = i + 1; j < count; ++j)
398 {
399 next = &ranges[j];
400
401 if (range->visibility != D3D12_SHADER_VISIBILITY_ALL
402 && next->visibility != D3D12_SHADER_VISIBILITY_ALL
403 && range->visibility != next->visibility)
404 continue;
405
406 if (range->type == next->type && range->space == next->space
407 && range->base_idx + range->count > next->base_idx)
408 return E_INVALIDARG;
409
410 break;
411 }
412
413 i = j;
414 }
415
416 return S_OK;
417}
418
420 const D3D12_ROOT_PARAMETER *param, bool use_array)
421{
422 bool cbv_unbounded_range = false, srv_unbounded_range = false, uav_unbounded_range = false;
423 const D3D12_ROOT_DESCRIPTOR_TABLE *table = &param->u.DescriptorTable;
424 bool sampler_unbounded_range = false;
425 bool unbounded = false;
426 unsigned int i, count;
427 HRESULT hr;
428
429 for (i = 0; i < table->NumDescriptorRanges; ++i)
430 {
431 const D3D12_DESCRIPTOR_RANGE *range = &table->pDescriptorRanges[i];
432 unsigned int binding_count;
433
434 if (!range->NumDescriptors)
435 {
436 WARN("A descriptor range is empty.\n");
437 return E_INVALIDARG;
438 }
439
440 if (range->NumDescriptors != UINT_MAX && !vkd3d_bound_range(range->BaseShaderRegister,
441 range->NumDescriptors, UINT_MAX))
442 {
443 WARN("A descriptor range overflows.\n");
444 return E_INVALIDARG;
445 }
446
447 if (unbounded && range->OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
448 {
449 WARN("A range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after "
450 "an unbounded range.\n");
451 return E_INVALIDARG;
452 }
453
454 count = range->NumDescriptors;
455
458 param->ShaderVisibility, range->RegisterSpace, range->BaseShaderRegister, count)))
459 return hr;
460
461 if (range->NumDescriptors == UINT_MAX)
462 {
463 unbounded = true;
464 count = 0;
465 }
466
467 binding_count = use_array ? 1 : range->NumDescriptors;
468
469 switch (range->RangeType)
470 {
472 /* XXX: Vulkan buffer and image descriptors have different types. In order
473 * to preserve compatibility between Vulkan resource bindings for the same
474 * root signature, we create descriptor set layouts with two bindings for
475 * each SRV and UAV. */
476 info->binding_count += binding_count;
477 info->srv_count += count * 2u;
478 srv_unbounded_range |= unbounded;
479 break;
481 /* As above. */
482 info->binding_count += binding_count;
483 info->uav_count += count * 2u;
484 uav_unbounded_range |= unbounded;
485 ++info->uav_range_count;
486 break;
488 info->cbv_count += count;
489 cbv_unbounded_range |= unbounded;
490 break;
492 info->sampler_count += count;
493 sampler_unbounded_range |= unbounded;
494 break;
495 default:
496 FIXME("Unhandled descriptor type %#x.\n", range->RangeType);
497 return E_NOTIMPL;
498 }
499
500 info->binding_count += binding_count;
501 }
502
503 if (unbounded && !use_array)
504 {
505 FIXME("The device does not support unbounded descriptor ranges.\n");
506 return E_FAIL;
507 }
508
509 info->srv_unbounded_range_count += srv_unbounded_range * 2u;
510 info->uav_unbounded_range_count += uav_unbounded_range * 2u;
511 info->cbv_unbounded_range_count += cbv_unbounded_range;
512 info->sampler_unbounded_range_count += sampler_unbounded_range;
513
514 return S_OK;
515}
516
518 const D3D12_ROOT_SIGNATURE_DESC *desc, bool use_array)
519{
520 unsigned int i;
521 HRESULT hr;
522
523 memset(info, 0, sizeof(*info));
524
525 for (i = 0; i < desc->NumParameters; ++i)
526 {
527 const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i];
528
529 switch (p->ParameterType)
530 {
533 p, use_array)))
534 goto done;
535 ++info->cost;
536 break;
537
539 ++info->root_descriptor_count;
540 ++info->cbv_count;
541 ++info->binding_count;
542 info->cost += 2;
544 VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, p->ShaderVisibility,
545 p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, 1)))
546 goto done;
547 break;
548
550 ++info->root_descriptor_count;
551 ++info->srv_count;
552 ++info->binding_count;
553 info->cost += 2;
555 VKD3D_SHADER_DESCRIPTOR_TYPE_SRV, p->ShaderVisibility,
556 p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, 1)))
557 goto done;
558 break;
559
561 ++info->root_descriptor_count;
562 ++info->uav_count;
563 ++info->binding_count;
564 info->cost += 2;
566 VKD3D_SHADER_DESCRIPTOR_TYPE_UAV, p->ShaderVisibility,
567 p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, 1)))
568 goto done;
569 break;
570
572 ++info->root_constant_count;
573 info->cost += p->u.Constants.Num32BitValues;
575 VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, p->ShaderVisibility,
576 p->u.Constants.RegisterSpace, p->u.Constants.ShaderRegister, 1)))
577 goto done;
578 break;
579
580 default:
581 FIXME("Unhandled type %#x for parameter %u.\n", p->ParameterType, i);
582 hr = E_NOTIMPL;
583 goto done;
584 }
585 }
586
587 info->binding_count += desc->NumStaticSamplers;
588 info->sampler_count += desc->NumStaticSamplers;
589
590 for (i = 0; i < desc->NumStaticSamplers; ++i)
591 {
592 const D3D12_STATIC_SAMPLER_DESC *s = &desc->pStaticSamplers[i];
593
595 VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->ShaderVisibility,
596 s->RegisterSpace, s->ShaderRegister, 1)))
597 goto done;
598 }
599
600 qsort(info->ranges, info->range_count, sizeof(*info->ranges),
602
604 {
605 if (FAILED(hr = d3d12_root_signature_info_range_validate(info->ranges, info->range_count, i)))
606 goto done;
607 }
608
609 hr = S_OK;
610done:
611 vkd3d_free(info->ranges);
612 info->ranges = NULL;
613 info->range_count = 0;
614 info->range_capacity = 0;
615
616 return hr;
617}
618
621 struct VkPushConstantRange push_constants[D3D12_SHADER_VISIBILITY_PIXEL + 1],
622 uint32_t *push_constant_range_count)
623{
624 uint32_t push_constants_offset[D3D12_SHADER_VISIBILITY_PIXEL + 1];
625 bool use_vk_heaps = root_signature->device->use_vk_heaps;
626 unsigned int i, j, push_constant_count;
628
629 memset(push_constants, 0, (D3D12_SHADER_VISIBILITY_PIXEL + 1) * sizeof(*push_constants));
630 memset(push_constants_offset, 0, sizeof(push_constants_offset));
631 for (i = 0; i < desc->NumParameters; ++i)
632 {
633 const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i];
634 D3D12_SHADER_VISIBILITY visibility;
635
636 if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
637 continue;
638
639 visibility = use_vk_heaps ? D3D12_SHADER_VISIBILITY_ALL : p->ShaderVisibility;
641
642 push_constants[visibility].stageFlags = stage_flags_from_visibility(visibility);
643 push_constants[visibility].size += align(p->u.Constants.Num32BitValues, 4) * sizeof(uint32_t);
644 }
645
646 if (push_constants[D3D12_SHADER_VISIBILITY_ALL].size)
647 {
648 /* When D3D12_SHADER_VISIBILITY_ALL is used we use a single push
649 * constants range because the Vulkan spec states:
650 *
651 * "Any two elements of pPushConstantRanges must not include the same
652 * stage in stageFlags".
653 */
654 push_constant_count = 1;
655 for (i = 0; i <= D3D12_SHADER_VISIBILITY_PIXEL; ++i)
656 {
658 continue;
659
660 push_constants[D3D12_SHADER_VISIBILITY_ALL].size += push_constants[i].size;
661 push_constants[i].size = 0;
662 }
663 }
664 else
665 {
666 /* Move non-empty push constants ranges to front and compute offsets. */
667 offset = 0;
668 for (i = 0, j = 0; i <= D3D12_SHADER_VISIBILITY_PIXEL; ++i)
669 {
670 if (push_constants[i].size)
671 {
672 push_constants[j] = push_constants[i];
673 push_constants[j].offset = offset;
674 push_constants_offset[i] = offset;
675 offset += push_constants[j].size;
676 ++j;
677 }
678 }
679 push_constant_count = j;
680 }
681
682 for (i = 0, j = 0; i < desc->NumParameters; ++i)
683 {
684 struct d3d12_root_constant *root_constant = &root_signature->parameters[i].u.constant;
685 const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i];
686 unsigned int idx;
687
688 if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
689 continue;
690
691 idx = push_constant_count == 1 ? 0 : p->ShaderVisibility;
692 offset = push_constants_offset[idx];
693 push_constants_offset[idx] += align(p->u.Constants.Num32BitValues, 4) * sizeof(uint32_t);
694
695 root_signature->parameters[i].parameter_type = p->ParameterType;
696 root_constant->stage_flags = push_constant_count == 1
697 ? push_constants[0].stageFlags : stage_flags_from_visibility(p->ShaderVisibility);
698 root_constant->offset = offset;
699
700 root_signature->root_constants[j].register_space = p->u.Constants.RegisterSpace;
701 root_signature->root_constants[j].register_index = p->u.Constants.ShaderRegister;
702 root_signature->root_constants[j].shader_visibility
703 = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
704 root_signature->root_constants[j].offset = offset;
705 root_signature->root_constants[j].size = p->u.Constants.Num32BitValues * sizeof(uint32_t);
706
707 ++j;
708 }
709
710 *push_constant_range_count = push_constant_count;
711
712 return S_OK;
713}
714
716{
719
720 unsigned int table_index;
721 unsigned int unbounded_offset;
723};
724
726{
727 vkd3d_free(array->bindings);
728 array->bindings = NULL;
729}
730
732 VkDescriptorType descriptor_type, unsigned int descriptor_count,
733 VkShaderStageFlags stage_flags, const VkSampler *immutable_sampler, unsigned int *binding_idx)
734{
735 unsigned int binding_count = array->count;
737
738 if (!vkd3d_array_reserve((void **)&array->bindings, &array->capacity,
739 array->count + 1, sizeof(*array->bindings)))
740 {
741 ERR("Failed to reallocate the Vulkan binding array.\n");
742 return false;
743 }
744
745 *binding_idx = binding_count;
746 binding = &array->bindings[binding_count];
747 binding->binding = binding_count;
748 binding->descriptorType = descriptor_type;
749 binding->descriptorCount = descriptor_count;
750 binding->stageFlags = stage_flags;
751 binding->pImmutableSamplers = immutable_sampler;
752 ++array->count;
753
754 return true;
755}
756
758{
760 unsigned int table_index;
761 unsigned int unbounded_offset;
762 unsigned int descriptor_index;
763 unsigned int uav_counter_index;
765};
766
768{
769 size_t i;
770
771 for (i = 0; i < ARRAY_SIZE(context->vk_bindings); ++i)
772 vk_binding_array_cleanup(&context->vk_bindings[i]);
773}
774
775static bool vkd3d_validate_descriptor_set_count(struct d3d12_device *device, unsigned int set_count)
776{
777 uint32_t max_count = min(VKD3D_MAX_DESCRIPTOR_SETS, device->vk_info.device_limits.maxBoundDescriptorSets);
778
779 if (set_count > max_count)
780 {
781 /* NOTE: If maxBoundDescriptorSets is < 9, try VKD3D_CONFIG=virtual_heaps */
782 WARN("Required descriptor set count exceeds maximum allowed count of %u.\n", max_count);
783 return false;
784 }
785
786 return true;
787}
788
790 struct d3d12_root_signature *root_signature, struct vkd3d_descriptor_set_context *context)
791{
792 if (root_signature->vk_set_count >= ARRAY_SIZE(context->vk_bindings))
793 return NULL;
794
795 return &context->vk_bindings[root_signature->vk_set_count];
796}
797
800{
801 struct vk_binding_array *array;
802
804 return;
805
806 array->table_index = context->table_index;
807 array->unbounded_offset = context->unbounded_offset;
808 array->flags = flags;
809
810 ++root_signature->vk_set_count;
811}
812
814 enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space,
815 unsigned int register_idx, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility,
816 unsigned int descriptor_count, struct vkd3d_descriptor_set_context *context,
817 const VkSampler *immutable_sampler, unsigned int *binding_idx)
818{
820 ? &root_signature->descriptor_offsets[context->descriptor_index] : NULL;
822 struct vk_binding_array *array;
823 unsigned int idx;
824
826 || !(vk_binding_array_add_binding(&context->vk_bindings[root_signature->vk_set_count],
827 vk_descriptor_type_from_vkd3d_descriptor_type(descriptor_type, buffer_descriptor), descriptor_count,
828 stage_flags_from_vkd3d_shader_visibility(shader_visibility), immutable_sampler, &idx)))
829 return E_OUTOFMEMORY;
830
831 mapping = &root_signature->descriptor_mapping[context->descriptor_index++];
832 mapping->type = descriptor_type;
833 mapping->register_space = register_space;
834 mapping->register_index = register_idx;
835 mapping->shader_visibility = shader_visibility;
837 mapping->binding.set = root_signature->vk_set_count;
838 mapping->binding.binding = idx;
839 mapping->binding.count = descriptor_count;
840 if (offset)
841 {
842 offset->static_offset = 0;
843 offset->dynamic_offset_index = ~0u;
844 }
845
846 if (context->unbounded_offset != UINT_MAX)
848
849 if (binding_idx)
850 *binding_idx = idx;
851
852 return S_OK;
853}
854
856{
857 switch (type)
858 {
867 default:
868 ERR("Invalid range type %#x.\n", type);
870 }
871}
872
874 const struct d3d12_root_signature_info *info, const struct vkd3d_device_descriptor_limits *limits)
875{
876 unsigned int count, limit;
877
878 if (range->descriptor_count != UINT_MAX)
879 return range->descriptor_count;
880
881 switch (range->type)
882 {
885 count = (limit - min(info->cbv_count, limit)) / info->cbv_unbounded_range_count;
886 break;
889 count = (limit - min(info->srv_count, limit)) / info->srv_unbounded_range_count;
890 break;
893 count = (limit - min(info->uav_count, limit)) / info->uav_unbounded_range_count;
894 break;
897 count = (limit - min(info->sampler_count, limit)) / info->sampler_unbounded_range_count;
898 break;
899 default:
900 ERR("Unhandled type %#x.\n", range->type);
901 return 1;
902 }
903
904 if (!count)
905 {
906 WARN("Descriptor table exceeds type %#x limit of %u.\n", range->type, limit);
907 count = 1;
908 }
909
911}
912
915 unsigned int vk_binding_array_count, unsigned int bindings_per_range,
917{
918 enum vkd3d_shader_visibility shader_visibility = vkd3d_shader_visibility_from_d3d12(visibility);
919 bool is_buffer = range->type != VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER;
920 enum vkd3d_shader_descriptor_type descriptor_type = range->type;
921 unsigned int i, register_space = range->register_space;
922 HRESULT hr;
923
924 if (range->descriptor_count == UINT_MAX)
925 context->unbounded_offset = range->offset;
926
927 for (i = 0; i < bindings_per_range; ++i)
928 {
929 if (FAILED(hr = d3d12_root_signature_append_vk_binding(root_signature, descriptor_type,
930 register_space, range->base_register_idx + i, is_buffer, shader_visibility,
931 vk_binding_array_count, context, NULL, NULL)))
932 return hr;
933 }
934
935 if (descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_SRV && descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_UAV)
936 {
937 context->unbounded_offset = UINT_MAX;
938 return S_OK;
939 }
940
941 for (i = 0; i < bindings_per_range; ++i)
942 {
943 if (FAILED(hr = d3d12_root_signature_append_vk_binding(root_signature, descriptor_type,
944 register_space, range->base_register_idx + i, false, shader_visibility,
945 vk_binding_array_count, context, NULL, NULL)))
946 return hr;
947 }
948
949 context->unbounded_offset = UINT_MAX;
950
951 return S_OK;
952}
953
955 const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset, bool buffer_descriptor,
956 enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
957{
958 struct vkd3d_shader_resource_binding *mapping = &root_signature->descriptor_mapping[context->descriptor_index];
959 struct vkd3d_shader_descriptor_offset *offset = &root_signature->descriptor_offsets[context->descriptor_index++];
960
961 mapping->type = range->type;
962 mapping->register_space = range->register_space;
963 mapping->register_index = range->base_register_idx;
964 mapping->shader_visibility = shader_visibility;
966 mapping->binding.set = root_signature->main_set + range->set + ((range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_SRV
967 || range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) && !buffer_descriptor);
968 mapping->binding.binding = range->binding;
969 mapping->binding.count = range->vk_binding_count;
970 offset->static_offset = descriptor_offset;
971 offset->dynamic_offset_index = ~0u;
972}
973
975 unsigned int descriptor_set_size)
976{
977 unsigned int max_count;
978
979 if (descriptor_set_size <= range->offset)
980 {
981 ERR("Descriptor range offset %u exceeds maximum available offset %u.\n", range->offset, descriptor_set_size - 1);
982 max_count = 0;
983 }
984 else
985 {
986 max_count = descriptor_set_size - range->offset;
987 }
988
989 if (range->descriptor_count != UINT_MAX)
990 {
991 if (range->descriptor_count > max_count)
992 ERR("Range size %u exceeds available descriptor count %u.\n", range->descriptor_count, max_count);
993 return range->descriptor_count;
994 }
995 else
996 {
997 /* Prefer an unsupported binding count vs a zero count, because shader compilation will fail
998 * to match a declaration to a zero binding, resulting in failure of pipeline state creation. */
999 return max_count + !max_count;
1000 }
1001}
1002
1004 bool is_buffer, const struct d3d12_root_signature *root_signature,
1006{
1007 const struct vkd3d_device_descriptor_limits *descriptor_limits = &root_signature->device->vk_info.descriptor_limits;
1008 unsigned int descriptor_set_size;
1009
1010 if (root_signature->device->vk_info.EXT_mutable_descriptor_type)
1011 {
1013 {
1015 descriptor_set_size = descriptor_limits->sampler_max_descriptors;
1016 }
1017 else
1018 {
1020 descriptor_set_size = descriptor_limits->sampled_image_max_descriptors;
1021 }
1022 }
1023 else switch (range->type)
1024 {
1027 descriptor_set_size = descriptor_limits->sampled_image_max_descriptors;
1028 break;
1031 descriptor_set_size = descriptor_limits->storage_image_max_descriptors;
1032 break;
1035 descriptor_set_size = descriptor_limits->uniform_buffer_max_descriptors;
1036 break;
1039 descriptor_set_size = descriptor_limits->sampler_max_descriptors;
1040 break;
1041 default:
1042 FIXME("Unhandled descriptor range type type %#x.\n", range->type);
1044 descriptor_set_size = descriptor_limits->sampled_image_max_descriptors;
1045 break;
1046 }
1047 binding->set += root_signature->vk_set_count;
1048 binding->binding = 0;
1049 binding->count = vk_heap_binding_count_from_descriptor_range(range, descriptor_set_size);
1050}
1051
1053 const struct d3d12_root_descriptor_table_range *range, bool buffer_descriptor,
1054 enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
1055{
1056 struct vkd3d_shader_resource_binding *mapping = &root_signature->descriptor_mapping[context->descriptor_index];
1057 struct vkd3d_shader_descriptor_offset *offset = &root_signature->descriptor_offsets[context->descriptor_index++];
1058
1059 mapping->type = range->type;
1060 mapping->register_space = range->register_space;
1061 mapping->register_index = range->base_register_idx;
1062 mapping->shader_visibility = shader_visibility;
1064 vkd3d_descriptor_heap_binding_from_descriptor_range(range, buffer_descriptor, root_signature, &mapping->binding);
1065 offset->static_offset = range->offset;
1066 offset->dynamic_offset_index = context->push_constant_index;
1067}
1068
1070 const struct d3d12_root_descriptor_table_range *range, enum vkd3d_shader_visibility shader_visibility,
1072{
1073 struct vkd3d_shader_uav_counter_binding *mapping = &root_signature->uav_counter_mapping[context->uav_counter_index];
1074 struct vkd3d_shader_descriptor_offset *offset = &root_signature->uav_counter_offsets[context->uav_counter_index++];
1075
1076 mapping->register_space = range->register_space;
1077 mapping->register_index = range->base_register_idx;
1078 mapping->shader_visibility = shader_visibility;
1079 mapping->binding.set = root_signature->vk_set_count + VKD3D_SET_INDEX_UAV_COUNTER;
1080 mapping->binding.binding = 0;
1082 root_signature->device->vk_info.descriptor_limits.storage_image_max_descriptors);
1083 offset->static_offset = range->offset;
1084 offset->dynamic_offset_index = context->push_constant_index;
1085}
1086
1088 const struct d3d12_root_descriptor_table_range *range, enum vkd3d_shader_visibility shader_visibility,
1090{
1091 bool is_buffer = range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_CBV;
1092
1094 {
1095 d3d12_root_signature_map_vk_heap_binding(root_signature, range, true, shader_visibility, context);
1097 d3d12_root_signature_map_vk_heap_uav_counter(root_signature, range, shader_visibility, context);
1098 }
1099
1100 d3d12_root_signature_map_vk_heap_binding(root_signature, range, is_buffer, shader_visibility, context);
1101}
1102
1104 const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset,
1105 enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
1106{
1107 bool is_buffer = range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_CBV;
1108
1111 descriptor_offset, true, shader_visibility, context);
1112
1114 descriptor_offset, is_buffer, shader_visibility, context);
1115}
1116
1117static int compare_descriptor_range(const void *a, const void *b)
1118{
1119 const struct d3d12_root_descriptor_table_range *range_a = a, *range_b = b;
1120 int ret;
1121
1122 if ((ret = vkd3d_u32_compare(range_a->type, range_b->type)))
1123 return ret;
1124
1125 if ((ret = vkd3d_u32_compare(range_a->offset, range_b->offset)))
1126 return ret;
1127
1128 /* Place bounded ranges after unbounded ones of equal offset,
1129 * so the bounded range can be mapped to the unbounded one. */
1130 return (range_b->descriptor_count == UINT_MAX) - (range_a->descriptor_count == UINT_MAX);
1131}
1132
1136{
1137 unsigned int i, j, range_count, bindings_per_range, vk_binding_array_count;
1138 const struct d3d12_device *device = root_signature->device;
1139 bool use_vk_heaps = root_signature->device->use_vk_heaps;
1141 HRESULT hr;
1142
1143 root_signature->descriptor_table_mask = 0;
1144
1145 for (i = 0; i < desc->NumParameters; ++i)
1146 {
1147 const struct d3d12_root_descriptor_table_range *base_range = NULL;
1148 const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i];
1149 enum vkd3d_shader_visibility shader_visibility;
1150 unsigned int offset = 0;
1151
1152 if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
1153 continue;
1154
1155 root_signature->descriptor_table_mask |= 1ull << i;
1156
1157 table = &root_signature->parameters[i].u.descriptor_table;
1158 range_count = p->u.DescriptorTable.NumDescriptorRanges;
1159 shader_visibility = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
1160
1161 root_signature->parameters[i].parameter_type = p->ParameterType;
1162 table->range_count = range_count;
1163 if (!(table->ranges = vkd3d_calloc(table->range_count, sizeof(*table->ranges))))
1164 return E_OUTOFMEMORY;
1165
1166 context->table_index = i;
1167
1168 for (j = 0; j < range_count; ++j)
1169 {
1170 const D3D12_DESCRIPTOR_RANGE *range = &p->u.DescriptorTable.pDescriptorRanges[j];
1171
1172 if (range->OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
1174
1175 if (range->NumDescriptors != UINT_MAX && !vkd3d_bound_range(offset, range->NumDescriptors, UINT_MAX))
1176 return E_INVALIDARG;
1177
1178 table->ranges[j].offset = offset;
1179 table->ranges[j].descriptor_count = range->NumDescriptors;
1180 table->ranges[j].type = vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType);
1181 table->ranges[j].descriptor_magic = vkd3d_descriptor_magic_from_d3d12(range->RangeType);
1182 table->ranges[j].register_space = range->RegisterSpace;
1183 table->ranges[j].base_register_idx = range->BaseShaderRegister;
1184
1185 TRACE("Descriptor table %u, range %u, offset %u, type %#x, count %u.\n", i, j,
1186 offset, range->RangeType, range->NumDescriptors);
1187
1188 /* If NumDescriptors == UINT_MAX, validation during counting ensures this offset is not used. */
1189 offset += range->NumDescriptors;
1190 }
1191
1192 qsort(table->ranges, range_count, sizeof(*table->ranges), compare_descriptor_range);
1193
1194 for (j = 0; j < range_count; ++j)
1195 {
1197
1198 range = &table->ranges[j];
1199
1200 if (use_vk_heaps)
1201 {
1202 /* set, binding and vk_binding_count are not used. */
1203 range->set = 0;
1204 range->binding = 0;
1205 range->vk_binding_count = 0;
1206 d3d12_root_signature_map_descriptor_heap_binding(root_signature, range, shader_visibility, context);
1207 continue;
1208 }
1209
1210 range->set = root_signature->vk_set_count - root_signature->main_set;
1211
1212 if (root_signature->use_descriptor_arrays)
1213 {
1214 if (j && range->type != table->ranges[j - 1].type)
1215 base_range = NULL;
1216
1217 /* Bounded and unbounded ranges can follow unbounded ones,
1218 * so map them all into the first unbounded range. */
1219 if (base_range)
1220 {
1221 unsigned int rel_offset = range->offset - base_range->offset;
1222
1223 if (rel_offset >= base_range->vk_binding_count)
1224 {
1225 ERR("Available binding size of %u is insufficient for an offset of %u.\n",
1226 base_range->vk_binding_count, rel_offset);
1227 continue;
1228 }
1229
1230 range->set = base_range->set;
1231 range->binding = base_range->binding;
1232 range->vk_binding_count = base_range->vk_binding_count - rel_offset;
1234 rel_offset, shader_visibility, context);
1235 continue;
1236 }
1237 else if (range->descriptor_count == UINT_MAX)
1238 {
1239 base_range = range;
1240 }
1241
1243 info, &device->vk_info.descriptor_limits);
1244 vk_binding_array_count = range->vk_binding_count;
1245 bindings_per_range = 1;
1246 }
1247 else
1248 {
1249 range->vk_binding_count = range->descriptor_count;
1250 vk_binding_array_count = 1;
1251 bindings_per_range = range->descriptor_count;
1252 }
1253
1254 range->binding = context->vk_bindings[root_signature->vk_set_count].count;
1255
1257 p->ShaderVisibility, vk_binding_array_count, bindings_per_range, context)))
1258 return hr;
1259 }
1260 ++context->push_constant_index;
1261 }
1262
1263 return S_OK;
1264}
1265
1268{
1269 unsigned int binding, i;
1270 HRESULT hr;
1271
1272 root_signature->push_descriptor_mask = 0;
1273
1274 for (i = 0; i < desc->NumParameters; ++i)
1275 {
1276 const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i];
1277 if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_CBV
1278 && p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_SRV
1279 && p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_UAV)
1280 continue;
1281
1282 root_signature->push_descriptor_mask |= 1u << i;
1283
1286 p->u.Descriptor.RegisterSpace, p->u.Descriptor.ShaderRegister, true,
1287 vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility), 1, context, NULL, &binding)))
1288 return hr;
1289
1290 root_signature->parameters[i].parameter_type = p->ParameterType;
1291 root_signature->parameters[i].u.descriptor.binding = binding;
1292 }
1293
1294 return S_OK;
1295}
1296
1300{
1301 unsigned int i;
1302 HRESULT hr;
1303
1304 VKD3D_ASSERT(root_signature->static_sampler_count == desc->NumStaticSamplers);
1305 for (i = 0; i < desc->NumStaticSamplers; ++i)
1306 {
1307 const D3D12_STATIC_SAMPLER_DESC *s = &desc->pStaticSamplers[i];
1308
1309 if (FAILED(hr = vkd3d_create_static_sampler(device, s, &root_signature->static_samplers[i])))
1310 return hr;
1311
1313 VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, s->RegisterSpace, s->ShaderRegister, false,
1314 vkd3d_shader_visibility_from_d3d12(s->ShaderVisibility), 1, context,
1315 &root_signature->static_samplers[i], NULL)))
1316 return hr;
1317 }
1318
1319 if (device->use_vk_heaps)
1321
1322 return S_OK;
1323}
1324
1327{
1328 root_signature->descriptor_table_offset = 0;
1329 if ((root_signature->descriptor_table_count = context->push_constant_index))
1330 {
1332
1333 root_signature->descriptor_table_offset = align(range->size, 16);
1334 range->size = root_signature->descriptor_table_offset
1335 + root_signature->descriptor_table_count * sizeof(uint32_t);
1336
1337 if (range->size > root_signature->device->vk_info.device_limits.maxPushConstantsSize)
1338 FIXME("Push constants size %u exceeds maximum allowed size %u. Try VKD3D_CONFIG=virtual_heaps.\n",
1339 range->size, root_signature->device->vk_info.device_limits.maxPushConstantsSize);
1340
1341 if (!root_signature->push_constant_range_count)
1342 {
1343 root_signature->push_constant_range_count = 1;
1344 range->stageFlags = VK_SHADER_STAGE_ALL;
1345 }
1346 }
1347}
1348
1350{
1351 if (binding->descriptorCount == 1)
1352 return false;
1353
1354 switch (binding->descriptorType)
1355 {
1356 /* Types mapped in vk_descriptor_type_from_vkd3d_descriptor_type() from D3D12 SRV and UAV types,
1357 * i.e. those which can be a buffer or an image. */
1362 return true;
1363 default:
1364 return false;
1365 }
1366}
1367
1369 VkDescriptorSetLayoutCreateFlags flags, unsigned int binding_count, bool unbounded,
1370 const VkDescriptorSetLayoutBinding *bindings, VkDescriptorSetLayout *set_layout)
1371{
1372 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1376 VkResult vr;
1377
1379 set_desc.pNext = NULL;
1380 set_desc.flags = flags;
1381 set_desc.bindingCount = binding_count;
1382 set_desc.pBindings = bindings;
1383 if (device->vk_info.EXT_descriptor_indexing)
1384 {
1385 unsigned int i;
1386
1387 for (i = 0; i < binding_count; ++i)
1388 if (unbounded || vk_binding_uses_partial_binding(&bindings[i]))
1389 break;
1390
1391 if (i < binding_count)
1392 {
1393 if (!(set_flags = vkd3d_malloc(binding_count * sizeof(*set_flags))))
1394 return E_OUTOFMEMORY;
1395
1396 for (i = 0; i < binding_count; ++i)
1399
1400 if (unbounded)
1403
1405 flags_info.pNext = NULL;
1406 flags_info.bindingCount = binding_count;
1407 flags_info.pBindingFlags = set_flags;
1408
1409 set_desc.pNext = &flags_info;
1410 }
1411 }
1412
1413 vr = VK_CALL(vkCreateDescriptorSetLayout(device->vk_device, &set_desc, NULL, set_layout));
1415 if (vr < 0)
1416 {
1417 WARN("Failed to create Vulkan descriptor set layout, vr %d.\n", vr);
1418 return hresult_from_vk_result(vr);
1419 }
1420
1421 return S_OK;
1422}
1423
1425 unsigned int set_layout_count, const VkDescriptorSetLayout *set_layouts,
1426 unsigned int push_constant_count, const VkPushConstantRange *push_constants,
1427 VkPipelineLayout *pipeline_layout)
1428{
1429 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1430 struct VkPipelineLayoutCreateInfo pipeline_layout_info;
1431 VkResult vr;
1432
1433 if (!vkd3d_validate_descriptor_set_count(device, set_layout_count))
1434 return E_INVALIDARG;
1435
1437 pipeline_layout_info.pNext = NULL;
1438 pipeline_layout_info.flags = 0;
1439 pipeline_layout_info.setLayoutCount = set_layout_count;
1440 pipeline_layout_info.pSetLayouts = set_layouts;
1441 pipeline_layout_info.pushConstantRangeCount = push_constant_count;
1442 pipeline_layout_info.pPushConstantRanges = push_constants;
1443 if ((vr = VK_CALL(vkCreatePipelineLayout(device->vk_device,
1444 &pipeline_layout_info, NULL, pipeline_layout))) < 0)
1445 {
1446 WARN("Failed to create Vulkan pipeline layout, vr %d.\n", vr);
1447 return hresult_from_vk_result(vr);
1448 }
1449
1450 return S_OK;
1451}
1452
1455{
1456 unsigned int i;
1457 HRESULT hr;
1458
1460
1461 if (!vkd3d_validate_descriptor_set_count(root_signature->device, root_signature->vk_set_count))
1462 return E_INVALIDARG;
1463
1464 for (i = 0; i < root_signature->vk_set_count; ++i)
1465 {
1466 struct d3d12_descriptor_set_layout *layout = &root_signature->descriptor_set_layouts[i];
1467 struct vk_binding_array *array = &context->vk_bindings[i];
1468
1470
1471 if (FAILED(hr = vkd3d_create_descriptor_set_layout(root_signature->device, array->flags, array->count,
1472 array->unbounded_offset != UINT_MAX, array->bindings, &layout->vk_layout)))
1473 return hr;
1474 layout->unbounded_offset = array->unbounded_offset;
1475 layout->table_index = array->table_index;
1476 }
1477
1478 return S_OK;
1479}
1480
1481static unsigned int d3d12_root_signature_copy_descriptor_set_layouts(const struct d3d12_root_signature *root_signature,
1482 VkDescriptorSetLayout *vk_set_layouts)
1483{
1484 const struct d3d12_device *device = root_signature->device;
1486 VkDescriptorSetLayout vk_set_layout;
1487 unsigned int i;
1488
1489 for (i = 0; i < root_signature->vk_set_count; ++i)
1490 vk_set_layouts[i] = root_signature->descriptor_set_layouts[i].vk_layout;
1491
1492 if (!device->use_vk_heaps)
1493 return i;
1494
1495 for (set = 0; set < ARRAY_SIZE(device->vk_descriptor_heap_layouts); ++set)
1496 {
1497 vk_set_layout = device->vk_descriptor_heap_layouts[set].vk_set_layout;
1498
1499 VKD3D_ASSERT(vk_set_layout);
1500 vk_set_layouts[i++] = vk_set_layout;
1501
1502 if (device->vk_info.EXT_mutable_descriptor_type && set == VKD3D_SET_INDEX_MUTABLE)
1503 break;
1504 }
1505
1506 return i;
1507}
1508
1511{
1512 VkDescriptorSetLayout vk_layouts[VKD3D_MAX_DESCRIPTOR_SETS];
1513 const struct vkd3d_vulkan_info *vk_info = &device->vk_info;
1516 bool use_vk_heaps;
1517 unsigned int i;
1518 HRESULT hr;
1519
1520 memset(&context, 0, sizeof(context));
1521 context.unbounded_offset = UINT_MAX;
1522
1523 root_signature->ID3D12RootSignature_iface.lpVtbl = &d3d12_root_signature_vtbl;
1524 root_signature->refcount = 1;
1525
1526 root_signature->vk_pipeline_layout = VK_NULL_HANDLE;
1527 root_signature->vk_set_count = 0;
1528 root_signature->parameters = NULL;
1529 root_signature->flags = desc->Flags;
1530 root_signature->descriptor_mapping = NULL;
1531 root_signature->descriptor_offsets = NULL;
1532 root_signature->uav_counter_mapping = NULL;
1533 root_signature->uav_counter_offsets = NULL;
1534 root_signature->static_sampler_count = 0;
1535 root_signature->static_samplers = NULL;
1536 root_signature->device = device;
1537
1540 FIXME("Ignoring root signature flags %#x.\n", desc->Flags);
1541
1542 if (FAILED(hr = d3d12_root_signature_info_from_desc(&info, desc, device->vk_info.EXT_descriptor_indexing)))
1543 return hr;
1544 if (info.cost > D3D12_MAX_ROOT_COST)
1545 {
1546 WARN("Root signature cost %zu exceeds maximum allowed cost.\n", info.cost);
1547 return E_INVALIDARG;
1548 }
1549
1550 root_signature->binding_count = info.binding_count;
1551 root_signature->uav_mapping_count = info.uav_range_count;
1552 root_signature->static_sampler_count = desc->NumStaticSamplers;
1553 root_signature->root_descriptor_count = info.root_descriptor_count;
1554 root_signature->use_descriptor_arrays = device->vk_info.EXT_descriptor_indexing;
1555 root_signature->descriptor_table_count = 0;
1556
1557 use_vk_heaps = device->use_vk_heaps;
1558
1559 hr = E_OUTOFMEMORY;
1560 root_signature->parameter_count = desc->NumParameters;
1561 if (!(root_signature->parameters = vkd3d_calloc(root_signature->parameter_count,
1562 sizeof(*root_signature->parameters))))
1563 goto fail;
1564 if (!(root_signature->descriptor_mapping = vkd3d_calloc(root_signature->binding_count,
1565 sizeof(*root_signature->descriptor_mapping))))
1566 goto fail;
1567 if (use_vk_heaps && (!(root_signature->uav_counter_mapping = vkd3d_calloc(root_signature->uav_mapping_count,
1568 sizeof(*root_signature->uav_counter_mapping)))
1569 || !(root_signature->uav_counter_offsets = vkd3d_calloc(root_signature->uav_mapping_count,
1570 sizeof(*root_signature->uav_counter_offsets)))))
1571 goto fail;
1572 if (root_signature->use_descriptor_arrays && !(root_signature->descriptor_offsets = vkd3d_calloc(
1573 root_signature->binding_count, sizeof(*root_signature->descriptor_offsets))))
1574 goto fail;
1575 root_signature->root_constant_count = info.root_constant_count;
1576 if (!(root_signature->root_constants = vkd3d_calloc(root_signature->root_constant_count,
1577 sizeof(*root_signature->root_constants))))
1578 goto fail;
1579 if (!(root_signature->static_samplers = vkd3d_calloc(root_signature->static_sampler_count,
1580 sizeof(*root_signature->static_samplers))))
1581 goto fail;
1582
1584 goto fail;
1585
1586 /* We use KHR_push_descriptor for root descriptor parameters. */
1587 if (vk_info->KHR_push_descriptor)
1588 {
1591 }
1592
1593 root_signature->main_set = root_signature->vk_set_count;
1594
1596 root_signature->push_constant_ranges, &root_signature->push_constant_range_count)))
1597 goto fail;
1599 goto fail;
1600 context.push_constant_index = 0;
1602 goto fail;
1603 if (use_vk_heaps)
1605
1607 goto fail;
1608
1610
1611 i = d3d12_root_signature_copy_descriptor_set_layouts(root_signature, vk_layouts);
1613 vk_layouts, root_signature->push_constant_range_count,
1614 root_signature->push_constant_ranges, &root_signature->vk_pipeline_layout)))
1615 goto fail;
1616
1617 if (FAILED(hr = vkd3d_private_store_init(&root_signature->private_store)))
1618 goto fail;
1619
1621
1622 return S_OK;
1623
1624fail:
1626 d3d12_root_signature_cleanup(root_signature, device);
1627 return hr;
1628}
1629
1631 const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature)
1632{
1633 const struct vkd3d_shader_code dxbc = {bytecode, bytecode_length};
1634 union
1635 {
1638 } root_signature_desc;
1640 HRESULT hr;
1641 int ret;
1642
1643 if ((ret = vkd3d_parse_root_signature_v_1_0(&dxbc, &root_signature_desc.vkd3d)) < 0)
1644 {
1645 WARN("Failed to parse root signature, vkd3d result %d.\n", ret);
1647 }
1648
1649 if (!(object = vkd3d_malloc(sizeof(*object))))
1650 {
1651 vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d);
1652 return E_OUTOFMEMORY;
1653 }
1654
1655 hr = d3d12_root_signature_init(object, device, &root_signature_desc.d3d12.u.Desc_1_0);
1656 vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d);
1657 if (FAILED(hr))
1658 {
1659 vkd3d_free(object);
1660 return hr;
1661 }
1662
1663 TRACE("Created root signature %p.\n", object);
1664
1665 *root_signature = object;
1666
1667 return S_OK;
1668}
1669
1670/* vkd3d_render_pass_cache */
1672{
1674 VkRenderPass vk_render_pass;
1675};
1676
1678
1680 struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
1681{
1684 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1686 unsigned int index, attachment_index;
1687 VkSubpassDescription sub_pass_desc;
1688 VkRenderPassCreateInfo pass_info;
1689 bool have_depth_stencil;
1690 unsigned int rt_count;
1691 VkResult vr;
1692
1693 if (!vkd3d_array_reserve((void **)&cache->render_passes, &cache->render_passes_size,
1694 cache->render_pass_count + 1, sizeof(*cache->render_passes)))
1695 {
1697 return E_OUTOFMEMORY;
1698 }
1699
1700 entry = &cache->render_passes[cache->render_pass_count];
1701
1702 entry->key = *key;
1703
1704 have_depth_stencil = key->depth_enable || key->stencil_enable;
1705 rt_count = have_depth_stencil ? key->attachment_count - 1 : key->attachment_count;
1707
1708 for (index = 0, attachment_index = 0; index < rt_count; ++index)
1709 {
1710 if (!key->vk_formats[index])
1711 {
1712 attachment_references[index].attachment = VK_ATTACHMENT_UNUSED;
1713 attachment_references[index].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1714 continue;
1715 }
1716
1717 attachments[attachment_index].flags = 0;
1718 attachments[attachment_index].format = key->vk_formats[index];
1719 attachments[attachment_index].samples = key->sample_count;
1720 attachments[attachment_index].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
1721 attachments[attachment_index].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
1722 attachments[attachment_index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
1723 attachments[attachment_index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
1724 attachments[attachment_index].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1725 attachments[attachment_index].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1726
1727 attachment_references[index].attachment = attachment_index;
1728 attachment_references[index].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1729
1730 ++attachment_index;
1731 }
1732
1733 if (have_depth_stencil)
1734 {
1735 VkImageLayout depth_layout = key->depth_stencil_write
1738
1739 attachments[attachment_index].flags = 0;
1740 attachments[attachment_index].format = key->vk_formats[index];
1741 attachments[attachment_index].samples = key->sample_count;
1742
1743 if (key->depth_enable)
1744 {
1745 attachments[attachment_index].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
1746 attachments[attachment_index].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
1747 }
1748 else
1749 {
1750 attachments[attachment_index].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
1751 attachments[attachment_index].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
1752 }
1753 if (key->stencil_enable)
1754 {
1755 attachments[attachment_index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
1756 attachments[attachment_index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
1757 }
1758 else
1759 {
1760 attachments[attachment_index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
1761 attachments[attachment_index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
1762 }
1763 attachments[attachment_index].initialLayout = depth_layout;
1764 attachments[attachment_index].finalLayout = depth_layout;
1765
1766 attachment_references[index].attachment = attachment_index;
1767 attachment_references[index].layout = depth_layout;
1768
1769 attachment_index++;
1770 }
1771
1772 sub_pass_desc.flags = 0;
1774 sub_pass_desc.inputAttachmentCount = 0;
1775 sub_pass_desc.pInputAttachments = NULL;
1776 sub_pass_desc.colorAttachmentCount = rt_count;
1777 sub_pass_desc.pColorAttachments = attachment_references;
1778 sub_pass_desc.pResolveAttachments = NULL;
1779 if (have_depth_stencil)
1780 sub_pass_desc.pDepthStencilAttachment = &attachment_references[rt_count];
1781 else
1782 sub_pass_desc.pDepthStencilAttachment = NULL;
1783 sub_pass_desc.preserveAttachmentCount = 0;
1784 sub_pass_desc.pPreserveAttachments = NULL;
1785
1787 pass_info.pNext = NULL;
1788 pass_info.flags = 0;
1789 pass_info.attachmentCount = attachment_index;
1790 pass_info.pAttachments = attachments;
1791 pass_info.subpassCount = 1;
1792 pass_info.pSubpasses = &sub_pass_desc;
1793 pass_info.dependencyCount = 0;
1794 pass_info.pDependencies = NULL;
1795 if ((vr = VK_CALL(vkCreateRenderPass(device->vk_device, &pass_info, NULL, vk_render_pass))) >= 0)
1796 {
1797 entry->vk_render_pass = *vk_render_pass;
1798 ++cache->render_pass_count;
1799 }
1800 else
1801 {
1802 WARN("Failed to create Vulkan render pass, vr %d.\n", vr);
1804 }
1805
1806 return hresult_from_vk_result(vr);
1807}
1808
1810 struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
1811{
1812 bool found = false;
1813 HRESULT hr = S_OK;
1814 unsigned int i;
1815
1816 vkd3d_mutex_lock(&device->pipeline_cache_mutex);
1817
1818 for (i = 0; i < cache->render_pass_count; ++i)
1819 {
1820 struct vkd3d_render_pass_entry *current = &cache->render_passes[i];
1821
1822 if (!memcmp(&current->key, key, sizeof(*key)))
1823 {
1824 *vk_render_pass = current->vk_render_pass;
1825 found = true;
1826 break;
1827 }
1828 }
1829
1830 if (!found)
1832
1833 vkd3d_mutex_unlock(&device->pipeline_cache_mutex);
1834
1835 return hr;
1836}
1837
1839{
1840 cache->render_passes = NULL;
1841 cache->render_pass_count = 0;
1842 cache->render_passes_size = 0;
1843}
1844
1846 struct d3d12_device *device)
1847{
1848 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1849 unsigned int i;
1850
1851 for (i = 0; i < cache->render_pass_count; ++i)
1852 {
1853 struct vkd3d_render_pass_entry *current = &cache->render_passes[i];
1854 VK_CALL(vkDestroyRenderPass(device->vk_device, current->vk_render_pass, NULL));
1855 }
1856
1857 vkd3d_free(cache->render_passes);
1858 cache->render_passes = NULL;
1859}
1860
1862{
1863 D3D12_DEPTH_STENCIL_DESC1 *ds_state = &desc->depth_stencil_state;
1864 D3D12_RASTERIZER_DESC *rs_state = &desc->rasterizer_state;
1865 D3D12_BLEND_DESC *blend_state = &desc->blend_state;
1866 DXGI_SAMPLE_DESC *sample_desc = &desc->sample_desc;
1867
1868 memset(desc, 0, sizeof(*desc));
1869 ds_state->DepthEnable = TRUE;
1878
1879 rs_state->FillMode = D3D12_FILL_MODE_SOLID;
1880 rs_state->CullMode = D3D12_CULL_MODE_BACK;
1881 rs_state->DepthClipEnable = TRUE;
1883
1885
1886 sample_desc->Count = 1;
1887 sample_desc->Quality = 0;
1888
1889 desc->sample_mask = D3D12_DEFAULT_SAMPLE_MASK;
1890}
1891
1894{
1895 memset(desc, 0, sizeof(*desc));
1896 desc->root_signature = d3d12_desc->pRootSignature;
1897 desc->vs = d3d12_desc->VS;
1898 desc->ps = d3d12_desc->PS;
1899 desc->ds = d3d12_desc->DS;
1900 desc->hs = d3d12_desc->HS;
1901 desc->gs = d3d12_desc->GS;
1902 desc->stream_output = d3d12_desc->StreamOutput;
1903 desc->blend_state = d3d12_desc->BlendState;
1904 desc->sample_mask = d3d12_desc->SampleMask;
1905 desc->rasterizer_state = d3d12_desc->RasterizerState;
1906 memcpy(&desc->depth_stencil_state, &d3d12_desc->DepthStencilState, sizeof(d3d12_desc->DepthStencilState));
1907 desc->input_layout = d3d12_desc->InputLayout;
1908 desc->strip_cut_value = d3d12_desc->IBStripCutValue;
1909 desc->primitive_topology_type = d3d12_desc->PrimitiveTopologyType;
1910 desc->rtv_formats.NumRenderTargets = d3d12_desc->NumRenderTargets;
1911 memcpy(desc->rtv_formats.RTFormats, d3d12_desc->RTVFormats, sizeof(desc->rtv_formats.RTFormats));
1912 desc->dsv_format = d3d12_desc->DSVFormat;
1913 desc->sample_desc = d3d12_desc->SampleDesc;
1914 desc->node_mask = d3d12_desc->NodeMask;
1915 desc->cached_pso = d3d12_desc->CachedPSO;
1916 desc->flags = d3d12_desc->Flags;
1917}
1918
1921{
1922 memset(desc, 0, sizeof(*desc));
1923 desc->root_signature = d3d12_desc->pRootSignature;
1924 desc->cs = d3d12_desc->CS;
1925 desc->node_mask = d3d12_desc->NodeMask;
1926 desc->cached_pso = d3d12_desc->CachedPSO;
1927 desc->flags = d3d12_desc->Flags;
1928}
1929
1932{
1934 uint64_t defined_subobjects = 0;
1935 const uint8_t *stream_ptr;
1936 uint64_t subobject_bit;
1937 size_t start, size, i;
1938 uint8_t *desc_bytes;
1939
1940 static const struct
1941 {
1942 size_t alignment;
1943 size_t size;
1944 size_t dst_offset;
1945 }
1946 subobject_info[] =
1947 {
1948#define DCL_SUBOBJECT_INFO(type, field) {__alignof__(type), sizeof(type), offsetof(struct d3d12_pipeline_state_desc, field)}
1972#undef DCL_SUBOBJECT_INFO
1973 };
1974 STATIC_ASSERT(ARRAY_SIZE(subobject_info) <= sizeof(defined_subobjects) * CHAR_BIT);
1975
1976 /* Initialize defaults for undefined subobjects. */
1978
1979 stream_ptr = d3d12_desc->pPipelineStateSubobjectStream;
1980 desc_bytes = (uint8_t *)desc;
1981
1982 for (i = 0; i < d3d12_desc->SizeInBytes; )
1983 {
1984 if (!vkd3d_bound_range(0, sizeof(subobject_type), d3d12_desc->SizeInBytes - i))
1985 {
1986 WARN("Invalid pipeline state stream.\n");
1987 return E_INVALIDARG;
1988 }
1989
1990 subobject_type = *(const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE *)&stream_ptr[i];
1991 if (subobject_type >= ARRAY_SIZE(subobject_info))
1992 {
1993 FIXME("Unhandled pipeline subobject type %#x.\n", subobject_type);
1994 return E_INVALIDARG;
1995 }
1996
1997 subobject_bit = 1ull << subobject_type;
1998 if (defined_subobjects & subobject_bit)
1999 {
2000 WARN("Duplicate pipeline subobject type %u.\n", subobject_type);
2001 return E_INVALIDARG;
2002 }
2003 defined_subobjects |= subobject_bit;
2004
2005 start = align(sizeof(subobject_type), subobject_info[subobject_type].alignment);
2006 size = subobject_info[subobject_type].size;
2007
2008 if (!vkd3d_bound_range(start, size, d3d12_desc->SizeInBytes - i))
2009 {
2010 WARN("Invalid pipeline state stream.\n");
2011 return E_INVALIDARG;
2012 }
2013
2014 memcpy(&desc_bytes[subobject_info[subobject_type].dst_offset], &stream_ptr[i + start], size);
2015 /* Stream packets are aligned to the size of pointers. */
2016 i += align(start + size, sizeof(void *));
2017 }
2018
2019 /* Deduce pipeline type from specified shaders. */
2020 if (desc->vs.BytecodeLength && desc->vs.pShaderBytecode)
2021 {
2022 *vk_bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS;
2023 }
2024 else if (desc->cs.BytecodeLength && desc->cs.pShaderBytecode)
2025 {
2026 *vk_bind_point = VK_PIPELINE_BIND_POINT_COMPUTE;
2027 }
2028 else
2029 {
2030 WARN("Cannot deduce pipeline type from shader stages.\n");
2031 return E_INVALIDARG;
2032 }
2033
2034 if (desc->vs.BytecodeLength && desc->vs.pShaderBytecode
2035 && desc->cs.BytecodeLength && desc->cs.pShaderBytecode)
2036 {
2037 WARN("Invalid combination of shader stages VS and CS.\n");
2038 return E_INVALIDARG;
2039 }
2040
2041 return S_OK;
2042}
2043
2045{
2049};
2050
2052{
2053 struct list entry;
2055 VkPipeline vk_pipeline;
2056 VkRenderPass vk_render_pass;
2057};
2058
2059/* ID3D12PipelineState */
2061{
2063}
2064
2066 REFIID riid, void **object)
2067{
2068 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
2069
2070 if (IsEqualGUID(riid, &IID_ID3D12PipelineState)
2071 || IsEqualGUID(riid, &IID_ID3D12Pageable)
2072 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
2073 || IsEqualGUID(riid, &IID_ID3D12Object)
2075 {
2076 ID3D12PipelineState_AddRef(iface);
2077 *object = iface;
2078 return S_OK;
2079 }
2080
2081 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2082
2083 *object = NULL;
2084 return E_NOINTERFACE;
2085}
2086
2088{
2090 unsigned int refcount = vkd3d_atomic_increment_u32(&state->refcount);
2091
2092 TRACE("%p increasing refcount to %u.\n", state, refcount);
2093
2094 return refcount;
2095}
2096
2098 struct d3d12_device *device)
2099{
2100 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
2101 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2103 unsigned int i;
2104
2105 for (i = 0; i < graphics->stage_count; ++i)
2106 {
2107 VK_CALL(vkDestroyShaderModule(device->vk_device, graphics->stages[i].module, NULL));
2108 }
2109
2111 {
2112 VK_CALL(vkDestroyPipeline(device->vk_device, current->vk_pipeline, NULL));
2114 }
2115}
2116
2118 struct d3d12_device *device)
2119{
2120 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2121
2122 if (uav_counters->vk_set_layout)
2123 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, uav_counters->vk_set_layout, NULL));
2124 if (uav_counters->vk_pipeline_layout)
2125 VK_CALL(vkDestroyPipelineLayout(device->vk_device, uav_counters->vk_pipeline_layout, NULL));
2126
2127 vkd3d_free(uav_counters->bindings);
2128}
2129
2131{
2133 unsigned int refcount = vkd3d_atomic_decrement_u32(&state->refcount);
2134
2135 TRACE("%p decreasing refcount to %u.\n", state, refcount);
2136
2137 if (!refcount)
2138 {
2139 struct d3d12_device *device = state->device;
2140 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2141
2142 vkd3d_private_store_destroy(&state->private_store);
2143
2147 VK_CALL(vkDestroyPipeline(device->vk_device, state->u.compute.vk_pipeline, NULL));
2148
2150
2151 if (state->implicit_root_signature)
2152 d3d12_root_signature_Release(state->implicit_root_signature);
2153
2155
2157 }
2158
2159 return refcount;
2160}
2161
2163 REFGUID guid, UINT *data_size, void *data)
2164{
2166
2167 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2168
2169 return vkd3d_get_private_data(&state->private_store, guid, data_size, data);
2170}
2171
2173 REFGUID guid, UINT data_size, const void *data)
2174{
2176
2177 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2178
2179 return vkd3d_set_private_data(&state->private_store, guid, data_size, data);
2180}
2181
2183 REFGUID guid, const IUnknown *data)
2184{
2186
2187 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2188
2189 return vkd3d_set_private_data_interface(&state->private_store, guid, data);
2190}
2191
2193{
2195
2196 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, state->device->wchar_size));
2197
2199 {
2200 return vkd3d_set_vk_object_name(state->device, (uint64_t)state->u.compute.vk_pipeline,
2202 }
2203
2204 return name ? S_OK : E_INVALIDARG;
2205}
2206
2208 REFIID iid, void **device)
2209{
2211
2212 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
2213
2214 return d3d12_device_query_interface(state->device, iid, device);
2215}
2216
2218 ID3DBlob **blob)
2219{
2220 FIXME("iface %p, blob %p stub!\n", iface, blob);
2221
2222 return E_NOTIMPL;
2223}
2224
2225static const struct ID3D12PipelineStateVtbl d3d12_pipeline_state_vtbl =
2226{
2227 /* IUnknown methods */
2231 /* ID3D12Object methods */
2236 /* ID3D12DeviceChild methods */
2238 /* ID3D12PipelineState methods */
2240};
2241
2243{
2244 if (!iface)
2245 return NULL;
2246 VKD3D_ASSERT(iface->lpVtbl == &d3d12_pipeline_state_vtbl);
2247 return impl_from_ID3D12PipelineState(iface);
2248}
2249
2250static inline unsigned int typed_uav_compile_option(const struct d3d12_device *device)
2251{
2252 return device->vk_info.uav_read_without_format
2255}
2256
2257static unsigned int feature_flags_compile_option(const struct d3d12_device *device)
2258{
2259 unsigned int flags = 0;
2260
2261 if (device->feature_options1.Int64ShaderOps)
2263 if (device->feature_options.DoublePrecisionFloatShaderOps)
2265 if (device->feature_options1.WaveOps)
2267
2268 return flags;
2269}
2270
2272 struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage,
2273 const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface)
2274{
2275 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2276 struct vkd3d_shader_compile_info compile_info;
2277 struct VkShaderModuleCreateInfo shader_desc;
2278 struct vkd3d_shader_code spirv = {0};
2279 VkResult vr;
2280 int ret;
2281
2282 const struct vkd3d_shader_compile_option options[] =
2283 {
2288 };
2289
2291 stage_desc->pNext = NULL;
2292 stage_desc->flags = 0;
2293 stage_desc->stage = stage;
2294 stage_desc->pName = "main";
2295 stage_desc->pSpecializationInfo = NULL;
2296
2298 shader_desc.pNext = NULL;
2299 shader_desc.flags = 0;
2300
2302 compile_info.next = shader_interface;
2303 compile_info.source.code = code->pShaderBytecode;
2304 compile_info.source.size = code->BytecodeLength;
2306 compile_info.options = options;
2307 compile_info.option_count = ARRAY_SIZE(options);
2308 compile_info.log_level = VKD3D_SHADER_LOG_NONE;
2309 compile_info.source_name = NULL;
2310
2311 if ((ret = vkd3d_shader_parse_dxbc_source_type(&compile_info.source, &compile_info.source_type, NULL)) < 0
2312 || (ret = vkd3d_shader_compile(&compile_info, &spirv, NULL)) < 0)
2313 {
2314 WARN("Failed to compile shader, vkd3d result %d.\n", ret);
2316 }
2317 shader_desc.codeSize = spirv.size;
2318 shader_desc.pCode = spirv.code;
2319
2320 vr = VK_CALL(vkCreateShaderModule(device->vk_device, &shader_desc, NULL, &stage_desc->module));
2322 if (vr < 0)
2323 {
2324 WARN("Failed to create Vulkan shader module, vr %d.\n", vr);
2325 return hresult_from_vk_result(vr);
2326 }
2327
2328 return S_OK;
2329}
2330
2332 struct vkd3d_shader_scan_descriptor_info *descriptor_info)
2333{
2334 struct vkd3d_shader_compile_info compile_info;
2335 enum vkd3d_result ret;
2336
2337 const struct vkd3d_shader_compile_option options[] =
2338 {
2341 };
2342
2344 compile_info.next = descriptor_info;
2345 compile_info.source.code = code->pShaderBytecode;
2346 compile_info.source.size = code->BytecodeLength;
2348 compile_info.options = options;
2349 compile_info.option_count = ARRAY_SIZE(options);
2350 compile_info.log_level = VKD3D_SHADER_LOG_NONE;
2351 compile_info.source_name = NULL;
2352
2353 if ((ret = vkd3d_shader_parse_dxbc_source_type(&compile_info.source, &compile_info.source_type, NULL)) < 0)
2354 return ret;
2355
2356 return vkd3d_shader_scan(&compile_info, NULL);
2357}
2358
2360 const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface,
2361 VkPipelineLayout vk_pipeline_layout, VkPipeline *vk_pipeline)
2362{
2363 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2364 VkComputePipelineCreateInfo pipeline_info;
2365 VkResult vr;
2366 HRESULT hr;
2367
2369 pipeline_info.pNext = NULL;
2370 pipeline_info.flags = 0;
2371 if (FAILED(hr = create_shader_stage(device, &pipeline_info.stage,
2372 VK_SHADER_STAGE_COMPUTE_BIT, code, shader_interface)))
2373 return hr;
2374 pipeline_info.layout = vk_pipeline_layout;
2375 pipeline_info.basePipelineHandle = VK_NULL_HANDLE;
2376 pipeline_info.basePipelineIndex = -1;
2377
2378 vr = VK_CALL(vkCreateComputePipelines(device->vk_device,
2379 VK_NULL_HANDLE, 1, &pipeline_info, NULL, vk_pipeline));
2380 VK_CALL(vkDestroyShaderModule(device->vk_device, pipeline_info.stage.module, NULL));
2381 if (vr < 0)
2382 {
2383 WARN("Failed to create Vulkan compute pipeline, hr %s.\n", debugstr_hresult(hr));
2384 return hresult_from_vk_result(vr);
2385 }
2386
2387 return S_OK;
2388}
2389
2391 struct d3d12_device *device, const struct d3d12_root_signature *root_signature,
2392 const struct vkd3d_shader_scan_descriptor_info *shader_info, VkShaderStageFlags stage_flags)
2393{
2394 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2395 VkDescriptorSetLayout set_layouts[VKD3D_MAX_DESCRIPTOR_SETS + 1];
2396 VkDescriptorSetLayoutBinding *binding_desc;
2397 uint32_t set_index, descriptor_binding;
2398 unsigned int uav_counter_count = 0;
2399 unsigned int i, j;
2400 HRESULT hr;
2401
2402 VKD3D_ASSERT(vkd3d_popcount(stage_flags) == 1);
2403
2404 for (i = 0; i < shader_info->descriptor_count; ++i)
2405 {
2406 const struct vkd3d_shader_descriptor_info *d = &shader_info->descriptors[i];
2407
2410 ++uav_counter_count;
2411 }
2412
2413 if (!uav_counter_count)
2414 return S_OK;
2415
2416 /* It should be possible to support other stages in Vulkan, but in a graphics pipeline
2417 * D3D12 currently only supports counters in pixel shaders, and handling multiple stages
2418 * would be more complex. */
2420 {
2421 FIXME("Found a UAV counter for Vulkan shader stage %#x. UAV counters in a "
2422 "graphics pipeline are only supported in pixel shaders.\n", stage_flags);
2423 return E_INVALIDARG;
2424 }
2425
2426 if (!(binding_desc = vkd3d_calloc(uav_counter_count, sizeof(*binding_desc))))
2427 return E_OUTOFMEMORY;
2428 if (!(state->uav_counters.bindings = vkd3d_calloc(uav_counter_count, sizeof(*state->uav_counters.bindings))))
2429 {
2430 vkd3d_free(binding_desc);
2431 return E_OUTOFMEMORY;
2432 }
2433 state->uav_counters.binding_count = uav_counter_count;
2434
2435 descriptor_binding = 0;
2436 set_index = d3d12_root_signature_copy_descriptor_set_layouts(root_signature, set_layouts);
2437
2438 for (i = 0, j = 0; i < shader_info->descriptor_count; ++i)
2439 {
2440 const struct vkd3d_shader_descriptor_info *d = &shader_info->descriptors[i];
2441
2444 continue;
2445
2446 state->uav_counters.bindings[j].register_space = d->register_space;
2447 state->uav_counters.bindings[j].register_index = d->register_index;
2448 state->uav_counters.bindings[j].shader_visibility = (stage_flags == VK_SHADER_STAGE_COMPUTE_BIT)
2450 state->uav_counters.bindings[j].binding.set = set_index;
2451 state->uav_counters.bindings[j].binding.binding = descriptor_binding;
2452 state->uav_counters.bindings[j].binding.count = 1;
2453
2454 binding_desc[j].binding = descriptor_binding;
2456 binding_desc[j].descriptorCount = 1;
2457 binding_desc[j].stageFlags = stage_flags;
2458 binding_desc[j].pImmutableSamplers = NULL;
2459
2460 ++descriptor_binding;
2461 ++j;
2462 }
2463
2464 /* Create a descriptor set layout for UAV counters. */
2465 hr = vkd3d_create_descriptor_set_layout(device, 0, descriptor_binding,
2466 false, binding_desc, &state->uav_counters.vk_set_layout);
2467 vkd3d_free(binding_desc);
2468 if (FAILED(hr))
2469 {
2470 vkd3d_free(state->uav_counters.bindings);
2471 return hr;
2472 }
2473
2474 /* Create a pipeline layout which is compatible for all other descriptor
2475 * sets with the root signature's pipeline layout.
2476 */
2477 state->uav_counters.set_index = set_index;
2478 set_layouts[set_index++] = state->uav_counters.vk_set_layout;
2479 if (FAILED(hr = vkd3d_create_pipeline_layout(device, set_index, set_layouts,
2480 root_signature->push_constant_range_count, root_signature->push_constant_ranges,
2481 &state->uav_counters.vk_pipeline_layout)))
2482 {
2483 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->uav_counters.vk_set_layout, NULL));
2484 vkd3d_free(state->uav_counters.bindings);
2485 return hr;
2486 }
2487
2488 return S_OK;
2489}
2490
2492 struct d3d12_device *device, const struct d3d12_root_signature *root_signature,
2493 const D3D12_SHADER_BYTECODE *code, VkShaderStageFlags stage_flags)
2494{
2495 struct vkd3d_shader_scan_descriptor_info shader_info;
2496 HRESULT hr;
2497 int ret;
2498
2499 if (device->use_vk_heaps)
2500 return S_OK;
2501
2503 shader_info.next = NULL;
2504 if ((ret = vkd3d_scan_dxbc(device, code, &shader_info)) < 0)
2505 {
2506 WARN("Failed to scan shader bytecode, stage %#x, vkd3d result %d.\n", stage_flags, ret);
2508 }
2509
2510 if (FAILED(hr = d3d12_pipeline_state_init_uav_counters(state, device, root_signature, &shader_info, stage_flags)))
2511 WARN("Failed to create descriptor set layout for UAV counters, hr %s.\n", debugstr_hresult(hr));
2512
2514
2515 return hr;
2516}
2517
2519 struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
2520{
2521 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2522 struct vkd3d_shader_interface_info shader_interface;
2523 struct vkd3d_shader_descriptor_offset_info offset_info;
2524 struct vkd3d_shader_spirv_target_info target_info;
2525 struct d3d12_root_signature *root_signature;
2526 VkPipelineLayout vk_pipeline_layout;
2527 HRESULT hr;
2528
2529 state->ID3D12PipelineState_iface.lpVtbl = &d3d12_pipeline_state_vtbl;
2530 state->refcount = 1;
2531
2532 memset(&state->uav_counters, 0, sizeof(state->uav_counters));
2533
2534 if (!(root_signature = unsafe_impl_from_ID3D12RootSignature(desc->root_signature)))
2535 {
2536 TRACE("Root signature is NULL, looking for an embedded signature.\n");
2538 desc->cs.pShaderBytecode, desc->cs.BytecodeLength, &root_signature)))
2539 {
2540 WARN("Failed to find an embedded root signature, hr %s.\n", debugstr_hresult(hr));
2541 return hr;
2542 }
2543 state->implicit_root_signature = &root_signature->ID3D12RootSignature_iface;
2544 }
2545 else
2546 {
2547 state->implicit_root_signature = NULL;
2548 }
2549
2552 {
2553 if (state->implicit_root_signature)
2554 d3d12_root_signature_Release(state->implicit_root_signature);
2555 return hr;
2556 }
2557
2558 memset(&target_info, 0, sizeof(target_info));
2560 target_info.environment = device->environment;
2561 target_info.extensions = device->vk_info.shader_extensions;
2562 target_info.extension_count = device->vk_info.shader_extension_count;
2563
2564 if (root_signature->descriptor_offsets)
2565 {
2567 offset_info.next = NULL;
2568 offset_info.descriptor_table_offset = root_signature->descriptor_table_offset;
2569 offset_info.descriptor_table_count = root_signature->descriptor_table_count;
2570 offset_info.binding_offsets = root_signature->descriptor_offsets;
2571 offset_info.uav_counter_offsets = root_signature->uav_counter_offsets;
2572 vkd3d_prepend_struct(&target_info, &offset_info);
2573 }
2574
2576 shader_interface.next = &target_info;
2577 shader_interface.bindings = root_signature->descriptor_mapping;
2578 shader_interface.binding_count = root_signature->binding_count;
2579 shader_interface.push_constant_buffers = root_signature->root_constants;
2580 shader_interface.push_constant_buffer_count = root_signature->root_constant_count;
2581 shader_interface.combined_samplers = NULL;
2582 shader_interface.combined_sampler_count = 0;
2583 if (root_signature->uav_counter_mapping)
2584 {
2585 shader_interface.uav_counters = root_signature->uav_counter_mapping;
2586 shader_interface.uav_counter_count = root_signature->uav_mapping_count;
2587 }
2588 else
2589 {
2590 shader_interface.uav_counters = state->uav_counters.bindings;
2591 shader_interface.uav_counter_count = state->uav_counters.binding_count;
2592 }
2593
2594 vk_pipeline_layout = state->uav_counters.vk_pipeline_layout
2595 ? state->uav_counters.vk_pipeline_layout : root_signature->vk_pipeline_layout;
2596 if (FAILED(hr = vkd3d_create_compute_pipeline(device, &desc->cs, &shader_interface,
2597 vk_pipeline_layout, &state->u.compute.vk_pipeline)))
2598 {
2599 WARN("Failed to create Vulkan compute pipeline, hr %s.\n", debugstr_hresult(hr));
2601 if (state->implicit_root_signature)
2602 d3d12_root_signature_Release(state->implicit_root_signature);
2603 return hr;
2604 }
2605
2606 if (FAILED(hr = vkd3d_private_store_init(&state->private_store)))
2607 {
2608 VK_CALL(vkDestroyPipeline(device->vk_device, state->u.compute.vk_pipeline, NULL));
2610 if (state->implicit_root_signature)
2611 d3d12_root_signature_Release(state->implicit_root_signature);
2612 return hr;
2613 }
2614
2615 state->vk_bind_point = VK_PIPELINE_BIND_POINT_COMPUTE;
2617
2618 return S_OK;
2619}
2620
2623{
2624 struct d3d12_pipeline_state_desc pipeline_desc;
2626 HRESULT hr;
2627
2629
2630 if (!(object = vkd3d_malloc(sizeof(*object))))
2631 return E_OUTOFMEMORY;
2632
2633 if (FAILED(hr = d3d12_pipeline_state_init_compute(object, device, &pipeline_desc)))
2634 {
2635 vkd3d_free(object);
2636 return hr;
2637 }
2638
2639 TRACE("Created compute pipeline state %p.\n", object);
2640
2641 *state = object;
2642
2643 return S_OK;
2644}
2645
2647{
2648 switch (mode)
2649 {
2651 return VK_POLYGON_MODE_LINE;
2653 return VK_POLYGON_MODE_FILL;
2654 default:
2655 FIXME("Unhandled fill mode %#x.\n", mode);
2656 return VK_POLYGON_MODE_FILL;
2657 }
2658}
2659
2661{
2662 switch (mode)
2663 {
2665 return VK_CULL_MODE_NONE;
2669 return VK_CULL_MODE_BACK_BIT;
2670 default:
2671 FIXME("Unhandled cull mode %#x.\n", mode);
2672 return VK_CULL_MODE_NONE;
2673 }
2674}
2675
2678{
2680 vk_desc->pNext = NULL;
2681 vk_desc->flags = 0;
2682 vk_desc->depthClampEnable = !d3d12_desc->DepthClipEnable;
2685 vk_desc->cullMode = vk_cull_mode_from_d3d12(d3d12_desc->CullMode);
2687 vk_desc->depthBiasEnable = d3d12_desc->DepthBias || d3d12_desc->SlopeScaledDepthBias;
2688 vk_desc->depthBiasConstantFactor = d3d12_desc->DepthBias;
2689 vk_desc->depthBiasClamp = d3d12_desc->DepthBiasClamp;
2690 vk_desc->depthBiasSlopeFactor = d3d12_desc->SlopeScaledDepthBias;
2691 vk_desc->lineWidth = 1.0f;
2692
2693 if (d3d12_desc->MultisampleEnable)
2694 FIXME_ONCE("Ignoring MultisampleEnable %#x.\n", d3d12_desc->MultisampleEnable);
2695 if (d3d12_desc->AntialiasedLineEnable)
2696 FIXME_ONCE("Ignoring AntialiasedLineEnable %#x.\n", d3d12_desc->AntialiasedLineEnable);
2697 if (d3d12_desc->ForcedSampleCount)
2698 FIXME("Ignoring ForcedSampleCount %#x.\n", d3d12_desc->ForcedSampleCount);
2699 if (d3d12_desc->ConservativeRaster)
2700 FIXME("Ignoring ConservativeRaster %#x.\n", d3d12_desc->ConservativeRaster);
2701}
2702
2705{
2706 vk_rs_desc->depthClampEnable = VK_TRUE;
2707
2709 depth_clip_info->pNext = NULL;
2710 depth_clip_info->flags = 0;
2711 depth_clip_info->depthClipEnable = d3d12_desc->DepthClipEnable;
2712
2713 vk_prepend_struct(vk_rs_desc, depth_clip_info);
2714}
2715
2718 const struct vkd3d_vulkan_info *vk_info)
2719{
2720 if (!so_desc->NumEntries || !so_desc->RasterizedStream
2722 return;
2723
2724 if (!vk_info->rasterization_stream)
2725 {
2726 FIXME("Rasterization stream select is not supported by Vulkan implementation.\n");
2727 return;
2728 }
2729
2731 stream_info->pNext = NULL;
2732 stream_info->flags = 0;
2733 stream_info->rasterizationStream = so_desc->RasterizedStream;
2734
2735 vk_prepend_struct(vk_rs_desc, stream_info);
2736}
2737
2739{
2740 switch (op)
2741 {
2743 return VK_STENCIL_OP_KEEP;
2745 return VK_STENCIL_OP_ZERO;
2747 return VK_STENCIL_OP_REPLACE;
2753 return VK_STENCIL_OP_INVERT;
2758 default:
2759 FIXME("Unhandled stencil op %#x.\n", op);
2760 return VK_STENCIL_OP_KEEP;
2761 }
2762}
2763
2765{
2766 switch (op)
2767 {
2769 return VK_COMPARE_OP_NEVER;
2771 return VK_COMPARE_OP_LESS;
2773 return VK_COMPARE_OP_EQUAL;
2777 return VK_COMPARE_OP_GREATER;
2783 return VK_COMPARE_OP_ALWAYS;
2784 default:
2785 FIXME("Unhandled compare op %#x.\n", op);
2786 return VK_COMPARE_OP_NEVER;
2787 }
2788}
2789
2791 const D3D12_DEPTH_STENCILOP_DESC *d3d12_desc, uint32_t compare_mask, uint32_t write_mask)
2792{
2793 vk_desc->failOp = vk_stencil_op_from_d3d12(d3d12_desc->StencilFailOp);
2794 vk_desc->passOp = vk_stencil_op_from_d3d12(d3d12_desc->StencilPassOp);
2795 vk_desc->depthFailOp = vk_stencil_op_from_d3d12(d3d12_desc->StencilDepthFailOp);
2796 vk_desc->compareOp = vk_compare_op_from_d3d12(d3d12_desc->StencilFunc);
2797 vk_desc->compareMask = compare_mask;
2798 vk_desc->writeMask = write_mask;
2799 /* The stencil reference value is a dynamic state. Set by OMSetStencilRef(). */
2800 vk_desc->reference = 0;
2801}
2802
2805{
2806 memset(vk_desc, 0, sizeof(*vk_desc));
2808 vk_desc->pNext = NULL;
2809 vk_desc->flags = 0;
2810 if ((vk_desc->depthTestEnable = d3d12_desc->DepthEnable))
2811 {
2812 vk_desc->depthWriteEnable = d3d12_desc->DepthWriteMask & D3D12_DEPTH_WRITE_MASK_ALL;
2813 vk_desc->depthCompareOp = vk_compare_op_from_d3d12(d3d12_desc->DepthFunc);
2814 }
2815 else
2816 {
2817 vk_desc->depthWriteEnable = VK_FALSE;
2819 }
2820 vk_desc->depthBoundsTestEnable = d3d12_desc->DepthBoundsTestEnable;
2821 if ((vk_desc->stencilTestEnable = d3d12_desc->StencilEnable))
2822 {
2823 vk_stencil_op_state_from_d3d12(&vk_desc->front, &d3d12_desc->FrontFace,
2824 d3d12_desc->StencilReadMask, d3d12_desc->StencilWriteMask);
2825 vk_stencil_op_state_from_d3d12(&vk_desc->back, &d3d12_desc->BackFace,
2826 d3d12_desc->StencilReadMask, d3d12_desc->StencilWriteMask);
2827 }
2828 else
2829 {
2830 memset(&vk_desc->front, 0, sizeof(vk_desc->front));
2831 memset(&vk_desc->back, 0, sizeof(vk_desc->back));
2832 }
2833 vk_desc->minDepthBounds = 0.0f;
2834 vk_desc->maxDepthBounds = 1.0f;
2835}
2836
2838{
2839 switch (blend)
2840 {
2841 case D3D12_BLEND_ZERO:
2842 return VK_BLEND_FACTOR_ZERO;
2843 case D3D12_BLEND_ONE:
2844 return VK_BLEND_FACTOR_ONE;
2864 if (alpha)
2868 if (alpha)
2879 default:
2880 FIXME("Unhandled blend %#x.\n", blend);
2881 return VK_BLEND_FACTOR_ZERO;
2882 }
2883}
2884
2886{
2887 switch (op)
2888 {
2889 case D3D12_BLEND_OP_ADD:
2890 return VK_BLEND_OP_ADD;
2892 return VK_BLEND_OP_SUBTRACT;
2895 case D3D12_BLEND_OP_MIN:
2896 return VK_BLEND_OP_MIN;
2897 case D3D12_BLEND_OP_MAX:
2898 return VK_BLEND_OP_MAX;
2899 default:
2900 FIXME("Unhandled blend op %#x.\n", op);
2901 return VK_BLEND_OP_ADD;
2902 }
2903}
2904
2907{
2908 if (d3d12_desc->BlendEnable)
2909 {
2910 vk_desc->blendEnable = VK_TRUE;
2911 vk_desc->srcColorBlendFactor = vk_blend_factor_from_d3d12(d3d12_desc->SrcBlend, false);
2912 vk_desc->dstColorBlendFactor = vk_blend_factor_from_d3d12(d3d12_desc->DestBlend, false);
2913 vk_desc->colorBlendOp = vk_blend_op_from_d3d12(d3d12_desc->BlendOp);
2914 vk_desc->srcAlphaBlendFactor = vk_blend_factor_from_d3d12(d3d12_desc->SrcBlendAlpha, true);
2915 vk_desc->dstAlphaBlendFactor = vk_blend_factor_from_d3d12(d3d12_desc->DestBlendAlpha, true);
2916 vk_desc->alphaBlendOp = vk_blend_op_from_d3d12(d3d12_desc->BlendOpAlpha);
2917 }
2918 else
2919 {
2920 memset(vk_desc, 0, sizeof(*vk_desc));
2921 }
2922 vk_desc->colorWriteMask = 0;
2923 if (d3d12_desc->RenderTargetWriteMask & D3D12_COLOR_WRITE_ENABLE_RED)
2925 if (d3d12_desc->RenderTargetWriteMask & D3D12_COLOR_WRITE_ENABLE_GREEN)
2927 if (d3d12_desc->RenderTargetWriteMask & D3D12_COLOR_WRITE_ENABLE_BLUE)
2929 if (d3d12_desc->RenderTargetWriteMask & D3D12_COLOR_WRITE_ENABLE_ALPHA)
2931}
2932
2934{
2937}
2938
2940{
2941 return desc->BlendEnable
2942 && (is_dual_source_blending_blend(desc->SrcBlend)
2943 || is_dual_source_blending_blend(desc->DestBlend)
2944 || is_dual_source_blending_blend(desc->SrcBlendAlpha)
2945 || is_dual_source_blending_blend(desc->DestBlendAlpha));
2946}
2947
2949 const D3D12_INPUT_LAYOUT_DESC *input_layout_desc, uint32_t *offsets)
2950{
2951 uint32_t input_slot_offsets[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = {0};
2953 const struct vkd3d_format *format;
2954 unsigned int i;
2955
2956 if (input_layout_desc->NumElements > D3D12_VS_INPUT_REGISTER_COUNT)
2957 {
2958 FIXME("InputLayout.NumElements %u > %u, ignoring extra elements.\n",
2959 input_layout_desc->NumElements, D3D12_VS_INPUT_REGISTER_COUNT);
2960 }
2961
2962 for (i = 0; i < min(input_layout_desc->NumElements, D3D12_VS_INPUT_REGISTER_COUNT); ++i)
2963 {
2964 e = &input_layout_desc->pInputElementDescs[i];
2965
2966 if (e->InputSlot >= ARRAY_SIZE(input_slot_offsets))
2967 {
2968 WARN("Invalid input slot %#x.\n", e->InputSlot);
2969 return E_INVALIDARG;
2970 }
2971
2972 /* TODO: DXGI_FORMAT_UNKNOWN will return a format with byte_count == 1,
2973 * which may not match driver behaviour (return E_INVALIDARG?). */
2974 if (!(format = vkd3d_get_format(device, e->Format, false)))
2975 {
2976 WARN("Invalid input element format %#x.\n", e->Format);
2977 return E_INVALIDARG;
2978 }
2979
2980 if (e->AlignedByteOffset != D3D12_APPEND_ALIGNED_ELEMENT)
2981 offsets[i] = e->AlignedByteOffset;
2982 else
2983 offsets[i] = align(input_slot_offsets[e->InputSlot], min(4, format->byte_count));
2984
2985 input_slot_offsets[e->InputSlot] = offsets[i] + format->byte_count;
2986 }
2987
2988 return S_OK;
2989}
2990
2991static unsigned int vkd3d_get_rt_format_swizzle(const struct vkd3d_format *format)
2992{
2993 if (format->dxgi_format == DXGI_FORMAT_A8_UNORM)
2994 return VKD3D_SHADER_SWIZZLE(W, X, Y, Z);
2995
2997}
2998
3000
3002 struct d3d12_graphics_pipeline_state *graphics, struct d3d12_device *device,
3003 VkFormat dynamic_dsv_format, VkRenderPass *vk_render_pass)
3004{
3006 VkFormat dsv_format;
3007 unsigned int i;
3008
3009 memcpy(key.vk_formats, graphics->rtv_formats, sizeof(graphics->rtv_formats));
3010 key.attachment_count = graphics->rt_count;
3011
3012 if (!(dsv_format = graphics->dsv_format) && (graphics->null_attachment_mask & dsv_attachment_mask(graphics)))
3013 dsv_format = dynamic_dsv_format;
3014
3015 if (dsv_format)
3016 {
3017 VKD3D_ASSERT(graphics->ds_desc.front.writeMask == graphics->ds_desc.back.writeMask);
3018 key.depth_enable = graphics->ds_desc.depthTestEnable;
3019 key.stencil_enable = graphics->ds_desc.stencilTestEnable;
3020 key.depth_stencil_write = graphics->ds_desc.depthWriteEnable
3021 || graphics->ds_desc.front.writeMask;
3022 key.vk_formats[key.attachment_count++] = dsv_format;
3023 }
3024 else
3025 {
3026 key.depth_enable = false;
3027 key.stencil_enable = false;
3028 key.depth_stencil_write = false;
3029 }
3030
3031 if (key.attachment_count != ARRAY_SIZE(key.vk_formats))
3032 key.vk_formats[ARRAY_SIZE(key.vk_formats) - 1] = VK_FORMAT_UNDEFINED;
3033 for (i = key.attachment_count; i < ARRAY_SIZE(key.vk_formats); ++i)
3034 VKD3D_ASSERT(key.vk_formats[i] == VK_FORMAT_UNDEFINED);
3035
3036 key.padding = 0;
3037 key.sample_count = graphics->ms_desc.rasterizationSamples;
3038
3039 return vkd3d_render_pass_cache_find(&device->render_pass_cache, device, &key, vk_render_pass);
3040}
3041
3043{
3044 switch (op)
3045 {
3047 return VK_LOGIC_OP_CLEAR;
3048 case D3D12_LOGIC_OP_SET:
3049 return VK_LOGIC_OP_SET;
3051 return VK_LOGIC_OP_COPY;
3055 return VK_LOGIC_OP_NO_OP;
3057 return VK_LOGIC_OP_INVERT;
3058 case D3D12_LOGIC_OP_AND:
3059 return VK_LOGIC_OP_AND;
3061 return VK_LOGIC_OP_NAND;
3062 case D3D12_LOGIC_OP_OR:
3063 return VK_LOGIC_OP_OR;
3064 case D3D12_LOGIC_OP_NOR:
3065 return VK_LOGIC_OP_NOR;
3066 case D3D12_LOGIC_OP_XOR:
3067 return VK_LOGIC_OP_XOR;
3078 default:
3079 FIXME("Unhandled logic op %#x.\n", op);
3080 return VK_LOGIC_OP_NO_OP;
3081 }
3082}
3083
3085 struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
3086{
3087 unsigned int ps_output_swizzle[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT];
3088 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
3089 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
3090 const D3D12_STREAM_OUTPUT_DESC *so_desc = &desc->stream_output;
3092 const struct vkd3d_vulkan_info *vk_info = &device->vk_info;
3093 uint32_t instance_divisors[D3D12_VS_INPUT_REGISTER_COUNT];
3094 struct vkd3d_shader_spirv_target_info *stage_target_info;
3095 uint32_t aligned_offsets[D3D12_VS_INPUT_REGISTER_COUNT];
3096 struct vkd3d_shader_descriptor_offset_info offset_info;
3097 struct vkd3d_shader_parameter ps_shader_parameters[1];
3099 struct vkd3d_shader_spirv_target_info ps_target_info;
3100 struct vkd3d_shader_interface_info shader_interface;
3101 struct vkd3d_shader_spirv_target_info target_info;
3102 const struct d3d12_root_signature *root_signature;
3103 struct vkd3d_shader_signature input_signature;
3104 bool have_attachment, is_dsv_format_unknown;
3105 VkShaderStageFlagBits xfb_stage = 0;
3106 VkSampleCountFlagBits sample_count;
3107 const struct vkd3d_format *format;
3108 unsigned int instance_divisor;
3109 VkVertexInputRate input_rate;
3110 unsigned int i, j;
3111 size_t rt_count;
3112 uint32_t mask;
3113 HRESULT hr;
3114 int ret;
3115
3116 static const DWORD default_ps_code[] =
3117 {
3118#if 0
3119 ps_4_0
3120 ret
3121#endif
3122 0x43425844, 0x19cbf606, 0x18f562b9, 0xdaeed4db, 0xc324aa46, 0x00000001, 0x00000060, 0x00000003,
3123 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
3124 0x00000008, 0x00000000, 0x00000008, 0x52444853, 0x0000000c, 0x00000040, 0x00000003, 0x0100003e,
3125 };
3126 static const D3D12_SHADER_BYTECODE default_ps = {default_ps_code, sizeof(default_ps_code)};
3127 static const struct
3128 {
3129 enum VkShaderStageFlagBits stage;
3131 }
3132 shader_stages[] =
3133 {
3139 };
3140
3141 state->ID3D12PipelineState_iface.lpVtbl = &d3d12_pipeline_state_vtbl;
3142 state->refcount = 1;
3143
3144 memset(&state->uav_counters, 0, sizeof(state->uav_counters));
3145 graphics->stage_count = 0;
3146
3147 memset(&input_signature, 0, sizeof(input_signature));
3148
3149 for (i = desc->rtv_formats.NumRenderTargets; i < ARRAY_SIZE(desc->rtv_formats.RTFormats); ++i)
3150 {
3151 if (desc->rtv_formats.RTFormats[i] != DXGI_FORMAT_UNKNOWN)
3152 {
3153 WARN("Format must be set to DXGI_FORMAT_UNKNOWN for inactive render targets.\n");
3154 return E_INVALIDARG;
3155 }
3156 }
3157
3158 if (!(root_signature = unsafe_impl_from_ID3D12RootSignature(desc->root_signature)))
3159 {
3160 WARN("Root signature is NULL.\n");
3161 return E_INVALIDARG;
3162 }
3163
3164 sample_count = vk_samples_from_dxgi_sample_desc(&desc->sample_desc);
3165 if (desc->sample_desc.Count != 1 && desc->sample_desc.Quality)
3166 WARN("Ignoring sample quality %u.\n", desc->sample_desc.Quality);
3167
3168 rt_count = desc->rtv_formats.NumRenderTargets;
3169 if (rt_count > ARRAY_SIZE(graphics->blend_attachments))
3170 {
3171 FIXME("NumRenderTargets %zu > %zu, ignoring extra formats.\n",
3172 rt_count, ARRAY_SIZE(graphics->blend_attachments));
3173 rt_count = ARRAY_SIZE(graphics->blend_attachments);
3174 }
3175
3176 graphics->om_logic_op_enable = desc->blend_state.RenderTarget[0].LogicOpEnable
3177 && device->feature_options.OutputMergerLogicOp;
3178 graphics->om_logic_op = graphics->om_logic_op_enable
3179 ? vk_logic_op_from_d3d12(desc->blend_state.RenderTarget[0].LogicOp)
3181 if (desc->blend_state.RenderTarget[0].LogicOpEnable && !graphics->om_logic_op_enable)
3182 WARN("The device does not support output merger logic ops. Ignoring logic op %#x.\n",
3183 desc->blend_state.RenderTarget[0].LogicOp);
3184
3185 graphics->null_attachment_mask = 0;
3186 for (i = 0; i < rt_count; ++i)
3187 {
3188 const D3D12_RENDER_TARGET_BLEND_DESC *rt_desc;
3189
3190 if (desc->rtv_formats.RTFormats[i] == DXGI_FORMAT_UNKNOWN)
3191 {
3192 graphics->null_attachment_mask |= 1u << i;
3193 ps_output_swizzle[i] = VKD3D_SHADER_NO_SWIZZLE;
3194 graphics->rtv_formats[i] = VK_FORMAT_UNDEFINED;
3195 }
3196 else if ((format = vkd3d_get_format(device, desc->rtv_formats.RTFormats[i], false)))
3197 {
3198 ps_output_swizzle[i] = vkd3d_get_rt_format_swizzle(format);
3199 graphics->rtv_formats[i] = format->vk_format;
3200 }
3201 else
3202 {
3203 WARN("Invalid RTV format %#x.\n", desc->rtv_formats.RTFormats[i]);
3204 hr = E_INVALIDARG;
3205 goto fail;
3206 }
3207
3208 rt_desc = &desc->blend_state.RenderTarget[desc->blend_state.IndependentBlendEnable ? i : 0];
3209 if (desc->blend_state.IndependentBlendEnable && rt_desc->LogicOpEnable)
3210 {
3211 WARN("IndependentBlendEnable must be FALSE when logic operations are enabled.\n");
3212 hr = E_INVALIDARG;
3213 goto fail;
3214 }
3215 if (rt_desc->BlendEnable && rt_desc->LogicOpEnable)
3216 {
3217 WARN("Only one of BlendEnable or LogicOpEnable can be set to TRUE.\n");
3218 hr = E_INVALIDARG;
3219 goto fail;
3220 }
3221
3222 blend_attachment_from_d3d12(&graphics->blend_attachments[i], rt_desc);
3223 }
3224 for (i = rt_count; i < ARRAY_SIZE(graphics->rtv_formats); ++i)
3225 graphics->rtv_formats[i] = VK_FORMAT_UNDEFINED;
3226 graphics->rt_count = rt_count;
3227
3228 ds_desc_from_d3d12(&graphics->ds_desc, &desc->depth_stencil_state);
3229 if (graphics->ds_desc.depthBoundsTestEnable && !device->feature_options2.DepthBoundsTestSupported)
3230 {
3231 WARN("Depth bounds test not supported by device.\n");
3232 hr = E_INVALIDARG;
3233 goto fail;
3234 }
3235 if (desc->dsv_format == DXGI_FORMAT_UNKNOWN
3236 && graphics->ds_desc.depthTestEnable && !graphics->ds_desc.depthWriteEnable
3238 {
3239 TRACE("Disabling depth test.\n");
3240 graphics->ds_desc.depthTestEnable = VK_FALSE;
3241 }
3242
3243 graphics->dsv_format = VK_FORMAT_UNDEFINED;
3244 if (graphics->ds_desc.depthTestEnable || graphics->ds_desc.stencilTestEnable
3245 || graphics->ds_desc.depthBoundsTestEnable)
3246 {
3247 if (desc->dsv_format == DXGI_FORMAT_UNKNOWN)
3248 {
3249 WARN("DSV format is DXGI_FORMAT_UNKNOWN.\n");
3250 graphics->dsv_format = VK_FORMAT_UNDEFINED;
3251 graphics->null_attachment_mask |= dsv_attachment_mask(graphics);
3252 }
3253 else if ((format = vkd3d_get_format(device, desc->dsv_format, true)))
3254 {
3256 FIXME("Format %#x is not depth/stencil format.\n", format->dxgi_format);
3257
3258 graphics->dsv_format = format->vk_format;
3259 }
3260 else
3261 {
3262 WARN("Invalid DSV format %#x.\n", desc->dsv_format);
3263 hr = E_INVALIDARG;
3264 goto fail;
3265 }
3266
3267 if (!desc->ps.pShaderBytecode)
3268 {
3269 if (FAILED(hr = create_shader_stage(device, &graphics->stages[graphics->stage_count],
3270 VK_SHADER_STAGE_FRAGMENT_BIT, &default_ps, NULL)))
3271 goto fail;
3272
3273 ++graphics->stage_count;
3274 }
3275 }
3276
3278 ps_shader_parameters[0].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT;
3279 ps_shader_parameters[0].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32;
3280 ps_shader_parameters[0].u.immediate_constant.u.u32 = sample_count;
3281
3283 ps_target_info.next = NULL;
3284 ps_target_info.entry_point = "main";
3285 ps_target_info.environment = device->environment;
3286 ps_target_info.extensions = vk_info->shader_extensions;
3287 ps_target_info.extension_count = vk_info->shader_extension_count;
3288 ps_target_info.parameters = ps_shader_parameters;
3289 ps_target_info.parameter_count = ARRAY_SIZE(ps_shader_parameters);
3290 ps_target_info.dual_source_blending = is_dual_source_blending(&desc->blend_state.RenderTarget[0]);
3291 ps_target_info.output_swizzles = ps_output_swizzle;
3292 ps_target_info.output_swizzle_count = rt_count;
3293
3294 if (ps_target_info.dual_source_blending && rt_count > 1)
3295 {
3296 WARN("Only one render target is allowed when dual source blending is used.\n");
3297 hr = E_INVALIDARG;
3298 goto fail;
3299 }
3300 if (ps_target_info.dual_source_blending && desc->blend_state.IndependentBlendEnable)
3301 {
3302 for (i = 1; i < ARRAY_SIZE(desc->blend_state.RenderTarget); ++i)
3303 {
3304 if (desc->blend_state.RenderTarget[i].BlendEnable)
3305 {
3306 WARN("Blend enable cannot be set for render target %u when dual source blending is used.\n", i);
3307 hr = E_INVALIDARG;
3308 goto fail;
3309 }
3310 }
3311 }
3312
3313 memset(&target_info, 0, sizeof(target_info));
3315 target_info.environment = device->environment;
3316 target_info.extensions = vk_info->shader_extensions;
3317 target_info.extension_count = vk_info->shader_extension_count;
3318
3319 graphics->xfb_enabled = false;
3320 if (so_desc->NumEntries)
3321 {
3323 {
3324 WARN("Stream output is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT.\n");
3325 hr = E_INVALIDARG;
3326 goto fail;
3327 }
3328
3329 if (!vk_info->EXT_transform_feedback)
3330 {
3331 FIXME("Transform feedback is not supported by Vulkan implementation.\n");
3332 hr = E_NOTIMPL;
3333 goto fail;
3334 }
3335
3336 graphics->xfb_enabled = true;
3337
3339 xfb_info.next = NULL;
3340
3341 xfb_info.elements = (const struct vkd3d_shader_transform_feedback_element *)so_desc->pSODeclaration;
3342 xfb_info.element_count = so_desc->NumEntries;
3343 xfb_info.buffer_strides = so_desc->pBufferStrides;
3344 xfb_info.buffer_stride_count = so_desc->NumStrides;
3345
3346 if (desc->gs.pShaderBytecode)
3347 xfb_stage = VK_SHADER_STAGE_GEOMETRY_BIT;
3348 else if (desc->ds.pShaderBytecode)
3350 else
3351 xfb_stage = VK_SHADER_STAGE_VERTEX_BIT;
3352 }
3353
3355 shader_interface.next = NULL;
3356 shader_interface.bindings = root_signature->descriptor_mapping;
3357 shader_interface.binding_count = root_signature->binding_count;
3358 shader_interface.push_constant_buffers = root_signature->root_constants;
3359 shader_interface.push_constant_buffer_count = root_signature->root_constant_count;
3360 shader_interface.combined_samplers = NULL;
3361 shader_interface.combined_sampler_count = 0;
3362
3363 if (root_signature->descriptor_offsets)
3364 {
3366 offset_info.next = NULL;
3367 offset_info.descriptor_table_offset = root_signature->descriptor_table_offset;
3368 offset_info.descriptor_table_count = root_signature->descriptor_table_count;
3369 offset_info.binding_offsets = root_signature->descriptor_offsets;
3370 offset_info.uav_counter_offsets = root_signature->uav_counter_offsets;
3371 }
3372
3373 for (i = 0; i < ARRAY_SIZE(shader_stages); ++i)
3374 {
3375 const D3D12_SHADER_BYTECODE *b = (const void *)((uintptr_t)desc + shader_stages[i].offset);
3376 const struct vkd3d_shader_code dxbc = {b->pShaderBytecode, b->BytecodeLength};
3377
3378 if (!b->pShaderBytecode)
3379 continue;
3380
3382 b, shader_stages[i].stage)))
3383 goto fail;
3384
3385 shader_interface.uav_counters = NULL;
3386 shader_interface.uav_counter_count = 0;
3387 stage_target_info = &target_info;
3388 switch (shader_stages[i].stage)
3389 {
3391 if ((ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature, NULL)) < 0)
3392 {
3394 goto fail;
3395 }
3396 break;
3397
3400 if (desc->primitive_topology_type != D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH)
3401 {
3402 WARN("D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH must be used with tessellation shaders.\n");
3403 hr = E_INVALIDARG;
3404 goto fail;
3405 }
3406 break;
3407
3409 break;
3410
3412 shader_interface.uav_counters = root_signature->uav_counter_mapping
3413 ? root_signature->uav_counter_mapping : state->uav_counters.bindings;
3414 shader_interface.uav_counter_count = root_signature->uav_counter_mapping
3415 ? root_signature->uav_mapping_count : state->uav_counters.binding_count;
3416 stage_target_info = &ps_target_info;
3417 break;
3418
3419 default:
3420 hr = E_INVALIDARG;
3421 goto fail;
3422 }
3423
3424 shader_interface.next = NULL;
3425 xfb_info.next = NULL;
3426 ps_target_info.next = NULL;
3427 target_info.next = NULL;
3428 offset_info.next = NULL;
3429 if (shader_stages[i].stage == xfb_stage)
3430 vkd3d_prepend_struct(&shader_interface, &xfb_info);
3431 vkd3d_prepend_struct(&shader_interface, stage_target_info);
3432 if (root_signature->descriptor_offsets)
3433 vkd3d_prepend_struct(&shader_interface, &offset_info);
3434
3435 if (FAILED(hr = create_shader_stage(device, &graphics->stages[graphics->stage_count],
3436 shader_stages[i].stage, b, &shader_interface)))
3437 goto fail;
3438
3439 ++graphics->stage_count;
3440 }
3441
3442 graphics->attribute_count = desc->input_layout.NumElements;
3443 if (graphics->attribute_count > ARRAY_SIZE(graphics->attributes))
3444 {
3445 FIXME("InputLayout.NumElements %zu > %zu, ignoring extra elements.\n",
3446 graphics->attribute_count, ARRAY_SIZE(graphics->attributes));
3447 graphics->attribute_count = ARRAY_SIZE(graphics->attributes);
3448 }
3449
3450 if (graphics->attribute_count
3452 {
3453 WARN("Input layout is used without D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT.\n");
3454 hr = E_INVALIDARG;
3455 goto fail;
3456 }
3457
3458 if (FAILED(hr = compute_input_layout_offsets(device, &desc->input_layout, aligned_offsets)))
3459 goto fail;
3460
3461 graphics->instance_divisor_count = 0;
3462 for (i = 0, j = 0, mask = 0; i < graphics->attribute_count; ++i)
3463 {
3464 const D3D12_INPUT_ELEMENT_DESC *e = &desc->input_layout.pInputElementDescs[i];
3466
3467 /* TODO: DXGI_FORMAT_UNKNOWN will succeed here, which may not match
3468 * driver behaviour (return E_INVALIDARG?). */
3469 if (!(format = vkd3d_get_format(device, e->Format, false)))
3470 {
3471 WARN("Invalid input element format %#x.\n", e->Format);
3472 hr = E_INVALIDARG;
3473 goto fail;
3474 }
3475
3476 if (e->InputSlot >= ARRAY_SIZE(graphics->input_rates)
3477 || e->InputSlot >= ARRAY_SIZE(instance_divisors))
3478 {
3479 WARN("Invalid input slot %#x.\n", e->InputSlot);
3480 hr = E_INVALIDARG;
3481 goto fail;
3482 }
3483
3485 e->SemanticName, e->SemanticIndex, 0)))
3486 {
3487 WARN("Unused input element %u.\n", i);
3488 continue;
3489 }
3490
3492 graphics->attributes[j].binding = e->InputSlot;
3493 graphics->attributes[j].format = format->vk_format;
3494 if (e->AlignedByteOffset != D3D12_APPEND_ALIGNED_ELEMENT)
3495 graphics->attributes[j].offset = e->AlignedByteOffset;
3496 else
3497 graphics->attributes[j].offset = aligned_offsets[i];
3498 ++j;
3499
3500 switch (e->InputSlotClass)
3501 {
3503 input_rate = VK_VERTEX_INPUT_RATE_VERTEX;
3504 instance_divisor = 1;
3505 break;
3506
3508 input_rate = VK_VERTEX_INPUT_RATE_INSTANCE;
3509 instance_divisor = e->InstanceDataStepRate;
3510 if (instance_divisor > vk_info->max_vertex_attrib_divisor
3511 || (!instance_divisor && !vk_info->vertex_attrib_zero_divisor))
3512 {
3513 FIXME("Instance divisor %u not supported by Vulkan implementation.\n", instance_divisor);
3514 instance_divisor = 1;
3515 }
3516 break;
3517
3518 default:
3519 FIXME("Unhandled input slot class %#x on input element %u.\n", e->InputSlotClass, i);
3520 hr = E_INVALIDARG;
3521 goto fail;
3522 }
3523
3524 if (mask & (1u << e->InputSlot) && (graphics->input_rates[e->InputSlot] != input_rate
3525 || instance_divisors[e->InputSlot] != instance_divisor))
3526 {
3527 FIXME("Input slot rate %#x, instance divisor %u on input element %u conflicts "
3528 "with earlier input slot rate %#x, instance divisor %u.\n",
3529 input_rate, instance_divisor, e->InputSlot,
3530 graphics->input_rates[e->InputSlot], instance_divisors[e->InputSlot]);
3531 hr = E_INVALIDARG;
3532 goto fail;
3533 }
3534
3535 graphics->input_rates[e->InputSlot] = input_rate;
3536 instance_divisors[e->InputSlot] = instance_divisor;
3537 if (instance_divisor != 1 && !(mask & (1u << e->InputSlot)))
3538 {
3539 binding_divisor = &graphics->instance_divisors[graphics->instance_divisor_count++];
3540 binding_divisor->binding = e->InputSlot;
3541 binding_divisor->divisor = instance_divisor;
3542 }
3543 mask |= 1u << e->InputSlot;
3544 }
3545 graphics->attribute_count = j;
3546 vkd3d_shader_free_shader_signature(&input_signature);
3547
3548 switch (desc->strip_cut_value)
3549 {
3553 graphics->index_buffer_strip_cut_value = desc->strip_cut_value;
3554 break;
3555 default:
3556 WARN("Invalid index buffer strip cut value %#x.\n", desc->strip_cut_value);
3557 hr = E_INVALIDARG;
3558 goto fail;
3559 }
3560
3561 is_dsv_format_unknown = graphics->null_attachment_mask & dsv_attachment_mask(graphics);
3562
3563 rs_desc_from_d3d12(&graphics->rs_desc, &desc->rasterizer_state);
3564 have_attachment = graphics->rt_count || graphics->dsv_format || is_dsv_format_unknown;
3565 if ((!have_attachment && !(desc->ps.pShaderBytecode && desc->ps.BytecodeLength))
3566 || (graphics->xfb_enabled && so_desc->RasterizedStream == D3D12_SO_NO_RASTERIZED_STREAM))
3568
3569 rs_stream_info_from_d3d12(&graphics->rs_stream_info, &graphics->rs_desc, so_desc, vk_info);
3570 if (vk_info->EXT_depth_clip_enable)
3571 rs_depth_clip_info_from_d3d12(&graphics->rs_depth_clip_info, &graphics->rs_desc, &desc->rasterizer_state);
3572
3574 graphics->ms_desc.pNext = NULL;
3575 graphics->ms_desc.flags = 0;
3576 graphics->ms_desc.rasterizationSamples = sample_count;
3578 graphics->ms_desc.minSampleShading = 0.0f;
3579 graphics->ms_desc.pSampleMask = NULL;
3580 if (desc->sample_mask != ~0u)
3581 {
3582 VKD3D_ASSERT(DIV_ROUND_UP(sample_count, 32) <= ARRAY_SIZE(graphics->sample_mask));
3583 graphics->sample_mask[0] = desc->sample_mask;
3584 graphics->sample_mask[1] = 0xffffffffu;
3585 graphics->ms_desc.pSampleMask = graphics->sample_mask;
3586 }
3587 graphics->ms_desc.alphaToCoverageEnable = desc->blend_state.AlphaToCoverageEnable;
3588 graphics->ms_desc.alphaToOneEnable = VK_FALSE;
3589
3590 if (desc->view_instancing_desc.ViewInstanceCount)
3591 {
3592 FIXME("View instancing is not supported yet.\n");
3593 hr = E_INVALIDARG;
3594 goto fail;
3595 }
3596
3597 /* We defer creating the render pass for pipelines with DSVFormat equal to
3598 * DXGI_FORMAT_UNKNOWN. We take the actual DSV format from the bound DSV. */
3599 if (is_dsv_format_unknown)
3600 graphics->render_pass = VK_NULL_HANDLE;
3602 device, 0, &graphics->render_pass)))
3603 goto fail;
3604
3605 graphics->root_signature = root_signature;
3606
3607 list_init(&graphics->compiled_pipelines);
3608
3609 if (FAILED(hr = vkd3d_private_store_init(&state->private_store)))
3610 goto fail;
3611
3612 state->vk_bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS;
3613 state->implicit_root_signature = NULL;
3615
3616 return S_OK;
3617
3618fail:
3619 for (i = 0; i < graphics->stage_count; ++i)
3620 {
3621 VK_CALL(vkDestroyShaderModule(device->vk_device, state->u.graphics.stages[i].module, NULL));
3622 }
3623 vkd3d_shader_free_shader_signature(&input_signature);
3624
3626
3627 return hr;
3628}
3629
3632{
3633 struct d3d12_pipeline_state_desc pipeline_desc;
3635 HRESULT hr;
3636
3638
3639 if (!(object = vkd3d_malloc(sizeof(*object))))
3640 return E_OUTOFMEMORY;
3641
3642 if (FAILED(hr = d3d12_pipeline_state_init_graphics(object, device, &pipeline_desc)))
3643 {
3644 vkd3d_free(object);
3645 return hr;
3646 }
3647
3648 TRACE("Created graphics pipeline state %p.\n", object);
3649
3650 *state = object;
3651
3652 return S_OK;
3653}
3654
3657{
3658 struct d3d12_pipeline_state_desc pipeline_desc;
3660 VkPipelineBindPoint bind_point;
3661 HRESULT hr;
3662
3663 if (FAILED(hr = pipeline_state_desc_from_d3d12_stream_desc(&pipeline_desc, desc, &bind_point)))
3664 return hr;
3665
3666 if (!(object = vkd3d_calloc(1, sizeof(*object))))
3667 return E_OUTOFMEMORY;
3668
3669 switch (bind_point)
3670 {
3672 hr = d3d12_pipeline_state_init_compute(object, device, &pipeline_desc);
3673 break;
3674
3676 hr = d3d12_pipeline_state_init_graphics(object, device, &pipeline_desc);
3677 break;
3678
3679 default:
3681 }
3682
3683 if (FAILED(hr))
3684 {
3685 vkd3d_free(object);
3686 return hr;
3687 }
3688
3689 TRACE("Created pipeline state %p.\n", object);
3690
3691 *state = object;
3692 return S_OK;
3693}
3694
3696{
3697 switch (topology)
3698 {
3744 default:
3745 FIXME("Unhandled primitive topology %#x.\n", topology);
3747 }
3748}
3749
3751{
3752 switch (topology)
3753 {
3760 return false;
3761
3762 default:
3763 return true;
3764 }
3765}
3766
3768 const struct vkd3d_pipeline_key *key, VkRenderPass *vk_render_pass)
3769{
3770 const struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
3771 struct d3d12_device *device = state->device;
3772 VkPipeline vk_pipeline = VK_NULL_HANDLE;
3774
3776
3777 vkd3d_mutex_lock(&device->pipeline_cache_mutex);
3778
3780 {
3781 if (!memcmp(&current->key, key, sizeof(*key)))
3782 {
3783 vk_pipeline = current->vk_pipeline;
3784 *vk_render_pass = current->vk_render_pass;
3785 break;
3786 }
3787 }
3788
3789 vkd3d_mutex_unlock(&device->pipeline_cache_mutex);
3790
3791 return vk_pipeline;
3792}
3793
3795 const struct vkd3d_pipeline_key *key, VkPipeline vk_pipeline, VkRenderPass vk_render_pass)
3796{
3797 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
3798 struct vkd3d_compiled_pipeline *compiled_pipeline, *current;
3799 struct d3d12_device *device = state->device;
3800
3801 if (!(compiled_pipeline = vkd3d_malloc(sizeof(*compiled_pipeline))))
3802 return false;
3803
3804 compiled_pipeline->key = *key;
3805 compiled_pipeline->vk_pipeline = vk_pipeline;
3806 compiled_pipeline->vk_render_pass = vk_render_pass;
3807
3808 vkd3d_mutex_lock(&device->pipeline_cache_mutex);
3809
3811 {
3812 if (!memcmp(&current->key, key, sizeof(*key)))
3813 {
3814 vkd3d_free(compiled_pipeline);
3815 compiled_pipeline = NULL;
3816 break;
3817 }
3818 }
3819
3820 if (compiled_pipeline)
3821 list_add_tail(&graphics->compiled_pipelines, &compiled_pipeline->entry);
3822
3823 vkd3d_mutex_unlock(&device->pipeline_cache_mutex);
3824 return compiled_pipeline;
3825}
3826
3828 D3D12_PRIMITIVE_TOPOLOGY topology, const uint32_t *strides, VkFormat dsv_format,
3829 VkRenderPass *vk_render_pass)
3830{
3832 const struct vkd3d_vk_device_procs *vk_procs = &state->device->vk_procs;
3833 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
3835 VkPipelineTessellationStateCreateInfo tessellation_info;
3839 struct d3d12_device *device = state->device;
3840 VkGraphicsPipelineCreateInfo pipeline_desc;
3841 struct vkd3d_pipeline_key pipeline_key;
3842 size_t binding_count = 0;
3843 VkPipeline vk_pipeline;
3844 unsigned int i;
3845 uint32_t mask;
3846 VkResult vr;
3847 HRESULT hr;
3848
3849 static const VkPipelineViewportStateCreateInfo vp_desc =
3850 {
3852 .pNext = NULL,
3853 .flags = 0,
3854 .viewportCount = 1,
3855 .pViewports = NULL,
3856 .scissorCount = 1,
3857 .pScissors = NULL,
3858 };
3859 static const VkDynamicState dynamic_states[] =
3860 {
3866 };
3867 static const VkPipelineDynamicStateCreateInfo dynamic_desc =
3868 {
3870 .pNext = NULL,
3871 .flags = 0,
3872 .dynamicStateCount = ARRAY_SIZE(dynamic_states),
3873 .pDynamicStates = dynamic_states,
3874 };
3875
3877
3878 memset(&pipeline_key, 0, sizeof(pipeline_key));
3879 pipeline_key.topology = topology;
3880
3881 for (i = 0, mask = 0; i < graphics->attribute_count; ++i)
3882 {
3885
3886 binding = graphics->attributes[i].binding;
3887 if (mask & (1u << binding))
3888 continue;
3889
3890 if (binding_count == ARRAY_SIZE(bindings))
3891 {
3892 FIXME("Maximum binding count exceeded.\n");
3893 break;
3894 }
3895
3896 mask |= 1u << binding;
3897 b = &bindings[binding_count];
3898 b->binding = binding;
3899 b->stride = strides[binding];
3900 b->inputRate = graphics->input_rates[binding];
3901
3902 pipeline_key.strides[binding_count] = strides[binding];
3903
3904 ++binding_count;
3905 }
3906
3907 pipeline_key.dsv_format = dsv_format;
3908
3909 if ((vk_pipeline = d3d12_pipeline_state_find_compiled_pipeline(state, &pipeline_key, vk_render_pass)))
3910 return vk_pipeline;
3911
3913 input_desc.pNext = NULL;
3914 input_desc.flags = 0;
3915 input_desc.vertexBindingDescriptionCount = binding_count;
3916 input_desc.pVertexBindingDescriptions = bindings;
3917 input_desc.vertexAttributeDescriptionCount = graphics->attribute_count;
3918 input_desc.pVertexAttributeDescriptions = graphics->attributes;
3919
3920 if (graphics->instance_divisor_count)
3921 {
3922 input_desc.pNext = &input_divisor_info;
3924 input_divisor_info.pNext = NULL;
3925 input_divisor_info.vertexBindingDivisorCount = graphics->instance_divisor_count;
3926 input_divisor_info.pVertexBindingDivisors = graphics->instance_divisors;
3927 }
3928
3930 ia_desc.pNext = NULL;
3931 ia_desc.flags = 0;
3932 ia_desc.topology = vk_topology_from_d3d12_topology(topology);
3935
3937 {
3938 WARN("Primitive topology is undefined.\n");
3939 return VK_NULL_HANDLE;
3940 }
3941
3943 tessellation_info.pNext = NULL;
3944 tessellation_info.flags = 0;
3945 tessellation_info.patchControlPoints
3947
3949 blend_desc.pNext = NULL;
3950 blend_desc.flags = 0;
3951 blend_desc.logicOpEnable = graphics->om_logic_op_enable;
3952 blend_desc.logicOp = graphics->om_logic_op;
3953 blend_desc.attachmentCount = graphics->rt_count;
3954 blend_desc.pAttachments = graphics->blend_attachments;
3955 blend_desc.blendConstants[0] = D3D12_DEFAULT_BLEND_FACTOR_RED;
3956 blend_desc.blendConstants[1] = D3D12_DEFAULT_BLEND_FACTOR_GREEN;
3957 blend_desc.blendConstants[2] = D3D12_DEFAULT_BLEND_FACTOR_BLUE;
3958 blend_desc.blendConstants[3] = D3D12_DEFAULT_BLEND_FACTOR_ALPHA;
3959
3961 pipeline_desc.pNext = NULL;
3962 pipeline_desc.flags = 0;
3963 pipeline_desc.stageCount = graphics->stage_count;
3964 pipeline_desc.pStages = graphics->stages;
3965 pipeline_desc.pVertexInputState = &input_desc;
3966 pipeline_desc.pInputAssemblyState = &ia_desc;
3967 pipeline_desc.pTessellationState = &tessellation_info;
3968 pipeline_desc.pViewportState = &vp_desc;
3969 pipeline_desc.pRasterizationState = &graphics->rs_desc;
3970 pipeline_desc.pMultisampleState = &graphics->ms_desc;
3971 pipeline_desc.pDepthStencilState = &graphics->ds_desc;
3972 pipeline_desc.pColorBlendState = &blend_desc;
3973 pipeline_desc.pDynamicState = &dynamic_desc;
3974 pipeline_desc.layout = state->uav_counters.vk_pipeline_layout ? state->uav_counters.vk_pipeline_layout
3975 : graphics->root_signature->vk_pipeline_layout;
3976 pipeline_desc.subpass = 0;
3977 pipeline_desc.basePipelineHandle = VK_NULL_HANDLE;
3978 pipeline_desc.basePipelineIndex = -1;
3979
3980 /* Create a render pass for pipelines with DXGI_FORMAT_UNKNOWN. */
3981 if (!(pipeline_desc.renderPass = graphics->render_pass))
3982 {
3983 if (graphics->null_attachment_mask & dsv_attachment_mask(graphics))
3984 TRACE("Compiling %p with DSV format %#x.\n", state, dsv_format);
3985
3987 &pipeline_desc.renderPass)))
3988 return VK_NULL_HANDLE;
3989 }
3990
3991 *vk_render_pass = pipeline_desc.renderPass;
3992
3993 if ((vr = VK_CALL(vkCreateGraphicsPipelines(device->vk_device, device->vk_pipeline_cache,
3994 1, &pipeline_desc, NULL, &vk_pipeline))) < 0)
3995 {
3996 WARN("Failed to create Vulkan graphics pipeline, vr %d.\n", vr);
3997 return VK_NULL_HANDLE;
3998 }
3999
4000 if (d3d12_pipeline_state_put_pipeline_to_cache(state, &pipeline_key, vk_pipeline, pipeline_desc.renderPass))
4001 return vk_pipeline;
4002
4003 /* Other thread compiled the pipeline before us. */
4004 VK_CALL(vkDestroyPipeline(device->vk_device, vk_pipeline, NULL));
4005 vk_pipeline = d3d12_pipeline_state_find_compiled_pipeline(state, &pipeline_key, vk_render_pass);
4006 if (!vk_pipeline)
4007 ERR("Could not get the pipeline compiled by other thread from the cache.\n");
4008 return vk_pipeline;
4009}
4010
4011static int compile_hlsl_cs(const struct vkd3d_shader_code *hlsl, struct vkd3d_shader_code *dxbc)
4012{
4013 struct vkd3d_shader_hlsl_source_info hlsl_info;
4015
4016 static const struct vkd3d_shader_compile_option options[] =
4017 {
4019 };
4020
4022 info.next = &hlsl_info;
4023 info.source = *hlsl;
4024 info.source_type = VKD3D_SHADER_SOURCE_HLSL;
4025 info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF;
4026 info.options = options;
4027 info.option_count = ARRAY_SIZE(options);
4028 info.log_level = VKD3D_SHADER_LOG_NONE;
4029 info.source_name = NULL;
4030
4032 hlsl_info.next = NULL;
4033 hlsl_info.entry_point = "main";
4034 hlsl_info.secondary_code.code = NULL;
4035 hlsl_info.secondary_code.size = 0;
4036 hlsl_info.profile = "cs_5_0";
4037
4038 return vkd3d_shader_compile(&info, dxbc, NULL);
4039}
4040
4042 struct d3d12_device *device)
4043{
4044 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4045
4046 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->image_3d, NULL));
4047 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->image_2d_array, NULL));
4048 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->image_2d, NULL));
4049 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->image_1d_array, NULL));
4050 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->image_1d, NULL));
4051 VK_CALL(vkDestroyPipeline(device->vk_device, pipelines->buffer, NULL));
4052}
4053
4055{
4056 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4057
4060
4061 VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout_image, NULL));
4062 VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout_buffer, NULL));
4063
4064 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout_image, NULL));
4065 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout_buffer, NULL));
4066}
4067
4069{
4070 struct vkd3d_shader_push_constant_buffer push_constant;
4071 struct vkd3d_shader_interface_info shader_interface;
4073 VkDescriptorSetLayoutBinding set_binding;
4074 VkPushConstantRange push_constant_range;
4075 unsigned int i;
4076 HRESULT hr;
4077
4078 const struct
4079 {
4080 VkDescriptorSetLayout *set_layout;
4081 VkPipelineLayout *pipeline_layout;
4082 VkDescriptorType descriptor_type;
4083 }
4084 set_layouts[] =
4085 {
4086 {&state->vk_set_layout_buffer, &state->vk_pipeline_layout_buffer, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER},
4087 {&state->vk_set_layout_image, &state->vk_pipeline_layout_image, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE},
4088 };
4089
4090 const struct
4091 {
4092 VkPipeline *pipeline;
4093 VkPipelineLayout *pipeline_layout;
4094 struct vkd3d_shader_code code;
4095 }
4096 pipelines[] =
4097 {
4098#define SHADER_CODE(name) {name, sizeof(name)}
4099 {&state->pipelines_float.buffer, &state->vk_pipeline_layout_buffer,
4101 {&state->pipelines_float.image_1d, &state->vk_pipeline_layout_image,
4103 {&state->pipelines_float.image_1d_array, &state->vk_pipeline_layout_image,
4105 {&state->pipelines_float.image_2d, &state->vk_pipeline_layout_image,
4107 {&state->pipelines_float.image_2d_array, &state->vk_pipeline_layout_image,
4109 {&state->pipelines_float.image_3d, &state->vk_pipeline_layout_image,
4111
4112 {&state->pipelines_uint.buffer, &state->vk_pipeline_layout_buffer,
4114 {&state->pipelines_uint.image_1d, &state->vk_pipeline_layout_image,
4116 {&state->pipelines_uint.image_1d_array, &state->vk_pipeline_layout_image,
4118 {&state->pipelines_uint.image_2d, &state->vk_pipeline_layout_image,
4120 {&state->pipelines_uint.image_2d_array, &state->vk_pipeline_layout_image,
4122 {&state->pipelines_uint.image_3d, &state->vk_pipeline_layout_image,
4124#undef SHADER_CODE
4125 };
4126
4127 memset(state, 0, sizeof(*state));
4128
4129 set_binding.binding = 0;
4130 set_binding.descriptorCount = 1;
4131 set_binding.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
4132 set_binding.pImmutableSamplers = NULL;
4133
4135 binding.register_space = 0;
4136 binding.register_index = 0;
4137 binding.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
4138 binding.binding.set = 0;
4139 binding.binding.binding = 0;
4140 binding.binding.count = 1;
4141
4142 push_constant_range.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
4143 push_constant_range.offset = 0;
4144 push_constant_range.size = sizeof(struct vkd3d_uav_clear_args);
4145
4146 push_constant.register_space = 0;
4147 push_constant.register_index = 0;
4149 push_constant.offset = 0;
4150 push_constant.size = sizeof(struct vkd3d_uav_clear_args);
4151
4152 for (i = 0; i < ARRAY_SIZE(set_layouts); ++i)
4153 {
4154 set_binding.descriptorType = set_layouts[i].descriptor_type;
4155
4157 1, false, &set_binding, set_layouts[i].set_layout)))
4158 {
4159 ERR("Failed to create descriptor set layout %u, hr %s.\n", i, debugstr_hresult(hr));
4160 goto fail;
4161 }
4162
4163 if (FAILED(hr = vkd3d_create_pipeline_layout(device, 1, set_layouts[i].set_layout,
4164 1, &push_constant_range, set_layouts[i].pipeline_layout)))
4165 {
4166 ERR("Failed to create pipeline layout %u, hr %s.\n", i, debugstr_hresult(hr));
4167 goto fail;
4168 }
4169 }
4170
4172 shader_interface.next = NULL;
4173 shader_interface.bindings = &binding;
4174 shader_interface.binding_count = 1;
4175 shader_interface.push_constant_buffers = &push_constant;
4176 shader_interface.push_constant_buffer_count = 1;
4177 shader_interface.combined_samplers = NULL;
4178 shader_interface.combined_sampler_count = 0;
4179 shader_interface.uav_counters = NULL;
4180 shader_interface.uav_counter_count = 0;
4181
4182 for (i = 0; i < ARRAY_SIZE(pipelines); ++i)
4183 {
4184 struct vkd3d_shader_code dxbc;
4185 int ret;
4186
4187 if ((ret = compile_hlsl_cs(&pipelines[i].code, &dxbc)))
4188 {
4189 ERR("Failed to compile HLSL compute shader %u, ret %d.\n", i, ret);
4191 goto fail;
4192 }
4193
4194 if (pipelines[i].pipeline_layout == &state->vk_pipeline_layout_buffer)
4196 else
4198
4200 &shader_interface, *pipelines[i].pipeline_layout, pipelines[i].pipeline);
4202 if (FAILED(hr))
4203 {
4204 ERR("Failed to create compute pipeline %u, hr %s.\n", i, debugstr_hresult(hr));
4205 goto fail;
4206 }
4207 }
4208
4209 return S_OK;
4210
4211fail:
4213 return hr;
4214}
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
static int state
Definition: maze.c:121
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: list.h:39
Definition: _set.h:50
D3D12_DESCRIPTOR_RANGE_TYPE
Definition: d3d12.idl:1097
@ D3D12_DESCRIPTOR_RANGE_TYPE_SRV
Definition: d3d12.idl:1098
@ D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER
Definition: d3d12.idl:1101
@ D3D12_DESCRIPTOR_RANGE_TYPE_CBV
Definition: d3d12.idl:1100
@ D3D12_DESCRIPTOR_RANGE_TYPE_UAV
Definition: d3d12.idl:1099
D3D12_FILL_MODE
Definition: d3d12.idl:1983
@ D3D12_FILL_MODE_SOLID
Definition: d3d12.idl:1985
@ D3D12_FILL_MODE_WIREFRAME
Definition: d3d12.idl:1984
D3D12_CULL_MODE
Definition: d3d12.idl:1989
@ D3D12_CULL_MODE_NONE
Definition: d3d12.idl:1990
@ D3D12_CULL_MODE_BACK
Definition: d3d12.idl:1992
@ D3D12_CULL_MODE_FRONT
Definition: d3d12.idl:1991
@ D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA
Definition: d3d12.idl:2037
@ D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA
Definition: d3d12.idl:2038
const UINT D3D12_VS_INPUT_REGISTER_COUNT
Definition: d3d12.idl:439
const UINT D3D12_SO_NO_RASTERIZED_STREAM
Definition: d3d12.idl:385
@ D3D12_COLOR_WRITE_ENABLE_GREEN
Definition: d3d12.idl:1953
@ D3D12_COLOR_WRITE_ENABLE_BLUE
Definition: d3d12.idl:1954
@ D3D12_COLOR_WRITE_ENABLE_ALPHA
Definition: d3d12.idl:1955
@ D3D12_COLOR_WRITE_ENABLE_ALL
Definition: d3d12.idl:1956
@ D3D12_COLOR_WRITE_ENABLE_RED
Definition: d3d12.idl:1952
const UINT D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND
Definition: d3d12.idl:157
D3D12_PRIMITIVE_TOPOLOGY_TYPE
Definition: d3d12.idl:2070
@ D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH
Definition: d3d12.idl:2075
const UINT D3D12_MAX_ROOT_COST
Definition: d3d12.idl:280
const UINT D3D12_DEFAULT_STENCIL_READ_MASK
Definition: d3d12.idl:147
D3D12_LOGIC_OP
Definition: d3d12.idl:1931
@ D3D12_LOGIC_OP_OR_INVERTED
Definition: d3d12.idl:1947
@ D3D12_LOGIC_OP_XOR
Definition: d3d12.idl:1942
@ D3D12_LOGIC_OP_SET
Definition: d3d12.idl:1933
@ D3D12_LOGIC_OP_AND_REVERSE
Definition: d3d12.idl:1944
@ D3D12_LOGIC_OP_EQUIV
Definition: d3d12.idl:1943
@ D3D12_LOGIC_OP_OR_REVERSE
Definition: d3d12.idl:1946
@ D3D12_LOGIC_OP_CLEAR
Definition: d3d12.idl:1932
@ D3D12_LOGIC_OP_NOOP
Definition: d3d12.idl:1936
@ D3D12_LOGIC_OP_NOR
Definition: d3d12.idl:1941
@ D3D12_LOGIC_OP_INVERT
Definition: d3d12.idl:1937
@ D3D12_LOGIC_OP_OR
Definition: d3d12.idl:1940
@ D3D12_LOGIC_OP_AND_INVERTED
Definition: d3d12.idl:1945
@ D3D12_LOGIC_OP_AND
Definition: d3d12.idl:1938
@ D3D12_LOGIC_OP_COPY
Definition: d3d12.idl:1934
@ D3D12_LOGIC_OP_COPY_INVERTED
Definition: d3d12.idl:1935
@ D3D12_LOGIC_OP_NAND
Definition: d3d12.idl:1939
@ D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF
Definition: d3d12.idl:1997
@ D3D12_DEPTH_WRITE_MASK_ALL
Definition: d3d12.idl:1870
const UINT D3D12_DEFAULT_SAMPLE_MASK
Definition: d3d12.idl:141
@ D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT
Definition: d3d12.idl:1375
@ D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT
Definition: d3d12.idl:1369
const UINT D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT
Definition: d3d12.idl:378
const UINT D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
Definition: d3d12.idl:265
D3D12_STENCIL_OP
Definition: d3d12.idl:1848
@ D3D12_STENCIL_OP_KEEP
Definition: d3d12.idl:1849
@ D3D12_STENCIL_OP_INVERT
Definition: d3d12.idl:1854
@ D3D12_STENCIL_OP_REPLACE
Definition: d3d12.idl:1851
@ D3D12_STENCIL_OP_ZERO
Definition: d3d12.idl:1850
@ D3D12_STENCIL_OP_INCR_SAT
Definition: d3d12.idl:1852
@ D3D12_STENCIL_OP_DECR
Definition: d3d12.idl:1856
@ D3D12_STENCIL_OP_INCR
Definition: d3d12.idl:1855
@ D3D12_STENCIL_OP_DECR_SAT
Definition: d3d12.idl:1853
D3D12_BLEND_OP
Definition: d3d12.idl:1922
@ D3D12_BLEND_OP_MAX
Definition: d3d12.idl:1927
@ D3D12_BLEND_OP_SUBTRACT
Definition: d3d12.idl:1924
@ D3D12_BLEND_OP_MIN
Definition: d3d12.idl:1926
@ D3D12_BLEND_OP_REV_SUBTRACT
Definition: d3d12.idl:1925
@ D3D12_BLEND_OP_ADD
Definition: d3d12.idl:1923
D3D12_ROOT_PARAMETER_TYPE
Definition: d3d12.idl:1176
@ D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE
Definition: d3d12.idl:1177
@ D3D12_ROOT_PARAMETER_TYPE_SRV
Definition: d3d12.idl:1180
@ D3D12_ROOT_PARAMETER_TYPE_UAV
Definition: d3d12.idl:1181
@ D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS
Definition: d3d12.idl:1178
@ D3D12_ROOT_PARAMETER_TYPE_CBV
Definition: d3d12.idl:1179
const UINT D3D12_DEFAULT_STENCIL_WRITE_MASK
Definition: d3d12.idl:149
D3D12_PIPELINE_STATE_SUBOBJECT_TYPE
Definition: d3d12.idl:2138
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER
Definition: d3d12.idl:2149
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK
Definition: d3d12.idl:2157
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS
Definition: d3d12.idl:2144
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1
Definition: d3d12.idl:2160
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS
Definition: d3d12.idl:2145
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING
Definition: d3d12.idl:2161
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS
Definition: d3d12.idl:2143
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS
Definition: d3d12.idl:2142
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND
Definition: d3d12.idl:2147
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS
Definition: d3d12.idl:2140
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK
Definition: d3d12.idl:2148
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE
Definition: d3d12.idl:2139
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY
Definition: d3d12.idl:2153
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT
Definition: d3d12.idl:2155
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS
Definition: d3d12.idl:2159
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL
Definition: d3d12.idl:2150
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC
Definition: d3d12.idl:2156
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT
Definition: d3d12.idl:2146
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE
Definition: d3d12.idl:2152
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT
Definition: d3d12.idl:2151
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS
Definition: d3d12.idl:2141
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS
Definition: d3d12.idl:2154
@ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO
Definition: d3d12.idl:2158
D3D12_COMPARISON_FUNC
Definition: d3d12.idl:1338
@ D3D12_COMPARISON_FUNC_GREATER_EQUAL
Definition: d3d12.idl:1345
@ D3D12_COMPARISON_FUNC_ALWAYS
Definition: d3d12.idl:1346
@ D3D12_COMPARISON_FUNC_NOT_EQUAL
Definition: d3d12.idl:1344
@ D3D12_COMPARISON_FUNC_LESS_EQUAL
Definition: d3d12.idl:1342
@ D3D12_COMPARISON_FUNC_LESS
Definition: d3d12.idl:1340
@ D3D12_COMPARISON_FUNC_NEVER
Definition: d3d12.idl:1339
@ D3D12_COMPARISON_FUNC_EQUAL
Definition: d3d12.idl:1341
@ D3D12_COMPARISON_FUNC_GREATER
Definition: d3d12.idl:1343
D3D12_SHADER_VISIBILITY
Definition: d3d12.idl:1185
@ D3D12_SHADER_VISIBILITY_DOMAIN
Definition: d3d12.idl:1189
@ D3D12_SHADER_VISIBILITY_MESH
Definition: d3d12.idl:1193
@ D3D12_SHADER_VISIBILITY_ALL
Definition: d3d12.idl:1186
@ D3D12_SHADER_VISIBILITY_GEOMETRY
Definition: d3d12.idl:1190
@ D3D12_SHADER_VISIBILITY_VERTEX
Definition: d3d12.idl:1187
@ D3D12_SHADER_VISIBILITY_HULL
Definition: d3d12.idl:1188
@ D3D12_SHADER_VISIBILITY_PIXEL
Definition: d3d12.idl:1191
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE
Definition: d3d12.idl:2059
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED
Definition: d3d12.idl:2060
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF
Definition: d3d12.idl:2061
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF
Definition: d3d12.idl:2062
D3D12_BLEND
Definition: d3d12.idl:1899
@ D3D12_BLEND_INV_SRC_COLOR
Definition: d3d12.idl:1903
@ D3D12_BLEND_DEST_COLOR
Definition: d3d12.idl:1908
@ D3D12_BLEND_INV_SRC1_ALPHA
Definition: d3d12.idl:1916
@ D3D12_BLEND_INV_BLEND_FACTOR
Definition: d3d12.idl:1912
@ D3D12_BLEND_BLEND_FACTOR
Definition: d3d12.idl:1911
@ D3D12_BLEND_SRC1_COLOR
Definition: d3d12.idl:1913
@ D3D12_BLEND_DEST_ALPHA
Definition: d3d12.idl:1906
@ D3D12_BLEND_INV_DEST_COLOR
Definition: d3d12.idl:1909
@ D3D12_BLEND_INV_SRC1_COLOR
Definition: d3d12.idl:1914
@ D3D12_BLEND_SRC_COLOR
Definition: d3d12.idl:1902
@ D3D12_BLEND_SRC_ALPHA
Definition: d3d12.idl:1904
@ D3D12_BLEND_ONE
Definition: d3d12.idl:1901
@ D3D12_BLEND_INV_DEST_ALPHA
Definition: d3d12.idl:1907
@ D3D12_BLEND_INV_SRC_ALPHA
Definition: d3d12.idl:1905
@ D3D12_BLEND_SRC_ALPHA_SAT
Definition: d3d12.idl:1910
@ D3D12_BLEND_ZERO
Definition: d3d12.idl:1900
@ D3D12_BLEND_SRC1_ALPHA
Definition: d3d12.idl:1915
const UINT D3D12_APPEND_ALIGNED_ELEMENT
Definition: d3d12.idl:30
D3D12_PIPELINE_STATE_FLAGS
Definition: d3d12.idl:2085
D3D_PRIMITIVE_TOPOLOGY
Definition: d3dcommon.idl:384
@ D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:423
@ D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:409
@ D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:416
@ D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:425
@ D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST
Definition: d3dcommon.idl:389
@ D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:398
@ D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:408
@ D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:410
@ D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:399
@ D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:400
@ D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:415
@ D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:402
@ D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP
Definition: d3dcommon.idl:390
@ D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:405
@ D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:424
@ D3D_PRIMITIVE_TOPOLOGY_UNDEFINED
Definition: d3dcommon.idl:385
@ D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:396
@ D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:397
@ D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:418
@ D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:406
@ D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:403
@ D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:420
@ D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:413
@ D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:414
@ D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:421
@ D3D_PRIMITIVE_TOPOLOGY_LINESTRIP
Definition: d3dcommon.idl:388
@ D3D_PRIMITIVE_TOPOLOGY_LINELIST
Definition: d3dcommon.idl:387
@ D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:411
@ D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:404
@ D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:426
@ D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:422
@ D3D_PRIMITIVE_TOPOLOGY_POINTLIST
Definition: d3dcommon.idl:386
@ D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:417
@ D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:395
@ D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:407
@ D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:401
@ D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:419
@ D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:412
static HRESULT hresult_from_vkd3d_result(int vkd3d_result)
Definition: compiler.c:30
range
Definition: d3dx9_private.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
UINT op
Definition: effect.c:235
unsigned int idx
Definition: utils.c:40
#define Z(I)
#define Y(I)
#define CHAR_BIT
Definition: cabinet.h:45
GUID guid
Definition: version.c:147
unsigned int uintptr_t
Definition: corecrt.h:185
int ptrdiff_t
Definition: corecrt.h:194
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define UINT_MAX
Definition: limits.h:27
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
unsigned char uint8_t
Definition: stdint.h:33
return ret
Definition: mutex.c:147
static HRESULT hresult_from_vk_result(VkResult vr)
Definition: swapchain.c:1114
DXGI_FORMAT
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
@ DXGI_FORMAT_A8_UNORM
Definition: dxgiformat.idl:88
static void blend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:337
unsigned long DWORD
Definition: ntddk_ex.h:95
Character const *const size_t const max_count
Definition: fullpath.cpp:66
static const FxOffsetAndName offsets[]
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const GLuint * pipelines
Definition: glext.h:7624
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint limit
Definition: glext.h:10326
GLenum mode
Definition: glext.h:6217
GLbitfield flags
Definition: glext.h:7161
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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
unsigned int UINT
Definition: sysinfo.c:13
#define ds
Definition: i386-dis.c:443
#define cs
Definition: i386-dis.c:442
#define gs
Definition: i386-dis.c:445
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct task_struct * current
Definition: linux.c:32
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
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
DWORD set_flags
Definition: misc.c:1973
#define min(a, b)
Definition: monoChain.cc:55
#define uint32_t
Definition: nsiface.idl:61
short WCHAR
Definition: pedump.c:58
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
static unsigned __int64 next
Definition: rand_nt.c:6
#define offsetof(TYPE, MEMBER)
#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 memset(x, y, z)
Definition: compat.h:39
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc)
Definition: resource.c:641
HRESULT vkd3d_create_static_sampler(struct d3d12_device *device, const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler)
Definition: resource.c:3814
void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache)
Definition: state.c:1838
static bool vkd3d_validate_descriptor_set_count(struct d3d12_device *device, unsigned int set_count)
Definition: state.c:775
static void descriptor_set_context_cleanup(struct vkd3d_descriptor_set_context *context)
Definition: state.c:767
struct d3d12_root_signature * unsafe_impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
Definition: state.c:193
static void pipeline_state_desc_from_d3d12_compute_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_COMPUTE_PIPELINE_STATE_DESC *d3d12_desc)
Definition: state.c:1919
static void ds_desc_from_d3d12(struct VkPipelineDepthStencilStateCreateInfo *vk_desc, const D3D12_DEPTH_STENCIL_DESC1 *d3d12_desc)
Definition: state.c:2803
static void d3d12_root_signature_append_vk_binding_array(struct d3d12_root_signature *root_signature, VkDescriptorSetLayoutCreateFlags flags, struct vkd3d_descriptor_set_context *context)
Definition: state.c:798
static unsigned int vkd3d_get_rt_format_swizzle(const struct vkd3d_format *format)
Definition: state.c:2991
HRESULT d3d12_root_signature_create(struct d3d12_device *device, const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature)
Definition: state.c:1630
static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signature *root_signature, const D3D12_ROOT_SIGNATURE_DESC *desc, struct VkPushConstantRange push_constants[D3D12_SHADER_VISIBILITY_PIXEL+1], uint32_t *push_constant_range_count)
Definition: state.c:619
static ULONG STDMETHODCALLTYPE d3d12_root_signature_AddRef(ID3D12RootSignature *iface)
Definition: state.c:52
static void d3d12_pipeline_uav_counter_state_cleanup(struct d3d12_pipeline_uav_counter_state *uav_counters, struct d3d12_device *device)
Definition: state.c:2117
static HRESULT d3d12_root_signature_info_from_desc(struct d3d12_root_signature_info *info, const D3D12_ROOT_SIGNATURE_DESC *desc, bool use_array)
Definition: state.c:517
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_QueryInterface(ID3D12RootSignature *iface, REFIID riid, void **object)
Definition: state.c:31
HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache, struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
Definition: state.c:1809
static void d3d12_root_signature_map_descriptor_unbounded_binding(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1103
static HRESULT d3d12_pipeline_state_find_and_init_uav_counters(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_root_signature *root_signature, const D3D12_SHADER_BYTECODE *code, VkShaderStageFlags stage_flags)
Definition: state.c:2491
static struct d3d12_root_signature * impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
Definition: state.c:26
static void d3d12_root_signature_cleanup(struct d3d12_root_signature *root_signature, struct d3d12_device *device)
Definition: state.c:70
static HRESULT d3d12_graphics_pipeline_state_create_render_pass(struct d3d12_graphics_pipeline_state *graphics, struct d3d12_device *device, VkFormat dynamic_dsv_format, VkRenderPass *vk_render_pass)
Definition: state.c:3001
static ULONG STDMETHODCALLTYPE d3d12_root_signature_Release(ID3D12RootSignature *iface)
Definition: state.c:110
static HRESULT pipeline_state_desc_from_d3d12_stream_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_PIPELINE_STATE_STREAM_DESC *d3d12_desc, VkPipelineBindPoint *vk_bind_point)
Definition: state.c:1930
static enum VkPrimitiveTopology vk_topology_from_d3d12_topology(D3D12_PRIMITIVE_TOPOLOGY topology)
Definition: state.c:3695
static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_signature_info *info, const D3D12_ROOT_PARAMETER *param, bool use_array)
Definition: state.c:419
static HRESULT vkd3d_create_pipeline_layout(struct d3d12_device *device, unsigned int set_layout_count, const VkDescriptorSetLayout *set_layouts, unsigned int push_constant_count, const VkPushConstantRange *push_constants, VkPipelineLayout *pipeline_layout)
Definition: state.c:1424
static bool is_dual_source_blending(const D3D12_RENDER_TARGET_BLEND_DESC *desc)
Definition: state.c:2939
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_GetDevice(ID3D12PipelineState *iface, REFIID iid, void **device)
Definition: state.c:2207
static HRESULT d3d12_root_signature_create_descriptor_set_layouts(struct d3d12_root_signature *root_signature, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1453
static HRESULT d3d12_root_signature_append_vk_binding(struct d3d12_root_signature *root_signature, enum vkd3d_shader_descriptor_type descriptor_type, unsigned int register_space, unsigned int register_idx, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility, unsigned int descriptor_count, struct vkd3d_descriptor_set_context *context, const VkSampler *immutable_sampler, unsigned int *binding_idx)
Definition: state.c:813
static unsigned int d3d12_root_signature_copy_descriptor_set_layouts(const struct d3d12_root_signature *root_signature, VkDescriptorSetLayout *vk_set_layouts)
Definition: state.c:1481
static VkShaderStageFlags stage_flags_from_visibility(D3D12_SHADER_VISIBILITY visibility)
Definition: state.c:201
#define SHADER_CODE(name)
static void d3d12_root_signature_map_vk_heap_binding(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1052
static enum VkCullModeFlagBits vk_cull_mode_from_d3d12(D3D12_CULL_MODE mode)
Definition: state.c:2660
static bool vk_topology_can_restart(VkPrimitiveTopology topology)
Definition: state.c:3750
static struct vk_binding_array * d3d12_root_signature_current_vk_binding_array(struct d3d12_root_signature *root_signature, struct vkd3d_descriptor_set_context *context)
Definition: state.c:789
static int vkd3d_scan_dxbc(const struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code, struct vkd3d_shader_scan_descriptor_info *descriptor_info)
Definition: state.c:2331
static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
Definition: state.c:2518
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetDevice(ID3D12RootSignature *iface, REFIID iid, void **device)
Definition: state.c:168
static enum VkBlendFactor vk_blend_factor_from_d3d12(D3D12_BLEND blend, bool alpha)
Definition: state.c:2837
HRESULT d3d12_pipeline_state_create_graphics(struct d3d12_device *device, const D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state)
Definition: state.c:3630
static VkShaderStageFlags stage_flags_from_vkd3d_shader_visibility(enum vkd3d_shader_visibility visibility)
Definition: state.c:222
static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
Definition: state.c:3084
static void d3d12_init_pipeline_state_desc(struct d3d12_pipeline_state_desc *desc)
Definition: state.c:1861
static enum vkd3d_shader_visibility vkd3d_shader_visibility_from_d3d12(D3D12_SHADER_VISIBILITY visibility)
Definition: state.c:246
static void d3d12_root_signature_map_vk_heap_uav_counter(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1069
static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_state *state, const struct vkd3d_pipeline_key *key, VkPipeline vk_pipeline, VkRenderPass vk_render_pass)
Definition: state.c:3794
static const struct ID3D12RootSignatureVtbl d3d12_root_signature_vtbl
Definition: state.c:178
static const struct ID3D12PipelineStateVtbl d3d12_pipeline_state_vtbl
Definition: state.c:2225
static enum VkBlendOp vk_blend_op_from_d3d12(D3D12_BLEND_OP op)
Definition: state.c:2885
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetPrivateData(ID3D12RootSignature *iface, REFGUID guid, UINT *data_size, void *data)
Definition: state.c:129
static void blend_attachment_from_d3d12(struct VkPipelineColorBlendAttachmentState *vk_desc, const D3D12_RENDER_TARGET_BLEND_DESC *d3d12_desc)
Definition: state.c:2905
static int d3d12_root_signature_info_range_compare(const void *a, const void *b)
Definition: state.c:373
static unsigned int feature_flags_compile_option(const struct d3d12_device *device)
Definition: state.c:2257
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetPrivateDataInterface(ID3D12RootSignature *iface, REFGUID guid, const IUnknown *data)
Definition: state.c:149
static bool is_dual_source_blending_blend(D3D12_BLEND b)
Definition: state.c:2933
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_GetPrivateData(ID3D12PipelineState *iface, REFGUID guid, UINT *data_size, void *data)
Definition: state.c:2162
static enum VkStencilOp vk_stencil_op_from_d3d12(D3D12_STENCIL_OP op)
Definition: state.c:2738
HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d3d12_device *device)
Definition: state.c:4068
enum VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op)
Definition: state.c:2764
static uint32_t vkd3d_descriptor_magic_from_d3d12(D3D12_DESCRIPTOR_RANGE_TYPE type)
Definition: state.c:855
VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_state *state, D3D12_PRIMITIVE_TOPOLOGY topology, const uint32_t *strides, VkFormat dsv_format, VkRenderPass *vk_render_pass)
Definition: state.c:3827
static void rs_desc_from_d3d12(VkPipelineRasterizationStateCreateInfo *vk_desc, const D3D12_RASTERIZER_DESC *d3d12_desc)
Definition: state.c:2676
static HRESULT d3d12_root_signature_init_static_samplers(struct d3d12_root_signature *root_signature, struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC *desc, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1297
static HRESULT d3d12_root_signature_info_add_range(struct d3d12_root_signature_info *info, enum vkd3d_shader_descriptor_type type, D3D12_SHADER_VISIBILITY visibility, unsigned int space, unsigned int base_idx, unsigned int count)
Definition: state.c:353
static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_root_signature *root_signature, const D3D12_ROOT_SIGNATURE_DESC *desc, const struct d3d12_root_signature_info *info, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1133
static enum VkPolygonMode vk_polygon_mode_from_d3d12(D3D12_FILL_MODE mode)
Definition: state.c:2646
static HRESULT d3d12_pipeline_state_init_uav_counters(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_root_signature *root_signature, const struct vkd3d_shader_scan_descriptor_info *shader_info, VkShaderStageFlags stage_flags)
Definition: state.c:2390
static int compare_descriptor_range(const void *a, const void *b)
Definition: state.c:1117
static unsigned int typed_uav_compile_option(const struct d3d12_device *device)
Definition: state.c:2250
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_SetPrivateData(ID3D12PipelineState *iface, REFGUID guid, UINT data_size, const void *data)
Definition: state.c:2172
static void d3d12_pipeline_state_destroy_graphics(struct d3d12_pipeline_state *state, struct d3d12_device *device)
Definition: state.c:2097
static ULONG STDMETHODCALLTYPE d3d12_pipeline_state_Release(ID3D12PipelineState *iface)
Definition: state.c:2130
static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12_pipeline_state *state, const struct vkd3d_pipeline_key *key, VkRenderPass *vk_render_pass)
Definition: state.c:3767
static VkDescriptorType vk_descriptor_type_from_vkd3d_descriptor_type(enum vkd3d_shader_descriptor_type type, bool is_buffer)
Definition: state.c:268
#define DCL_SUBOBJECT_INFO(type, field)
static HRESULT d3d12_root_signature_init_descriptor_table_binding(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, D3D12_SHADER_VISIBILITY visibility, unsigned int vk_binding_array_count, unsigned int bindings_per_range, struct vkd3d_descriptor_set_context *context)
Definition: state.c:913
static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pass_cache *cache, struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
Definition: state.c:1679
static enum vkd3d_shader_descriptor_type vkd3d_descriptor_type_from_d3d12_root_parameter_type(D3D12_ROOT_PARAMETER_TYPE type)
Definition: state.c:306
static HRESULT vkd3d_create_descriptor_set_layout(struct d3d12_device *device, VkDescriptorSetLayoutCreateFlags flags, unsigned int binding_count, bool unbounded, const VkDescriptorSetLayoutBinding *bindings, VkDescriptorSetLayout *set_layout)
Definition: state.c:1368
static void vkd3d_uav_clear_pipelines_cleanup(struct vkd3d_uav_clear_pipelines *pipelines, struct d3d12_device *device)
Definition: state.c:4041
static void vkd3d_descriptor_heap_binding_from_descriptor_range(const struct d3d12_root_descriptor_table_range *range, bool is_buffer, const struct d3d12_root_signature *root_signature, struct vkd3d_shader_descriptor_binding *binding)
Definition: state.c:1003
void vkd3d_uav_clear_state_cleanup(struct vkd3d_uav_clear_state *state, struct d3d12_device *device)
Definition: state.c:4054
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetName(ID3D12RootSignature *iface, const WCHAR *name)
Definition: state.c:159
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_SetName(ID3D12PipelineState *iface, const WCHAR *name)
Definition: state.c:2192
static enum vkd3d_shader_descriptor_type vkd3d_descriptor_type_from_d3d12_range_type(D3D12_DESCRIPTOR_RANGE_TYPE type)
Definition: state.c:287
struct d3d12_pipeline_state * unsafe_impl_from_ID3D12PipelineState(ID3D12PipelineState *iface)
Definition: state.c:2242
static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_signature *root_signature, const D3D12_ROOT_SIGNATURE_DESC *desc, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1266
static void d3d12_descriptor_set_layout_cleanup(struct d3d12_descriptor_set_layout *layout, struct d3d12_device *device)
Definition: state.c:62
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_QueryInterface(ID3D12PipelineState *iface, REFIID riid, void **object)
Definition: state.c:2065
static bool vk_binding_uses_partial_binding(const VkDescriptorSetLayoutBinding *binding)
Definition: state.c:1349
static HRESULT vkd3d_create_compute_pipeline(struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface, VkPipelineLayout vk_pipeline_layout, VkPipeline *vk_pipeline)
Definition: state.c:2359
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_SetPrivateDataInterface(ID3D12PipelineState *iface, REFGUID guid, const IUnknown *data)
Definition: state.c:2182
static VkLogicOp vk_logic_op_from_d3d12(D3D12_LOGIC_OP op)
Definition: state.c:3042
static void d3d12_root_signature_map_descriptor_heap_binding(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
Definition: state.c:1087
static HRESULT compute_input_layout_offsets(const struct d3d12_device *device, const D3D12_INPUT_LAYOUT_DESC *input_layout_desc, uint32_t *offsets)
Definition: state.c:2948
static void rs_stream_info_from_d3d12(VkPipelineRasterizationStateStreamCreateInfoEXT *stream_info, VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_STREAM_OUTPUT_DESC *so_desc, const struct vkd3d_vulkan_info *vk_info)
Definition: state.c:2716
static HRESULT create_shader_stage(struct d3d12_device *device, struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface)
Definition: state.c:2271
static void vk_stencil_op_state_from_d3d12(struct VkStencilOpState *vk_desc, const D3D12_DEPTH_STENCILOP_DESC *d3d12_desc, uint32_t compare_mask, uint32_t write_mask)
Definition: state.c:2790
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_GetCachedBlob(ID3D12PipelineState *iface, ID3DBlob **blob)
Definition: state.c:2217
static struct d3d12_pipeline_state * impl_from_ID3D12PipelineState(ID3D12PipelineState *iface)
Definition: state.c:2060
static unsigned int vk_heap_binding_count_from_descriptor_range(const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_set_size)
Definition: state.c:974
static void d3d12_root_signature_map_vk_unbounded_binding(struct d3d12_root_signature *root_signature, const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context)
Definition: state.c:954
HRESULT d3d12_pipeline_state_create_compute(struct d3d12_device *device, const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state)
Definition: state.c:2621
static unsigned int vk_binding_count_from_descriptor_range(const struct d3d12_root_descriptor_table_range *range, const struct d3d12_root_signature_info *info, const struct vkd3d_device_descriptor_limits *limits)
Definition: state.c:873
void vkd3d_render_pass_cache_cleanup(struct vkd3d_render_pass_cache *cache, struct d3d12_device *device)
Definition: state.c:1845
static HRESULT d3d12_root_signature_info_range_validate(const struct d3d12_root_signature_info_range *ranges, unsigned int count, D3D12_SHADER_VISIBILITY visibility)
Definition: state.c:387
HRESULT d3d12_pipeline_state_create(struct d3d12_device *device, const D3D12_PIPELINE_STATE_STREAM_DESC *desc, struct d3d12_pipeline_state **state)
Definition: state.c:3655
static int compile_hlsl_cs(const struct vkd3d_shader_code *hlsl, struct vkd3d_shader_code *dxbc)
Definition: state.c:4011
static void pipeline_state_desc_from_d3d12_graphics_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_GRAPHICS_PIPELINE_STATE_DESC *d3d12_desc)
Definition: state.c:1892
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetPrivateData(ID3D12RootSignature *iface, REFGUID guid, UINT data_size, const void *data)
Definition: state.c:139
static HRESULT d3d12_root_signature_init(struct d3d12_root_signature *root_signature, struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC *desc)
Definition: state.c:1509
static void vk_binding_array_cleanup(struct vk_binding_array *array)
Definition: state.c:725
static bool vk_binding_array_add_binding(struct vk_binding_array *array, VkDescriptorType descriptor_type, unsigned int descriptor_count, VkShaderStageFlags stage_flags, const VkSampler *immutable_sampler, unsigned int *binding_idx)
Definition: state.c:731
static void d3d12_root_signature_init_descriptor_table_push_constants(struct d3d12_root_signature *root_signature, const struct vkd3d_descriptor_set_context *context)
Definition: state.c:1325
static ULONG STDMETHODCALLTYPE d3d12_pipeline_state_AddRef(ID3D12PipelineState *iface)
Definition: state.c:2087
static void rs_depth_clip_info_from_d3d12(VkPipelineRasterizationDepthClipStateCreateInfoEXT *depth_clip_info, VkPipelineRasterizationStateCreateInfo *vk_rs_desc, const D3D12_RASTERIZER_DESC *d3d12_desc)
Definition: state.c:2703
HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int data_size, const void *data)
Definition: utils.c:1033
HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store, const GUID *tag, const IUnknown *object)
Definition: utils.c:1046
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name)
Definition: utils.c:1077
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out)
Definition: utils.c:994
#define TRACE(s)
Definition: solgame.cpp:4
@ unbounded
Definition: strnlen.cpp:29
D3D12_RENDER_TARGET_BLEND_DESC RenderTarget[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]
Definition: d3d12.idl:1979
D3D12_STENCIL_OP StencilFailOp
Definition: d3d12.idl:1861
D3D12_COMPARISON_FUNC StencilFunc
Definition: d3d12.idl:1864
D3D12_STENCIL_OP StencilDepthFailOp
Definition: d3d12.idl:1862
D3D12_STENCIL_OP StencilPassOp
Definition: d3d12.idl:1863
D3D12_DEPTH_STENCILOP_DESC FrontFace
Definition: d3d12.idl:1893
D3D12_DEPTH_WRITE_MASK DepthWriteMask
Definition: d3d12.idl:1888
D3D12_DEPTH_STENCILOP_DESC BackFace
Definition: d3d12.idl:1894
D3D12_COMPARISON_FUNC DepthFunc
Definition: d3d12.idl:1889
UINT OffsetInDescriptorsFromTableStart
Definition: d3d12.idl:1110
const D3D12_INPUT_ELEMENT_DESC * pInputElementDescs
Definition: d3d12.idl:2054
D3D12_FILL_MODE FillMode
Definition: d3d12.idl:2003
D3D12_CULL_MODE CullMode
Definition: d3d12.idl:2004
D3D12_CONSERVATIVE_RASTERIZATION_MODE ConservativeRaster
Definition: d3d12.idl:2013
Definition: d3d12.idl:2017
const D3D12_SO_DECLARATION_ENTRY * pSODeclaration
Definition: d3d12.idl:2028
const UINT * pBufferStrides
Definition: d3d12.idl:2030
VkAttachmentLoadOp loadOp
Definition: vulkan.h:7355
VkAttachmentStoreOp stencilStoreOp
Definition: vulkan.h:7358
VkSampleCountFlagBits samples
Definition: vulkan.h:7354
VkAttachmentDescriptionFlags flags
Definition: vulkan.h:7352
VkAttachmentStoreOp storeOp
Definition: vulkan.h:7356
VkImageLayout initialLayout
Definition: vulkan.h:7359
VkImageLayout finalLayout
Definition: vulkan.h:7360
VkAttachmentLoadOp stencilLoadOp
Definition: vulkan.h:7357
uint32_t attachment
Definition: vulkan.h:7390
VkImageLayout layout
Definition: vulkan.h:7391
VkStructureType sType
Definition: vulkan.h:17583
VkPipelineCreateFlags flags
Definition: vulkan.h:17585
const VkDescriptorBindingFlags * pBindingFlags
Definition: vulkan.h:8314
VkDescriptorType descriptorType
Definition: vulkan.h:8303
const VkSampler * pImmutableSamplers
Definition: vulkan.h:8306
VkShaderStageFlags stageFlags
Definition: vulkan.h:8305
const VkDescriptorSetLayoutBinding * pBindings
Definition: vulkan.h:8324
VkDescriptorSetLayoutCreateFlags flags
Definition: vulkan.h:8322
const VkPipelineTessellationStateCreateInfo * pTessellationState
Definition: vulkan.h:17601
const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState
Definition: vulkan.h:17605
const VkPipelineDynamicStateCreateInfo * pDynamicState
Definition: vulkan.h:17607
const VkPipelineColorBlendStateCreateInfo * pColorBlendState
Definition: vulkan.h:17606
VkPipelineCreateFlags flags
Definition: vulkan.h:17596
const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState
Definition: vulkan.h:17600
const VkPipelineMultisampleStateCreateInfo * pMultisampleState
Definition: vulkan.h:17604
const VkPipelineVertexInputStateCreateInfo * pVertexInputState
Definition: vulkan.h:17599
const VkPipelineShaderStageCreateInfo * pStages
Definition: vulkan.h:17598
VkStructureType sType
Definition: vulkan.h:17594
const VkPipelineRasterizationStateCreateInfo * pRasterizationState
Definition: vulkan.h:17603
const VkPipelineViewportStateCreateInfo * pViewportState
Definition: vulkan.h:17602
VkColorComponentFlags colorWriteMask
Definition: vulkan.h:13043
VkPipelineColorBlendStateCreateFlags flags
Definition: vulkan.h:13050
const VkPipelineColorBlendAttachmentState * pAttachments
Definition: vulkan.h:13054
VkPipelineDepthStencilStateCreateFlags flags
Definition: vulkan.h:16610
VkPipelineInputAssemblyStateCreateFlags flags
Definition: vulkan.h:13216
VkPipelineLayoutCreateFlags flags
Definition: vulkan.h:16646
VkStructureType sType
Definition: vulkan.h:16644
uint32_t pushConstantRangeCount
Definition: vulkan.h:16649
const VkPushConstantRange * pPushConstantRanges
Definition: vulkan.h:16650
const VkDescriptorSetLayout * pSetLayouts
Definition: vulkan.h:16648
VkPipelineMultisampleStateCreateFlags flags
Definition: vulkan.h:13233
VkSampleCountFlagBits rasterizationSamples
Definition: vulkan.h:13234
const VkSampleMask * pSampleMask
Definition: vulkan.h:13237
VkPipelineRasterizationDepthClipStateCreateFlagsEXT flags
Definition: vulkan.h:13262
VkPipelineRasterizationStateCreateFlags flags
Definition: vulkan.h:13289
VkPipelineShaderStageCreateFlags flags
Definition: vulkan.h:17328
const VkSpecializationInfo * pSpecializationInfo
Definition: vulkan.h:17332
VkShaderStageFlagBits stage
Definition: vulkan.h:17329
VkPipelineTessellationStateCreateFlags flags
Definition: vulkan.h:13376
const VkVertexInputBindingDivisorDescription * pVertexBindingDivisors
Definition: vulkan.h:16666
const VkVertexInputAttributeDescription * pVertexAttributeDescriptions
Definition: vulkan.h:16679
const VkVertexInputBindingDescription * pVertexBindingDescriptions
Definition: vulkan.h:16677
VkPipelineVertexInputStateCreateFlags flags
Definition: vulkan.h:16675
VkShaderStageFlags stageFlags
Definition: vulkan.h:13441
uint32_t attachmentCount
Definition: vulkan.h:16759
VkStructureType sType
Definition: vulkan.h:16756
const VkSubpassDescription * pSubpasses
Definition: vulkan.h:16762
const void * pNext
Definition: vulkan.h:16757
const VkSubpassDependency * pDependencies
Definition: vulkan.h:16764
const VkAttachmentDescription * pAttachments
Definition: vulkan.h:16760
VkRenderPassCreateFlags flags
Definition: vulkan.h:16758
uint32_t dependencyCount
Definition: vulkan.h:16763
const void * pNext
Definition: vulkan.h:14010
VkShaderModuleCreateFlags flags
Definition: vulkan.h:14011
const uint32_t * pCode
Definition: vulkan.h:14013
VkStructureType sType
Definition: vulkan.h:14009
VkStencilOp failOp
Definition: vulkan.h:14124
VkStencilOp passOp
Definition: vulkan.h:14125
uint32_t reference
Definition: vulkan.h:14130
VkCompareOp compareOp
Definition: vulkan.h:14127
uint32_t writeMask
Definition: vulkan.h:14129
uint32_t compareMask
Definition: vulkan.h:14128
VkStencilOp depthFailOp
Definition: vulkan.h:14126
const VkAttachmentReference * pDepthStencilAttachment
Definition: vulkan.h:14216
VkSubpassDescriptionFlags flags
Definition: vulkan.h:14209
uint32_t inputAttachmentCount
Definition: vulkan.h:14211
const VkAttachmentReference * pResolveAttachments
Definition: vulkan.h:14215
const uint32_t * pPreserveAttachments
Definition: vulkan.h:14218
const VkAttachmentReference * pInputAttachments
Definition: vulkan.h:14212
uint32_t colorAttachmentCount
Definition: vulkan.h:14213
const VkAttachmentReference * pColorAttachments
Definition: vulkan.h:14214
VkPipelineBindPoint pipelineBindPoint
Definition: vulkan.h:14210
uint32_t preserveAttachmentCount
Definition: vulkan.h:14217
Definition: polytest.cpp:36
Definition: scsiwmi.h:51
Definition: undname.c:54
Definition: image.c:229
Definition: cache.c:41
Definition: inflate.c:139
Definition: http.c:7252
VkDescriptorSetLayout vk_layout
unsigned int refcount
VkFormat rtv_formats[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]
VkPipelineDepthStencilStateCreateInfo ds_desc
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE index_buffer_strip_cut_value
VkPipelineMultisampleStateCreateInfo ms_desc
VkVertexInputAttributeDescription attributes[D3D12_VS_INPUT_REGISTER_COUNT]
VkPipelineRasterizationStateCreateInfo rs_desc
const struct d3d12_root_signature * root_signature
VkPipelineShaderStageCreateInfo stages[VKD3D_MAX_SHADER_STAGES]
VkVertexInputBindingDivisorDescriptionEXT instance_divisors[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
VkPipelineRasterizationDepthClipStateCreateInfoEXT rs_depth_clip_info
VkVertexInputRate input_rates[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
VkPipelineColorBlendAttachmentState blend_attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]
VkPipelineRasterizationStateStreamCreateInfoEXT rs_stream_info
ID3D12PipelineState ID3D12PipelineState_iface
struct vkd3d_shader_uav_counter_binding * bindings
VkDescriptorSetLayout vk_set_layout
VkShaderStageFlags stage_flags
enum vkd3d_shader_descriptor_type type
enum vkd3d_shader_descriptor_type type
Definition: state.c:344
unsigned int sampler_unbounded_range_count
Definition: state.c:338
unsigned int srv_unbounded_range_count
Definition: state.c:336
unsigned int cbv_unbounded_range_count
Definition: state.c:335
unsigned int cbv_count
Definition: state.c:331
size_t root_descriptor_count
Definition: state.c:329
unsigned int srv_count
Definition: state.c:332
size_t root_constant_count
Definition: state.c:328
unsigned int sampler_count
Definition: state.c:334
struct d3d12_root_signature_info::d3d12_root_signature_info_range * ranges
unsigned int uav_count
Definition: state.c:333
unsigned int uav_unbounded_range_count
Definition: state.c:337
VkPushConstantRange push_constant_ranges[D3D12_SHADER_VISIBILITY_PIXEL+1]
unsigned int static_sampler_count
unsigned int root_constant_count
uint64_t descriptor_table_mask
uint32_t push_descriptor_mask
unsigned int root_descriptor_count
unsigned int push_constant_range_count
struct d3d12_descriptor_set_layout descriptor_set_layouts[VKD3D_MAX_DESCRIPTOR_SETS]
ID3D12RootSignature ID3D12RootSignature_iface
unsigned int descriptor_table_offset
unsigned int uav_mapping_count
unsigned int binding_count
unsigned int parameter_count
struct vkd3d_shader_push_constant_buffer * root_constants
struct d3d12_root_parameter * parameters
struct vkd3d_shader_descriptor_offset * descriptor_offsets
struct vkd3d_shader_descriptor_offset * uav_counter_offsets
VkSampler * static_samplers
unsigned int descriptor_table_count
struct vkd3d_private_store private_store
struct vkd3d_shader_uav_counter_binding * uav_counter_mapping
unsigned int refcount
D3D12_ROOT_SIGNATURE_FLAGS flags
struct vkd3d_shader_resource_binding * descriptor_mapping
struct d3d12_device * device
VkPipelineLayout vk_pipeline_layout
Definition: devices.h:37
Definition: copy.c:22
Definition: name.c:39
size_t capacity
Definition: state.c:718
VkDescriptorSetLayoutCreateFlags flags
Definition: state.c:722
unsigned int table_index
Definition: state.c:720
VkDescriptorSetLayoutBinding * bindings
Definition: state.c:717
size_t count
Definition: state.c:718
unsigned int unbounded_offset
Definition: state.c:721
VkPipeline vk_pipeline
Definition: state.c:2055
struct list entry
Definition: state.c:2053
struct vkd3d_pipeline_key key
Definition: state.c:2054
VkRenderPass vk_render_pass
Definition: state.c:2056
unsigned int uav_counter_index
Definition: state.c:763
unsigned int descriptor_index
Definition: state.c:762
unsigned int unbounded_offset
Definition: state.c:761
unsigned int table_index
Definition: state.c:760
struct vk_binding_array vk_bindings[VKD3D_MAX_DESCRIPTOR_SETS]
Definition: state.c:759
unsigned int push_constant_index
Definition: state.c:764
unsigned int storage_image_max_descriptors
unsigned int uniform_buffer_max_descriptors
unsigned int sampled_image_max_descriptors
D3D12_PRIMITIVE_TOPOLOGY topology
Definition: state.c:2046
VkFormat dsv_format
Definition: state.c:2048
uint32_t strides[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
Definition: state.c:2047
Definition: state.c:1672
struct vkd3d_render_pass_key key
Definition: state.c:1673
VkRenderPass vk_render_pass
Definition: state.c:1674
const void * code
Definition: vkd3d_shader.h:413
const struct vkd3d_shader_compile_option * options
struct vkd3d_shader_code source
enum vkd3d_shader_log_level log_level
enum vkd3d_shader_structure_type type
enum vkd3d_shader_source_type source_type
enum vkd3d_shader_target_type target_type
const struct vkd3d_shader_descriptor_offset * uav_counter_offsets
enum vkd3d_shader_structure_type type
const struct vkd3d_shader_descriptor_offset * binding_offsets
enum vkd3d_shader_structure_type type
struct vkd3d_shader_code secondary_code
unsigned int combined_sampler_count
const struct vkd3d_shader_resource_binding * bindings
const struct vkd3d_shader_push_constant_buffer * push_constant_buffers
const struct vkd3d_shader_uav_counter_binding * uav_counters
unsigned int push_constant_buffer_count
const struct vkd3d_shader_combined_resource_sampler * combined_samplers
enum vkd3d_shader_structure_type type
struct vkd3d_shader_parameter_immediate_constant immediate_constant
Definition: vkd3d_shader.h:848
enum vkd3d_shader_parameter_type type
Definition: vkd3d_shader.h:844
enum vkd3d_shader_parameter_name name
Definition: vkd3d_shader.h:843
union vkd3d_shader_parameter::@5985 u
enum vkd3d_shader_parameter_data_type data_type
Definition: vkd3d_shader.h:845
enum vkd3d_shader_visibility shader_visibility
enum vkd3d_shader_structure_type type
struct vkd3d_shader_descriptor_info * descriptors
const struct vkd3d_shader_parameter * parameters
const unsigned int * output_swizzles
enum vkd3d_shader_spirv_environment environment
enum vkd3d_shader_structure_type type
enum vkd3d_shader_spirv_extension * extensions
enum vkd3d_shader_structure_type type
const struct vkd3d_shader_transform_feedback_element * elements
bool vertex_attrib_zero_divisor
unsigned int shader_extension_count
enum vkd3d_shader_spirv_extension shader_extensions[VKD3D_MAX_SHADER_EXTENSIONS]
unsigned int max_vertex_attrib_divisor
#define max(a, b)
Definition: svc.c:63
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
static const char * debugstr_hresult(HRESULT hr)
Definition: vkd3d_common.h:244
static unsigned int vkd3d_popcount(unsigned int v)
Definition: vkd3d_common.h:280
static bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
Definition: vkd3d_common.h:360
#define FIXME_ONCE
Definition: vkd3d_common.h:228
static void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:584
static void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:572
static uint32_t vkd3d_atomic_decrement_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:477
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
static uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:482
#define DIV_ROUND_UP(a, b)
Definition: vkd3d_common.h:45
#define STATIC_ASSERT(e)
Definition: vkd3d_common.h:47
static int vkd3d_u32_compare(uint32_t x, uint32_t y)
Definition: vkd3d_common.h:386
int vkd3d_parse_root_signature_v_1_0(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc *out_desc)
Definition: vkd3d_main.c:170
static void * vkd3d_calloc(size_t count, size_t size)
Definition: vkd3d_memory.h:43
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
static void * vkd3d_malloc(size_t size)
Definition: vkd3d_memory.h:28
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22
#define VKD3D_DESCRIPTOR_MAGIC_SRV
Definition: vkd3d_private.h:48
#define VKD3D_MAX_DESCRIPTOR_SETS
Definition: vkd3d_private.h:60
vkd3d_vk_descriptor_set_index
@ VKD3D_SET_INDEX_MUTABLE
@ VKD3D_SET_INDEX_STORAGE_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLED_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_BUFFER
@ VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLER
@ VKD3D_SET_INDEX_UAV_COUNTER
static void vk_prepend_struct(void *header, void *structure)
#define VKD3D_DESCRIPTOR_MAGIC_FREE
Definition: vkd3d_private.h:46
static void vkd3d_private_store_destroy(struct vkd3d_private_store *store)
static ULONG d3d12_device_release(struct d3d12_device *device)
#define VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE
Definition: vkd3d_private.h:66
#define VKD3D_DESCRIPTOR_MAGIC_CBV
Definition: vkd3d_private.h:47
static ULONG d3d12_device_add_ref(struct d3d12_device *device)
static HRESULT d3d12_device_query_interface(struct d3d12_device *device, REFIID iid, void **object)
static bool d3d12_pipeline_state_is_graphics(const struct d3d12_pipeline_state *state)
static HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store)
static unsigned int dsv_attachment_mask(const struct d3d12_graphics_pipeline_state *graphics)
static bool d3d12_pipeline_state_is_compute(const struct d3d12_pipeline_state *state)
#define VKD3D_DESCRIPTOR_MAGIC_UAV
Definition: vkd3d_private.h:49
static void vkd3d_prepend_struct(void *header, void *structure)
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER
Definition: vkd3d_private.h:50
VKD3D_SHADER_API struct vkd3d_shader_signature_element * vkd3d_shader_find_signature_element(const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index)
@ VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV
Definition: vkd3d_shader.h:281
@ VKD3D_SHADER_COMPILE_OPTION_API_VERSION
Definition: vkd3d_shader.h:279
@ VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE
Definition: vkd3d_shader.h:293
@ VKD3D_SHADER_COMPILE_OPTION_FEATURE
Definition: vkd3d_shader.h:330
@ VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT
Definition: vkd3d_shader.h:482
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32
Definition: vkd3d_shader.h:507
@ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER
VKD3D_SHADER_API int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature, char **messages)
@ VKD3D_SHADER_SOURCE_HLSL
VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature)
@ VKD3D_SHADER_LOG_NONE
VKD3D_SHADER_API int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
@ VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO
Definition: vkd3d_shader.h:78
@ VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO
Definition: vkd3d_shader.h:68
@ VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO
Definition: vkd3d_shader.h:72
@ VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO
Definition: vkd3d_shader.h:94
@ VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO
Definition: vkd3d_shader.h:70
@ VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO
Definition: vkd3d_shader.h:76
@ VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO
Definition: vkd3d_shader.h:84
vkd3d_shader_visibility
Definition: vkd3d_shader.h:383
@ VKD3D_SHADER_VISIBILITY_DOMAIN
Definition: vkd3d_shader.h:391
@ VKD3D_SHADER_VISIBILITY_COMPUTE
Definition: vkd3d_shader.h:398
@ VKD3D_SHADER_VISIBILITY_PIXEL
Definition: vkd3d_shader.h:395
@ VKD3D_SHADER_VISIBILITY_ALL
Definition: vkd3d_shader.h:385
@ VKD3D_SHADER_VISIBILITY_GEOMETRY
Definition: vkd3d_shader.h:393
@ VKD3D_SHADER_VISIBILITY_VERTEX
Definition: vkd3d_shader.h:387
@ VKD3D_SHADER_VISIBILITY_HULL
Definition: vkd3d_shader.h:389
@ VKD3D_SHADER_API_VERSION_1_14
Definition: vkd3d_shader.h:59
vkd3d_shader_descriptor_type
Definition: vkd3d_shader.h:420
@ VKD3D_SHADER_DESCRIPTOR_TYPE_UAV
Definition: vkd3d_shader.h:430
@ VKD3D_SHADER_DESCRIPTOR_TYPE_CBV
Definition: vkd3d_shader.h:435
@ VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
Definition: vkd3d_shader.h:440
@ VKD3D_SHADER_DESCRIPTOR_TYPE_SRV
Definition: vkd3d_shader.h:425
@ VKD3D_SHADER_BINDING_FLAG_IMAGE
Definition: vkd3d_shader.h:469
@ VKD3D_SHADER_BINDING_FLAG_BUFFER
Definition: vkd3d_shader.h:468
@ VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_UNKNOWN
Definition: vkd3d_shader.h:147
@ VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_R32
Definition: vkd3d_shader.h:142
VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
VKD3D_SHADER_API void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info)
#define VKD3D_SHADER_SWIZZLE(x, y, z, w)
#define VKD3D_SHADER_NO_SWIZZLE
@ VKD3D_SHADER_TARGET_SPIRV_BINARY
@ VKD3D_SHADER_TARGET_DXBC_TPF
@ VKD3D_SHADER_COMPILE_OPTION_FEATURE_WAVE_OPS
Definition: vkd3d_shader.h:245
@ VKD3D_SHADER_COMPILE_OPTION_FEATURE_INT64
Definition: vkd3d_shader.h:232
@ VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLOAT64
Definition: vkd3d_shader.h:236
@ VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT
Definition: vkd3d_shader.h:540
VKD3D_SHADER_API void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *root_signature)
static enum vkd3d_result vkd3d_shader_parse_dxbc_source_type(const struct vkd3d_shader_code *dxbc, enum vkd3d_shader_source_type *type, char **messages)
static const char cs_uav_clear_3d_uint_code[]
static const char cs_uav_clear_1d_array_float_code[]
Definition: vkd3d_shaders.h:56
static const char cs_uav_clear_2d_array_uint_code[]
static const char cs_uav_clear_1d_array_uint_code[]
Definition: vkd3d_shaders.h:73
static const char cs_uav_clear_1d_float_code[]
Definition: vkd3d_shaders.h:90
static const char cs_uav_clear_buffer_float_code[]
Definition: vkd3d_shaders.h:22
static const char cs_uav_clear_2d_uint_code[]
static const char cs_uav_clear_3d_float_code[]
static const char cs_uav_clear_buffer_uint_code[]
Definition: vkd3d_shaders.h:39
static const char cs_uav_clear_1d_uint_code[]
static const char cs_uav_clear_2d_array_float_code[]
static const char cs_uav_clear_2d_float_code[]
vkd3d_result
Definition: vkd3d_types.h:41
VkImageLayout
Definition: vulkan.h:3450
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3454
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3453
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
Definition: vulkan.h:3455
void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)
VkShaderStageFlagBits
Definition: vulkan.h:4873
@ VK_SHADER_STAGE_VERTEX_BIT
Definition: vulkan.h:4874
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan.h:4880
@ VK_SHADER_STAGE_ALL
Definition: vulkan.h:4899
@ VK_SHADER_STAGE_GEOMETRY_BIT
Definition: vulkan.h:4877
@ VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
Definition: vulkan.h:4875
@ VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
Definition: vulkan.h:4876
@ VK_SHADER_STAGE_FRAGMENT_BIT
Definition: vulkan.h:4878
VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout)
#define VK_TRUE
Definition: vulkan.h:55
VkFlags VkDescriptorSetLayoutCreateFlags
Definition: vulkan.h:996
VkDynamicState
Definition: vulkan.h:2605
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
Definition: vulkan.h:2610
@ VK_DYNAMIC_STATE_VIEWPORT
Definition: vulkan.h:2606
@ VK_DYNAMIC_STATE_DEPTH_BOUNDS
Definition: vulkan.h:2611
@ VK_DYNAMIC_STATE_STENCIL_REFERENCE
Definition: vulkan.h:2614
@ VK_DYNAMIC_STATE_SCISSOR
Definition: vulkan.h:2607
VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout)
VkPipelineBindPoint
Definition: vulkan.h:4067
@ VK_PIPELINE_BIND_POINT_GRAPHICS
Definition: vulkan.h:4068
@ VK_PIPELINE_BIND_POINT_COMPUTE
Definition: vulkan.h:4069
VkStencilOp
Definition: vulkan.h:4950
@ VK_STENCIL_OP_INCREMENT_AND_CLAMP
Definition: vulkan.h:4954
@ VK_STENCIL_OP_DECREMENT_AND_CLAMP
Definition: vulkan.h:4955
@ VK_STENCIL_OP_INCREMENT_AND_WRAP
Definition: vulkan.h:4957
@ VK_STENCIL_OP_KEEP
Definition: vulkan.h:4951
@ VK_STENCIL_OP_REPLACE
Definition: vulkan.h:4953
@ VK_STENCIL_OP_ZERO
Definition: vulkan.h:4952
@ VK_STENCIL_OP_DECREMENT_AND_WRAP
Definition: vulkan.h:4958
@ VK_STENCIL_OP_INVERT
Definition: vulkan.h:4956
VkCullModeFlagBits
Definition: vulkan.h:2309
@ VK_CULL_MODE_FRONT_BIT
Definition: vulkan.h:2311
@ VK_CULL_MODE_NONE
Definition: vulkan.h:2310
@ VK_CULL_MODE_BACK_BIT
Definition: vulkan.h:2312
@ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT
Definition: vulkan.h:2348
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366
#define VK_ATTACHMENT_UNUSED
Definition: vulkan.h:54
void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator)
VkSampleCountFlagBits
Definition: vulkan.h:4700
@ VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT_EXT
Definition: vulkan.h:2429
@ VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT
Definition: vulkan.h:2430
VkCompareOp
Definition: vulkan.h:2174
@ VK_COMPARE_OP_LESS_OR_EQUAL
Definition: vulkan.h:2178
@ VK_COMPARE_OP_LESS
Definition: vulkan.h:2176
@ VK_COMPARE_OP_NOT_EQUAL
Definition: vulkan.h:2180
@ VK_COMPARE_OP_NEVER
Definition: vulkan.h:2175
@ VK_COMPARE_OP_ALWAYS
Definition: vulkan.h:2182
@ VK_COMPARE_OP_EQUAL
Definition: vulkan.h:2177
@ VK_COMPARE_OP_GREATER_OR_EQUAL
Definition: vulkan.h:2181
@ VK_COMPARE_OP_GREATER
Definition: vulkan.h:2179
VkLogicOp
Definition: vulkan.h:3710
@ VK_LOGIC_OP_AND
Definition: vulkan.h:3712
@ VK_LOGIC_OP_CLEAR
Definition: vulkan.h:3711
@ VK_LOGIC_OP_EQUIVALENT
Definition: vulkan.h:3720
@ VK_LOGIC_OP_AND_REVERSE
Definition: vulkan.h:3713
@ VK_LOGIC_OP_SET
Definition: vulkan.h:3726
@ VK_LOGIC_OP_NOR
Definition: vulkan.h:3719
@ VK_LOGIC_OP_NO_OP
Definition: vulkan.h:3716
@ VK_LOGIC_OP_COPY
Definition: vulkan.h:3714
@ VK_LOGIC_OP_NAND
Definition: vulkan.h:3725
@ VK_LOGIC_OP_OR_REVERSE
Definition: vulkan.h:3722
@ VK_LOGIC_OP_COPY_INVERTED
Definition: vulkan.h:3723
@ VK_LOGIC_OP_OR
Definition: vulkan.h:3718
@ VK_LOGIC_OP_OR_INVERTED
Definition: vulkan.h:3724
@ VK_LOGIC_OP_AND_INVERTED
Definition: vulkan.h:3715
@ VK_LOGIC_OP_INVERT
Definition: vulkan.h:3721
@ VK_LOGIC_OP_XOR
Definition: vulkan.h:3717
VkBlendOp
Definition: vulkan.h:1816
@ VK_BLEND_OP_ADD
Definition: vulkan.h:1817
@ VK_BLEND_OP_SUBTRACT
Definition: vulkan.h:1818
@ VK_BLEND_OP_MIN
Definition: vulkan.h:1820
@ VK_BLEND_OP_MAX
Definition: vulkan.h:1821
@ VK_BLEND_OP_REVERSE_SUBTRACT
Definition: vulkan.h:1819
VkFlags VkShaderStageFlags
Definition: vulkan.h:1134
void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)
#define VK_FALSE
Definition: vulkan.h:56
@ VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR
Definition: vulkan.h:2456
VkPrimitiveTopology
Definition: vulkan.h:4435
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
Definition: vulkan.h:4439
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
Definition: vulkan.h:4440
@ VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
Definition: vulkan.h:4446
@ VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY
Definition: vulkan.h:4442
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY
Definition: vulkan.h:4444
@ VK_PRIMITIVE_TOPOLOGY_POINT_LIST
Definition: vulkan.h:4436
@ VK_PRIMITIVE_TOPOLOGY_MAX_ENUM
Definition: vulkan.h:4447
@ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
Definition: vulkan.h:4438
@ VK_PRIMITIVE_TOPOLOGY_LINE_LIST
Definition: vulkan.h:4437
VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
@ VK_FRONT_FACE_CLOCKWISE
Definition: vulkan.h:3301
@ VK_FRONT_FACE_COUNTER_CLOCKWISE
Definition: vulkan.h:3300
VkResult
Definition: vulkan.h:4639
VkDescriptorType
Definition: vulkan.h:2463
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
Definition: vulkan.h:2466
@ VK_DESCRIPTOR_TYPE_SAMPLER
Definition: vulkan.h:2464
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
Definition: vulkan.h:2468
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
VkDescriptorBindingFlags VkDescriptorBindingFlagsEXT
Definition: vulkan.h:993
#define VK_NULL_HANDLE
Definition: vulkan.h:861
VkVertexInputRate
Definition: vulkan.h:6259
@ VK_VERTEX_INPUT_RATE_VERTEX
Definition: vulkan.h:6260
@ VK_VERTEX_INPUT_RATE_INSTANCE
Definition: vulkan.h:6261
@ VK_COLOR_COMPONENT_R_BIT
Definition: vulkan.h:2109
@ VK_COLOR_COMPONENT_A_BIT
Definition: vulkan.h:2112
@ VK_COLOR_COMPONENT_B_BIT
Definition: vulkan.h:2111
@ VK_COLOR_COMPONENT_G_BIT
Definition: vulkan.h:2110
VkFormat
Definition: vulkan.h:2815
@ VK_FORMAT_UNDEFINED
Definition: vulkan.h:2816
VkBlendFactor
Definition: vulkan.h:1792
@ VK_BLEND_FACTOR_ONE
Definition: vulkan.h:1794
@ VK_BLEND_FACTOR_SRC1_ALPHA
Definition: vulkan.h:1810
@ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
Definition: vulkan.h:1802
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
Definition: vulkan.h:1809
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
Definition: vulkan.h:1796
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
Definition: vulkan.h:1804
@ VK_BLEND_FACTOR_SRC_COLOR
Definition: vulkan.h:1795
@ VK_BLEND_FACTOR_CONSTANT_COLOR
Definition: vulkan.h:1803
@ VK_BLEND_FACTOR_SRC_ALPHA
Definition: vulkan.h:1799
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
Definition: vulkan.h:1806
@ VK_BLEND_FACTOR_CONSTANT_ALPHA
Definition: vulkan.h:1805
@ VK_BLEND_FACTOR_DST_ALPHA
Definition: vulkan.h:1801
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
Definition: vulkan.h:1811
@ VK_BLEND_FACTOR_ZERO
Definition: vulkan.h:1793
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
Definition: vulkan.h:1800
@ VK_BLEND_FACTOR_DST_COLOR
Definition: vulkan.h:1797
@ VK_BLEND_FACTOR_SRC_ALPHA_SATURATE
Definition: vulkan.h:1807
@ VK_BLEND_FACTOR_SRC1_COLOR
Definition: vulkan.h:1808
@ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR
Definition: vulkan.h:1798
@ VK_ATTACHMENT_LOAD_OP_LOAD
Definition: vulkan.h:1771
@ VK_ATTACHMENT_LOAD_OP_DONT_CARE
Definition: vulkan.h:1773
@ VK_ATTACHMENT_STORE_OP_DONT_CARE
Definition: vulkan.h:1783
@ VK_ATTACHMENT_STORE_OP_STORE
Definition: vulkan.h:1782
void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)
VkPolygonMode
Definition: vulkan.h:4400
@ VK_POLYGON_MODE_FILL
Definition: vulkan.h:4401
@ VK_POLYGON_MODE_LINE
Definition: vulkan.h:4402
VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkShaderModule *pShaderModule)
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
Definition: vulkan.h:4991
@ VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO
Definition: vulkan.h:4993
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
Definition: vulkan.h:4990
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT
Definition: vulkan.h:5054
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
Definition: vulkan.h:4984
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
Definition: vulkan.h:4994
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT
Definition: vulkan.h:5171
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
Definition: vulkan.h:4988
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
Definition: vulkan.h:4987
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT
Definition: vulkan.h:5923
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
Definition: vulkan.h:4996
@ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
Definition: vulkan.h:5002
@ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
Definition: vulkan.h:4980
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
Definition: vulkan.h:4982
@ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
Definition: vulkan.h:4992
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT
Definition: vulkan.h:5938
@ VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO
Definition: vulkan.h:4985
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
Definition: vulkan.h:4986
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
Definition: vulkan.h:4983
@ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO
Definition: vulkan.h:4989
static size_t align(size_t addr, size_t alignment)
#define VK_CALL(f)
Definition: wined3d_vk.h:272
#define E_NOINTERFACE
Definition: winerror.h:3479