-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathstate.c
5626 lines (4805 loc) · 232 KB
/
state.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2016 Józef Kucia for CodeWeavers
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define VKD3D_DBG_CHANNEL VKD3D_DBG_CHANNEL_API
#include "vkd3d_private.h"
#include "vkd3d_descriptor_debug.h"
#include "vkd3d_rw_spinlock.h"
#include <stdio.h>
/* ID3D12RootSignature */
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_QueryInterface(ID3D12RootSignature *iface,
REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_ID3D12RootSignature)
|| IsEqualGUID(riid, &IID_ID3D12DeviceChild)
|| IsEqualGUID(riid, &IID_ID3D12Object)
|| IsEqualGUID(riid, &IID_IUnknown))
{
ID3D12RootSignature_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d3d12_root_signature_AddRef(ID3D12RootSignature *iface)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
ULONG refcount = InterlockedIncrement(&root_signature->refcount);
TRACE("%p increasing refcount to %u.\n", root_signature, refcount);
if (refcount == 1)
{
d3d12_root_signature_inc_ref(root_signature);
d3d12_device_add_ref(root_signature->device);
}
return refcount;
}
static void d3d12_root_signature_cleanup(struct d3d12_root_signature *root_signature,
struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
vkd3d_sampler_state_free_descriptor_set(&device->sampler_state, device,
root_signature->vk_sampler_set, root_signature->vk_sampler_pool);
VK_CALL(vkDestroyPipelineLayout(device->vk_device, root_signature->graphics.vk_pipeline_layout, NULL));
VK_CALL(vkDestroyPipelineLayout(device->vk_device, root_signature->mesh.vk_pipeline_layout, NULL));
VK_CALL(vkDestroyPipelineLayout(device->vk_device, root_signature->compute.vk_pipeline_layout, NULL));
VK_CALL(vkDestroyPipelineLayout(device->vk_device, root_signature->raygen.vk_pipeline_layout, NULL));
VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, root_signature->vk_sampler_descriptor_layout, NULL));
VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, root_signature->vk_root_descriptor_layout, NULL));
vkd3d_free(root_signature->parameters);
vkd3d_free(root_signature->bindings);
vkd3d_free(root_signature->root_constants);
vkd3d_free(root_signature->static_samplers);
vkd3d_free(root_signature->static_samplers_desc);
}
void d3d12_root_signature_inc_ref(struct d3d12_root_signature *root_signature)
{
InterlockedIncrement(&root_signature->internal_refcount);
}
void d3d12_root_signature_dec_ref(struct d3d12_root_signature *root_signature)
{
struct d3d12_device *device = root_signature->device;
ULONG refcount = InterlockedDecrement(&root_signature->internal_refcount);
if (refcount == 0)
{
vkd3d_private_store_destroy(&root_signature->private_store);
d3d12_root_signature_cleanup(root_signature, device);
vkd3d_free(root_signature);
}
}
static ULONG STDMETHODCALLTYPE d3d12_root_signature_Release(ID3D12RootSignature *iface)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
struct d3d12_device *device = root_signature->device;
ULONG refcount = InterlockedDecrement(&root_signature->refcount);
TRACE("%p decreasing refcount to %u.\n", root_signature, refcount);
if (!refcount)
{
d3d12_root_signature_dec_ref(root_signature);
d3d12_device_release(device);
}
return refcount;
}
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetPrivateData(ID3D12RootSignature *iface,
REFGUID guid, UINT *data_size, void *data)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_get_private_data(&root_signature->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetPrivateData(ID3D12RootSignature *iface,
REFGUID guid, UINT data_size, const void *data)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_set_private_data(&root_signature->private_store, guid, data_size, data,
NULL, NULL);
}
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetPrivateDataInterface(ID3D12RootSignature *iface,
REFGUID guid, const IUnknown *data)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return vkd3d_set_private_data_interface(&root_signature->private_store, guid, data,
NULL, NULL);
}
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetDevice(ID3D12RootSignature *iface,
REFIID iid, void **device)
{
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
return d3d12_device_query_interface(root_signature->device, iid, device);
}
CONST_VTBL struct ID3D12RootSignatureVtbl d3d12_root_signature_vtbl =
{
/* IUnknown methods */
d3d12_root_signature_QueryInterface,
d3d12_root_signature_AddRef,
d3d12_root_signature_Release,
/* ID3D12Object methods */
d3d12_root_signature_GetPrivateData,
d3d12_root_signature_SetPrivateData,
d3d12_root_signature_SetPrivateDataInterface,
(void *)d3d12_object_SetName,
/* ID3D12DeviceChild methods */
d3d12_root_signature_GetDevice,
};
VkShaderStageFlags vkd3d_vk_stage_flags_from_visibility(D3D12_SHADER_VISIBILITY visibility)
{
switch (visibility)
{
case D3D12_SHADER_VISIBILITY_ALL:
return VK_SHADER_STAGE_ALL;
case D3D12_SHADER_VISIBILITY_VERTEX:
return VK_SHADER_STAGE_VERTEX_BIT;
case D3D12_SHADER_VISIBILITY_HULL:
return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
case D3D12_SHADER_VISIBILITY_DOMAIN:
return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
case D3D12_SHADER_VISIBILITY_GEOMETRY:
return VK_SHADER_STAGE_GEOMETRY_BIT;
case D3D12_SHADER_VISIBILITY_PIXEL:
return VK_SHADER_STAGE_FRAGMENT_BIT;
case D3D12_SHADER_VISIBILITY_AMPLIFICATION:
return VK_SHADER_STAGE_TASK_BIT_EXT;
case D3D12_SHADER_VISIBILITY_MESH:
return VK_SHADER_STAGE_MESH_BIT_EXT;
default:
return 0;
}
}
enum vkd3d_shader_visibility vkd3d_shader_visibility_from_d3d12(D3D12_SHADER_VISIBILITY visibility)
{
switch (visibility)
{
case D3D12_SHADER_VISIBILITY_ALL:
return VKD3D_SHADER_VISIBILITY_ALL;
case D3D12_SHADER_VISIBILITY_VERTEX:
return VKD3D_SHADER_VISIBILITY_VERTEX;
case D3D12_SHADER_VISIBILITY_HULL:
return VKD3D_SHADER_VISIBILITY_HULL;
case D3D12_SHADER_VISIBILITY_DOMAIN:
return VKD3D_SHADER_VISIBILITY_DOMAIN;
case D3D12_SHADER_VISIBILITY_GEOMETRY:
return VKD3D_SHADER_VISIBILITY_GEOMETRY;
case D3D12_SHADER_VISIBILITY_PIXEL:
return VKD3D_SHADER_VISIBILITY_PIXEL;
case D3D12_SHADER_VISIBILITY_AMPLIFICATION:
return VKD3D_SHADER_VISIBILITY_AMPLIFICATION;
case D3D12_SHADER_VISIBILITY_MESH:
return VKD3D_SHADER_VISIBILITY_MESH;
default:
FIXME("Unhandled visibility %#x.\n", visibility);
return VKD3D_SHADER_VISIBILITY_ALL;
}
}
static VkDescriptorType vk_descriptor_type_from_d3d12_root_parameter(struct d3d12_device *device, D3D12_ROOT_PARAMETER_TYPE type)
{
bool use_ssbo = d3d12_device_use_ssbo_root_descriptors(device);
switch (type)
{
/* SRV and UAV root parameters are buffer views. */
case D3D12_ROOT_PARAMETER_TYPE_SRV:
return use_ssbo ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER : VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
case D3D12_ROOT_PARAMETER_TYPE_UAV:
return use_ssbo ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER : VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
case D3D12_ROOT_PARAMETER_TYPE_CBV:
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
default:
FIXME("Unhandled descriptor root parameter type %#x.\n", type);
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
}
}
static enum vkd3d_shader_descriptor_type vkd3d_descriptor_type_from_d3d12_range_type(
D3D12_DESCRIPTOR_RANGE_TYPE type)
{
switch (type)
{
case D3D12_DESCRIPTOR_RANGE_TYPE_SRV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
case D3D12_DESCRIPTOR_RANGE_TYPE_UAV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
case D3D12_DESCRIPTOR_RANGE_TYPE_CBV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_CBV;
case D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER:
return VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER;
default:
FIXME("Unhandled descriptor range type type %#x.\n", type);
return VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
}
}
static enum vkd3d_shader_descriptor_type vkd3d_descriptor_type_from_d3d12_root_parameter_type(
D3D12_ROOT_PARAMETER_TYPE type)
{
switch (type)
{
case D3D12_ROOT_PARAMETER_TYPE_SRV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
case D3D12_ROOT_PARAMETER_TYPE_UAV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
case D3D12_ROOT_PARAMETER_TYPE_CBV:
return VKD3D_SHADER_DESCRIPTOR_TYPE_CBV;
default:
FIXME("Unhandled descriptor root parameter type %#x.\n", type);
return VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
}
}
HRESULT vkd3d_create_descriptor_set_layout(struct d3d12_device *device,
VkDescriptorSetLayoutCreateFlags flags, unsigned int binding_count,
const VkDescriptorSetLayoutBinding *bindings,
VkDescriptorSetLayoutCreateFlags descriptor_buffer_flags,
VkDescriptorSetLayout *set_layout)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
VkDescriptorSetLayoutCreateInfo set_desc;
VkResult vr;
set_desc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
set_desc.pNext = NULL;
set_desc.flags = flags;
set_desc.bindingCount = binding_count;
set_desc.pBindings = bindings;
if (d3d12_device_uses_descriptor_buffers(device))
set_desc.flags |= descriptor_buffer_flags;
if ((vr = VK_CALL(vkCreateDescriptorSetLayout(device->vk_device, &set_desc, NULL, set_layout))) < 0)
{
WARN("Failed to create Vulkan descriptor set layout, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
return S_OK;
}
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)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct VkPipelineLayoutCreateInfo pipeline_layout_info;
VkResult vr;
if (set_layout_count > device->vk_info.device_limits.maxBoundDescriptorSets)
{
ERR("Root signature requires %u descriptor sets, but device only supports %u.\n",
set_layout_count, device->vk_info.device_limits.maxBoundDescriptorSets);
return E_INVALIDARG;
}
pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipeline_layout_info.pNext = NULL;
pipeline_layout_info.flags = 0;
pipeline_layout_info.setLayoutCount = set_layout_count;
pipeline_layout_info.pSetLayouts = set_layouts;
pipeline_layout_info.pushConstantRangeCount = push_constant_count;
pipeline_layout_info.pPushConstantRanges = push_constants;
if ((vr = VK_CALL(vkCreatePipelineLayout(device->vk_device,
&pipeline_layout_info, NULL, pipeline_layout))) < 0)
{
WARN("Failed to create Vulkan pipeline layout, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
return S_OK;
}
static HRESULT vkd3d_create_pipeline_layout_for_stage_mask(struct d3d12_device *device,
unsigned int set_layout_count, const VkDescriptorSetLayout *set_layouts,
const VkPushConstantRange *push_constants,
VkShaderStageFlags stages,
struct d3d12_bind_point_layout *bind_point_layout)
{
VkPushConstantRange range;
/* Can just mask directly since STAGE_ALL and ALL_GRAPHICS are OR masks. */
range.stageFlags = push_constants->stageFlags & stages;
range.offset = push_constants->offset;
range.size = push_constants->size;
bind_point_layout->vk_push_stages = range.stageFlags;
return vkd3d_create_pipeline_layout(device, set_layout_count, set_layouts,
range.stageFlags ? 1 : 0, &range,
&bind_point_layout->vk_pipeline_layout);
}
struct d3d12_root_signature_info
{
uint32_t binding_count;
uint32_t descriptor_count;
uint32_t parameter_count;
uint32_t push_descriptor_count;
uint32_t root_constant_count;
uint32_t hoist_descriptor_count;
bool has_ssbo_offset_buffer;
bool has_typed_offset_buffer;
uint32_t cost;
};
static bool d3d12_descriptor_range_can_hoist_cbv_descriptor(
struct d3d12_device *device, const D3D12_DESCRIPTOR_RANGE1 *range)
{
/* Cannot/should not hoist arrays.
* We only care about CBVs. SRVs and UAVs are too fiddly
* since they don't necessary map to buffers at all. */
if (!(device->bindless_state.flags & VKD3D_HOIST_STATIC_TABLE_CBV) ||
range->RangeType != D3D12_DESCRIPTOR_RANGE_TYPE_CBV ||
range->NumDescriptors != 1)
{
return false;
}
/* If descriptors are not marked volatile, we are guaranteed that the descriptors are
* set before updating the root table parameter in the command list.
* We can latch the descriptor at draw time.
* As a speed hack, we can pretend that all CBVs have this flag set.
* Basically no applications set this flag, even though they really could. */
return !(range->Flags & D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE) ||
(vkd3d_config_flags & VKD3D_CONFIG_FLAG_FORCE_STATIC_CBV);
}
static void d3d12_root_signature_info_count_srv_uav_table(struct d3d12_root_signature_info *info,
struct d3d12_device *device)
{
/* separate image + buffer descriptors + aux buffer descriptor. */
info->binding_count += 3;
if (device->bindless_state.flags & VKD3D_BINDLESS_RAW_SSBO)
info->binding_count += 1;
if (device->bindless_state.flags & VKD3D_SSBO_OFFSET_BUFFER)
info->has_ssbo_offset_buffer = true;
if (device->bindless_state.flags & VKD3D_TYPED_OFFSET_BUFFER)
info->has_typed_offset_buffer = true;
}
static void d3d12_root_signature_info_count_cbv_table(struct d3d12_root_signature_info *info)
{
info->binding_count += 1;
}
static void d3d12_root_signature_info_count_sampler_table(struct d3d12_root_signature_info *info)
{
info->binding_count += 1;
}
static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_signature_info *info,
struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC1 *desc, const D3D12_DESCRIPTOR_RANGE1 *range)
{
switch (range->RangeType)
{
case D3D12_DESCRIPTOR_RANGE_TYPE_SRV:
case D3D12_DESCRIPTOR_RANGE_TYPE_UAV:
d3d12_root_signature_info_count_srv_uav_table(info, device);
break;
case D3D12_DESCRIPTOR_RANGE_TYPE_CBV:
if (!(desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE) &&
d3d12_descriptor_range_can_hoist_cbv_descriptor(device, range))
{
info->hoist_descriptor_count += 1;
}
d3d12_root_signature_info_count_cbv_table(info);
break;
case D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER:
d3d12_root_signature_info_count_sampler_table(info);
break;
default:
FIXME("Unhandled descriptor type %#x.\n", range->RangeType);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT d3d12_root_signature_info_from_desc(struct d3d12_root_signature_info *info,
struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC1 *desc)
{
bool local_root_signature;
unsigned int i, j;
HRESULT hr;
memset(info, 0, sizeof(*info));
local_root_signature = !!(desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE);
/* Need to emit bindings for the magic internal table binding. */
if (desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED)
{
d3d12_root_signature_info_count_srv_uav_table(info, device);
d3d12_root_signature_info_count_srv_uav_table(info, device);
d3d12_root_signature_info_count_cbv_table(info);
}
if (desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED)
d3d12_root_signature_info_count_sampler_table(info);
for (i = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
switch (p->ParameterType)
{
case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
for (j = 0; j < p->DescriptorTable.NumDescriptorRanges; ++j)
if (FAILED(hr = d3d12_root_signature_info_count_descriptors(info,
device, desc, &p->DescriptorTable.pDescriptorRanges[j])))
return hr;
/* Local root signature directly affects memory layout. */
if (local_root_signature)
info->cost = (info->cost + 1u) & ~1u;
info->cost += local_root_signature ? 2 : 1;
break;
case D3D12_ROOT_PARAMETER_TYPE_CBV:
/* Local root signature directly affects memory layout. */
if (local_root_signature)
info->cost = (info->cost + 1u) & ~1u;
else if (!(device->bindless_state.flags & VKD3D_RAW_VA_ROOT_DESCRIPTOR_CBV))
info->push_descriptor_count += 1;
info->binding_count += 1;
info->cost += 2;
break;
case D3D12_ROOT_PARAMETER_TYPE_SRV:
case D3D12_ROOT_PARAMETER_TYPE_UAV:
/* Local root signature directly affects memory layout. */
if (local_root_signature)
info->cost = (info->cost + 1u) & ~1u;
else if (!(device->bindless_state.flags & VKD3D_RAW_VA_ROOT_DESCRIPTOR_SRV_UAV))
info->push_descriptor_count += 1;
info->binding_count += 1;
info->cost += 2;
break;
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
info->root_constant_count += 1;
info->cost += p->Constants.Num32BitValues;
break;
default:
FIXME("Unhandled type %#x for parameter %u.\n", p->ParameterType, i);
return E_NOTIMPL;
}
}
if (!local_root_signature)
{
/* Make sure that we won't exceed device limits.
* Minimum spec for push descriptors is 32 descriptors, which fits exactly what we need for D3D12.
* Worst case scenarios:
* - 32 root CBVs -> all 32 push descriptors are used. No push constants.
* - Root constants > 128 bytes, 15 root CBVs. 1 push descriptor for push UBO. Can hoist 16 other descriptors.
* Just base the amount of descriptors we can hoist on the root signature cost. This is simple and is trivially correct. */
info->hoist_descriptor_count = min(info->hoist_descriptor_count, VKD3D_MAX_HOISTED_DESCRIPTORS);
info->hoist_descriptor_count = min(info->hoist_descriptor_count, (D3D12_MAX_ROOT_COST - info->cost) / 2);
info->push_descriptor_count += info->hoist_descriptor_count;
info->binding_count += info->hoist_descriptor_count;
info->binding_count += desc->NumStaticSamplers;
}
info->parameter_count = desc->NumParameters + info->hoist_descriptor_count;
return S_OK;
}
static bool d3d12_root_signature_parameter_is_raw_va(struct d3d12_root_signature *root_signature,
D3D12_ROOT_PARAMETER_TYPE type)
{
if (type == D3D12_ROOT_PARAMETER_TYPE_CBV)
return !!(root_signature->device->bindless_state.flags & VKD3D_RAW_VA_ROOT_DESCRIPTOR_CBV);
else if (type == D3D12_ROOT_PARAMETER_TYPE_SRV || type == D3D12_ROOT_PARAMETER_TYPE_UAV)
return !!(root_signature->device->bindless_state.flags & VKD3D_RAW_VA_ROOT_DESCRIPTOR_SRV_UAV);
else
return false;
}
static HRESULT d3d12_root_signature_init_shader_record_constants(
struct d3d12_root_signature *root_signature,
const D3D12_ROOT_SIGNATURE_DESC1 *desc, const struct d3d12_root_signature_info *info)
{
unsigned int i, j;
for (i = 0, j = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
continue;
root_signature->parameters[i].parameter_type = p->ParameterType;
root_signature->parameters[i].constant.constant_index = j;
root_signature->parameters[i].constant.constant_count = p->Constants.Num32BitValues;
root_signature->root_constants[j].register_space = p->Constants.RegisterSpace;
root_signature->root_constants[j].register_index = p->Constants.ShaderRegister;
root_signature->root_constants[j].shader_visibility = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
root_signature->root_constants[j].offset = 0;
root_signature->root_constants[j].size = p->Constants.Num32BitValues * sizeof(uint32_t);
++j;
}
return S_OK;
}
static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signature *root_signature,
const D3D12_ROOT_SIGNATURE_DESC1 *desc, const struct d3d12_root_signature_info *info,
struct VkPushConstantRange *push_constant_range)
{
unsigned int i, j;
/* Stages set later. */
push_constant_range->stageFlags = 0;
push_constant_range->offset = 0;
push_constant_range->size = 0;
/* Put root descriptor VAs at the start to avoid alignment issues */
for (i = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (d3d12_root_signature_parameter_is_raw_va(root_signature, p->ParameterType))
{
push_constant_range->stageFlags |= vkd3d_vk_stage_flags_from_visibility(p->ShaderVisibility);
push_constant_range->size += sizeof(VkDeviceSize);
}
}
/* Append actual root constants */
for (i = 0, j = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
continue;
root_signature->root_constant_mask |= 1ull << i;
root_signature->parameters[i].parameter_type = p->ParameterType;
root_signature->parameters[i].constant.constant_index = push_constant_range->size / sizeof(uint32_t);
root_signature->parameters[i].constant.constant_count = p->Constants.Num32BitValues;
root_signature->root_constants[j].register_space = p->Constants.RegisterSpace;
root_signature->root_constants[j].register_index = p->Constants.ShaderRegister;
root_signature->root_constants[j].shader_visibility = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
root_signature->root_constants[j].offset = push_constant_range->size;
root_signature->root_constants[j].size = p->Constants.Num32BitValues * sizeof(uint32_t);
push_constant_range->stageFlags |= vkd3d_vk_stage_flags_from_visibility(p->ShaderVisibility);
push_constant_range->size += p->Constants.Num32BitValues * sizeof(uint32_t);
++j;
}
/* Append one 32-bit push constant for each descriptor table offset */
if (root_signature->device->bindless_state.flags)
{
root_signature->descriptor_table_offset = push_constant_range->size;
for (i = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
continue;
root_signature->descriptor_table_count += 1;
push_constant_range->stageFlags |= vkd3d_vk_stage_flags_from_visibility(p->ShaderVisibility);
push_constant_range->size += sizeof(uint32_t);
}
}
return S_OK;
}
struct vkd3d_descriptor_set_context
{
uint32_t binding_index;
uint32_t vk_set;
uint32_t vk_binding;
};
static enum vkd3d_bindless_set_flag vkd3d_bindless_set_flag_from_descriptor_range_type(D3D12_DESCRIPTOR_RANGE_TYPE range_type)
{
switch (range_type)
{
case D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER:
return VKD3D_BINDLESS_SET_SAMPLER;
case D3D12_DESCRIPTOR_RANGE_TYPE_CBV:
return VKD3D_BINDLESS_SET_CBV;
case D3D12_DESCRIPTOR_RANGE_TYPE_SRV:
return VKD3D_BINDLESS_SET_SRV;
case D3D12_DESCRIPTOR_RANGE_TYPE_UAV:
return VKD3D_BINDLESS_SET_UAV;
default:
ERR("Unhandled descriptor range type %u.\n", range_type);
return VKD3D_BINDLESS_SET_SRV;
}
}
static void vkd3d_shader_resource_binding_init_global_heap(struct vkd3d_shader_resource_binding *binding,
D3D12_DESCRIPTOR_RANGE_TYPE range_type)
{
binding->type = vkd3d_descriptor_type_from_d3d12_range_type(range_type);
binding->register_space = UINT32_MAX;
binding->register_index = UINT32_MAX;
binding->register_count = UINT32_MAX;
binding->shader_visibility = VKD3D_SHADER_VISIBILITY_ALL;
binding->descriptor_table = 0; /* Ignored. */
binding->descriptor_offset = 0; /* Ignored. */
}
static void d3d12_root_signature_init_srv_uav_binding(struct d3d12_root_signature *root_signature,
struct vkd3d_descriptor_set_context *context, D3D12_DESCRIPTOR_RANGE_TYPE range_type,
struct vkd3d_shader_resource_binding *binding,
struct vkd3d_shader_resource_binding *out_bindings_base, uint32_t *out_index)
{
struct vkd3d_bindless_state *bindless_state = &root_signature->device->bindless_state;
enum vkd3d_bindless_set_flag range_flag;
range_flag = vkd3d_bindless_set_flag_from_descriptor_range_type(range_type);
binding->flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_AUX_BUFFER;
binding->flags |= VKD3D_SHADER_BINDING_FLAG_RAW_VA;
binding->binding = root_signature->raw_va_aux_buffer_binding;
out_bindings_base[(*out_index)++] = *binding;
if (vkd3d_bindless_state_find_binding(bindless_state, range_flag | VKD3D_BINDLESS_SET_BUFFER, &binding->binding))
{
binding->flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_BUFFER;
out_bindings_base[(*out_index)++] = *binding;
}
if (vkd3d_bindless_state_find_binding(bindless_state, range_flag | VKD3D_BINDLESS_SET_RAW_SSBO, &binding->binding))
{
binding->flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_BUFFER | VKD3D_SHADER_BINDING_FLAG_RAW_SSBO;
out_bindings_base[(*out_index)++] = *binding;
}
if (vkd3d_bindless_state_find_binding(bindless_state, range_flag | VKD3D_BINDLESS_SET_IMAGE, &binding->binding))
{
binding->flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_IMAGE;
out_bindings_base[(*out_index)++] = *binding;
}
}
static void d3d12_root_signature_init_srv_uav_heap_bindings(struct d3d12_root_signature *root_signature,
struct vkd3d_descriptor_set_context *context, D3D12_DESCRIPTOR_RANGE_TYPE range_type)
{
struct vkd3d_shader_resource_binding binding;
vkd3d_shader_resource_binding_init_global_heap(&binding, range_type);
d3d12_root_signature_init_srv_uav_binding(root_signature, context, range_type, &binding,
root_signature->bindings, &context->binding_index);
}
static void d3d12_root_signature_init_cbv_srv_uav_heap_bindings(struct d3d12_root_signature *root_signature,
struct vkd3d_descriptor_set_context *context)
{
struct vkd3d_bindless_state *bindless_state = &root_signature->device->bindless_state;
struct vkd3d_shader_resource_binding binding;
d3d12_root_signature_init_srv_uav_heap_bindings(root_signature, context, D3D12_DESCRIPTOR_RANGE_TYPE_SRV);
d3d12_root_signature_init_srv_uav_heap_bindings(root_signature, context, D3D12_DESCRIPTOR_RANGE_TYPE_UAV);
vkd3d_shader_resource_binding_init_global_heap(&binding, D3D12_DESCRIPTOR_RANGE_TYPE_CBV);
if (vkd3d_bindless_state_find_binding(bindless_state, VKD3D_BINDLESS_SET_CBV, &binding.binding))
{
binding.flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_BUFFER;
root_signature->bindings[context->binding_index++] = binding;
}
}
static void d3d12_root_signature_init_sampler_heap_bindings(struct d3d12_root_signature *root_signature,
struct vkd3d_descriptor_set_context *context)
{
struct vkd3d_bindless_state *bindless_state = &root_signature->device->bindless_state;
struct vkd3d_shader_resource_binding binding;
vkd3d_shader_resource_binding_init_global_heap(&binding, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER);
if (vkd3d_bindless_state_find_binding(bindless_state, VKD3D_BINDLESS_SET_SAMPLER, &binding.binding))
{
binding.flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_IMAGE;
root_signature->bindings[context->binding_index++] = binding;
}
}
static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_root_signature *root_signature,
const D3D12_ROOT_SIGNATURE_DESC1 *desc, const struct d3d12_root_signature_info *info,
struct vkd3d_descriptor_set_context *context)
{
struct vkd3d_bindless_state *bindless_state = &root_signature->device->bindless_state;
struct vkd3d_shader_resource_binding binding;
struct vkd3d_shader_descriptor_table *table;
unsigned int i, j, t, range_count;
uint32_t range_descriptor_offset;
bool local_root_signature;
local_root_signature = !!(desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE);
if (desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED)
d3d12_root_signature_init_cbv_srv_uav_heap_bindings(root_signature, context);
if (desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED)
d3d12_root_signature_init_sampler_heap_bindings(root_signature, context);
for (i = 0, t = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
continue;
if (!local_root_signature)
root_signature->descriptor_table_mask |= 1ull << i;
table = &root_signature->parameters[i].descriptor_table;
range_count = p->DescriptorTable.NumDescriptorRanges;
range_descriptor_offset = 0;
root_signature->parameters[i].parameter_type = p->ParameterType;
if (local_root_signature)
table->table_index = i;
else
table->table_index = t++;
table->binding_count = 0;
table->first_binding = &root_signature->bindings[context->binding_index];
for (j = 0; j < range_count; ++j)
{
const D3D12_DESCRIPTOR_RANGE1 *range = &p->DescriptorTable.pDescriptorRanges[j];
enum vkd3d_bindless_set_flag range_flag = vkd3d_bindless_set_flag_from_descriptor_range_type(range->RangeType);
if (range->OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
range_descriptor_offset = range->OffsetInDescriptorsFromTableStart;
binding.type = vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType);
binding.register_space = range->RegisterSpace;
binding.register_index = range->BaseShaderRegister;
binding.register_count = range->NumDescriptors;
binding.descriptor_table = table->table_index;
binding.descriptor_offset = range_descriptor_offset;
binding.shader_visibility = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
switch (range->RangeType)
{
case D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER:
if (vkd3d_bindless_state_find_binding(bindless_state, range_flag, &binding.binding))
{
binding.flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_IMAGE;
table->first_binding[table->binding_count++] = binding;
}
break;
case D3D12_DESCRIPTOR_RANGE_TYPE_CBV:
if (vkd3d_bindless_state_find_binding(bindless_state, range_flag, &binding.binding))
{
binding.flags = VKD3D_SHADER_BINDING_FLAG_BINDLESS | VKD3D_SHADER_BINDING_FLAG_BUFFER;
table->first_binding[table->binding_count++] = binding;
}
break;
case D3D12_DESCRIPTOR_RANGE_TYPE_UAV:
case D3D12_DESCRIPTOR_RANGE_TYPE_SRV:
d3d12_root_signature_init_srv_uav_binding(root_signature, context, range->RangeType,
&binding, table->first_binding, &table->binding_count);
break;
default:
FIXME("Unhandled descriptor range type %u.\n", range->RangeType);
}
range_descriptor_offset = binding.descriptor_offset + binding.register_count;
}
context->binding_index += table->binding_count;
}
return S_OK;
}
static void d3d12_root_signature_init_extra_bindings(struct d3d12_root_signature *root_signature,
const struct d3d12_root_signature_info *info)
{
vkd3d_bindless_state_find_binding(&root_signature->device->bindless_state,
VKD3D_BINDLESS_SET_EXTRA_RAW_VA_AUX_BUFFER,
&root_signature->raw_va_aux_buffer_binding);
if (info->has_ssbo_offset_buffer || info->has_typed_offset_buffer)
{
if (info->has_ssbo_offset_buffer)
root_signature->flags |= VKD3D_ROOT_SIGNATURE_USE_SSBO_OFFSET_BUFFER;
if (info->has_typed_offset_buffer)
root_signature->flags |= VKD3D_ROOT_SIGNATURE_USE_TYPED_OFFSET_BUFFER;
vkd3d_bindless_state_find_binding(&root_signature->device->bindless_state,
VKD3D_BINDLESS_SET_EXTRA_OFFSET_BUFFER,
&root_signature->offset_buffer_binding);
}
#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
if (vkd3d_descriptor_debug_active_qa_checks())
{
vkd3d_bindless_state_find_binding(&root_signature->device->bindless_state,
VKD3D_BINDLESS_SET_EXTRA_DESCRIPTOR_HEAP_INFO_BUFFER,
&root_signature->descriptor_qa_heap_binding);
vkd3d_bindless_state_find_binding(&root_signature->device->bindless_state,
VKD3D_BINDLESS_SET_EXTRA_GLOBAL_HEAP_INFO_BUFFER,
&root_signature->descriptor_qa_global_info);
}
#endif
}
static HRESULT d3d12_root_signature_init_shader_record_descriptors(
struct d3d12_root_signature *root_signature,
const D3D12_ROOT_SIGNATURE_DESC1 *desc, const struct d3d12_root_signature_info *info,
struct vkd3d_descriptor_set_context *context)
{
struct vkd3d_shader_resource_binding *binding;
struct vkd3d_shader_root_parameter *param;
unsigned int i;
for (i = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_CBV
&& p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_SRV
&& p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_UAV)
continue;
binding = &root_signature->bindings[context->binding_index];
binding->type = vkd3d_descriptor_type_from_d3d12_root_parameter_type(p->ParameterType);
binding->register_space = p->Descriptor.RegisterSpace;
binding->register_index = p->Descriptor.ShaderRegister;
binding->register_count = 1;
binding->descriptor_table = 0; /* ignored */
binding->descriptor_offset = 0; /* ignored */
binding->shader_visibility = vkd3d_shader_visibility_from_d3d12(p->ShaderVisibility);
binding->flags = VKD3D_SHADER_BINDING_FLAG_BUFFER;
binding->binding.binding = 0; /* ignored */
binding->binding.set = 0; /* ignored */
binding->flags |= VKD3D_SHADER_BINDING_FLAG_RAW_VA;
param = &root_signature->parameters[i];
param->parameter_type = p->ParameterType;
param->descriptor.binding = binding;
context->binding_index++;
}
return S_OK;
}
static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_signature *root_signature,
const D3D12_ROOT_SIGNATURE_DESC1 *desc, struct d3d12_root_signature_info *info,
const VkPushConstantRange *push_constant_range, struct vkd3d_descriptor_set_context *context,
VkDescriptorSetLayout *vk_set_layout)
{
VkDescriptorSetLayoutBinding *vk_binding, *vk_binding_info = NULL;
struct vkd3d_descriptor_hoist_desc *hoist_desc;
struct vkd3d_shader_resource_binding *binding;
struct vkd3d_shader_root_parameter *param;
uint32_t raw_va_root_descriptor_count = 0;
unsigned int hoisted_parameter_index;
const D3D12_DESCRIPTOR_RANGE1 *range;
unsigned int i, j, k;
HRESULT hr = S_OK;
if (info->push_descriptor_count || (root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_PUSH_CONSTANT_UNIFORM_BLOCK))
{
if (!(vk_binding_info = vkd3d_malloc(sizeof(*vk_binding_info) * (info->push_descriptor_count + 1))))
return E_OUTOFMEMORY;
}
else if (!(root_signature->device->bindless_state.flags &
(VKD3D_RAW_VA_ROOT_DESCRIPTOR_CBV | VKD3D_RAW_VA_ROOT_DESCRIPTOR_SRV_UAV)))
{
return S_OK;
}
hoisted_parameter_index = desc->NumParameters;
for (i = 0, j = 0; i < desc->NumParameters; ++i)
{
const D3D12_ROOT_PARAMETER1 *p = &desc->pParameters[i];
bool raw_va;
if (!(desc->Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE) &&
p->ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
{
unsigned int range_descriptor_offset = 0;
for (k = 0; k < p->DescriptorTable.NumDescriptorRanges && info->hoist_descriptor_count; k++)
{
range = &p->DescriptorTable.pDescriptorRanges[k];
if (range->OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
range_descriptor_offset = range->OffsetInDescriptorsFromTableStart;
if (d3d12_descriptor_range_can_hoist_cbv_descriptor(root_signature->device, range))
{
vk_binding = &vk_binding_info[j++];
vk_binding->binding = context->vk_binding;
vk_binding->descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
vk_binding->descriptorCount = 1;
vk_binding->stageFlags = vkd3d_vk_stage_flags_from_visibility(p->ShaderVisibility);
vk_binding->pImmutableSamplers = NULL;
root_signature->root_descriptor_push_mask |= 1ull << hoisted_parameter_index;
hoist_desc = &root_signature->hoist_info.desc[root_signature->hoist_info.num_desc];
hoist_desc->table_index = i;
hoist_desc->parameter_index = hoisted_parameter_index;
hoist_desc->table_offset = range_descriptor_offset;
root_signature->hoist_info.num_desc++;
binding = &root_signature->bindings[context->binding_index];
binding->type = vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType);
binding->register_space = range->RegisterSpace;
binding->register_index = range->BaseShaderRegister;
binding->register_count = 1;
binding->descriptor_table = 0; /* ignored */