forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_tracker.cpp
4151 lines (3603 loc) · 234 KB
/
state_tracker.cpp
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 (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 LunarG, Inc.
* Copyright (C) 2015-2021 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Mark Lobodzinski <[email protected]>
* Author: Dave Houlton <[email protected]>
* Shannon McPherson <[email protected]>
* Author: Tobias Hector <[email protected]>
*/
#include <algorithm>
#include <cmath>
#include "vk_enum_string_helper.h"
#include "vk_format_utils.h"
#include "vk_layer_data.h"
#include "vk_layer_utils.h"
#include "vk_layer_logging.h"
#include "vk_typemap_helper.h"
#include "chassis.h"
#include "state_tracker.h"
#include "shader_validation.h"
#include "sync_utils.h"
#include "cmd_buffer_state.h"
#include "render_pass_state.h"
extern template PIPELINE_STATE::PIPELINE_STATE(const ValidationStateTracker *, const VkRayTracingPipelineCreateInfoKHR *,
std::shared_ptr<const PIPELINE_LAYOUT_STATE> &&);
extern template PIPELINE_STATE::PIPELINE_STATE(const ValidationStateTracker *, const VkRayTracingPipelineCreateInfoNV *,
std::shared_ptr<const PIPELINE_LAYOUT_STATE> &&);
void ValidationStateTracker::InitDeviceValidationObject(bool add_obj, ValidationObject *inst_obj, ValidationObject *dev_obj) {
if (add_obj) {
instance_state = reinterpret_cast<ValidationStateTracker *>(GetValidationObject(inst_obj->object_dispatch, container_type));
// Call base class
ValidationObject::InitDeviceValidationObject(add_obj, inst_obj, dev_obj);
}
}
// NOTE: Beware the lifespan of the rp_begin when holding the return. If the rp_begin isn't a "safe" copy, "IMAGELESS"
// attachments won't persist past the API entry point exit.
static std::pair<uint32_t, const VkImageView *> GetFramebufferAttachments(const VkRenderPassBeginInfo &rp_begin,
const FRAMEBUFFER_STATE &fb_state) {
const VkImageView *attachments = fb_state.createInfo.pAttachments;
uint32_t count = fb_state.createInfo.attachmentCount;
if (fb_state.createInfo.flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) {
const auto *framebuffer_attachments = LvlFindInChain<VkRenderPassAttachmentBeginInfo>(rp_begin.pNext);
if (framebuffer_attachments) {
attachments = framebuffer_attachments->pAttachments;
count = framebuffer_attachments->attachmentCount;
}
}
return std::make_pair(count, attachments);
}
template <typename ImageViewPointer, typename Get>
std::vector<ImageViewPointer> GetAttachmentViewsImpl(const VkRenderPassBeginInfo &rp_begin, const FRAMEBUFFER_STATE &fb_state,
const Get &get_fn) {
std::vector<ImageViewPointer> views;
const auto count_attachment = GetFramebufferAttachments(rp_begin, fb_state);
const auto attachment_count = count_attachment.first;
const auto *attachments = count_attachment.second;
views.resize(attachment_count, nullptr);
for (uint32_t i = 0; i < attachment_count; i++) {
if (attachments[i] != VK_NULL_HANDLE) {
views[i] = get_fn(attachments[i]);
}
}
return views;
}
std::vector<std::shared_ptr<const IMAGE_VIEW_STATE>> ValidationStateTracker::GetAttachmentViews(
const VkRenderPassBeginInfo &rp_begin, const FRAMEBUFFER_STATE &fb_state) const {
auto get_fn = [this](VkImageView handle) { return this->Get<IMAGE_VIEW_STATE>(handle); };
return GetAttachmentViewsImpl<std::shared_ptr<const IMAGE_VIEW_STATE>>(rp_begin, fb_state, get_fn);
}
#ifdef VK_USE_PLATFORM_ANDROID_KHR
// Android-specific validation that uses types defined only with VK_USE_PLATFORM_ANDROID_KHR
// This could also move into a seperate core_validation_android.cpp file... ?
template <typename CreateInfo>
VkFormatFeatureFlags ValidationStateTracker::GetExternalFormatFeaturesANDROID(const CreateInfo *create_info) const {
VkFormatFeatureFlags format_features = 0;
const VkExternalFormatANDROID *ext_fmt_android = LvlFindInChain<VkExternalFormatANDROID>(create_info->pNext);
if (ext_fmt_android && (0 != ext_fmt_android->externalFormat)) {
// VUID 01894 will catch if not found in map
auto it = ahb_ext_formats_map.find(ext_fmt_android->externalFormat);
if (it != ahb_ext_formats_map.end()) {
format_features = it->second;
}
}
return format_features;
}
void ValidationStateTracker::PostCallRecordGetAndroidHardwareBufferPropertiesANDROID(
VkDevice device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties, VkResult result) {
if (VK_SUCCESS != result) return;
auto ahb_format_props = LvlFindInChain<VkAndroidHardwareBufferFormatPropertiesANDROID>(pProperties->pNext);
if (ahb_format_props) {
ahb_ext_formats_map.emplace(ahb_format_props->externalFormat, ahb_format_props->formatFeatures);
}
}
#else
template <typename CreateInfo>
VkFormatFeatureFlags ValidationStateTracker::GetExternalFormatFeaturesANDROID(const CreateInfo *create_info) const {
return 0;
}
#endif // VK_USE_PLATFORM_ANDROID_KHR
VkFormatFeatureFlags GetImageFormatFeatures(VkPhysicalDevice physical_device, VkDevice device, VkImage image, VkFormat format,
VkImageTiling tiling) {
VkFormatFeatureFlags format_features = 0;
// Add feature support according to Image Format Features (vkspec.html#resources-image-format-features)
// if format is AHB external format then the features are already set
if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
VkImageDrmFormatModifierPropertiesEXT drm_format_properties = {VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT,
nullptr};
DispatchGetImageDrmFormatModifierPropertiesEXT(device, image, &drm_format_properties);
VkFormatProperties2 format_properties_2 = {VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, nullptr};
VkDrmFormatModifierPropertiesListEXT drm_properties_list = {VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
nullptr};
format_properties_2.pNext = (void *)&drm_properties_list;
DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2);
std::vector<VkDrmFormatModifierPropertiesEXT> drm_properties;
drm_properties.resize(drm_properties_list.drmFormatModifierCount);
drm_properties_list.pDrmFormatModifierProperties = &drm_properties[0];
DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2);
for (uint32_t i = 0; i < drm_properties_list.drmFormatModifierCount; i++) {
if (drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifier == drm_format_properties.drmFormatModifier) {
format_features = drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures;
break;
}
}
} else {
VkFormatProperties format_properties;
DispatchGetPhysicalDeviceFormatProperties(physical_device, format, &format_properties);
format_features =
(tiling == VK_IMAGE_TILING_LINEAR) ? format_properties.linearTilingFeatures : format_properties.optimalTilingFeatures;
}
return format_features;
}
void ValidationStateTracker::PostCallRecordCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkImage *pImage, VkResult result) {
if (VK_SUCCESS != result) return;
VkFormatFeatureFlags format_features = 0;
if (IsExtEnabled(device_extensions.vk_android_external_memory_android_hardware_buffer)) {
format_features = GetExternalFormatFeaturesANDROID(pCreateInfo);
}
if (format_features == 0) {
format_features = GetImageFormatFeatures(physical_device, device, *pImage, pCreateInfo->format, pCreateInfo->tiling);
}
Add(std::make_shared<IMAGE_STATE>(this, *pImage, pCreateInfo, format_features));
}
void ValidationStateTracker::PreCallRecordDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) {
Destroy<IMAGE_STATE>(image);
}
void ValidationStateTracker::PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
VkImageLayout imageLayout, const VkClearColorValue *pColor,
uint32_t rangeCount, const VkImageSubresourceRange *pRanges) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
if (cb_node) {
cb_node->RecordTransferCmd(CMD_CLEARCOLORIMAGE, Get<IMAGE_STATE>(image));
}
}
void ValidationStateTracker::PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image,
VkImageLayout imageLayout,
const VkClearDepthStencilValue *pDepthStencil,
uint32_t rangeCount, const VkImageSubresourceRange *pRanges) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
if (cb_node) {
cb_node->RecordTransferCmd(CMD_CLEARDEPTHSTENCILIMAGE, Get<IMAGE_STATE>(image));
}
}
void ValidationStateTracker::PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkImageCopy *pRegions) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage));
}
void ValidationStateTracker::PreCallRecordCmdCopyImage2KHR(VkCommandBuffer commandBuffer,
const VkCopyImageInfo2KHR *pCopyImageInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYIMAGE2KHR, Get<IMAGE_STATE>(pCopyImageInfo->srcImage),
Get<IMAGE_STATE>(pCopyImageInfo->dstImage));
}
void ValidationStateTracker::PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage,
VkImageLayout dstImageLayout, uint32_t regionCount,
const VkImageResolve *pRegions) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_RESOLVEIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage));
}
void ValidationStateTracker::PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer,
const VkResolveImageInfo2KHR *pResolveImageInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_RESOLVEIMAGE2KHR, Get<IMAGE_STATE>(pResolveImageInfo->srcImage),
Get<IMAGE_STATE>(pResolveImageInfo->dstImage));
}
void ValidationStateTracker::PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_BLITIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage));
}
void ValidationStateTracker::PreCallRecordCmdBlitImage2KHR(VkCommandBuffer commandBuffer,
const VkBlitImageInfo2KHR *pBlitImageInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_BLITIMAGE2KHR, Get<IMAGE_STATE>(pBlitImageInfo->srcImage),
Get<IMAGE_STATE>(pBlitImageInfo->dstImage));
}
void ValidationStateTracker::PostCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer,
VkResult result) {
if (result != VK_SUCCESS) return;
auto buffer_state = std::make_shared<BUFFER_STATE>(this, *pBuffer, pCreateInfo);
if (pCreateInfo) {
const auto *opaque_capture_address = LvlFindInChain<VkBufferOpaqueCaptureAddressCreateInfo>(pCreateInfo->pNext);
if (opaque_capture_address) {
// address is used for GPU-AV and ray tracing buffer validation
buffer_state->deviceAddress = opaque_capture_address->opaqueCaptureAddress;
buffer_address_map_.emplace(opaque_capture_address->opaqueCaptureAddress, buffer_state.get());
}
}
Add(std::move(buffer_state));
}
void ValidationStateTracker::PostCallRecordCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkBufferView *pView,
VkResult result) {
if (result != VK_SUCCESS) return;
auto buffer_state = Get<BUFFER_STATE>(pCreateInfo->buffer);
VkFormatProperties format_properties;
DispatchGetPhysicalDeviceFormatProperties(physical_device, pCreateInfo->format, &format_properties);
Add(std::make_shared<BUFFER_VIEW_STATE>(buffer_state, *pView, pCreateInfo, format_properties.bufferFeatures));
}
void ValidationStateTracker::PostCallRecordCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkImageView *pView,
VkResult result) {
if (result != VK_SUCCESS) return;
auto image_state = Get<IMAGE_STATE>(pCreateInfo->image);
VkFormatFeatureFlags format_features = 0;
if (image_state->HasAHBFormat() == true) {
// The ImageView uses same Image's format feature since they share same AHB
format_features = image_state->format_features;
} else {
format_features = GetImageFormatFeatures(physical_device, device, image_state->image(), pCreateInfo->format,
image_state->createInfo.tiling);
}
// filter_cubic_props is used in CmdDraw validation. But it takes a lot of performance if it does in CmdDraw.
auto filter_cubic_props = LvlInitStruct<VkFilterCubicImageViewImageFormatPropertiesEXT>();
if (IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
auto imageview_format_info = LvlInitStruct<VkPhysicalDeviceImageViewImageFormatInfoEXT>();
imageview_format_info.imageViewType = pCreateInfo->viewType;
auto image_format_info = LvlInitStruct<VkPhysicalDeviceImageFormatInfo2>(&imageview_format_info);
image_format_info.type = image_state->createInfo.imageType;
image_format_info.format = image_state->createInfo.format;
image_format_info.tiling = image_state->createInfo.tiling;
auto usage_create_info = LvlFindInChain<VkImageViewUsageCreateInfo>(pCreateInfo->pNext);
image_format_info.usage = usage_create_info ? usage_create_info->usage : image_state->createInfo.usage;
image_format_info.flags = image_state->createInfo.flags;
auto image_format_properties = LvlInitStruct<VkImageFormatProperties2>(&filter_cubic_props);
DispatchGetPhysicalDeviceImageFormatProperties2(physical_device, &image_format_info, &image_format_properties);
}
Add(std::make_shared<IMAGE_VIEW_STATE>(image_state, *pView, pCreateInfo, format_features, filter_cubic_props));
}
void ValidationStateTracker::PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
uint32_t regionCount, const VkBufferCopy *pRegions) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYBUFFER, Get<BUFFER_STATE>(srcBuffer), Get<BUFFER_STATE>(dstBuffer));
}
void ValidationStateTracker::PreCallRecordCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
const VkCopyBufferInfo2KHR *pCopyBufferInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYBUFFER2KHR, Get<BUFFER_STATE>(pCopyBufferInfo->srcBuffer),
Get<BUFFER_STATE>(pCopyBufferInfo->dstBuffer));
}
void ValidationStateTracker::PreCallRecordDestroyImageView(VkDevice device, VkImageView imageView,
const VkAllocationCallbacks *pAllocator) {
Destroy<IMAGE_VIEW_STATE>(imageView);
}
void ValidationStateTracker::PreCallRecordDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator) {
Destroy<BUFFER_STATE>(buffer);
}
void ValidationStateTracker::PreCallRecordDestroyBufferView(VkDevice device, VkBufferView bufferView,
const VkAllocationCallbacks *pAllocator) {
Destroy<BUFFER_VIEW_STATE>(bufferView);
}
void ValidationStateTracker::PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
VkDeviceSize size, uint32_t data) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_FILLBUFFER, Get<BUFFER_STATE>(dstBuffer));
}
void ValidationStateTracker::PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
VkImageLayout srcImageLayout, VkBuffer dstBuffer,
uint32_t regionCount, const VkBufferImageCopy *pRegions) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYIMAGETOBUFFER, Get<IMAGE_STATE>(srcImage), Get<BUFFER_STATE>(dstBuffer));
}
void ValidationStateTracker::PreCallRecordCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer,
const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYIMAGETOBUFFER2KHR, Get<IMAGE_STATE>(pCopyImageToBufferInfo->srcImage),
Get<BUFFER_STATE>(pCopyImageToBufferInfo->dstBuffer));
}
void ValidationStateTracker::PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage,
VkImageLayout dstImageLayout, uint32_t regionCount,
const VkBufferImageCopy *pRegions) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYBUFFERTOIMAGE, Get<BUFFER_STATE>(srcBuffer), Get<IMAGE_STATE>(dstImage));
}
void ValidationStateTracker::PreCallRecordCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer,
const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) {
if (disabled[command_buffer_state]) return;
auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer);
cb_node->RecordTransferCmd(CMD_COPYBUFFERTOIMAGE2KHR, Get<BUFFER_STATE>(pCopyBufferToImageInfo->srcBuffer),
Get<IMAGE_STATE>(pCopyBufferToImageInfo->dstImage));
}
// Gets union of all features defined by Potential Format Features
// except, does not handle the external format case for AHB as that only can be used for sampled images
VkFormatFeatureFlags ValidationStateTracker::GetPotentialFormatFeatures(VkFormat format) const {
VkFormatFeatureFlags format_features = 0;
if (format != VK_FORMAT_UNDEFINED) {
VkFormatProperties format_properties;
DispatchGetPhysicalDeviceFormatProperties(physical_device, format, &format_properties);
format_features |= format_properties.linearTilingFeatures;
format_features |= format_properties.optimalTilingFeatures;
if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
// VK_KHR_get_physical_device_properties2 is required in this case
VkFormatProperties2 format_properties_2 = {VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2};
VkDrmFormatModifierPropertiesListEXT drm_properties_list = {VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
nullptr};
format_properties_2.pNext = (void *)&drm_properties_list;
// First call is to get the number of modifiers compatible with the queried format
DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2);
std::vector<VkDrmFormatModifierPropertiesEXT> drm_properties;
drm_properties.resize(drm_properties_list.drmFormatModifierCount);
drm_properties_list.pDrmFormatModifierProperties = drm_properties.data();
// Second call, now with an allocated array in pDrmFormatModifierProperties, is to get the modifiers
// compatible with the queried format
DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2);
for (uint32_t i = 0; i < drm_properties_list.drmFormatModifierCount; i++) {
format_features |= drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures;
}
}
}
return format_features;
}
void ValidationStateTracker::PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice,
VkResult result) {
if (VK_SUCCESS != result) return;
ValidationObject *device_object = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
ValidationObject *validation_data = GetValidationObject(device_object->object_dispatch, this->container_type);
ValidationStateTracker *state_tracker = static_cast<ValidationStateTracker *>(validation_data);
const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures;
if (nullptr == enabled_features_found) {
const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
if (features2) {
enabled_features_found = &(features2->features);
}
}
if (nullptr == enabled_features_found) {
state_tracker->enabled_features.core = {};
} else {
state_tracker->enabled_features.core = *enabled_features_found;
}
// Save local link to this device's physical device state
state_tracker->physical_device_state = Get<PHYSICAL_DEVICE_STATE>(gpu).get();
const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
if (vulkan_12_features) {
state_tracker->enabled_features.core12 = *vulkan_12_features;
} else {
// Set Extension Feature Aliases to false as there is no struct to check
state_tracker->enabled_features.core12.drawIndirectCount = VK_FALSE;
state_tracker->enabled_features.core12.samplerMirrorClampToEdge = VK_FALSE;
state_tracker->enabled_features.core12.descriptorIndexing = VK_FALSE;
state_tracker->enabled_features.core12.samplerFilterMinmax = VK_FALSE;
state_tracker->enabled_features.core12.shaderOutputLayer = VK_FALSE;
state_tracker->enabled_features.core12.shaderOutputViewportIndex = VK_FALSE;
state_tracker->enabled_features.core12.subgroupBroadcastDynamicId = VK_FALSE;
// These structs are only allowed in pNext chain if there is no VkPhysicalDeviceVulkan12Features
const auto *eight_bit_storage_features = LvlFindInChain<VkPhysicalDevice8BitStorageFeatures>(pCreateInfo->pNext);
if (eight_bit_storage_features) {
state_tracker->enabled_features.core12.storageBuffer8BitAccess = eight_bit_storage_features->storageBuffer8BitAccess;
state_tracker->enabled_features.core12.uniformAndStorageBuffer8BitAccess =
eight_bit_storage_features->uniformAndStorageBuffer8BitAccess;
state_tracker->enabled_features.core12.storagePushConstant8 = eight_bit_storage_features->storagePushConstant8;
}
const auto *float16_int8_features = LvlFindInChain<VkPhysicalDeviceShaderFloat16Int8Features>(pCreateInfo->pNext);
if (float16_int8_features) {
state_tracker->enabled_features.core12.shaderFloat16 = float16_int8_features->shaderFloat16;
state_tracker->enabled_features.core12.shaderInt8 = float16_int8_features->shaderInt8;
}
const auto *descriptor_indexing_features = LvlFindInChain<VkPhysicalDeviceDescriptorIndexingFeatures>(pCreateInfo->pNext);
if (descriptor_indexing_features) {
state_tracker->enabled_features.core12.shaderInputAttachmentArrayDynamicIndexing =
descriptor_indexing_features->shaderInputAttachmentArrayDynamicIndexing;
state_tracker->enabled_features.core12.shaderUniformTexelBufferArrayDynamicIndexing =
descriptor_indexing_features->shaderUniformTexelBufferArrayDynamicIndexing;
state_tracker->enabled_features.core12.shaderStorageTexelBufferArrayDynamicIndexing =
descriptor_indexing_features->shaderStorageTexelBufferArrayDynamicIndexing;
state_tracker->enabled_features.core12.shaderUniformBufferArrayNonUniformIndexing =
descriptor_indexing_features->shaderUniformBufferArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderSampledImageArrayNonUniformIndexing =
descriptor_indexing_features->shaderSampledImageArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderStorageBufferArrayNonUniformIndexing =
descriptor_indexing_features->shaderStorageBufferArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderStorageImageArrayNonUniformIndexing =
descriptor_indexing_features->shaderStorageImageArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderInputAttachmentArrayNonUniformIndexing =
descriptor_indexing_features->shaderInputAttachmentArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderUniformTexelBufferArrayNonUniformIndexing =
descriptor_indexing_features->shaderUniformTexelBufferArrayNonUniformIndexing;
state_tracker->enabled_features.core12.shaderStorageTexelBufferArrayNonUniformIndexing =
descriptor_indexing_features->shaderStorageTexelBufferArrayNonUniformIndexing;
state_tracker->enabled_features.core12.descriptorBindingUniformBufferUpdateAfterBind =
descriptor_indexing_features->descriptorBindingUniformBufferUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingSampledImageUpdateAfterBind =
descriptor_indexing_features->descriptorBindingSampledImageUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingStorageImageUpdateAfterBind =
descriptor_indexing_features->descriptorBindingStorageImageUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingStorageBufferUpdateAfterBind =
descriptor_indexing_features->descriptorBindingStorageBufferUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingUniformTexelBufferUpdateAfterBind =
descriptor_indexing_features->descriptorBindingUniformTexelBufferUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingStorageTexelBufferUpdateAfterBind =
descriptor_indexing_features->descriptorBindingStorageTexelBufferUpdateAfterBind;
state_tracker->enabled_features.core12.descriptorBindingUpdateUnusedWhilePending =
descriptor_indexing_features->descriptorBindingUpdateUnusedWhilePending;
state_tracker->enabled_features.core12.descriptorBindingPartiallyBound =
descriptor_indexing_features->descriptorBindingPartiallyBound;
state_tracker->enabled_features.core12.descriptorBindingVariableDescriptorCount =
descriptor_indexing_features->descriptorBindingVariableDescriptorCount;
state_tracker->enabled_features.core12.runtimeDescriptorArray = descriptor_indexing_features->runtimeDescriptorArray;
}
const auto *scalar_block_layout_features = LvlFindInChain<VkPhysicalDeviceScalarBlockLayoutFeatures>(pCreateInfo->pNext);
if (scalar_block_layout_features) {
state_tracker->enabled_features.core12.scalarBlockLayout = scalar_block_layout_features->scalarBlockLayout;
}
const auto *imageless_framebuffer_features =
LvlFindInChain<VkPhysicalDeviceImagelessFramebufferFeatures>(pCreateInfo->pNext);
if (imageless_framebuffer_features) {
state_tracker->enabled_features.core12.imagelessFramebuffer = imageless_framebuffer_features->imagelessFramebuffer;
}
const auto *uniform_buffer_standard_layout_features =
LvlFindInChain<VkPhysicalDeviceUniformBufferStandardLayoutFeatures>(pCreateInfo->pNext);
if (uniform_buffer_standard_layout_features) {
state_tracker->enabled_features.core12.uniformBufferStandardLayout =
uniform_buffer_standard_layout_features->uniformBufferStandardLayout;
}
const auto *subgroup_extended_types_features =
LvlFindInChain<VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures>(pCreateInfo->pNext);
if (subgroup_extended_types_features) {
state_tracker->enabled_features.core12.shaderSubgroupExtendedTypes =
subgroup_extended_types_features->shaderSubgroupExtendedTypes;
}
const auto *separate_depth_stencil_layouts_features =
LvlFindInChain<VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures>(pCreateInfo->pNext);
if (separate_depth_stencil_layouts_features) {
state_tracker->enabled_features.core12.separateDepthStencilLayouts =
separate_depth_stencil_layouts_features->separateDepthStencilLayouts;
}
const auto *host_query_reset_features = LvlFindInChain<VkPhysicalDeviceHostQueryResetFeatures>(pCreateInfo->pNext);
if (host_query_reset_features) {
state_tracker->enabled_features.core12.hostQueryReset = host_query_reset_features->hostQueryReset;
}
const auto *timeline_semaphore_features = LvlFindInChain<VkPhysicalDeviceTimelineSemaphoreFeatures>(pCreateInfo->pNext);
if (timeline_semaphore_features) {
state_tracker->enabled_features.core12.timelineSemaphore = timeline_semaphore_features->timelineSemaphore;
}
const auto *buffer_device_address = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(pCreateInfo->pNext);
if (buffer_device_address) {
state_tracker->enabled_features.core12.bufferDeviceAddress = buffer_device_address->bufferDeviceAddress;
state_tracker->enabled_features.core12.bufferDeviceAddressCaptureReplay =
buffer_device_address->bufferDeviceAddressCaptureReplay;
state_tracker->enabled_features.core12.bufferDeviceAddressMultiDevice =
buffer_device_address->bufferDeviceAddressMultiDevice;
}
const auto *atomic_int64_features = LvlFindInChain<VkPhysicalDeviceShaderAtomicInt64Features>(pCreateInfo->pNext);
if (atomic_int64_features) {
state_tracker->enabled_features.core12.shaderBufferInt64Atomics = atomic_int64_features->shaderBufferInt64Atomics;
state_tracker->enabled_features.core12.shaderSharedInt64Atomics = atomic_int64_features->shaderSharedInt64Atomics;
}
const auto *memory_model_features = LvlFindInChain<VkPhysicalDeviceVulkanMemoryModelFeatures>(pCreateInfo->pNext);
if (memory_model_features) {
state_tracker->enabled_features.core12.vulkanMemoryModel = memory_model_features->vulkanMemoryModel;
state_tracker->enabled_features.core12.vulkanMemoryModelDeviceScope =
memory_model_features->vulkanMemoryModelDeviceScope;
state_tracker->enabled_features.core12.vulkanMemoryModelAvailabilityVisibilityChains =
memory_model_features->vulkanMemoryModelAvailabilityVisibilityChains;
}
}
const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
if (vulkan_11_features) {
state_tracker->enabled_features.core11 = *vulkan_11_features;
} else {
// These structs are only allowed in pNext chain if there is no vkPhysicalDeviceVulkan11Features
const auto *sixteen_bit_storage_features = LvlFindInChain<VkPhysicalDevice16BitStorageFeatures>(pCreateInfo->pNext);
if (sixteen_bit_storage_features) {
state_tracker->enabled_features.core11.storageBuffer16BitAccess =
sixteen_bit_storage_features->storageBuffer16BitAccess;
state_tracker->enabled_features.core11.uniformAndStorageBuffer16BitAccess =
sixteen_bit_storage_features->uniformAndStorageBuffer16BitAccess;
state_tracker->enabled_features.core11.storagePushConstant16 = sixteen_bit_storage_features->storagePushConstant16;
state_tracker->enabled_features.core11.storageInputOutput16 = sixteen_bit_storage_features->storageInputOutput16;
}
const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
if (multiview_features) {
state_tracker->enabled_features.core11.multiview = multiview_features->multiview;
state_tracker->enabled_features.core11.multiviewGeometryShader = multiview_features->multiviewGeometryShader;
state_tracker->enabled_features.core11.multiviewTessellationShader = multiview_features->multiviewTessellationShader;
}
const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
if (variable_pointers_features) {
state_tracker->enabled_features.core11.variablePointersStorageBuffer =
variable_pointers_features->variablePointersStorageBuffer;
state_tracker->enabled_features.core11.variablePointers = variable_pointers_features->variablePointers;
}
const auto *protected_memory_features = LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
if (protected_memory_features) {
state_tracker->enabled_features.core11.protectedMemory = protected_memory_features->protectedMemory;
}
const auto *ycbcr_conversion_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(pCreateInfo->pNext);
if (ycbcr_conversion_features) {
state_tracker->enabled_features.core11.samplerYcbcrConversion = ycbcr_conversion_features->samplerYcbcrConversion;
}
const auto *shader_draw_parameters_features =
LvlFindInChain<VkPhysicalDeviceShaderDrawParametersFeatures>(pCreateInfo->pNext);
if (shader_draw_parameters_features) {
state_tracker->enabled_features.core11.shaderDrawParameters = shader_draw_parameters_features->shaderDrawParameters;
}
}
const auto *device_group_ci = LvlFindInChain<VkDeviceGroupDeviceCreateInfo>(pCreateInfo->pNext);
if (device_group_ci) {
state_tracker->physical_device_count = device_group_ci->physicalDeviceCount;
state_tracker->device_group_create_info = *device_group_ci;
} else {
state_tracker->physical_device_count = 1;
}
// Features from other extensions passesd in create info
{
const auto *exclusive_scissor_features = LvlFindInChain<VkPhysicalDeviceExclusiveScissorFeaturesNV>(pCreateInfo->pNext);
if (exclusive_scissor_features) {
state_tracker->enabled_features.exclusive_scissor_features = *exclusive_scissor_features;
}
const auto *shading_rate_image_features = LvlFindInChain<VkPhysicalDeviceShadingRateImageFeaturesNV>(pCreateInfo->pNext);
if (shading_rate_image_features) {
state_tracker->enabled_features.shading_rate_image_features = *shading_rate_image_features;
}
const auto *mesh_shader_features = LvlFindInChain<VkPhysicalDeviceMeshShaderFeaturesNV>(pCreateInfo->pNext);
if (mesh_shader_features) {
state_tracker->enabled_features.mesh_shader_features = *mesh_shader_features;
}
const auto *inline_uniform_block_features =
LvlFindInChain<VkPhysicalDeviceInlineUniformBlockFeaturesEXT>(pCreateInfo->pNext);
if (inline_uniform_block_features) {
state_tracker->enabled_features.inline_uniform_block_features = *inline_uniform_block_features;
}
const auto *transform_feedback_features = LvlFindInChain<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(pCreateInfo->pNext);
if (transform_feedback_features) {
state_tracker->enabled_features.transform_feedback_features = *transform_feedback_features;
}
const auto *vtx_attrib_div_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
if (vtx_attrib_div_features) {
state_tracker->enabled_features.vtx_attrib_divisor_features = *vtx_attrib_div_features;
}
const auto *buffer_device_address_ext_features =
LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeaturesEXT>(pCreateInfo->pNext);
if (buffer_device_address_ext_features) {
state_tracker->enabled_features.buffer_device_address_ext_features = *buffer_device_address_ext_features;
}
const auto *cooperative_matrix_features = LvlFindInChain<VkPhysicalDeviceCooperativeMatrixFeaturesNV>(pCreateInfo->pNext);
if (cooperative_matrix_features) {
state_tracker->enabled_features.cooperative_matrix_features = *cooperative_matrix_features;
}
const auto *compute_shader_derivatives_features =
LvlFindInChain<VkPhysicalDeviceComputeShaderDerivativesFeaturesNV>(pCreateInfo->pNext);
if (compute_shader_derivatives_features) {
state_tracker->enabled_features.compute_shader_derivatives_features = *compute_shader_derivatives_features;
}
const auto *fragment_shader_barycentric_features =
LvlFindInChain<VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV>(pCreateInfo->pNext);
if (fragment_shader_barycentric_features) {
state_tracker->enabled_features.fragment_shader_barycentric_features = *fragment_shader_barycentric_features;
}
const auto *shader_image_footprint_features =
LvlFindInChain<VkPhysicalDeviceShaderImageFootprintFeaturesNV>(pCreateInfo->pNext);
if (shader_image_footprint_features) {
state_tracker->enabled_features.shader_image_footprint_features = *shader_image_footprint_features;
}
const auto *fragment_shader_interlock_features =
LvlFindInChain<VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT>(pCreateInfo->pNext);
if (fragment_shader_interlock_features) {
state_tracker->enabled_features.fragment_shader_interlock_features = *fragment_shader_interlock_features;
}
const auto *demote_to_helper_invocation_features =
LvlFindInChain<VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT>(pCreateInfo->pNext);
if (demote_to_helper_invocation_features) {
state_tracker->enabled_features.demote_to_helper_invocation_features = *demote_to_helper_invocation_features;
}
const auto *texel_buffer_alignment_features =
LvlFindInChain<VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT>(pCreateInfo->pNext);
if (texel_buffer_alignment_features) {
state_tracker->enabled_features.texel_buffer_alignment_features = *texel_buffer_alignment_features;
}
const auto *pipeline_exe_props_features =
LvlFindInChain<VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR>(pCreateInfo->pNext);
if (pipeline_exe_props_features) {
state_tracker->enabled_features.pipeline_exe_props_features = *pipeline_exe_props_features;
}
const auto *dedicated_allocation_image_aliasing_features =
LvlFindInChain<VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV>(pCreateInfo->pNext);
if (dedicated_allocation_image_aliasing_features) {
state_tracker->enabled_features.dedicated_allocation_image_aliasing_features =
*dedicated_allocation_image_aliasing_features;
}
const auto *performance_query_features = LvlFindInChain<VkPhysicalDevicePerformanceQueryFeaturesKHR>(pCreateInfo->pNext);
if (performance_query_features) {
state_tracker->enabled_features.performance_query_features = *performance_query_features;
}
const auto *device_coherent_memory_features = LvlFindInChain<VkPhysicalDeviceCoherentMemoryFeaturesAMD>(pCreateInfo->pNext);
if (device_coherent_memory_features) {
state_tracker->enabled_features.device_coherent_memory_features = *device_coherent_memory_features;
}
const auto *ycbcr_image_array_features = LvlFindInChain<VkPhysicalDeviceYcbcrImageArraysFeaturesEXT>(pCreateInfo->pNext);
if (ycbcr_image_array_features) {
state_tracker->enabled_features.ycbcr_image_array_features = *ycbcr_image_array_features;
}
const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(pCreateInfo->pNext);
if (ray_query_features) {
state_tracker->enabled_features.ray_query_features = *ray_query_features;
}
const auto *ray_tracing_pipeline_features =
LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
if (ray_tracing_pipeline_features) {
state_tracker->enabled_features.ray_tracing_pipeline_features = *ray_tracing_pipeline_features;
}
const auto *ray_tracing_acceleration_structure_features =
LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(pCreateInfo->pNext);
if (ray_tracing_acceleration_structure_features) {
state_tracker->enabled_features.ray_tracing_acceleration_structure_features =
*ray_tracing_acceleration_structure_features;
}
const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
if (robustness2_features) {
state_tracker->enabled_features.robustness2_features = *robustness2_features;
}
const auto *fragment_density_map_features =
LvlFindInChain<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>(pCreateInfo->pNext);
if (fragment_density_map_features) {
state_tracker->enabled_features.fragment_density_map_features = *fragment_density_map_features;
}
const auto *fragment_density_map_features2 =
LvlFindInChain<VkPhysicalDeviceFragmentDensityMap2FeaturesEXT>(pCreateInfo->pNext);
if (fragment_density_map_features2) {
state_tracker->enabled_features.fragment_density_map2_features = *fragment_density_map_features2;
}
const auto *astc_decode_features = LvlFindInChain<VkPhysicalDeviceASTCDecodeFeaturesEXT>(pCreateInfo->pNext);
if (astc_decode_features) {
state_tracker->enabled_features.astc_decode_features = *astc_decode_features;
}
const auto *custom_border_color_features = LvlFindInChain<VkPhysicalDeviceCustomBorderColorFeaturesEXT>(pCreateInfo->pNext);
if (custom_border_color_features) {
state_tracker->enabled_features.custom_border_color_features = *custom_border_color_features;
}
const auto *pipeline_creation_cache_control_features =
LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(pCreateInfo->pNext);
if (pipeline_creation_cache_control_features) {
state_tracker->enabled_features.pipeline_creation_cache_control_features = *pipeline_creation_cache_control_features;
}
const auto *fragment_shading_rate_features =
LvlFindInChain<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(pCreateInfo->pNext);
if (fragment_shading_rate_features) {
state_tracker->enabled_features.fragment_shading_rate_features = *fragment_shading_rate_features;
}
const auto *extended_dynamic_state_features =
LvlFindInChain<VkPhysicalDeviceExtendedDynamicStateFeaturesEXT>(pCreateInfo->pNext);
if (extended_dynamic_state_features) {
state_tracker->enabled_features.extended_dynamic_state_features = *extended_dynamic_state_features;
}
const auto *extended_dynamic_state2_features =
LvlFindInChain<VkPhysicalDeviceExtendedDynamicState2FeaturesEXT>(pCreateInfo->pNext);
if (extended_dynamic_state2_features) {
state_tracker->enabled_features.extended_dynamic_state2_features = *extended_dynamic_state2_features;
}
const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
if (multiview_features) {
state_tracker->enabled_features.multiview_features = *multiview_features;
}
const auto *portability_features = LvlFindInChain<VkPhysicalDevicePortabilitySubsetFeaturesKHR>(pCreateInfo->pNext);
if (portability_features) {
state_tracker->enabled_features.portability_subset_features = *portability_features;
}
const auto *shader_integer_functions2_features =
LvlFindInChain<VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL>(pCreateInfo->pNext);
if (shader_integer_functions2_features) {
state_tracker->enabled_features.shader_integer_functions2_features = *shader_integer_functions2_features;
}
const auto *shader_sm_builtins_features = LvlFindInChain<VkPhysicalDeviceShaderSMBuiltinsFeaturesNV>(pCreateInfo->pNext);
if (shader_sm_builtins_features) {
state_tracker->enabled_features.shader_sm_builtins_features = *shader_sm_builtins_features;
}
const auto *shader_atomic_float_features = LvlFindInChain<VkPhysicalDeviceShaderAtomicFloatFeaturesEXT>(pCreateInfo->pNext);
if (shader_atomic_float_features) {
state_tracker->enabled_features.shader_atomic_float_features = *shader_atomic_float_features;
}
const auto *shader_image_atomic_int64_features =
LvlFindInChain<VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT>(pCreateInfo->pNext);
if (shader_image_atomic_int64_features) {
state_tracker->enabled_features.shader_image_atomic_int64_features = *shader_image_atomic_int64_features;
}
const auto *shader_clock_features = LvlFindInChain<VkPhysicalDeviceShaderClockFeaturesKHR>(pCreateInfo->pNext);
if (shader_clock_features) {
state_tracker->enabled_features.shader_clock_features = *shader_clock_features;
}
const auto *conditional_rendering_features =
LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(pCreateInfo->pNext);
if (conditional_rendering_features) {
state_tracker->enabled_features.conditional_rendering_features = *conditional_rendering_features;
}
const auto *workgroup_memory_explicit_layout_features =
LvlFindInChain<VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR>(pCreateInfo->pNext);
if (workgroup_memory_explicit_layout_features) {
state_tracker->enabled_features.workgroup_memory_explicit_layout_features = *workgroup_memory_explicit_layout_features;
}
const auto *synchronization2_features = LvlFindInChain<VkPhysicalDeviceSynchronization2FeaturesKHR>(pCreateInfo->pNext);
if (synchronization2_features) {
state_tracker->enabled_features.synchronization2_features = *synchronization2_features;
}
const auto *provoking_vertex_features = lvl_find_in_chain<VkPhysicalDeviceProvokingVertexFeaturesEXT>(pCreateInfo->pNext);
if (provoking_vertex_features) {
state_tracker->enabled_features.provoking_vertex_features = *provoking_vertex_features;
}
const auto *vertex_input_dynamic_state_features =
LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(pCreateInfo->pNext);
if (vertex_input_dynamic_state_features) {
state_tracker->enabled_features.vertex_input_dynamic_state_features = *vertex_input_dynamic_state_features;
}
const auto *inherited_viewport_scissor_features =
LvlFindInChain<VkPhysicalDeviceInheritedViewportScissorFeaturesNV>(pCreateInfo->pNext);
if (inherited_viewport_scissor_features) {
state_tracker->enabled_features.inherited_viewport_scissor_features = *inherited_viewport_scissor_features;
}
const auto *multi_draw_features = LvlFindInChain<VkPhysicalDeviceMultiDrawFeaturesEXT>(pCreateInfo->pNext);
if (multi_draw_features) {
state_tracker->enabled_features.multi_draw_features = *multi_draw_features;
}
const auto *color_write_features = LvlFindInChain<VkPhysicalDeviceColorWriteEnableFeaturesEXT>(pCreateInfo->pNext);
if (color_write_features) {
state_tracker->enabled_features.color_write_features = *color_write_features;
}
const auto *shader_atomic_float2_features =
LvlFindInChain<VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT>(pCreateInfo->pNext);
if (shader_atomic_float2_features) {
state_tracker->enabled_features.shader_atomic_float2_features = *shader_atomic_float2_features;
}
const auto *present_id_features = LvlFindInChain<VkPhysicalDevicePresentIdFeaturesKHR>(pCreateInfo->pNext);
if (present_id_features) {
state_tracker->enabled_features.present_id_features = *present_id_features;
}
const auto *present_wait_features = LvlFindInChain<VkPhysicalDevicePresentWaitFeaturesKHR>(pCreateInfo->pNext);
if (present_wait_features) {
state_tracker->enabled_features.present_wait_features = *present_wait_features;
}
const auto *ray_tracing_motion_blur_features =
LvlFindInChain<VkPhysicalDeviceRayTracingMotionBlurFeaturesNV>(pCreateInfo->pNext);
if (ray_tracing_motion_blur_features) {
state_tracker->enabled_features.ray_tracing_motion_blur_features = *ray_tracing_motion_blur_features;
}
const auto *shader_integer_dot_product_features =
LvlFindInChain<VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR>(pCreateInfo->pNext);
if (shader_integer_dot_product_features) {
state_tracker->enabled_features.shader_integer_dot_product_features = *shader_integer_dot_product_features;
}
const auto *primitive_topology_list_restart_features =
LvlFindInChain<VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT>(pCreateInfo->pNext);
if (primitive_topology_list_restart_features) {
state_tracker->enabled_features.primitive_topology_list_restart_features = *primitive_topology_list_restart_features;
}
const auto *rgba10x6_formats_features = LvlFindInChain<VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT>(pCreateInfo->pNext);
if (rgba10x6_formats_features) {
state_tracker->enabled_features.rgba10x6_formats_features = *rgba10x6_formats_features;
}
const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(pCreateInfo->pNext);
if (maintenance4_features) {
state_tracker->enabled_features.maintenance4_features = *maintenance4_features;
}
const auto *dynamic_rendering_features = LvlFindInChain<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(pCreateInfo->pNext);
if (dynamic_rendering_features) {
state_tracker->enabled_features.dynamic_rendering_features = *dynamic_rendering_features;
}
const auto *image_view_min_lod_features = LvlFindInChain<VkPhysicalDeviceImageViewMinLodFeaturesEXT>(pCreateInfo->pNext);
if (image_view_min_lod_features) {
state_tracker->enabled_features.image_view_min_lod_features = *image_view_min_lod_features;
}
}
const auto *subgroup_size_control_features = LvlFindInChain<VkPhysicalDeviceSubgroupSizeControlFeaturesEXT>(pCreateInfo->pNext);
if (subgroup_size_control_features) {
state_tracker->enabled_features.subgroup_size_control_features = *subgroup_size_control_features;
}
// Store physical device properties and physical device mem limits into CoreChecks structs
DispatchGetPhysicalDeviceMemoryProperties(gpu, &state_tracker->phys_dev_mem_props);
DispatchGetPhysicalDeviceProperties(gpu, &state_tracker->phys_dev_props);
const auto &dev_ext = state_tracker->device_extensions;
auto *phys_dev_props = &state_tracker->phys_dev_ext_props;
// Vulkan 1.2 can get properties from single struct, otherwise need to add to it per extension
if (dev_ext.vk_feature_version_1_2) {
GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_feature_version_1_2, &state_tracker->phys_dev_props_core11);
GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_feature_version_1_2, &state_tracker->phys_dev_props_core12);
} else {
// VkPhysicalDeviceVulkan11Properties
//
// Can ingnore VkPhysicalDeviceIDProperties as it has no validation purpose
if (dev_ext.vk_khr_multiview) {
auto multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_multiview, &multiview_props);
state_tracker->phys_dev_props_core11.maxMultiviewViewCount = multiview_props.maxMultiviewViewCount;
state_tracker->phys_dev_props_core11.maxMultiviewInstanceIndex = multiview_props.maxMultiviewInstanceIndex;
}