sfricke-samsung | 486a51e | 2021-01-02 00:10:15 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2021 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2021 Valve Corporation |
| 3 | * Copyright (c) 2015-2021 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2021 Google Inc. |
Tobias Hector | 6663c9b | 2020-11-05 10:18:02 +0000 | [diff] [blame] | 5 | * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * |
| 19 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 20 | * Author: Dave Houlton <daveh@lunarg.com> |
| 21 | * Shannon McPherson <shannon@lunarg.com> |
Tobias Hector | 6663c9b | 2020-11-05 10:18:02 +0000 | [diff] [blame] | 22 | * Author: Tobias Hector <tobias.hector@amd.com> |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 23 | */ |
| 24 | |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 25 | #include <algorithm> |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 26 | #include <cmath> |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 27 | |
| 28 | #include "vk_enum_string_helper.h" |
| 29 | #include "vk_format_utils.h" |
| 30 | #include "vk_layer_data.h" |
| 31 | #include "vk_layer_utils.h" |
| 32 | #include "vk_layer_logging.h" |
| 33 | #include "vk_typemap_helper.h" |
| 34 | |
| 35 | #include "chassis.h" |
| 36 | #include "state_tracker.h" |
| 37 | #include "shader_validation.h" |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 38 | #include "sync_utils.h" |
Jeremy Gebben | 159b3cc | 2021-06-03 09:09:03 -0600 | [diff] [blame] | 39 | #include "cmd_buffer_state.h" |
| 40 | #include "render_pass_state.h" |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 41 | |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 42 | extern template PIPELINE_STATE::PIPELINE_STATE(const ValidationStateTracker *, const VkRayTracingPipelineCreateInfoKHR *, |
| 43 | std::shared_ptr<const PIPELINE_LAYOUT_STATE> &&); |
| 44 | extern template PIPELINE_STATE::PIPELINE_STATE(const ValidationStateTracker *, const VkRayTracingPipelineCreateInfoNV *, |
| 45 | std::shared_ptr<const PIPELINE_LAYOUT_STATE> &&); |
| 46 | |
Mark Lobodzinski | b4ab6ac | 2020-04-02 13:12:06 -0600 | [diff] [blame] | 47 | void ValidationStateTracker::InitDeviceValidationObject(bool add_obj, ValidationObject *inst_obj, ValidationObject *dev_obj) { |
| 48 | if (add_obj) { |
| 49 | instance_state = reinterpret_cast<ValidationStateTracker *>(GetValidationObject(inst_obj->object_dispatch, container_type)); |
| 50 | // Call base class |
| 51 | ValidationObject::InitDeviceValidationObject(add_obj, inst_obj, dev_obj); |
| 52 | } |
| 53 | } |
| 54 | |
John Zulauf | 2bc1fde | 2020-04-24 15:09:51 -0600 | [diff] [blame] | 55 | // NOTE: Beware the lifespan of the rp_begin when holding the return. If the rp_begin isn't a "safe" copy, "IMAGELESS" |
| 56 | // attachments won't persist past the API entry point exit. |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 57 | static std::pair<uint32_t, const VkImageView *> GetFramebufferAttachments(const VkRenderPassBeginInfo &rp_begin, |
| 58 | const FRAMEBUFFER_STATE &fb_state) { |
John Zulauf | 2bc1fde | 2020-04-24 15:09:51 -0600 | [diff] [blame] | 59 | const VkImageView *attachments = fb_state.createInfo.pAttachments; |
| 60 | uint32_t count = fb_state.createInfo.attachmentCount; |
| 61 | if (fb_state.createInfo.flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 62 | const auto *framebuffer_attachments = LvlFindInChain<VkRenderPassAttachmentBeginInfo>(rp_begin.pNext); |
John Zulauf | 2bc1fde | 2020-04-24 15:09:51 -0600 | [diff] [blame] | 63 | if (framebuffer_attachments) { |
| 64 | attachments = framebuffer_attachments->pAttachments; |
| 65 | count = framebuffer_attachments->attachmentCount; |
| 66 | } |
| 67 | } |
| 68 | return std::make_pair(count, attachments); |
| 69 | } |
| 70 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 71 | template <typename ImageViewPointer, typename Get> |
| 72 | std::vector<ImageViewPointer> GetAttachmentViewsImpl(const VkRenderPassBeginInfo &rp_begin, const FRAMEBUFFER_STATE &fb_state, |
| 73 | const Get &get_fn) { |
| 74 | std::vector<ImageViewPointer> views; |
John Zulauf | 2bc1fde | 2020-04-24 15:09:51 -0600 | [diff] [blame] | 75 | |
| 76 | const auto count_attachment = GetFramebufferAttachments(rp_begin, fb_state); |
| 77 | const auto attachment_count = count_attachment.first; |
| 78 | const auto *attachments = count_attachment.second; |
| 79 | views.resize(attachment_count, nullptr); |
| 80 | for (uint32_t i = 0; i < attachment_count; i++) { |
| 81 | if (attachments[i] != VK_NULL_HANDLE) { |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 82 | views[i] = get_fn(attachments[i]); |
John Zulauf | 2bc1fde | 2020-04-24 15:09:51 -0600 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | return views; |
| 86 | } |
| 87 | |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 88 | std::vector<std::shared_ptr<const IMAGE_VIEW_STATE>> ValidationStateTracker::GetAttachmentViews( |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 89 | const VkRenderPassBeginInfo &rp_begin, const FRAMEBUFFER_STATE &fb_state) const { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 90 | auto get_fn = [this](VkImageView handle) { return this->Get<IMAGE_VIEW_STATE>(handle); }; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 91 | return GetAttachmentViewsImpl<std::shared_ptr<const IMAGE_VIEW_STATE>>(rp_begin, fb_state, get_fn); |
| 92 | } |
| 93 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 94 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 95 | // Android-specific validation that uses types defined only with VK_USE_PLATFORM_ANDROID_KHR |
| 96 | // This could also move into a seperate core_validation_android.cpp file... ? |
| 97 | |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 98 | template <typename CreateInfo> |
| 99 | VkFormatFeatureFlags ValidationStateTracker::GetExternalFormatFeaturesANDROID(const CreateInfo *create_info) const { |
| 100 | VkFormatFeatureFlags format_features = 0; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 101 | const VkExternalFormatANDROID *ext_fmt_android = LvlFindInChain<VkExternalFormatANDROID>(create_info->pNext); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 102 | if (ext_fmt_android && (0 != ext_fmt_android->externalFormat)) { |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 103 | // VUID 01894 will catch if not found in map |
| 104 | auto it = ahb_ext_formats_map.find(ext_fmt_android->externalFormat); |
| 105 | if (it != ahb_ext_formats_map.end()) { |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 106 | format_features = it->second; |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 107 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 108 | } |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 109 | return format_features; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 110 | } |
| 111 | |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 112 | void ValidationStateTracker::PostCallRecordGetAndroidHardwareBufferPropertiesANDROID( |
| 113 | VkDevice device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties, VkResult result) { |
| 114 | if (VK_SUCCESS != result) return; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 115 | auto ahb_format_props = LvlFindInChain<VkAndroidHardwareBufferFormatPropertiesANDROID>(pProperties->pNext); |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 116 | if (ahb_format_props) { |
Jeremy Gebben | fc6f815 | 2021-03-18 16:58:55 -0600 | [diff] [blame] | 117 | ahb_ext_formats_map.emplace(ahb_format_props->externalFormat, ahb_format_props->formatFeatures); |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 121 | #else |
| 122 | |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 123 | template <typename CreateInfo> |
| 124 | VkFormatFeatureFlags ValidationStateTracker::GetExternalFormatFeaturesANDROID(const CreateInfo *create_info) const { |
| 125 | return 0; |
| 126 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 127 | |
| 128 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 129 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 130 | VkFormatFeatureFlags GetImageFormatFeatures(VkPhysicalDevice physical_device, VkDevice device, VkImage image, VkFormat format, |
| 131 | VkImageTiling tiling) { |
| 132 | VkFormatFeatureFlags format_features = 0; |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 133 | // Add feature support according to Image Format Features (vkspec.html#resources-image-format-features) |
| 134 | // if format is AHB external format then the features are already set |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 135 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 136 | VkImageDrmFormatModifierPropertiesEXT drm_format_properties = {VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT, |
| 137 | nullptr}; |
| 138 | DispatchGetImageDrmFormatModifierPropertiesEXT(device, image, &drm_format_properties); |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 139 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 140 | VkFormatProperties2 format_properties_2 = {VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, nullptr}; |
| 141 | VkDrmFormatModifierPropertiesListEXT drm_properties_list = {VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT, |
| 142 | nullptr}; |
| 143 | format_properties_2.pNext = (void *)&drm_properties_list; |
| 144 | DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2); |
| 145 | std::vector<VkDrmFormatModifierPropertiesEXT> drm_properties; |
| 146 | drm_properties.resize(drm_properties_list.drmFormatModifierCount); |
| 147 | drm_properties_list.pDrmFormatModifierProperties = &drm_properties[0]; |
| 148 | DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2); |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 149 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 150 | for (uint32_t i = 0; i < drm_properties_list.drmFormatModifierCount; i++) { |
| 151 | if (drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifier == drm_format_properties.drmFormatModifier) { |
| 152 | format_features = drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures; |
| 153 | break; |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 154 | } |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 155 | } |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 156 | } else { |
| 157 | VkFormatProperties format_properties; |
| 158 | DispatchGetPhysicalDeviceFormatProperties(physical_device, format, &format_properties); |
| 159 | format_features = |
| 160 | (tiling == VK_IMAGE_TILING_LINEAR) ? format_properties.linearTilingFeatures : format_properties.optimalTilingFeatures; |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 161 | } |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 162 | return format_features; |
Petr Kraus | 44f1c48 | 2020-04-25 20:09:25 +0200 | [diff] [blame] | 163 | } |
| 164 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 165 | void ValidationStateTracker::PostCallRecordCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
| 166 | const VkAllocationCallbacks *pAllocator, VkImage *pImage, VkResult result) { |
| 167 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 168 | VkFormatFeatureFlags format_features = 0; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 169 | if (IsExtEnabled(device_extensions.vk_android_external_memory_android_hardware_buffer)) { |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 170 | format_features = GetExternalFormatFeaturesANDROID(pCreateInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 171 | } |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 172 | if (format_features == 0) { |
| 173 | format_features = GetImageFormatFeatures(physical_device, device, *pImage, pCreateInfo->format, pCreateInfo->tiling); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 174 | } |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 175 | Add(std::make_shared<IMAGE_STATE>(this, *pImage, pCreateInfo, format_features)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void ValidationStateTracker::PreCallRecordDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 179 | Destroy<IMAGE_STATE>(image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | void ValidationStateTracker::PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, |
| 183 | VkImageLayout imageLayout, const VkClearColorValue *pColor, |
| 184 | uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 185 | if (disabled[command_buffer_state]) return; |
| 186 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 187 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 188 | if (cb_node) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 189 | cb_node->RecordTransferCmd(CMD_CLEARCOLORIMAGE, Get<IMAGE_STATE>(image)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | |
| 193 | void ValidationStateTracker::PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, |
| 194 | VkImageLayout imageLayout, |
| 195 | const VkClearDepthStencilValue *pDepthStencil, |
| 196 | uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 197 | if (disabled[command_buffer_state]) return; |
| 198 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 199 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 200 | if (cb_node) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 201 | cb_node->RecordTransferCmd(CMD_CLEARDEPTHSTENCILIMAGE, Get<IMAGE_STATE>(image)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
| 205 | void ValidationStateTracker::PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 206 | VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, |
| 207 | uint32_t regionCount, const VkImageCopy *pRegions) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 208 | if (disabled[command_buffer_state]) return; |
| 209 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 210 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 211 | cb_node->RecordTransferCmd(CMD_COPYIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 212 | } |
| 213 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 214 | void ValidationStateTracker::PreCallRecordCmdCopyImage2KHR(VkCommandBuffer commandBuffer, |
| 215 | const VkCopyImageInfo2KHR *pCopyImageInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 216 | if (disabled[command_buffer_state]) return; |
| 217 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 218 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 219 | cb_node->RecordTransferCmd(CMD_COPYIMAGE2KHR, Get<IMAGE_STATE>(pCopyImageInfo->srcImage), |
| 220 | Get<IMAGE_STATE>(pCopyImageInfo->dstImage)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 221 | } |
| 222 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 223 | void ValidationStateTracker::PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 224 | VkImageLayout srcImageLayout, VkImage dstImage, |
| 225 | VkImageLayout dstImageLayout, uint32_t regionCount, |
| 226 | const VkImageResolve *pRegions) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 227 | if (disabled[command_buffer_state]) return; |
| 228 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 229 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 230 | cb_node->RecordTransferCmd(CMD_RESOLVEIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 231 | } |
| 232 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 233 | void ValidationStateTracker::PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, |
| 234 | const VkResolveImageInfo2KHR *pResolveImageInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 235 | if (disabled[command_buffer_state]) return; |
| 236 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 237 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 238 | cb_node->RecordTransferCmd(CMD_RESOLVEIMAGE2KHR, Get<IMAGE_STATE>(pResolveImageInfo->srcImage), |
| 239 | Get<IMAGE_STATE>(pResolveImageInfo->dstImage)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 240 | } |
| 241 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 242 | void ValidationStateTracker::PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 243 | VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, |
| 244 | uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 245 | if (disabled[command_buffer_state]) return; |
| 246 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 247 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 248 | cb_node->RecordTransferCmd(CMD_BLITIMAGE, Get<IMAGE_STATE>(srcImage), Get<IMAGE_STATE>(dstImage)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 249 | } |
| 250 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 251 | void ValidationStateTracker::PreCallRecordCmdBlitImage2KHR(VkCommandBuffer commandBuffer, |
| 252 | const VkBlitImageInfo2KHR *pBlitImageInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 253 | if (disabled[command_buffer_state]) return; |
| 254 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 255 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 256 | cb_node->RecordTransferCmd(CMD_BLITIMAGE2KHR, Get<IMAGE_STATE>(pBlitImageInfo->srcImage), |
| 257 | Get<IMAGE_STATE>(pBlitImageInfo->dstImage)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 258 | } |
| 259 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 260 | void ValidationStateTracker::PostCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
| 261 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer, |
| 262 | VkResult result) { |
| 263 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | f2912cd | 2021-07-07 07:57:39 -0600 | [diff] [blame] | 264 | |
Jeremy Gebben | c8937b6 | 2021-09-24 15:50:56 -0600 | [diff] [blame] | 265 | auto buffer_state = std::make_shared<BUFFER_STATE>(this, *pBuffer, pCreateInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 266 | |
James Rumble | 2f6e7bb | 2021-07-13 15:21:20 +0100 | [diff] [blame] | 267 | if (pCreateInfo) { |
| 268 | const auto *opaque_capture_address = LvlFindInChain<VkBufferOpaqueCaptureAddressCreateInfo>(pCreateInfo->pNext); |
| 269 | if (opaque_capture_address) { |
| 270 | // address is used for GPU-AV and ray tracing buffer validation |
| 271 | buffer_state->deviceAddress = opaque_capture_address->opaqueCaptureAddress; |
| 272 | buffer_address_map_.emplace(opaque_capture_address->opaqueCaptureAddress, buffer_state.get()); |
| 273 | } |
| 274 | } |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 275 | Add(std::move(buffer_state)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | void ValidationStateTracker::PostCallRecordCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, |
| 279 | const VkAllocationCallbacks *pAllocator, VkBufferView *pView, |
| 280 | VkResult result) { |
| 281 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | f2912cd | 2021-07-07 07:57:39 -0600 | [diff] [blame] | 282 | |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 283 | auto buffer_state = Get<BUFFER_STATE>(pCreateInfo->buffer); |
locke-lunarg | 25b6c35 | 2020-08-06 17:44:18 -0600 | [diff] [blame] | 284 | |
| 285 | VkFormatProperties format_properties; |
| 286 | DispatchGetPhysicalDeviceFormatProperties(physical_device, pCreateInfo->format, &format_properties); |
locke-lunarg | 25b6c35 | 2020-08-06 17:44:18 -0600 | [diff] [blame] | 287 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 288 | Add(std::make_shared<BUFFER_VIEW_STATE>(buffer_state, *pView, pCreateInfo, format_properties.bufferFeatures)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | void ValidationStateTracker::PostCallRecordCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 292 | const VkAllocationCallbacks *pAllocator, VkImageView *pView, |
| 293 | VkResult result) { |
| 294 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 295 | auto image_state = Get<IMAGE_STATE>(pCreateInfo->image); |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 296 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 297 | VkFormatFeatureFlags format_features = 0; |
| 298 | if (image_state->HasAHBFormat() == true) { |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 299 | // The ImageView uses same Image's format feature since they share same AHB |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 300 | format_features = image_state->format_features; |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 301 | } else { |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 302 | format_features = GetImageFormatFeatures(physical_device, device, image_state->image(), pCreateInfo->format, |
| 303 | image_state->createInfo.tiling); |
Spencer Fricke | 6bba8c7 | 2020-04-06 07:41:21 -0700 | [diff] [blame] | 304 | } |
| 305 | |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 306 | // filter_cubic_props is used in CmdDraw validation. But it takes a lot of performance if it does in CmdDraw. |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 307 | auto filter_cubic_props = LvlInitStruct<VkFilterCubicImageViewImageFormatPropertiesEXT>(); |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 308 | if (IsExtEnabled(device_extensions.vk_ext_filter_cubic)) { |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 309 | auto imageview_format_info = LvlInitStruct<VkPhysicalDeviceImageViewImageFormatInfoEXT>(); |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 310 | imageview_format_info.imageViewType = pCreateInfo->viewType; |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 311 | auto image_format_info = LvlInitStruct<VkPhysicalDeviceImageFormatInfo2>(&imageview_format_info); |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 312 | image_format_info.type = image_state->createInfo.imageType; |
| 313 | image_format_info.format = image_state->createInfo.format; |
| 314 | image_format_info.tiling = image_state->createInfo.tiling; |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 315 | auto usage_create_info = LvlFindInChain<VkImageViewUsageCreateInfo>(pCreateInfo->pNext); |
| 316 | image_format_info.usage = usage_create_info ? usage_create_info->usage : image_state->createInfo.usage; |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 317 | image_format_info.flags = image_state->createInfo.flags; |
| 318 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 319 | auto image_format_properties = LvlInitStruct<VkImageFormatProperties2>(&filter_cubic_props); |
locke-lunarg | 9939d4b | 2020-10-26 20:11:08 -0600 | [diff] [blame] | 320 | |
| 321 | DispatchGetPhysicalDeviceImageFormatProperties2(physical_device, &image_format_info, &image_format_properties); |
| 322 | } |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 323 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 324 | Add(std::make_shared<IMAGE_VIEW_STATE>(image_state, *pView, pCreateInfo, format_features, filter_cubic_props)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | void ValidationStateTracker::PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 328 | uint32_t regionCount, const VkBufferCopy *pRegions) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 329 | if (disabled[command_buffer_state]) return; |
| 330 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 331 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 332 | cb_node->RecordTransferCmd(CMD_COPYBUFFER, Get<BUFFER_STATE>(srcBuffer), Get<BUFFER_STATE>(dstBuffer)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 333 | } |
| 334 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 335 | void ValidationStateTracker::PreCallRecordCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 336 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 337 | if (disabled[command_buffer_state]) return; |
| 338 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 339 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 340 | cb_node->RecordTransferCmd(CMD_COPYBUFFER2KHR, Get<BUFFER_STATE>(pCopyBufferInfo->srcBuffer), |
| 341 | Get<BUFFER_STATE>(pCopyBufferInfo->dstBuffer)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 342 | } |
| 343 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 344 | void ValidationStateTracker::PreCallRecordDestroyImageView(VkDevice device, VkImageView imageView, |
| 345 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 346 | Destroy<IMAGE_VIEW_STATE>(imageView); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | void ValidationStateTracker::PreCallRecordDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 350 | Destroy<BUFFER_STATE>(buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void ValidationStateTracker::PreCallRecordDestroyBufferView(VkDevice device, VkBufferView bufferView, |
| 354 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 355 | Destroy<BUFFER_VIEW_STATE>(bufferView); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | void ValidationStateTracker::PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
| 359 | VkDeviceSize size, uint32_t data) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 360 | if (disabled[command_buffer_state]) return; |
| 361 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 362 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 363 | cb_node->RecordTransferCmd(CMD_FILLBUFFER, Get<BUFFER_STATE>(dstBuffer)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | void ValidationStateTracker::PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, |
| 367 | VkImageLayout srcImageLayout, VkBuffer dstBuffer, |
| 368 | uint32_t regionCount, const VkBufferImageCopy *pRegions) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 369 | if (disabled[command_buffer_state]) return; |
| 370 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 371 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 372 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 373 | cb_node->RecordTransferCmd(CMD_COPYIMAGETOBUFFER, Get<IMAGE_STATE>(srcImage), Get<BUFFER_STATE>(dstBuffer)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 374 | } |
| 375 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 376 | void ValidationStateTracker::PreCallRecordCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer, |
| 377 | const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 378 | if (disabled[command_buffer_state]) return; |
| 379 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 380 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 381 | cb_node->RecordTransferCmd(CMD_COPYIMAGETOBUFFER2KHR, Get<IMAGE_STATE>(pCopyImageToBufferInfo->srcImage), |
| 382 | Get<BUFFER_STATE>(pCopyImageToBufferInfo->dstBuffer)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 383 | } |
| 384 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 385 | void ValidationStateTracker::PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 386 | VkImageLayout dstImageLayout, uint32_t regionCount, |
| 387 | const VkBufferImageCopy *pRegions) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 388 | if (disabled[command_buffer_state]) return; |
| 389 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 390 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 391 | cb_node->RecordTransferCmd(CMD_COPYBUFFERTOIMAGE, Get<BUFFER_STATE>(srcBuffer), Get<IMAGE_STATE>(dstImage)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 392 | } |
| 393 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 394 | void ValidationStateTracker::PreCallRecordCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer, |
| 395 | const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 396 | if (disabled[command_buffer_state]) return; |
| 397 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 398 | auto cb_node = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 399 | cb_node->RecordTransferCmd(CMD_COPYBUFFERTOIMAGE2KHR, Get<BUFFER_STATE>(pCopyBufferToImageInfo->srcBuffer), |
| 400 | Get<IMAGE_STATE>(pCopyBufferToImageInfo->dstImage)); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 401 | } |
| 402 | |
sfricke-samsung | bf1a2ed | 2020-06-14 23:31:00 -0700 | [diff] [blame] | 403 | // Gets union of all features defined by Potential Format Features |
| 404 | // except, does not handle the external format case for AHB as that only can be used for sampled images |
sfricke-samsung | be3584f | 2020-04-22 14:58:06 -0700 | [diff] [blame] | 405 | VkFormatFeatureFlags ValidationStateTracker::GetPotentialFormatFeatures(VkFormat format) const { |
| 406 | VkFormatFeatureFlags format_features = 0; |
| 407 | |
| 408 | if (format != VK_FORMAT_UNDEFINED) { |
| 409 | VkFormatProperties format_properties; |
| 410 | DispatchGetPhysicalDeviceFormatProperties(physical_device, format, &format_properties); |
| 411 | format_features |= format_properties.linearTilingFeatures; |
| 412 | format_features |= format_properties.optimalTilingFeatures; |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 413 | if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) { |
sfricke-samsung | be3584f | 2020-04-22 14:58:06 -0700 | [diff] [blame] | 414 | // VK_KHR_get_physical_device_properties2 is required in this case |
| 415 | VkFormatProperties2 format_properties_2 = {VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2}; |
| 416 | VkDrmFormatModifierPropertiesListEXT drm_properties_list = {VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT, |
| 417 | nullptr}; |
| 418 | format_properties_2.pNext = (void *)&drm_properties_list; |
Marc Alcala Prieto | 773871c | 2021-02-04 19:24:43 +0100 | [diff] [blame] | 419 | |
| 420 | // First call is to get the number of modifiers compatible with the queried format |
sfricke-samsung | be3584f | 2020-04-22 14:58:06 -0700 | [diff] [blame] | 421 | DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2); |
Marc Alcala Prieto | 773871c | 2021-02-04 19:24:43 +0100 | [diff] [blame] | 422 | |
| 423 | std::vector<VkDrmFormatModifierPropertiesEXT> drm_properties; |
| 424 | drm_properties.resize(drm_properties_list.drmFormatModifierCount); |
| 425 | drm_properties_list.pDrmFormatModifierProperties = drm_properties.data(); |
| 426 | |
| 427 | // Second call, now with an allocated array in pDrmFormatModifierProperties, is to get the modifiers |
| 428 | // compatible with the queried format |
| 429 | DispatchGetPhysicalDeviceFormatProperties2(physical_device, format, &format_properties_2); |
| 430 | |
sfricke-samsung | be3584f | 2020-04-22 14:58:06 -0700 | [diff] [blame] | 431 | for (uint32_t i = 0; i < drm_properties_list.drmFormatModifierCount; i++) { |
| 432 | format_features |= drm_properties_list.pDrmFormatModifierProperties[i].drmFormatModifierTilingFeatures; |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | return format_features; |
| 438 | } |
| 439 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 440 | void ValidationStateTracker::PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
| 441 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, |
| 442 | VkResult result) { |
| 443 | if (VK_SUCCESS != result) return; |
| 444 | |
Locke Lin | f387354 | 2021-04-26 11:25:10 -0600 | [diff] [blame] | 445 | ValidationObject *device_object = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
| 446 | ValidationObject *validation_data = GetValidationObject(device_object->object_dispatch, this->container_type); |
| 447 | ValidationStateTracker *state_tracker = static_cast<ValidationStateTracker *>(validation_data); |
| 448 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 449 | const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures; |
| 450 | if (nullptr == enabled_features_found) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 451 | const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 452 | if (features2) { |
| 453 | enabled_features_found = &(features2->features); |
| 454 | } |
| 455 | } |
| 456 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 457 | if (nullptr == enabled_features_found) { |
| 458 | state_tracker->enabled_features.core = {}; |
| 459 | } else { |
| 460 | state_tracker->enabled_features.core = *enabled_features_found; |
| 461 | } |
| 462 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 463 | // Save local link to this device's physical device state |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 464 | state_tracker->physical_device_state = Get<PHYSICAL_DEVICE_STATE>(gpu).get(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 465 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 466 | const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 467 | if (vulkan_12_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 468 | state_tracker->enabled_features.core12 = *vulkan_12_features; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 469 | } else { |
sfricke-samsung | 27c7072 | 2020-05-02 08:42:39 -0700 | [diff] [blame] | 470 | // Set Extension Feature Aliases to false as there is no struct to check |
| 471 | state_tracker->enabled_features.core12.drawIndirectCount = VK_FALSE; |
| 472 | state_tracker->enabled_features.core12.samplerMirrorClampToEdge = VK_FALSE; |
| 473 | state_tracker->enabled_features.core12.descriptorIndexing = VK_FALSE; |
| 474 | state_tracker->enabled_features.core12.samplerFilterMinmax = VK_FALSE; |
| 475 | state_tracker->enabled_features.core12.shaderOutputLayer = VK_FALSE; |
| 476 | state_tracker->enabled_features.core12.shaderOutputViewportIndex = VK_FALSE; |
sfricke-samsung | a4143ac | 2020-12-18 00:00:53 -0800 | [diff] [blame] | 477 | state_tracker->enabled_features.core12.subgroupBroadcastDynamicId = VK_FALSE; |
sfricke-samsung | 27c7072 | 2020-05-02 08:42:39 -0700 | [diff] [blame] | 478 | |
| 479 | // These structs are only allowed in pNext chain if there is no VkPhysicalDeviceVulkan12Features |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 480 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 481 | const auto *eight_bit_storage_features = LvlFindInChain<VkPhysicalDevice8BitStorageFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 482 | if (eight_bit_storage_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 483 | state_tracker->enabled_features.core12.storageBuffer8BitAccess = eight_bit_storage_features->storageBuffer8BitAccess; |
| 484 | state_tracker->enabled_features.core12.uniformAndStorageBuffer8BitAccess = |
| 485 | eight_bit_storage_features->uniformAndStorageBuffer8BitAccess; |
| 486 | state_tracker->enabled_features.core12.storagePushConstant8 = eight_bit_storage_features->storagePushConstant8; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 487 | } |
| 488 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 489 | const auto *float16_int8_features = LvlFindInChain<VkPhysicalDeviceShaderFloat16Int8Features>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 490 | if (float16_int8_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 491 | state_tracker->enabled_features.core12.shaderFloat16 = float16_int8_features->shaderFloat16; |
| 492 | state_tracker->enabled_features.core12.shaderInt8 = float16_int8_features->shaderInt8; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 495 | const auto *descriptor_indexing_features = LvlFindInChain<VkPhysicalDeviceDescriptorIndexingFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 496 | if (descriptor_indexing_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 497 | state_tracker->enabled_features.core12.shaderInputAttachmentArrayDynamicIndexing = |
| 498 | descriptor_indexing_features->shaderInputAttachmentArrayDynamicIndexing; |
| 499 | state_tracker->enabled_features.core12.shaderUniformTexelBufferArrayDynamicIndexing = |
| 500 | descriptor_indexing_features->shaderUniformTexelBufferArrayDynamicIndexing; |
| 501 | state_tracker->enabled_features.core12.shaderStorageTexelBufferArrayDynamicIndexing = |
| 502 | descriptor_indexing_features->shaderStorageTexelBufferArrayDynamicIndexing; |
| 503 | state_tracker->enabled_features.core12.shaderUniformBufferArrayNonUniformIndexing = |
| 504 | descriptor_indexing_features->shaderUniformBufferArrayNonUniformIndexing; |
| 505 | state_tracker->enabled_features.core12.shaderSampledImageArrayNonUniformIndexing = |
| 506 | descriptor_indexing_features->shaderSampledImageArrayNonUniformIndexing; |
| 507 | state_tracker->enabled_features.core12.shaderStorageBufferArrayNonUniformIndexing = |
| 508 | descriptor_indexing_features->shaderStorageBufferArrayNonUniformIndexing; |
| 509 | state_tracker->enabled_features.core12.shaderStorageImageArrayNonUniformIndexing = |
| 510 | descriptor_indexing_features->shaderStorageImageArrayNonUniformIndexing; |
| 511 | state_tracker->enabled_features.core12.shaderInputAttachmentArrayNonUniformIndexing = |
| 512 | descriptor_indexing_features->shaderInputAttachmentArrayNonUniformIndexing; |
| 513 | state_tracker->enabled_features.core12.shaderUniformTexelBufferArrayNonUniformIndexing = |
| 514 | descriptor_indexing_features->shaderUniformTexelBufferArrayNonUniformIndexing; |
| 515 | state_tracker->enabled_features.core12.shaderStorageTexelBufferArrayNonUniformIndexing = |
| 516 | descriptor_indexing_features->shaderStorageTexelBufferArrayNonUniformIndexing; |
| 517 | state_tracker->enabled_features.core12.descriptorBindingUniformBufferUpdateAfterBind = |
| 518 | descriptor_indexing_features->descriptorBindingUniformBufferUpdateAfterBind; |
| 519 | state_tracker->enabled_features.core12.descriptorBindingSampledImageUpdateAfterBind = |
| 520 | descriptor_indexing_features->descriptorBindingSampledImageUpdateAfterBind; |
| 521 | state_tracker->enabled_features.core12.descriptorBindingStorageImageUpdateAfterBind = |
| 522 | descriptor_indexing_features->descriptorBindingStorageImageUpdateAfterBind; |
| 523 | state_tracker->enabled_features.core12.descriptorBindingStorageBufferUpdateAfterBind = |
| 524 | descriptor_indexing_features->descriptorBindingStorageBufferUpdateAfterBind; |
| 525 | state_tracker->enabled_features.core12.descriptorBindingUniformTexelBufferUpdateAfterBind = |
| 526 | descriptor_indexing_features->descriptorBindingUniformTexelBufferUpdateAfterBind; |
| 527 | state_tracker->enabled_features.core12.descriptorBindingStorageTexelBufferUpdateAfterBind = |
| 528 | descriptor_indexing_features->descriptorBindingStorageTexelBufferUpdateAfterBind; |
| 529 | state_tracker->enabled_features.core12.descriptorBindingUpdateUnusedWhilePending = |
| 530 | descriptor_indexing_features->descriptorBindingUpdateUnusedWhilePending; |
| 531 | state_tracker->enabled_features.core12.descriptorBindingPartiallyBound = |
| 532 | descriptor_indexing_features->descriptorBindingPartiallyBound; |
| 533 | state_tracker->enabled_features.core12.descriptorBindingVariableDescriptorCount = |
| 534 | descriptor_indexing_features->descriptorBindingVariableDescriptorCount; |
| 535 | state_tracker->enabled_features.core12.runtimeDescriptorArray = descriptor_indexing_features->runtimeDescriptorArray; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 538 | const auto *scalar_block_layout_features = LvlFindInChain<VkPhysicalDeviceScalarBlockLayoutFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 539 | if (scalar_block_layout_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 540 | state_tracker->enabled_features.core12.scalarBlockLayout = scalar_block_layout_features->scalarBlockLayout; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | const auto *imageless_framebuffer_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 544 | LvlFindInChain<VkPhysicalDeviceImagelessFramebufferFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 545 | if (imageless_framebuffer_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 546 | state_tracker->enabled_features.core12.imagelessFramebuffer = imageless_framebuffer_features->imagelessFramebuffer; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | const auto *uniform_buffer_standard_layout_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 550 | LvlFindInChain<VkPhysicalDeviceUniformBufferStandardLayoutFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 551 | if (uniform_buffer_standard_layout_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 552 | state_tracker->enabled_features.core12.uniformBufferStandardLayout = |
| 553 | uniform_buffer_standard_layout_features->uniformBufferStandardLayout; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | const auto *subgroup_extended_types_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 557 | LvlFindInChain<VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 558 | if (subgroup_extended_types_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 559 | state_tracker->enabled_features.core12.shaderSubgroupExtendedTypes = |
| 560 | subgroup_extended_types_features->shaderSubgroupExtendedTypes; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | const auto *separate_depth_stencil_layouts_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 564 | LvlFindInChain<VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 565 | if (separate_depth_stencil_layouts_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 566 | state_tracker->enabled_features.core12.separateDepthStencilLayouts = |
| 567 | separate_depth_stencil_layouts_features->separateDepthStencilLayouts; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 570 | const auto *host_query_reset_features = LvlFindInChain<VkPhysicalDeviceHostQueryResetFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 571 | if (host_query_reset_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 572 | state_tracker->enabled_features.core12.hostQueryReset = host_query_reset_features->hostQueryReset; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 575 | const auto *timeline_semaphore_features = LvlFindInChain<VkPhysicalDeviceTimelineSemaphoreFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 576 | if (timeline_semaphore_features) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 577 | state_tracker->enabled_features.core12.timelineSemaphore = timeline_semaphore_features->timelineSemaphore; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 580 | const auto *buffer_device_address = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(pCreateInfo->pNext); |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 581 | if (buffer_device_address) { |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 582 | state_tracker->enabled_features.core12.bufferDeviceAddress = buffer_device_address->bufferDeviceAddress; |
| 583 | state_tracker->enabled_features.core12.bufferDeviceAddressCaptureReplay = |
| 584 | buffer_device_address->bufferDeviceAddressCaptureReplay; |
| 585 | state_tracker->enabled_features.core12.bufferDeviceAddressMultiDevice = |
| 586 | buffer_device_address->bufferDeviceAddressMultiDevice; |
| 587 | } |
sfricke-samsung | a4143ac | 2020-12-18 00:00:53 -0800 | [diff] [blame] | 588 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 589 | const auto *atomic_int64_features = LvlFindInChain<VkPhysicalDeviceShaderAtomicInt64Features>(pCreateInfo->pNext); |
sfricke-samsung | a4143ac | 2020-12-18 00:00:53 -0800 | [diff] [blame] | 590 | if (atomic_int64_features) { |
| 591 | state_tracker->enabled_features.core12.shaderBufferInt64Atomics = atomic_int64_features->shaderBufferInt64Atomics; |
| 592 | state_tracker->enabled_features.core12.shaderSharedInt64Atomics = atomic_int64_features->shaderSharedInt64Atomics; |
| 593 | } |
| 594 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 595 | const auto *memory_model_features = LvlFindInChain<VkPhysicalDeviceVulkanMemoryModelFeatures>(pCreateInfo->pNext); |
sfricke-samsung | a4143ac | 2020-12-18 00:00:53 -0800 | [diff] [blame] | 596 | if (memory_model_features) { |
| 597 | state_tracker->enabled_features.core12.vulkanMemoryModel = memory_model_features->vulkanMemoryModel; |
| 598 | state_tracker->enabled_features.core12.vulkanMemoryModelDeviceScope = |
| 599 | memory_model_features->vulkanMemoryModelDeviceScope; |
| 600 | state_tracker->enabled_features.core12.vulkanMemoryModelAvailabilityVisibilityChains = |
| 601 | memory_model_features->vulkanMemoryModelAvailabilityVisibilityChains; |
| 602 | } |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 603 | } |
| 604 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 605 | const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 606 | if (vulkan_11_features) { |
| 607 | state_tracker->enabled_features.core11 = *vulkan_11_features; |
| 608 | } else { |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 609 | // These structs are only allowed in pNext chain if there is no vkPhysicalDeviceVulkan11Features |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 610 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 611 | const auto *sixteen_bit_storage_features = LvlFindInChain<VkPhysicalDevice16BitStorageFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 612 | if (sixteen_bit_storage_features) { |
| 613 | state_tracker->enabled_features.core11.storageBuffer16BitAccess = |
| 614 | sixteen_bit_storage_features->storageBuffer16BitAccess; |
| 615 | state_tracker->enabled_features.core11.uniformAndStorageBuffer16BitAccess = |
| 616 | sixteen_bit_storage_features->uniformAndStorageBuffer16BitAccess; |
| 617 | state_tracker->enabled_features.core11.storagePushConstant16 = sixteen_bit_storage_features->storagePushConstant16; |
| 618 | state_tracker->enabled_features.core11.storageInputOutput16 = sixteen_bit_storage_features->storageInputOutput16; |
| 619 | } |
| 620 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 621 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 622 | if (multiview_features) { |
| 623 | state_tracker->enabled_features.core11.multiview = multiview_features->multiview; |
| 624 | state_tracker->enabled_features.core11.multiviewGeometryShader = multiview_features->multiviewGeometryShader; |
| 625 | state_tracker->enabled_features.core11.multiviewTessellationShader = multiview_features->multiviewTessellationShader; |
| 626 | } |
| 627 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 628 | const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 629 | if (variable_pointers_features) { |
| 630 | state_tracker->enabled_features.core11.variablePointersStorageBuffer = |
| 631 | variable_pointers_features->variablePointersStorageBuffer; |
| 632 | state_tracker->enabled_features.core11.variablePointers = variable_pointers_features->variablePointers; |
| 633 | } |
| 634 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 635 | const auto *protected_memory_features = LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 636 | if (protected_memory_features) { |
| 637 | state_tracker->enabled_features.core11.protectedMemory = protected_memory_features->protectedMemory; |
| 638 | } |
| 639 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 640 | const auto *ycbcr_conversion_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 641 | if (ycbcr_conversion_features) { |
| 642 | state_tracker->enabled_features.core11.samplerYcbcrConversion = ycbcr_conversion_features->samplerYcbcrConversion; |
| 643 | } |
| 644 | |
| 645 | const auto *shader_draw_parameters_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 646 | LvlFindInChain<VkPhysicalDeviceShaderDrawParametersFeatures>(pCreateInfo->pNext); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 647 | if (shader_draw_parameters_features) { |
| 648 | state_tracker->enabled_features.core11.shaderDrawParameters = shader_draw_parameters_features->shaderDrawParameters; |
Tony-LunarG | b036c2f | 2019-12-05 14:38:25 -0700 | [diff] [blame] | 649 | } |
| 650 | } |
| 651 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 652 | const auto *device_group_ci = LvlFindInChain<VkDeviceGroupDeviceCreateInfo>(pCreateInfo->pNext); |
Tony-LunarG | ca4891a | 2020-08-10 15:46:46 -0600 | [diff] [blame] | 653 | if (device_group_ci) { |
| 654 | state_tracker->physical_device_count = device_group_ci->physicalDeviceCount; |
| 655 | state_tracker->device_group_create_info = *device_group_ci; |
| 656 | } else { |
| 657 | state_tracker->physical_device_count = 1; |
| 658 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 659 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 660 | // Features from other extensions passesd in create info |
| 661 | { |
| 662 | const auto *exclusive_scissor_features = LvlFindInChain<VkPhysicalDeviceExclusiveScissorFeaturesNV>(pCreateInfo->pNext); |
| 663 | if (exclusive_scissor_features) { |
| 664 | state_tracker->enabled_features.exclusive_scissor_features = *exclusive_scissor_features; |
| 665 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 666 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 667 | const auto *shading_rate_image_features = LvlFindInChain<VkPhysicalDeviceShadingRateImageFeaturesNV>(pCreateInfo->pNext); |
| 668 | if (shading_rate_image_features) { |
| 669 | state_tracker->enabled_features.shading_rate_image_features = *shading_rate_image_features; |
| 670 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 671 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 672 | const auto *mesh_shader_features = LvlFindInChain<VkPhysicalDeviceMeshShaderFeaturesNV>(pCreateInfo->pNext); |
| 673 | if (mesh_shader_features) { |
| 674 | state_tracker->enabled_features.mesh_shader_features = *mesh_shader_features; |
| 675 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 676 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 677 | const auto *inline_uniform_block_features = |
| 678 | LvlFindInChain<VkPhysicalDeviceInlineUniformBlockFeaturesEXT>(pCreateInfo->pNext); |
| 679 | if (inline_uniform_block_features) { |
| 680 | state_tracker->enabled_features.inline_uniform_block_features = *inline_uniform_block_features; |
| 681 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 682 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 683 | const auto *transform_feedback_features = LvlFindInChain<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(pCreateInfo->pNext); |
| 684 | if (transform_feedback_features) { |
| 685 | state_tracker->enabled_features.transform_feedback_features = *transform_feedback_features; |
| 686 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 687 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 688 | const auto *vtx_attrib_div_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
| 689 | if (vtx_attrib_div_features) { |
| 690 | state_tracker->enabled_features.vtx_attrib_divisor_features = *vtx_attrib_div_features; |
| 691 | } |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 692 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 693 | const auto *buffer_device_address_ext_features = |
| 694 | LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeaturesEXT>(pCreateInfo->pNext); |
| 695 | if (buffer_device_address_ext_features) { |
| 696 | state_tracker->enabled_features.buffer_device_address_ext_features = *buffer_device_address_ext_features; |
| 697 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 698 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 699 | const auto *cooperative_matrix_features = LvlFindInChain<VkPhysicalDeviceCooperativeMatrixFeaturesNV>(pCreateInfo->pNext); |
| 700 | if (cooperative_matrix_features) { |
| 701 | state_tracker->enabled_features.cooperative_matrix_features = *cooperative_matrix_features; |
| 702 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 703 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 704 | const auto *compute_shader_derivatives_features = |
| 705 | LvlFindInChain<VkPhysicalDeviceComputeShaderDerivativesFeaturesNV>(pCreateInfo->pNext); |
| 706 | if (compute_shader_derivatives_features) { |
| 707 | state_tracker->enabled_features.compute_shader_derivatives_features = *compute_shader_derivatives_features; |
| 708 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 709 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 710 | const auto *fragment_shader_barycentric_features = |
| 711 | LvlFindInChain<VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV>(pCreateInfo->pNext); |
| 712 | if (fragment_shader_barycentric_features) { |
| 713 | state_tracker->enabled_features.fragment_shader_barycentric_features = *fragment_shader_barycentric_features; |
| 714 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 715 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 716 | const auto *shader_image_footprint_features = |
| 717 | LvlFindInChain<VkPhysicalDeviceShaderImageFootprintFeaturesNV>(pCreateInfo->pNext); |
| 718 | if (shader_image_footprint_features) { |
| 719 | state_tracker->enabled_features.shader_image_footprint_features = *shader_image_footprint_features; |
| 720 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 721 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 722 | const auto *fragment_shader_interlock_features = |
| 723 | LvlFindInChain<VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT>(pCreateInfo->pNext); |
| 724 | if (fragment_shader_interlock_features) { |
| 725 | state_tracker->enabled_features.fragment_shader_interlock_features = *fragment_shader_interlock_features; |
| 726 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 727 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 728 | const auto *demote_to_helper_invocation_features = |
| 729 | LvlFindInChain<VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT>(pCreateInfo->pNext); |
| 730 | if (demote_to_helper_invocation_features) { |
| 731 | state_tracker->enabled_features.demote_to_helper_invocation_features = *demote_to_helper_invocation_features; |
| 732 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 733 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 734 | const auto *texel_buffer_alignment_features = |
| 735 | LvlFindInChain<VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT>(pCreateInfo->pNext); |
| 736 | if (texel_buffer_alignment_features) { |
| 737 | state_tracker->enabled_features.texel_buffer_alignment_features = *texel_buffer_alignment_features; |
| 738 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 739 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 740 | const auto *pipeline_exe_props_features = |
| 741 | LvlFindInChain<VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR>(pCreateInfo->pNext); |
| 742 | if (pipeline_exe_props_features) { |
| 743 | state_tracker->enabled_features.pipeline_exe_props_features = *pipeline_exe_props_features; |
| 744 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 745 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 746 | const auto *dedicated_allocation_image_aliasing_features = |
| 747 | LvlFindInChain<VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV>(pCreateInfo->pNext); |
| 748 | if (dedicated_allocation_image_aliasing_features) { |
| 749 | state_tracker->enabled_features.dedicated_allocation_image_aliasing_features = |
| 750 | *dedicated_allocation_image_aliasing_features; |
| 751 | } |
Jeff Bolz | 82f854d | 2019-09-17 14:56:47 -0500 | [diff] [blame] | 752 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 753 | const auto *performance_query_features = LvlFindInChain<VkPhysicalDevicePerformanceQueryFeaturesKHR>(pCreateInfo->pNext); |
| 754 | if (performance_query_features) { |
| 755 | state_tracker->enabled_features.performance_query_features = *performance_query_features; |
| 756 | } |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 757 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 758 | const auto *device_coherent_memory_features = LvlFindInChain<VkPhysicalDeviceCoherentMemoryFeaturesAMD>(pCreateInfo->pNext); |
| 759 | if (device_coherent_memory_features) { |
| 760 | state_tracker->enabled_features.device_coherent_memory_features = *device_coherent_memory_features; |
| 761 | } |
Tobias Hector | 782bcde | 2019-11-28 16:19:42 +0000 | [diff] [blame] | 762 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 763 | const auto *ycbcr_image_array_features = LvlFindInChain<VkPhysicalDeviceYcbcrImageArraysFeaturesEXT>(pCreateInfo->pNext); |
| 764 | if (ycbcr_image_array_features) { |
| 765 | state_tracker->enabled_features.ycbcr_image_array_features = *ycbcr_image_array_features; |
| 766 | } |
sfricke-samsung | cead080 | 2020-01-30 22:20:10 -0800 | [diff] [blame] | 767 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 768 | const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(pCreateInfo->pNext); |
| 769 | if (ray_query_features) { |
| 770 | state_tracker->enabled_features.ray_query_features = *ray_query_features; |
| 771 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 772 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 773 | const auto *ray_tracing_pipeline_features = |
| 774 | LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
| 775 | if (ray_tracing_pipeline_features) { |
| 776 | state_tracker->enabled_features.ray_tracing_pipeline_features = *ray_tracing_pipeline_features; |
| 777 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 778 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 779 | const auto *ray_tracing_acceleration_structure_features = |
| 780 | LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(pCreateInfo->pNext); |
| 781 | if (ray_tracing_acceleration_structure_features) { |
| 782 | state_tracker->enabled_features.ray_tracing_acceleration_structure_features = |
| 783 | *ray_tracing_acceleration_structure_features; |
| 784 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 785 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 786 | const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
| 787 | if (robustness2_features) { |
| 788 | state_tracker->enabled_features.robustness2_features = *robustness2_features; |
| 789 | } |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 790 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 791 | const auto *fragment_density_map_features = |
| 792 | LvlFindInChain<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>(pCreateInfo->pNext); |
| 793 | if (fragment_density_map_features) { |
| 794 | state_tracker->enabled_features.fragment_density_map_features = *fragment_density_map_features; |
| 795 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 796 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 797 | const auto *fragment_density_map_features2 = |
| 798 | LvlFindInChain<VkPhysicalDeviceFragmentDensityMap2FeaturesEXT>(pCreateInfo->pNext); |
| 799 | if (fragment_density_map_features2) { |
| 800 | state_tracker->enabled_features.fragment_density_map2_features = *fragment_density_map_features2; |
| 801 | } |
janharaldfredriksen-arm | 36e1757 | 2020-07-07 13:59:28 +0200 | [diff] [blame] | 802 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 803 | const auto *astc_decode_features = LvlFindInChain<VkPhysicalDeviceASTCDecodeFeaturesEXT>(pCreateInfo->pNext); |
| 804 | if (astc_decode_features) { |
| 805 | state_tracker->enabled_features.astc_decode_features = *astc_decode_features; |
| 806 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 807 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 808 | const auto *custom_border_color_features = LvlFindInChain<VkPhysicalDeviceCustomBorderColorFeaturesEXT>(pCreateInfo->pNext); |
| 809 | if (custom_border_color_features) { |
| 810 | state_tracker->enabled_features.custom_border_color_features = *custom_border_color_features; |
| 811 | } |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 812 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 813 | const auto *pipeline_creation_cache_control_features = |
| 814 | LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(pCreateInfo->pNext); |
| 815 | if (pipeline_creation_cache_control_features) { |
| 816 | state_tracker->enabled_features.pipeline_creation_cache_control_features = *pipeline_creation_cache_control_features; |
| 817 | } |
sfricke-samsung | fd661d6 | 2020-05-16 00:57:27 -0700 | [diff] [blame] | 818 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 819 | const auto *fragment_shading_rate_features = |
| 820 | LvlFindInChain<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(pCreateInfo->pNext); |
| 821 | if (fragment_shading_rate_features) { |
| 822 | state_tracker->enabled_features.fragment_shading_rate_features = *fragment_shading_rate_features; |
| 823 | } |
Tobias Hector | 6663c9b | 2020-11-05 10:18:02 +0000 | [diff] [blame] | 824 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 825 | const auto *extended_dynamic_state_features = |
| 826 | LvlFindInChain<VkPhysicalDeviceExtendedDynamicStateFeaturesEXT>(pCreateInfo->pNext); |
| 827 | if (extended_dynamic_state_features) { |
| 828 | state_tracker->enabled_features.extended_dynamic_state_features = *extended_dynamic_state_features; |
| 829 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 830 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 831 | const auto *extended_dynamic_state2_features = |
| 832 | LvlFindInChain<VkPhysicalDeviceExtendedDynamicState2FeaturesEXT>(pCreateInfo->pNext); |
| 833 | if (extended_dynamic_state2_features) { |
| 834 | state_tracker->enabled_features.extended_dynamic_state2_features = *extended_dynamic_state2_features; |
| 835 | } |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 836 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 837 | const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
| 838 | if (multiview_features) { |
| 839 | state_tracker->enabled_features.multiview_features = *multiview_features; |
| 840 | } |
locke-lunarg | 3fa463a | 2020-10-23 16:39:04 -0600 | [diff] [blame] | 841 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 842 | const auto *portability_features = LvlFindInChain<VkPhysicalDevicePortabilitySubsetFeaturesKHR>(pCreateInfo->pNext); |
| 843 | if (portability_features) { |
| 844 | state_tracker->enabled_features.portability_subset_features = *portability_features; |
| 845 | } |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 846 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 847 | const auto *shader_integer_functions2_features = |
| 848 | LvlFindInChain<VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL>(pCreateInfo->pNext); |
| 849 | if (shader_integer_functions2_features) { |
| 850 | state_tracker->enabled_features.shader_integer_functions2_features = *shader_integer_functions2_features; |
| 851 | } |
sfricke-samsung | 0065ce0 | 2020-12-03 22:46:37 -0800 | [diff] [blame] | 852 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 853 | const auto *shader_sm_builtins_features = LvlFindInChain<VkPhysicalDeviceShaderSMBuiltinsFeaturesNV>(pCreateInfo->pNext); |
| 854 | if (shader_sm_builtins_features) { |
| 855 | state_tracker->enabled_features.shader_sm_builtins_features = *shader_sm_builtins_features; |
| 856 | } |
sfricke-samsung | 0065ce0 | 2020-12-03 22:46:37 -0800 | [diff] [blame] | 857 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 858 | const auto *shader_atomic_float_features = LvlFindInChain<VkPhysicalDeviceShaderAtomicFloatFeaturesEXT>(pCreateInfo->pNext); |
| 859 | if (shader_atomic_float_features) { |
| 860 | state_tracker->enabled_features.shader_atomic_float_features = *shader_atomic_float_features; |
| 861 | } |
sfricke-samsung | 0065ce0 | 2020-12-03 22:46:37 -0800 | [diff] [blame] | 862 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 863 | const auto *shader_image_atomic_int64_features = |
| 864 | LvlFindInChain<VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT>(pCreateInfo->pNext); |
| 865 | if (shader_image_atomic_int64_features) { |
| 866 | state_tracker->enabled_features.shader_image_atomic_int64_features = *shader_image_atomic_int64_features; |
| 867 | } |
sfricke-samsung | 0065ce0 | 2020-12-03 22:46:37 -0800 | [diff] [blame] | 868 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 869 | const auto *shader_clock_features = LvlFindInChain<VkPhysicalDeviceShaderClockFeaturesKHR>(pCreateInfo->pNext); |
| 870 | if (shader_clock_features) { |
| 871 | state_tracker->enabled_features.shader_clock_features = *shader_clock_features; |
| 872 | } |
sfricke-samsung | 486a51e | 2021-01-02 00:10:15 -0800 | [diff] [blame] | 873 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 874 | const auto *conditional_rendering_features = |
| 875 | LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(pCreateInfo->pNext); |
| 876 | if (conditional_rendering_features) { |
| 877 | state_tracker->enabled_features.conditional_rendering_features = *conditional_rendering_features; |
| 878 | } |
Jeremy Gebben | 5f585ae | 2021-02-02 09:03:06 -0700 | [diff] [blame] | 879 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 880 | const auto *workgroup_memory_explicit_layout_features = |
| 881 | LvlFindInChain<VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR>(pCreateInfo->pNext); |
| 882 | if (workgroup_memory_explicit_layout_features) { |
| 883 | state_tracker->enabled_features.workgroup_memory_explicit_layout_features = *workgroup_memory_explicit_layout_features; |
| 884 | } |
Shannon McPherson | db287d4 | 2021-02-02 15:27:32 -0700 | [diff] [blame] | 885 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 886 | const auto *synchronization2_features = LvlFindInChain<VkPhysicalDeviceSynchronization2FeaturesKHR>(pCreateInfo->pNext); |
| 887 | if (synchronization2_features) { |
| 888 | state_tracker->enabled_features.synchronization2_features = *synchronization2_features; |
| 889 | } |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 890 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 891 | const auto *provoking_vertex_features = lvl_find_in_chain<VkPhysicalDeviceProvokingVertexFeaturesEXT>(pCreateInfo->pNext); |
| 892 | if (provoking_vertex_features) { |
| 893 | state_tracker->enabled_features.provoking_vertex_features = *provoking_vertex_features; |
| 894 | } |
Locke Lin | f387354 | 2021-04-26 11:25:10 -0600 | [diff] [blame] | 895 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 896 | const auto *vertex_input_dynamic_state_features = |
| 897 | LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(pCreateInfo->pNext); |
| 898 | if (vertex_input_dynamic_state_features) { |
| 899 | state_tracker->enabled_features.vertex_input_dynamic_state_features = *vertex_input_dynamic_state_features; |
| 900 | } |
Piers Daniell | cb6d803 | 2021-04-19 18:51:26 -0600 | [diff] [blame] | 901 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 902 | const auto *inherited_viewport_scissor_features = |
| 903 | LvlFindInChain<VkPhysicalDeviceInheritedViewportScissorFeaturesNV>(pCreateInfo->pNext); |
| 904 | if (inherited_viewport_scissor_features) { |
| 905 | state_tracker->enabled_features.inherited_viewport_scissor_features = *inherited_viewport_scissor_features; |
| 906 | } |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 907 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 908 | const auto *multi_draw_features = LvlFindInChain<VkPhysicalDeviceMultiDrawFeaturesEXT>(pCreateInfo->pNext); |
| 909 | if (multi_draw_features) { |
| 910 | state_tracker->enabled_features.multi_draw_features = *multi_draw_features; |
| 911 | } |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 912 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 913 | const auto *color_write_features = LvlFindInChain<VkPhysicalDeviceColorWriteEnableFeaturesEXT>(pCreateInfo->pNext); |
| 914 | if (color_write_features) { |
| 915 | state_tracker->enabled_features.color_write_features = *color_write_features; |
| 916 | } |
ziga-lunarg | 29ba2b9 | 2021-07-20 21:51:45 +0200 | [diff] [blame] | 917 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 918 | const auto *shader_atomic_float2_features = |
| 919 | LvlFindInChain<VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT>(pCreateInfo->pNext); |
| 920 | if (shader_atomic_float2_features) { |
| 921 | state_tracker->enabled_features.shader_atomic_float2_features = *shader_atomic_float2_features; |
| 922 | } |
Mike Schuchardt | b3870ea | 2021-07-20 18:56:51 -0700 | [diff] [blame] | 923 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 924 | const auto *present_id_features = LvlFindInChain<VkPhysicalDevicePresentIdFeaturesKHR>(pCreateInfo->pNext); |
| 925 | if (present_id_features) { |
| 926 | state_tracker->enabled_features.present_id_features = *present_id_features; |
| 927 | } |
Tony-LunarG | 6f887e5 | 2021-07-27 11:23:14 -0600 | [diff] [blame] | 928 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 929 | const auto *present_wait_features = LvlFindInChain<VkPhysicalDevicePresentWaitFeaturesKHR>(pCreateInfo->pNext); |
| 930 | if (present_wait_features) { |
| 931 | state_tracker->enabled_features.present_wait_features = *present_wait_features; |
| 932 | } |
Mike Schuchardt | 9f65d3f | 2021-08-25 15:11:39 -0700 | [diff] [blame] | 933 | |
| 934 | const auto *ray_tracing_motion_blur_features = |
| 935 | LvlFindInChain<VkPhysicalDeviceRayTracingMotionBlurFeaturesNV>(pCreateInfo->pNext); |
| 936 | if (ray_tracing_motion_blur_features) { |
| 937 | state_tracker->enabled_features.ray_tracing_motion_blur_features = *ray_tracing_motion_blur_features; |
| 938 | } |
Mike Schuchardt | b4d9045 | 2021-08-30 09:24:51 -0700 | [diff] [blame] | 939 | |
| 940 | const auto *shader_integer_dot_product_features = |
| 941 | LvlFindInChain<VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR>(pCreateInfo->pNext); |
| 942 | if (shader_integer_dot_product_features) { |
| 943 | state_tracker->enabled_features.shader_integer_dot_product_features = *shader_integer_dot_product_features; |
| 944 | } |
Tony-LunarG | 0b0d8be | 2021-08-30 13:50:38 -0600 | [diff] [blame] | 945 | |
| 946 | const auto *primitive_topology_list_restart_features = |
| 947 | LvlFindInChain<VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT>(pCreateInfo->pNext); |
| 948 | if (primitive_topology_list_restart_features) { |
| 949 | state_tracker->enabled_features.primitive_topology_list_restart_features = *primitive_topology_list_restart_features; |
| 950 | } |
sfricke-samsung | 10b35ce | 2021-09-29 08:50:20 -0700 | [diff] [blame] | 951 | |
| 952 | const auto *rgba10x6_formats_features = LvlFindInChain<VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT>(pCreateInfo->pNext); |
| 953 | if (rgba10x6_formats_features) { |
| 954 | state_tracker->enabled_features.rgba10x6_formats_features = *rgba10x6_formats_features; |
| 955 | } |
sfricke-samsung | d3c917b | 2021-10-19 08:24:57 -0700 | [diff] [blame] | 956 | |
| 957 | const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(pCreateInfo->pNext); |
| 958 | if (maintenance4_features) { |
| 959 | state_tracker->enabled_features.maintenance4_features = *maintenance4_features; |
| 960 | } |
Jeremy Gebben | ce23dac | 2021-11-10 10:19:42 -0700 | [diff] [blame] | 961 | |
| 962 | const auto *dynamic_rendering_features = LvlFindInChain<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(pCreateInfo->pNext); |
| 963 | if (dynamic_rendering_features) { |
| 964 | state_tracker->enabled_features.dynamic_rendering_features = *dynamic_rendering_features; |
| 965 | } |
Tony-LunarG | 69604c4 | 2021-11-22 16:00:12 -0700 | [diff] [blame] | 966 | |
| 967 | const auto *image_view_min_lod_features = LvlFindInChain<VkPhysicalDeviceImageViewMinLodFeaturesEXT>(pCreateInfo->pNext); |
| 968 | if (image_view_min_lod_features) { |
| 969 | state_tracker->enabled_features.image_view_min_lod_features = *image_view_min_lod_features; |
| 970 | } |
Tony-LunarG | 6f887e5 | 2021-07-27 11:23:14 -0600 | [diff] [blame] | 971 | } |
| 972 | |
ziga-lunarg | 7316374 | 2021-08-25 13:15:29 +0200 | [diff] [blame] | 973 | const auto *subgroup_size_control_features = LvlFindInChain<VkPhysicalDeviceSubgroupSizeControlFeaturesEXT>(pCreateInfo->pNext); |
| 974 | if (subgroup_size_control_features) { |
| 975 | state_tracker->enabled_features.subgroup_size_control_features = *subgroup_size_control_features; |
| 976 | } |
| 977 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 978 | // Store physical device properties and physical device mem limits into CoreChecks structs |
| 979 | DispatchGetPhysicalDeviceMemoryProperties(gpu, &state_tracker->phys_dev_mem_props); |
| 980 | DispatchGetPhysicalDeviceProperties(gpu, &state_tracker->phys_dev_props); |
| 981 | |
| 982 | const auto &dev_ext = state_tracker->device_extensions; |
| 983 | auto *phys_dev_props = &state_tracker->phys_dev_ext_props; |
| 984 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 985 | // Vulkan 1.2 can get properties from single struct, otherwise need to add to it per extension |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 986 | if (dev_ext.vk_feature_version_1_2) { |
| 987 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_feature_version_1_2, &state_tracker->phys_dev_props_core11); |
| 988 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_feature_version_1_2, &state_tracker->phys_dev_props_core12); |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 989 | } else { |
| 990 | // VkPhysicalDeviceVulkan11Properties |
| 991 | // |
| 992 | // Can ingnore VkPhysicalDeviceIDProperties as it has no validation purpose |
| 993 | |
| 994 | if (dev_ext.vk_khr_multiview) { |
| 995 | auto multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>(); |
| 996 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_multiview, &multiview_props); |
| 997 | state_tracker->phys_dev_props_core11.maxMultiviewViewCount = multiview_props.maxMultiviewViewCount; |
| 998 | state_tracker->phys_dev_props_core11.maxMultiviewInstanceIndex = multiview_props.maxMultiviewInstanceIndex; |
| 999 | } |
| 1000 | |
| 1001 | if (dev_ext.vk_khr_maintenance3) { |
| 1002 | auto maintenance3_props = LvlInitStruct<VkPhysicalDeviceMaintenance3Properties>(); |
| 1003 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_maintenance3, &maintenance3_props); |
| 1004 | state_tracker->phys_dev_props_core11.maxPerSetDescriptors = maintenance3_props.maxPerSetDescriptors; |
| 1005 | state_tracker->phys_dev_props_core11.maxMemoryAllocationSize = maintenance3_props.maxMemoryAllocationSize; |
| 1006 | } |
| 1007 | |
| 1008 | // Some 1.1 properties were added to core without previous extensions |
| 1009 | if (state_tracker->api_version >= VK_API_VERSION_1_1) { |
| 1010 | auto subgroup_prop = LvlInitStruct<VkPhysicalDeviceSubgroupProperties>(); |
| 1011 | auto protected_memory_prop = LvlInitStruct<VkPhysicalDeviceProtectedMemoryProperties>(&subgroup_prop); |
| 1012 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&protected_memory_prop); |
| 1013 | instance_dispatch_table.GetPhysicalDeviceProperties2(gpu, &prop2); |
| 1014 | |
| 1015 | state_tracker->phys_dev_props_core11.subgroupSize = subgroup_prop.subgroupSize; |
| 1016 | state_tracker->phys_dev_props_core11.subgroupSupportedStages = subgroup_prop.supportedStages; |
| 1017 | state_tracker->phys_dev_props_core11.subgroupSupportedOperations = subgroup_prop.supportedOperations; |
| 1018 | state_tracker->phys_dev_props_core11.subgroupQuadOperationsInAllStages = subgroup_prop.quadOperationsInAllStages; |
| 1019 | |
| 1020 | state_tracker->phys_dev_props_core11.protectedNoFault = protected_memory_prop.protectedNoFault; |
| 1021 | } |
| 1022 | |
| 1023 | // VkPhysicalDeviceVulkan12Properties |
| 1024 | // |
| 1025 | // Can ingnore VkPhysicalDeviceDriverProperties as it has no validation purpose |
| 1026 | |
| 1027 | if (dev_ext.vk_ext_descriptor_indexing) { |
| 1028 | auto descriptor_indexing_prop = LvlInitStruct<VkPhysicalDeviceDescriptorIndexingProperties>(); |
| 1029 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_descriptor_indexing, &descriptor_indexing_prop); |
| 1030 | state_tracker->phys_dev_props_core12.maxUpdateAfterBindDescriptorsInAllPools = |
| 1031 | descriptor_indexing_prop.maxUpdateAfterBindDescriptorsInAllPools; |
| 1032 | state_tracker->phys_dev_props_core12.shaderUniformBufferArrayNonUniformIndexingNative = |
| 1033 | descriptor_indexing_prop.shaderUniformBufferArrayNonUniformIndexingNative; |
| 1034 | state_tracker->phys_dev_props_core12.shaderSampledImageArrayNonUniformIndexingNative = |
| 1035 | descriptor_indexing_prop.shaderSampledImageArrayNonUniformIndexingNative; |
| 1036 | state_tracker->phys_dev_props_core12.shaderStorageBufferArrayNonUniformIndexingNative = |
| 1037 | descriptor_indexing_prop.shaderStorageBufferArrayNonUniformIndexingNative; |
| 1038 | state_tracker->phys_dev_props_core12.shaderStorageImageArrayNonUniformIndexingNative = |
| 1039 | descriptor_indexing_prop.shaderStorageImageArrayNonUniformIndexingNative; |
| 1040 | state_tracker->phys_dev_props_core12.shaderInputAttachmentArrayNonUniformIndexingNative = |
| 1041 | descriptor_indexing_prop.shaderInputAttachmentArrayNonUniformIndexingNative; |
| 1042 | state_tracker->phys_dev_props_core12.robustBufferAccessUpdateAfterBind = |
| 1043 | descriptor_indexing_prop.robustBufferAccessUpdateAfterBind; |
| 1044 | state_tracker->phys_dev_props_core12.quadDivergentImplicitLod = descriptor_indexing_prop.quadDivergentImplicitLod; |
| 1045 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindSamplers = |
| 1046 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindSamplers; |
| 1047 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindUniformBuffers = |
| 1048 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindUniformBuffers; |
| 1049 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindStorageBuffers = |
| 1050 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindStorageBuffers; |
| 1051 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindSampledImages = |
| 1052 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindSampledImages; |
| 1053 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindStorageImages = |
| 1054 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindStorageImages; |
| 1055 | state_tracker->phys_dev_props_core12.maxPerStageDescriptorUpdateAfterBindInputAttachments = |
| 1056 | descriptor_indexing_prop.maxPerStageDescriptorUpdateAfterBindInputAttachments; |
| 1057 | state_tracker->phys_dev_props_core12.maxPerStageUpdateAfterBindResources = |
| 1058 | descriptor_indexing_prop.maxPerStageUpdateAfterBindResources; |
| 1059 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindSamplers = |
| 1060 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindSamplers; |
| 1061 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindUniformBuffers = |
| 1062 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindUniformBuffers; |
| 1063 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic = |
| 1064 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic; |
| 1065 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindStorageBuffers = |
| 1066 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindStorageBuffers; |
| 1067 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic = |
| 1068 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic; |
| 1069 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindSampledImages = |
| 1070 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindSampledImages; |
| 1071 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindStorageImages = |
| 1072 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindStorageImages; |
| 1073 | state_tracker->phys_dev_props_core12.maxDescriptorSetUpdateAfterBindInputAttachments = |
| 1074 | descriptor_indexing_prop.maxDescriptorSetUpdateAfterBindInputAttachments; |
| 1075 | } |
| 1076 | |
| 1077 | if (dev_ext.vk_khr_depth_stencil_resolve) { |
| 1078 | auto depth_stencil_resolve_props = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>(); |
| 1079 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_depth_stencil_resolve, &depth_stencil_resolve_props); |
| 1080 | state_tracker->phys_dev_props_core12.supportedDepthResolveModes = |
| 1081 | depth_stencil_resolve_props.supportedDepthResolveModes; |
| 1082 | state_tracker->phys_dev_props_core12.supportedStencilResolveModes = |
| 1083 | depth_stencil_resolve_props.supportedStencilResolveModes; |
| 1084 | state_tracker->phys_dev_props_core12.independentResolveNone = depth_stencil_resolve_props.independentResolveNone; |
| 1085 | state_tracker->phys_dev_props_core12.independentResolve = depth_stencil_resolve_props.independentResolve; |
| 1086 | } |
| 1087 | |
| 1088 | if (dev_ext.vk_khr_timeline_semaphore) { |
| 1089 | auto timeline_semaphore_props = LvlInitStruct<VkPhysicalDeviceTimelineSemaphoreProperties>(); |
| 1090 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_timeline_semaphore, &timeline_semaphore_props); |
| 1091 | state_tracker->phys_dev_props_core12.maxTimelineSemaphoreValueDifference = |
| 1092 | timeline_semaphore_props.maxTimelineSemaphoreValueDifference; |
| 1093 | } |
| 1094 | |
| 1095 | if (dev_ext.vk_ext_sampler_filter_minmax) { |
| 1096 | auto sampler_filter_minmax_props = LvlInitStruct<VkPhysicalDeviceSamplerFilterMinmaxProperties>(); |
| 1097 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_sampler_filter_minmax, &sampler_filter_minmax_props); |
| 1098 | state_tracker->phys_dev_props_core12.filterMinmaxSingleComponentFormats = |
| 1099 | sampler_filter_minmax_props.filterMinmaxSingleComponentFormats; |
| 1100 | state_tracker->phys_dev_props_core12.filterMinmaxImageComponentMapping = |
| 1101 | sampler_filter_minmax_props.filterMinmaxImageComponentMapping; |
| 1102 | } |
| 1103 | |
| 1104 | if (dev_ext.vk_khr_shader_float_controls) { |
| 1105 | auto float_controls_props = LvlInitStruct<VkPhysicalDeviceFloatControlsProperties>(); |
| 1106 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_shader_float_controls, &float_controls_props); |
| 1107 | state_tracker->phys_dev_props_core12.denormBehaviorIndependence = float_controls_props.denormBehaviorIndependence; |
| 1108 | state_tracker->phys_dev_props_core12.roundingModeIndependence = float_controls_props.roundingModeIndependence; |
| 1109 | state_tracker->phys_dev_props_core12.shaderSignedZeroInfNanPreserveFloat16 = |
| 1110 | float_controls_props.shaderSignedZeroInfNanPreserveFloat16; |
| 1111 | state_tracker->phys_dev_props_core12.shaderSignedZeroInfNanPreserveFloat32 = |
| 1112 | float_controls_props.shaderSignedZeroInfNanPreserveFloat32; |
| 1113 | state_tracker->phys_dev_props_core12.shaderSignedZeroInfNanPreserveFloat64 = |
| 1114 | float_controls_props.shaderSignedZeroInfNanPreserveFloat64; |
| 1115 | state_tracker->phys_dev_props_core12.shaderDenormPreserveFloat16 = float_controls_props.shaderDenormPreserveFloat16; |
| 1116 | state_tracker->phys_dev_props_core12.shaderDenormPreserveFloat32 = float_controls_props.shaderDenormPreserveFloat32; |
| 1117 | state_tracker->phys_dev_props_core12.shaderDenormPreserveFloat64 = float_controls_props.shaderDenormPreserveFloat64; |
| 1118 | state_tracker->phys_dev_props_core12.shaderDenormFlushToZeroFloat16 = |
| 1119 | float_controls_props.shaderDenormFlushToZeroFloat16; |
| 1120 | state_tracker->phys_dev_props_core12.shaderDenormFlushToZeroFloat32 = |
| 1121 | float_controls_props.shaderDenormFlushToZeroFloat32; |
| 1122 | state_tracker->phys_dev_props_core12.shaderDenormFlushToZeroFloat64 = |
| 1123 | float_controls_props.shaderDenormFlushToZeroFloat64; |
| 1124 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTEFloat16 = float_controls_props.shaderRoundingModeRTEFloat16; |
| 1125 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTEFloat32 = float_controls_props.shaderRoundingModeRTEFloat32; |
| 1126 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTEFloat64 = float_controls_props.shaderRoundingModeRTEFloat64; |
| 1127 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTZFloat16 = float_controls_props.shaderRoundingModeRTZFloat16; |
| 1128 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTZFloat32 = float_controls_props.shaderRoundingModeRTZFloat32; |
| 1129 | state_tracker->phys_dev_props_core12.shaderRoundingModeRTZFloat64 = float_controls_props.shaderRoundingModeRTZFloat64; |
| 1130 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1131 | } |
| 1132 | |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 1133 | // Extensions with properties to extract to DeviceExtensionProperties |
| 1134 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_push_descriptor, &phys_dev_props->push_descriptor_props); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1135 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_nv_shading_rate_image, &phys_dev_props->shading_rate_image_props); |
| 1136 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_nv_mesh_shader, &phys_dev_props->mesh_shader_props); |
| 1137 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_inline_uniform_block, &phys_dev_props->inline_uniform_block_props); |
| 1138 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_vertex_attribute_divisor, &phys_dev_props->vtx_attrib_divisor_props); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1139 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_transform_feedback, &phys_dev_props->transform_feedback_props); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1140 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_nv_ray_tracing, &phys_dev_props->ray_tracing_propsNV); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 1141 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_ray_tracing_pipeline, &phys_dev_props->ray_tracing_propsKHR); |
| 1142 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_acceleration_structure, &phys_dev_props->acc_structure_props); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1143 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_texel_buffer_alignment, &phys_dev_props->texel_buffer_alignment_props); |
| 1144 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_fragment_density_map, &phys_dev_props->fragment_density_map_props); |
Mike Schuchardt | c57de4a | 2021-07-20 17:26:32 -0700 | [diff] [blame] | 1145 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_fragment_density_map2, &phys_dev_props->fragment_density_map2_props); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1146 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_performance_query, &phys_dev_props->performance_query_props); |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 1147 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_sample_locations, &phys_dev_props->sample_locations_props); |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 1148 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_custom_border_color, &phys_dev_props->custom_border_color_props); |
locke-lunarg | 3fa463a | 2020-10-23 16:39:04 -0600 | [diff] [blame] | 1149 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_multiview, &phys_dev_props->multiview_props); |
Nathaniel Cesario | 3291c91 | 2020-11-17 16:54:41 -0700 | [diff] [blame] | 1150 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_portability_subset, &phys_dev_props->portability_props); |
sfricke-samsung | 828e59d | 2021-08-22 23:20:49 -0700 | [diff] [blame] | 1151 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_khr_fragment_shading_rate, &phys_dev_props->fragment_shading_rate_props); |
Locke Lin | 016d848 | 2021-05-27 12:11:31 -0600 | [diff] [blame] | 1152 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_provoking_vertex, &phys_dev_props->provoking_vertex_props); |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 1153 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_multi_draw, &phys_dev_props->multi_draw_props); |
ziga-lunarg | 128904a | 2021-07-30 13:49:01 +0200 | [diff] [blame] | 1154 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_discard_rectangles, &phys_dev_props->discard_rectangle_props); |
ziga-lunarg | 8649281 | 2021-08-05 23:58:16 +0200 | [diff] [blame] | 1155 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_blend_operation_advanced, &phys_dev_props->blend_operation_advanced_props); |
ziga-lunarg | bd8ded6 | 2021-09-20 18:24:39 +0200 | [diff] [blame] | 1156 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_conservative_rasterization, &phys_dev_props->conservative_rasterization_props); |
ziga-lunarg | 11fecb9 | 2021-09-20 16:48:06 +0200 | [diff] [blame] | 1157 | GetPhysicalDeviceExtProperties(gpu, dev_ext.vk_ext_subgroup_size_control, &phys_dev_props->subgroup_size_control_props); |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 1158 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 1159 | if (IsExtEnabled(dev_ext.vk_nv_cooperative_matrix)) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1160 | // Get the needed cooperative_matrix properties |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 1161 | auto cooperative_matrix_props = LvlInitStruct<VkPhysicalDeviceCooperativeMatrixPropertiesNV>(); |
| 1162 | auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&cooperative_matrix_props); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1163 | instance_dispatch_table.GetPhysicalDeviceProperties2KHR(gpu, &prop2); |
| 1164 | state_tracker->phys_dev_ext_props.cooperative_matrix_props = cooperative_matrix_props; |
| 1165 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1166 | uint32_t num_cooperative_matrix_properties = 0; |
| 1167 | instance_dispatch_table.GetPhysicalDeviceCooperativeMatrixPropertiesNV(gpu, &num_cooperative_matrix_properties, NULL); |
| 1168 | state_tracker->cooperative_matrix_properties.resize(num_cooperative_matrix_properties, |
Mark Lobodzinski | 6fe9e70 | 2020-12-30 15:36:39 -0700 | [diff] [blame] | 1169 | LvlInitStruct<VkCooperativeMatrixPropertiesNV>()); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1170 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1171 | instance_dispatch_table.GetPhysicalDeviceCooperativeMatrixPropertiesNV(gpu, &num_cooperative_matrix_properties, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1172 | state_tracker->cooperative_matrix_properties.data()); |
| 1173 | } |
Tobias Hector | 6663c9b | 2020-11-05 10:18:02 +0000 | [diff] [blame] | 1174 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1175 | // Store queue family data |
| 1176 | if (pCreateInfo->pQueueCreateInfos != nullptr) { |
Jeremy Gebben | a15e238 | 2021-09-30 11:49:32 -0600 | [diff] [blame] | 1177 | uint32_t total_count = 0; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1178 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 1179 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
sfricke-samsung | b585ec1 | 2021-05-06 03:10:13 -0700 | [diff] [blame] | 1180 | state_tracker->queue_family_index_set.insert(queue_create_info.queueFamilyIndex); |
| 1181 | state_tracker->device_queue_info_list.push_back( |
| 1182 | {i, queue_create_info.queueFamilyIndex, queue_create_info.flags, queue_create_info.queueCount}); |
Jeremy Gebben | a15e238 | 2021-09-30 11:49:32 -0600 | [diff] [blame] | 1183 | total_count += queue_create_info.queueCount; |
| 1184 | } |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1185 | queue_map_.reserve(total_count); |
Jeremy Gebben | a15e238 | 2021-09-30 11:49:32 -0600 | [diff] [blame] | 1186 | for (const auto &queue_info : state_tracker->device_queue_info_list) { |
| 1187 | for (uint32_t i = 0; i < queue_info.queue_count; i++) { |
| 1188 | VkQueue queue = VK_NULL_HANDLE; |
| 1189 | // vkGetDeviceQueue2() was added in vulkan 1.1, and there was never a KHR version of it. |
| 1190 | if (api_version >= VK_API_VERSION_1_1 && queue_info.flags != 0) { |
| 1191 | auto get_info = LvlInitStruct<VkDeviceQueueInfo2>(); |
| 1192 | get_info.flags = queue_info.flags; |
| 1193 | get_info.queueFamilyIndex = queue_info.queue_family_index; |
| 1194 | get_info.queueIndex = i; |
| 1195 | DispatchGetDeviceQueue2(*pDevice, &get_info, &queue); |
| 1196 | } else { |
| 1197 | DispatchGetDeviceQueue(*pDevice, queue_info.queue_family_index, i, &queue); |
| 1198 | } |
| 1199 | assert(queue != VK_NULL_HANDLE); |
Mike Schuchardt | a9101d3 | 2021-11-12 12:24:08 -0800 | [diff] [blame] | 1200 | state_tracker->Add(std::make_shared<QUEUE_STATE>(queue, queue_info.queue_family_index, queue_info.flags)); |
Jeremy Gebben | a15e238 | 2021-09-30 11:49:32 -0600 | [diff] [blame] | 1201 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1202 | } |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | void ValidationStateTracker::PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 1207 | if (!device) return; |
| 1208 | |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1209 | command_pool_map_.clear(); |
| 1210 | assert(command_buffer_map_.empty()); |
| 1211 | pipeline_map_.clear(); |
| 1212 | render_pass_map_.clear(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1213 | |
| 1214 | // This will also delete all sets in the pool & remove them from setMap |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1215 | descriptor_pool_map_.clear(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1216 | // All sets should be removed |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1217 | assert(descriptor_set_map_.empty()); |
| 1218 | desc_template_map_.clear(); |
| 1219 | descriptor_set_layout_map_.clear(); |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 1220 | // Because swapchains are associated with Surfaces, which are at instance level, |
| 1221 | // they need to be explicitly destroyed here to avoid continued references to |
| 1222 | // the device we're destroying. |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1223 | for (auto &entry : swapchain_map_) { |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 1224 | entry.second->Destroy(); |
| 1225 | } |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1226 | swapchain_map_.clear(); |
| 1227 | image_view_map_.clear(); |
| 1228 | image_map_.clear(); |
| 1229 | buffer_view_map_.clear(); |
| 1230 | buffer_map_.clear(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1231 | // Queues persist until device is destroyed |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1232 | queue_map_.clear(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1233 | } |
| 1234 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1235 | void ValidationStateTracker::PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, |
| 1236 | VkFence fence, VkResult result) { |
| 1237 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1238 | auto queue_state = Get<QUEUE_STATE>(queue); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1239 | |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1240 | uint64_t early_retire_seq = 0; |
| 1241 | |
| 1242 | if (submitCount == 0) { |
| 1243 | CB_SUBMISSION submission; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1244 | submission.AddFence(Get<FENCE_STATE>(fence)); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1245 | early_retire_seq = queue_state->Submit(std::move(submission)); |
| 1246 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1247 | |
| 1248 | // Now process each individual submit |
| 1249 | for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1250 | CB_SUBMISSION submission; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1251 | const VkSubmitInfo *submit = &pSubmits[submit_idx]; |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1252 | auto *timeline_semaphore_submit = LvlFindInChain<VkTimelineSemaphoreSubmitInfo>(submit->pNext); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1253 | for (uint32_t i = 0; i < submit->waitSemaphoreCount; ++i) { |
Jeremy Gebben | 4ae5cc7 | 2021-03-10 15:34:44 -0700 | [diff] [blame] | 1254 | uint64_t value = 0; |
| 1255 | if (timeline_semaphore_submit && timeline_semaphore_submit->pWaitSemaphoreValues != nullptr && |
| 1256 | (i < timeline_semaphore_submit->waitSemaphoreValueCount)) { |
| 1257 | value = timeline_semaphore_submit->pWaitSemaphoreValues[i]; |
| 1258 | } |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1259 | submission.AddWaitSemaphore(Get<SEMAPHORE_STATE>(submit->pWaitSemaphores[i]), value); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1260 | } |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1261 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1262 | for (uint32_t i = 0; i < submit->signalSemaphoreCount; ++i) { |
Jeremy Gebben | 4ae5cc7 | 2021-03-10 15:34:44 -0700 | [diff] [blame] | 1263 | uint64_t value = 0; |
| 1264 | if (timeline_semaphore_submit && timeline_semaphore_submit->pSignalSemaphoreValues != nullptr && |
| 1265 | (i < timeline_semaphore_submit->signalSemaphoreValueCount)) { |
| 1266 | value = timeline_semaphore_submit->pSignalSemaphoreValues[i]; |
| 1267 | } |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1268 | submission.AddSignalSemaphore(Get<SEMAPHORE_STATE>(submit->pSignalSemaphores[i]), value); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1269 | } |
| 1270 | |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1271 | const auto perf_submit = LvlFindInChain<VkPerformanceQuerySubmitInfoKHR>(submit->pNext); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1272 | submission.perf_submit_pass = perf_submit ? perf_submit->counterPassIndex : 0; |
Lionel Landwerlin | 7dc796b | 2020-02-18 18:17:10 +0200 | [diff] [blame] | 1273 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1274 | for (uint32_t i = 0; i < submit->commandBufferCount; i++) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1275 | submission.AddCommandBuffer(Get<CMD_BUFFER_STATE>(submit->pCommandBuffers[i])); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1276 | } |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1277 | if (submit_idx == (submitCount - 1) && fence != VK_NULL_HANDLE) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1278 | submission.AddFence(Get<FENCE_STATE>(fence)); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1279 | } |
| 1280 | auto submit_seq = queue_state->Submit(std::move(submission)); |
| 1281 | early_retire_seq = std::max(early_retire_seq, submit_seq); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1282 | } |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1283 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1284 | if (early_retire_seq) { |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1285 | queue_state->Retire(early_retire_seq); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | void ValidationStateTracker::PostCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR *pSubmits, |
| 1290 | VkFence fence, VkResult result) { |
| 1291 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1292 | auto queue_state = Get<QUEUE_STATE>(queue); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1293 | uint64_t early_retire_seq = 0; |
| 1294 | if (submitCount == 0) { |
| 1295 | CB_SUBMISSION submission; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1296 | submission.AddFence(Get<FENCE_STATE>(fence)); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1297 | early_retire_seq = queue_state->Submit(std::move(submission)); |
| 1298 | } |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1299 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1300 | for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { |
| 1301 | CB_SUBMISSION submission; |
| 1302 | const VkSubmitInfo2KHR *submit = &pSubmits[submit_idx]; |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1303 | for (uint32_t i = 0; i < submit->waitSemaphoreInfoCount; ++i) { |
| 1304 | const auto &sem_info = submit->pWaitSemaphoreInfos[i]; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1305 | submission.AddWaitSemaphore(Get<SEMAPHORE_STATE>(sem_info.semaphore), sem_info.value); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1306 | } |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1307 | for (uint32_t i = 0; i < submit->signalSemaphoreInfoCount; ++i) { |
| 1308 | const auto &sem_info = submit->pSignalSemaphoreInfos[i]; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1309 | submission.AddSignalSemaphore(Get<SEMAPHORE_STATE>(sem_info.semaphore), sem_info.value); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1310 | } |
| 1311 | const auto perf_submit = lvl_find_in_chain<VkPerformanceQuerySubmitInfoKHR>(submit->pNext); |
| 1312 | submission.perf_submit_pass = perf_submit ? perf_submit->counterPassIndex : 0; |
| 1313 | |
| 1314 | for (uint32_t i = 0; i < submit->commandBufferInfoCount; i++) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1315 | submission.AddCommandBuffer(Get<CMD_BUFFER_STATE>(submit->pCommandBufferInfos[i].commandBuffer)); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1316 | } |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1317 | if (submit_idx == (submitCount - 1)) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1318 | submission.AddFence(Get<FENCE_STATE>(fence)); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1319 | } |
| 1320 | auto submit_seq = queue_state->Submit(std::move(submission)); |
| 1321 | early_retire_seq = std::max(early_retire_seq, submit_seq); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1322 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1323 | if (early_retire_seq) { |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1324 | queue_state->Retire(early_retire_seq); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | void ValidationStateTracker::PostCallRecordAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
| 1329 | const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory, |
| 1330 | VkResult result) { |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1331 | if (VK_SUCCESS != result) { |
| 1332 | return; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1333 | } |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1334 | const auto &memory_type = phys_dev_mem_props.memoryTypes[pAllocateInfo->memoryTypeIndex]; |
| 1335 | const auto &memory_heap = phys_dev_mem_props.memoryHeaps[memory_type.heapIndex]; |
| 1336 | auto fake_address = fake_memory.Alloc(pAllocateInfo->allocationSize); |
| 1337 | |
| 1338 | layer_data::optional<DedicatedBinding> dedicated_binding; |
| 1339 | |
| 1340 | auto dedicated = LvlFindInChain<VkMemoryDedicatedAllocateInfo>(pAllocateInfo->pNext); |
| 1341 | if (dedicated) { |
| 1342 | if (dedicated->buffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1343 | const auto buffer_state = Get<BUFFER_STATE>(dedicated->buffer); |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1344 | assert(buffer_state); |
| 1345 | if (!buffer_state) { |
| 1346 | return; |
| 1347 | } |
| 1348 | dedicated_binding.emplace(dedicated->buffer, buffer_state->createInfo); |
| 1349 | } else if (dedicated->image) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1350 | const auto image_state = Get<IMAGE_STATE>(dedicated->image); |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1351 | assert(image_state); |
| 1352 | if (!image_state) { |
| 1353 | return; |
| 1354 | } |
| 1355 | dedicated_binding.emplace(dedicated->image, image_state->createInfo); |
| 1356 | } |
| 1357 | } |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1358 | Add(std::make_shared<DEVICE_MEMORY_STATE>(*pMemory, pAllocateInfo, fake_address, memory_type, memory_heap, |
| 1359 | std::move(dedicated_binding), physical_device_count)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1360 | return; |
| 1361 | } |
| 1362 | |
| 1363 | void ValidationStateTracker::PreCallRecordFreeMemory(VkDevice device, VkDeviceMemory mem, const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1364 | auto mem_info = Get<DEVICE_MEMORY_STATE>(mem); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1365 | if (mem_info) { |
| 1366 | fake_memory.Free(mem_info->fake_base_address); |
| 1367 | } |
| 1368 | Destroy<DEVICE_MEMORY_STATE>(mem); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1369 | } |
| 1370 | |
| 1371 | void ValidationStateTracker::PostCallRecordQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, |
| 1372 | VkFence fence, VkResult result) { |
| 1373 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1374 | auto queue_state = Get<QUEUE_STATE>(queue); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1375 | |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1376 | uint64_t early_retire_seq = 0; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1377 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1378 | for (uint32_t bind_idx = 0; bind_idx < bindInfoCount; ++bind_idx) { |
| 1379 | const VkBindSparseInfo &bind_info = pBindInfo[bind_idx]; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1380 | // Track objects tied to memory |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1381 | for (uint32_t j = 0; j < bind_info.bufferBindCount; j++) { |
| 1382 | for (uint32_t k = 0; k < bind_info.pBufferBinds[j].bindCount; k++) { |
| 1383 | auto sparse_binding = bind_info.pBufferBinds[j].pBinds[k]; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1384 | auto buffer_state = Get<BUFFER_STATE>(bind_info.pBufferBinds[j].buffer); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1385 | auto mem_state = Get<DEVICE_MEMORY_STATE>(sparse_binding.memory); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1386 | if (buffer_state && mem_state) { |
| 1387 | buffer_state->SetSparseMemBinding(mem_state, sparse_binding.memoryOffset, sparse_binding.size); |
| 1388 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1389 | } |
| 1390 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1391 | for (uint32_t j = 0; j < bind_info.imageOpaqueBindCount; j++) { |
| 1392 | for (uint32_t k = 0; k < bind_info.pImageOpaqueBinds[j].bindCount; k++) { |
| 1393 | auto sparse_binding = bind_info.pImageOpaqueBinds[j].pBinds[k]; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1394 | auto image_state = Get<IMAGE_STATE>(bind_info.pImageOpaqueBinds[j].image); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1395 | auto mem_state = Get<DEVICE_MEMORY_STATE>(sparse_binding.memory); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1396 | if (image_state && mem_state) { |
| 1397 | image_state->SetSparseMemBinding(mem_state, sparse_binding.memoryOffset, sparse_binding.size); |
| 1398 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1399 | } |
| 1400 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1401 | for (uint32_t j = 0; j < bind_info.imageBindCount; j++) { |
| 1402 | for (uint32_t k = 0; k < bind_info.pImageBinds[j].bindCount; k++) { |
| 1403 | auto sparse_binding = bind_info.pImageBinds[j].pBinds[k]; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1404 | // TODO: This size is broken for non-opaque bindings, need to update to comprehend full sparse binding data |
| 1405 | VkDeviceSize size = sparse_binding.extent.depth * sparse_binding.extent.height * sparse_binding.extent.width * 4; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1406 | auto image_state = Get<IMAGE_STATE>(bind_info.pImageBinds[j].image); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1407 | auto mem_state = Get<DEVICE_MEMORY_STATE>(sparse_binding.memory); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1408 | if (image_state && mem_state) { |
| 1409 | image_state->SetSparseMemBinding(mem_state, sparse_binding.memoryOffset, size); |
| 1410 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1411 | } |
| 1412 | } |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1413 | CB_SUBMISSION submission; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1414 | for (uint32_t i = 0; i < bind_info.waitSemaphoreCount; ++i) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1415 | submission.AddWaitSemaphore(Get<SEMAPHORE_STATE>(bind_info.pWaitSemaphores[i]), 0); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1416 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1417 | for (uint32_t i = 0; i < bind_info.signalSemaphoreCount; ++i) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1418 | submission.AddSignalSemaphore(Get<SEMAPHORE_STATE>(bind_info.pSignalSemaphores[i]), 0); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 1419 | } |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1420 | if (bind_idx == (bindInfoCount - 1)) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1421 | submission.AddFence(Get<FENCE_STATE>(fence)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1422 | } |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1423 | auto submit_seq = queue_state->Submit(std::move(submission)); |
| 1424 | early_retire_seq = std::max(early_retire_seq, submit_seq); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | if (early_retire_seq) { |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1428 | queue_state->Retire(early_retire_seq); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | void ValidationStateTracker::PostCallRecordCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, |
| 1433 | const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore, |
| 1434 | VkResult result) { |
| 1435 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1436 | Add(std::make_shared<SEMAPHORE_STATE>(*pSemaphore, LvlFindInChain<VkSemaphoreTypeCreateInfo>(pCreateInfo->pNext))); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1437 | } |
| 1438 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1439 | void ValidationStateTracker::RecordImportSemaphoreState(VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBits handle_type, |
| 1440 | VkSemaphoreImportFlags flags) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1441 | auto sema_node = Get<SEMAPHORE_STATE>(semaphore); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1442 | if (sema_node && sema_node->scope != kSyncScopeExternalPermanent) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1443 | if ((handle_type == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT || flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) && |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1444 | sema_node->scope == kSyncScopeInternal) { |
| 1445 | sema_node->scope = kSyncScopeExternalTemporary; |
| 1446 | } else { |
| 1447 | sema_node->scope = kSyncScopeExternalPermanent; |
| 1448 | } |
| 1449 | } |
| 1450 | } |
| 1451 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1452 | void ValidationStateTracker::PostCallRecordSignalSemaphoreKHR(VkDevice device, const VkSemaphoreSignalInfo *pSignalInfo, |
Juan A. Suarez Romero | f302416 | 2019-10-31 17:57:50 +0000 | [diff] [blame] | 1453 | VkResult result) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1454 | auto semaphore_state = Get<SEMAPHORE_STATE>(pSignalInfo->semaphore); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1455 | semaphore_state->payload = pSignalInfo->value; |
Juan A. Suarez Romero | f302416 | 2019-10-31 17:57:50 +0000 | [diff] [blame] | 1456 | } |
| 1457 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1458 | void ValidationStateTracker::RecordMappedMemory(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, void **ppData) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1459 | auto mem_info = Get<DEVICE_MEMORY_STATE>(mem); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1460 | if (mem_info) { |
| 1461 | mem_info->mapped_range.offset = offset; |
| 1462 | mem_info->mapped_range.size = size; |
| 1463 | mem_info->p_driver_data = *ppData; |
| 1464 | } |
| 1465 | } |
| 1466 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1467 | void ValidationStateTracker::PostCallRecordWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, |
| 1468 | VkBool32 waitAll, uint64_t timeout, VkResult result) { |
| 1469 | if (VK_SUCCESS != result) return; |
| 1470 | |
| 1471 | // When we know that all fences are complete we can clean/remove their CBs |
| 1472 | if ((VK_TRUE == waitAll) || (1 == fenceCount)) { |
| 1473 | for (uint32_t i = 0; i < fenceCount; i++) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1474 | auto fence_state = Get<FENCE_STATE>(pFences[i]); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1475 | if (fence_state) { |
| 1476 | fence_state->Retire(); |
| 1477 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1478 | } |
| 1479 | } |
| 1480 | // NOTE : Alternate case not handled here is when some fences have completed. In |
| 1481 | // this case for app to guarantee which fences completed it will have to call |
| 1482 | // vkGetFenceStatus() at which point we'll clean/remove their CBs if complete. |
| 1483 | } |
| 1484 | |
John Zulauf | f89de66 | 2020-04-13 18:57:34 -0600 | [diff] [blame] | 1485 | void ValidationStateTracker::RecordWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo *pWaitInfo, uint64_t timeout, |
| 1486 | VkResult result) { |
Jakub Okoński | 04feb3b | 2020-02-01 18:31:01 +0100 | [diff] [blame] | 1487 | if (VK_SUCCESS != result) return; |
| 1488 | |
| 1489 | for (uint32_t i = 0; i < pWaitInfo->semaphoreCount; i++) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1490 | auto semaphore_state = Get<SEMAPHORE_STATE>(pWaitInfo->pSemaphores[i]); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1491 | if (semaphore_state) { |
| 1492 | semaphore_state->Retire(pWaitInfo->pValues[i]); |
| 1493 | } |
Jakub Okoński | 04feb3b | 2020-02-01 18:31:01 +0100 | [diff] [blame] | 1494 | } |
| 1495 | } |
| 1496 | |
John Zulauf | f89de66 | 2020-04-13 18:57:34 -0600 | [diff] [blame] | 1497 | void ValidationStateTracker::PostCallRecordWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo *pWaitInfo, uint64_t timeout, |
| 1498 | VkResult result) { |
| 1499 | RecordWaitSemaphores(device, pWaitInfo, timeout, result); |
| 1500 | } |
| 1501 | |
| 1502 | void ValidationStateTracker::PostCallRecordWaitSemaphoresKHR(VkDevice device, const VkSemaphoreWaitInfo *pWaitInfo, |
| 1503 | uint64_t timeout, VkResult result) { |
| 1504 | RecordWaitSemaphores(device, pWaitInfo, timeout, result); |
| 1505 | } |
| 1506 | |
Adrian Coca Lorente | c7d7610 | 2020-09-28 13:58:16 +0200 | [diff] [blame] | 1507 | void ValidationStateTracker::RecordGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t *pValue, |
| 1508 | VkResult result) { |
| 1509 | if (VK_SUCCESS != result) return; |
| 1510 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1511 | auto semaphore_state = Get<SEMAPHORE_STATE>(semaphore); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1512 | if (semaphore_state) { |
| 1513 | semaphore_state->Retire(*pValue); |
| 1514 | } |
Adrian Coca Lorente | c7d7610 | 2020-09-28 13:58:16 +0200 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | void ValidationStateTracker::PostCallRecordGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t *pValue, |
| 1518 | VkResult result) { |
| 1519 | RecordGetSemaphoreCounterValue(device, semaphore, pValue, result); |
| 1520 | } |
| 1521 | void ValidationStateTracker::PostCallRecordGetSemaphoreCounterValueKHR(VkDevice device, VkSemaphore semaphore, uint64_t *pValue, |
| 1522 | VkResult result) { |
| 1523 | RecordGetSemaphoreCounterValue(device, semaphore, pValue, result); |
| 1524 | } |
| 1525 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1526 | void ValidationStateTracker::PostCallRecordGetFenceStatus(VkDevice device, VkFence fence, VkResult result) { |
| 1527 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1528 | auto fence_state = Get<FENCE_STATE>(fence); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1529 | if (fence_state) { |
| 1530 | fence_state->Retire(); |
| 1531 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1532 | } |
| 1533 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1534 | void ValidationStateTracker::PostCallRecordQueueWaitIdle(VkQueue queue, VkResult result) { |
| 1535 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1536 | auto queue_state = Get<QUEUE_STATE>(queue); |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1537 | if (queue_state) { |
| 1538 | queue_state->Retire(); |
| 1539 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1540 | } |
| 1541 | |
| 1542 | void ValidationStateTracker::PostCallRecordDeviceWaitIdle(VkDevice device, VkResult result) { |
| 1543 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 1544 | for (auto &queue : queue_map_) { |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 1545 | queue.second->Retire(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1546 | } |
| 1547 | } |
| 1548 | |
| 1549 | void ValidationStateTracker::PreCallRecordDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1550 | Destroy<FENCE_STATE>(fence); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | void ValidationStateTracker::PreCallRecordDestroySemaphore(VkDevice device, VkSemaphore semaphore, |
| 1554 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1555 | Destroy<SEMAPHORE_STATE>(semaphore); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | void ValidationStateTracker::PreCallRecordDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1559 | Destroy<EVENT_STATE>(event); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1560 | } |
| 1561 | |
| 1562 | void ValidationStateTracker::PreCallRecordDestroyQueryPool(VkDevice device, VkQueryPool queryPool, |
| 1563 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1564 | Destroy<QUERY_POOL_STATE>(queryPool); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1565 | } |
| 1566 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1567 | void ValidationStateTracker::UpdateBindBufferMemoryState(VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memoryOffset) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1568 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1569 | if (buffer_state) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1570 | // Track objects tied to memory |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1571 | auto mem_state = Get<DEVICE_MEMORY_STATE>(mem); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1572 | if (mem_state) { |
| 1573 | buffer_state->SetMemBinding(mem_state, memoryOffset); |
| 1574 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1575 | } |
| 1576 | } |
| 1577 | |
| 1578 | void ValidationStateTracker::PostCallRecordBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, |
| 1579 | VkDeviceSize memoryOffset, VkResult result) { |
| 1580 | if (VK_SUCCESS != result) return; |
| 1581 | UpdateBindBufferMemoryState(buffer, mem, memoryOffset); |
| 1582 | } |
| 1583 | |
| 1584 | void ValidationStateTracker::PostCallRecordBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1585 | const VkBindBufferMemoryInfo *pBindInfos, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1586 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 1587 | UpdateBindBufferMemoryState(pBindInfos[i].buffer, pBindInfos[i].memory, pBindInfos[i].memoryOffset); |
| 1588 | } |
| 1589 | } |
| 1590 | |
| 1591 | void ValidationStateTracker::PostCallRecordBindBufferMemory2KHR(VkDevice device, uint32_t bindInfoCount, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1592 | const VkBindBufferMemoryInfo *pBindInfos, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1593 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 1594 | UpdateBindBufferMemoryState(pBindInfos[i].buffer, pBindInfos[i].memory, pBindInfos[i].memoryOffset); |
| 1595 | } |
| 1596 | } |
| 1597 | |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1598 | void ValidationStateTracker::RecordGetBufferMemoryRequirementsState(VkBuffer buffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1599 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1600 | if (buffer_state) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1601 | buffer_state->memory_requirements_checked = true; |
| 1602 | } |
| 1603 | } |
| 1604 | |
| 1605 | void ValidationStateTracker::PostCallRecordGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, |
| 1606 | VkMemoryRequirements *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1607 | RecordGetBufferMemoryRequirementsState(buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1608 | } |
| 1609 | |
| 1610 | void ValidationStateTracker::PostCallRecordGetBufferMemoryRequirements2(VkDevice device, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1611 | const VkBufferMemoryRequirementsInfo2 *pInfo, |
| 1612 | VkMemoryRequirements2 *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1613 | RecordGetBufferMemoryRequirementsState(pInfo->buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | void ValidationStateTracker::PostCallRecordGetBufferMemoryRequirements2KHR(VkDevice device, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1617 | const VkBufferMemoryRequirementsInfo2 *pInfo, |
| 1618 | VkMemoryRequirements2 *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1619 | RecordGetBufferMemoryRequirementsState(pInfo->buffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1620 | } |
| 1621 | |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1622 | void ValidationStateTracker::RecordGetImageMemoryRequirementsState(VkImage image, const VkImageMemoryRequirementsInfo2 *pInfo) { |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1623 | const VkImagePlaneMemoryRequirementsInfo *plane_info = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1624 | (pInfo == nullptr) ? nullptr : LvlFindInChain<VkImagePlaneMemoryRequirementsInfo>(pInfo->pNext); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1625 | auto image_state = Get<IMAGE_STATE>(image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1626 | if (image_state) { |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1627 | if (plane_info != nullptr) { |
| 1628 | // Multi-plane image |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1629 | if (plane_info->planeAspect == VK_IMAGE_ASPECT_PLANE_0_BIT) { |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1630 | image_state->memory_requirements_checked[0] = true; |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1631 | } else if (plane_info->planeAspect == VK_IMAGE_ASPECT_PLANE_1_BIT) { |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1632 | image_state->memory_requirements_checked[1] = true; |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1633 | } else if (plane_info->planeAspect == VK_IMAGE_ASPECT_PLANE_2_BIT) { |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1634 | image_state->memory_requirements_checked[2] = true; |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1635 | } |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1636 | } else if (!image_state->disjoint) { |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1637 | // Single Plane image |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 1638 | image_state->memory_requirements_checked[0] = true; |
sfricke-samsung | d7ea5de | 2020-04-08 09:19:18 -0700 | [diff] [blame] | 1639 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | void ValidationStateTracker::PostCallRecordGetImageMemoryRequirements(VkDevice device, VkImage image, |
| 1644 | VkMemoryRequirements *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1645 | RecordGetImageMemoryRequirementsState(image, nullptr); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | void ValidationStateTracker::PostCallRecordGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2 *pInfo, |
| 1649 | VkMemoryRequirements2 *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1650 | RecordGetImageMemoryRequirementsState(pInfo->image, pInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | void ValidationStateTracker::PostCallRecordGetImageMemoryRequirements2KHR(VkDevice device, |
| 1654 | const VkImageMemoryRequirementsInfo2 *pInfo, |
| 1655 | VkMemoryRequirements2 *pMemoryRequirements) { |
Spencer Fricke | 6c12710 | 2020-04-16 06:25:20 -0700 | [diff] [blame] | 1656 | RecordGetImageMemoryRequirementsState(pInfo->image, pInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1657 | } |
| 1658 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1659 | void ValidationStateTracker::PostCallRecordGetImageSparseMemoryRequirements( |
| 1660 | VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, |
| 1661 | VkSparseImageMemoryRequirements *pSparseMemoryRequirements) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1662 | auto image_state = Get<IMAGE_STATE>(image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1663 | image_state->get_sparse_reqs_called = true; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1664 | } |
| 1665 | |
| 1666 | void ValidationStateTracker::PostCallRecordGetImageSparseMemoryRequirements2( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1667 | VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo, uint32_t *pSparseMemoryRequirementCount, |
| 1668 | VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1669 | auto image_state = Get<IMAGE_STATE>(pInfo->image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1670 | image_state->get_sparse_reqs_called = true; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1671 | } |
| 1672 | |
| 1673 | void ValidationStateTracker::PostCallRecordGetImageSparseMemoryRequirements2KHR( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1674 | VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo, uint32_t *pSparseMemoryRequirementCount, |
| 1675 | VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1676 | auto image_state = Get<IMAGE_STATE>(pInfo->image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1677 | image_state->get_sparse_reqs_called = true; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1678 | } |
| 1679 | |
| 1680 | void ValidationStateTracker::PreCallRecordDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, |
| 1681 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1682 | Destroy<SHADER_MODULE_STATE>(shaderModule); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1683 | } |
| 1684 | |
| 1685 | void ValidationStateTracker::PreCallRecordDestroyPipeline(VkDevice device, VkPipeline pipeline, |
| 1686 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1687 | Destroy<PIPELINE_STATE>(pipeline); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | void ValidationStateTracker::PreCallRecordDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, |
| 1691 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1692 | Destroy<PIPELINE_LAYOUT_STATE>(pipelineLayout); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1693 | } |
| 1694 | |
| 1695 | void ValidationStateTracker::PreCallRecordDestroySampler(VkDevice device, VkSampler sampler, |
| 1696 | const VkAllocationCallbacks *pAllocator) { |
| 1697 | if (!sampler) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1698 | auto sampler_state = Get<SAMPLER_STATE>(sampler); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1699 | // Any bound cmd buffers are now invalid |
| 1700 | if (sampler_state) { |
Yuly Novikov | 424cdd5 | 2020-05-26 16:45:12 -0400 | [diff] [blame] | 1701 | if (sampler_state->createInfo.borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 1702 | sampler_state->createInfo.borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 1703 | custom_border_color_sampler_count--; |
| 1704 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1705 | } |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1706 | Destroy<SAMPLER_STATE>(sampler); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | void ValidationStateTracker::PreCallRecordDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, |
| 1710 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1711 | Destroy<cvdescriptorset::DescriptorSetLayout>(descriptorSetLayout); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | void ValidationStateTracker::PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 1715 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1716 | Destroy<DESCRIPTOR_POOL_STATE>(descriptorPool); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1717 | } |
| 1718 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1719 | void ValidationStateTracker::PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 1720 | uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 1721 | auto pool = Get<COMMAND_POOL_STATE>(commandPool); |
| 1722 | if (pool) { |
| 1723 | pool->Free(commandBufferCount, pCommandBuffers); |
| 1724 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | void ValidationStateTracker::PostCallRecordCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
| 1728 | const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool, |
| 1729 | VkResult result) { |
| 1730 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 1731 | auto queue_flags = physical_device_state->queue_family_properties[pCreateInfo->queueFamilyIndex].queueFlags; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1732 | Add(std::make_shared<COMMAND_POOL_STATE>(this, *pCommandPool, pCreateInfo, queue_flags)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1733 | } |
| 1734 | |
| 1735 | void ValidationStateTracker::PostCallRecordCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
| 1736 | const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool, |
| 1737 | VkResult result) { |
| 1738 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | e9206ee | 2021-06-02 12:44:41 -0600 | [diff] [blame] | 1739 | |
| 1740 | uint32_t index_count = 0, n_perf_pass = 0; |
| 1741 | bool has_cb = false, has_rb = false; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1742 | if (pCreateInfo->queryType == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 1743 | const auto *perf = LvlFindInChain<VkQueryPoolPerformanceCreateInfoKHR>(pCreateInfo->pNext); |
Jeremy Gebben | e9206ee | 2021-06-02 12:44:41 -0600 | [diff] [blame] | 1744 | index_count = perf->counterIndexCount; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1745 | |
Mark Lobodzinski | 7e948e4 | 2020-09-09 10:23:36 -0600 | [diff] [blame] | 1746 | const QUEUE_FAMILY_PERF_COUNTERS &counters = *physical_device_state->perf_counters[perf->queueFamilyIndex]; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1747 | for (uint32_t i = 0; i < perf->counterIndexCount; i++) { |
| 1748 | const auto &counter = counters.counters[perf->pCounterIndices[i]]; |
| 1749 | switch (counter.scope) { |
| 1750 | case VK_QUERY_SCOPE_COMMAND_BUFFER_KHR: |
Jeremy Gebben | e9206ee | 2021-06-02 12:44:41 -0600 | [diff] [blame] | 1751 | has_cb = true; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1752 | break; |
| 1753 | case VK_QUERY_SCOPE_RENDER_PASS_KHR: |
Jeremy Gebben | e9206ee | 2021-06-02 12:44:41 -0600 | [diff] [blame] | 1754 | has_rb = true; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1755 | break; |
| 1756 | default: |
| 1757 | break; |
| 1758 | } |
| 1759 | } |
| 1760 | |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 1761 | DispatchGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(physical_device_state->PhysDev(), perf, &n_perf_pass); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 1762 | } |
| 1763 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1764 | Add(std::make_shared<QUERY_POOL_STATE>(*pQueryPool, pCreateInfo, index_count, n_perf_pass, has_cb, has_rb)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1765 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1766 | } |
| 1767 | |
| 1768 | void ValidationStateTracker::PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 1769 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1770 | Destroy<COMMAND_POOL_STATE>(commandPool); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1771 | } |
| 1772 | |
| 1773 | void ValidationStateTracker::PostCallRecordResetCommandPool(VkDevice device, VkCommandPool commandPool, |
| 1774 | VkCommandPoolResetFlags flags, VkResult result) { |
| 1775 | if (VK_SUCCESS != result) return; |
| 1776 | // Reset all of the CBs allocated from this pool |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 1777 | auto pool = Get<COMMAND_POOL_STATE>(commandPool); |
| 1778 | if (pool) { |
| 1779 | pool->Reset(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1780 | } |
| 1781 | } |
| 1782 | |
| 1783 | void ValidationStateTracker::PostCallRecordResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, |
| 1784 | VkResult result) { |
| 1785 | for (uint32_t i = 0; i < fenceCount; ++i) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1786 | auto fence_state = Get<FENCE_STATE>(pFences[i]); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1787 | if (fence_state) { |
| 1788 | if (fence_state->scope == kSyncScopeInternal) { |
| 1789 | fence_state->state = FENCE_UNSIGNALED; |
| 1790 | } else if (fence_state->scope == kSyncScopeExternalTemporary) { |
| 1791 | fence_state->scope = kSyncScopeInternal; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1792 | } |
| 1793 | } |
| 1794 | } |
| 1795 | } |
| 1796 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1797 | void ValidationStateTracker::PreCallRecordDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, |
| 1798 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1799 | Destroy<FRAMEBUFFER_STATE>(framebuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | void ValidationStateTracker::PreCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 1803 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1804 | Destroy<RENDER_PASS_STATE>(renderPass); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1805 | } |
| 1806 | |
| 1807 | void ValidationStateTracker::PostCallRecordCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, |
| 1808 | const VkAllocationCallbacks *pAllocator, VkFence *pFence, VkResult result) { |
| 1809 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1810 | Add(std::make_shared<FENCE_STATE>(*pFence, pCreateInfo)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1811 | } |
| 1812 | |
| 1813 | bool ValidationStateTracker::PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, |
| 1814 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1815 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1816 | void *cgpl_state_data) const { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1817 | // Set up the state that CoreChecks, gpu_validation and later StateTracker Record will use. |
| 1818 | create_graphics_pipeline_api_state *cgpl_state = reinterpret_cast<create_graphics_pipeline_api_state *>(cgpl_state_data); |
| 1819 | cgpl_state->pCreateInfos = pCreateInfos; // GPU validation can alter this, so we have to set a default value for the Chassis |
| 1820 | cgpl_state->pipe_state.reserve(count); |
| 1821 | for (uint32_t i = 0; i < count; i++) { |
Jeremy Gebben | ce23dac | 2021-11-10 10:19:42 -0700 | [diff] [blame] | 1822 | if (pCreateInfos[i].renderPass != VK_NULL_HANDLE) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1823 | cgpl_state->pipe_state.push_back(std::make_shared<PIPELINE_STATE>(this, &pCreateInfos[i], |
| 1824 | Get<RENDER_PASS_STATE>(pCreateInfos[i].renderPass), |
| 1825 | Get<PIPELINE_LAYOUT_STATE>(pCreateInfos[i].layout))); |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 1826 | } else if (enabled_features.dynamic_rendering_features.dynamicRendering) { |
| 1827 | auto dynamic_rendering = LvlFindInChain<VkPipelineRenderingCreateInfoKHR>(pCreateInfos[i].pNext); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1828 | cgpl_state->pipe_state.push_back( |
| 1829 | std::make_shared<PIPELINE_STATE>(this, &pCreateInfos[i], std::make_shared<RENDER_PASS_STATE>(dynamic_rendering), |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1830 | Get<PIPELINE_LAYOUT_STATE>(pCreateInfos[i].layout))); |
Jeremy Gebben | ce23dac | 2021-11-10 10:19:42 -0700 | [diff] [blame] | 1831 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1832 | } |
| 1833 | return false; |
| 1834 | } |
| 1835 | |
| 1836 | void ValidationStateTracker::PostCallRecordCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, |
| 1837 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1838 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines, |
| 1839 | VkResult result, void *cgpl_state_data) { |
| 1840 | create_graphics_pipeline_api_state *cgpl_state = reinterpret_cast<create_graphics_pipeline_api_state *>(cgpl_state_data); |
| 1841 | // This API may create pipelines regardless of the return value |
| 1842 | for (uint32_t i = 0; i < count; i++) { |
| 1843 | if (pPipelines[i] != VK_NULL_HANDLE) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1844 | (cgpl_state->pipe_state)[i]->SetHandle(pPipelines[i]); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1845 | Add(std::move((cgpl_state->pipe_state)[i])); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1846 | } |
| 1847 | } |
| 1848 | cgpl_state->pipe_state.clear(); |
| 1849 | } |
| 1850 | |
| 1851 | bool ValidationStateTracker::PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, |
| 1852 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 1853 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1854 | void *ccpl_state_data) const { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1855 | auto *ccpl_state = reinterpret_cast<create_compute_pipeline_api_state *>(ccpl_state_data); |
| 1856 | ccpl_state->pCreateInfos = pCreateInfos; // GPU validation can alter this, so we have to set a default value for the Chassis |
| 1857 | ccpl_state->pipe_state.reserve(count); |
| 1858 | for (uint32_t i = 0; i < count; i++) { |
| 1859 | // Create and initialize internal tracking data structure |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 1860 | ccpl_state->pipe_state.push_back( |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1861 | std::make_shared<PIPELINE_STATE>(this, &pCreateInfos[i], Get<PIPELINE_LAYOUT_STATE>(pCreateInfos[i].layout))); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1862 | } |
| 1863 | return false; |
| 1864 | } |
| 1865 | |
| 1866 | void ValidationStateTracker::PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, |
| 1867 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 1868 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines, |
| 1869 | VkResult result, void *ccpl_state_data) { |
| 1870 | create_compute_pipeline_api_state *ccpl_state = reinterpret_cast<create_compute_pipeline_api_state *>(ccpl_state_data); |
| 1871 | |
| 1872 | // This API may create pipelines regardless of the return value |
| 1873 | for (uint32_t i = 0; i < count; i++) { |
| 1874 | if (pPipelines[i] != VK_NULL_HANDLE) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1875 | (ccpl_state->pipe_state)[i]->SetHandle(pPipelines[i]); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1876 | Add(std::move((ccpl_state->pipe_state)[i])); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1877 | } |
| 1878 | } |
| 1879 | ccpl_state->pipe_state.clear(); |
| 1880 | } |
| 1881 | |
| 1882 | bool ValidationStateTracker::PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 1883 | uint32_t count, |
| 1884 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 1885 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1886 | VkPipeline *pPipelines, void *crtpl_state_data) const { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1887 | auto *crtpl_state = reinterpret_cast<create_ray_tracing_pipeline_api_state *>(crtpl_state_data); |
| 1888 | crtpl_state->pipe_state.reserve(count); |
| 1889 | for (uint32_t i = 0; i < count; i++) { |
| 1890 | // Create and initialize internal tracking data structure |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 1891 | crtpl_state->pipe_state.push_back( |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1892 | std::make_shared<PIPELINE_STATE>(this, &pCreateInfos[i], Get<PIPELINE_LAYOUT_STATE>(pCreateInfos[i].layout))); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1893 | } |
| 1894 | return false; |
| 1895 | } |
| 1896 | |
| 1897 | void ValidationStateTracker::PostCallRecordCreateRayTracingPipelinesNV( |
| 1898 | VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 1899 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines, VkResult result, void *crtpl_state_data) { |
| 1900 | auto *crtpl_state = reinterpret_cast<create_ray_tracing_pipeline_api_state *>(crtpl_state_data); |
| 1901 | // This API may create pipelines regardless of the return value |
| 1902 | for (uint32_t i = 0; i < count; i++) { |
| 1903 | if (pPipelines[i] != VK_NULL_HANDLE) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1904 | (crtpl_state->pipe_state)[i]->SetHandle(pPipelines[i]); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1905 | Add(std::move((crtpl_state->pipe_state)[i])); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1906 | } |
| 1907 | } |
| 1908 | crtpl_state->pipe_state.clear(); |
| 1909 | } |
| 1910 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 1911 | bool ValidationStateTracker::PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation, |
| 1912 | VkPipelineCache pipelineCache, uint32_t count, |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1913 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, |
| 1914 | const VkAllocationCallbacks *pAllocator, |
| 1915 | VkPipeline *pPipelines, void *crtpl_state_data) const { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 1916 | auto crtpl_state = reinterpret_cast<create_ray_tracing_pipeline_khr_api_state *>(crtpl_state_data); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1917 | crtpl_state->pipe_state.reserve(count); |
| 1918 | for (uint32_t i = 0; i < count; i++) { |
| 1919 | // Create and initialize internal tracking data structure |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 1920 | crtpl_state->pipe_state.push_back( |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 1921 | std::make_shared<PIPELINE_STATE>(this, &pCreateInfos[i], Get<PIPELINE_LAYOUT_STATE>(pCreateInfos[i].layout))); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1922 | } |
| 1923 | return false; |
| 1924 | } |
| 1925 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 1926 | void ValidationStateTracker::PostCallRecordCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation, |
| 1927 | VkPipelineCache pipelineCache, uint32_t count, |
| 1928 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, |
| 1929 | const VkAllocationCallbacks *pAllocator, |
| 1930 | VkPipeline *pPipelines, VkResult result, |
| 1931 | void *crtpl_state_data) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1932 | auto *crtpl_state = reinterpret_cast<create_ray_tracing_pipeline_khr_api_state *>(crtpl_state_data); |
| 1933 | // This API may create pipelines regardless of the return value |
| 1934 | for (uint32_t i = 0; i < count; i++) { |
| 1935 | if (pPipelines[i] != VK_NULL_HANDLE) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 1936 | (crtpl_state->pipe_state)[i]->SetHandle(pPipelines[i]); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1937 | Add(std::move((crtpl_state->pipe_state)[i])); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 1938 | } |
| 1939 | } |
| 1940 | crtpl_state->pipe_state.clear(); |
| 1941 | } |
| 1942 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1943 | void ValidationStateTracker::PostCallRecordCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
| 1944 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler, |
| 1945 | VkResult result) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1946 | Add(std::make_shared<SAMPLER_STATE>(pSampler, pCreateInfo)); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1947 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 1948 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 1949 | custom_border_color_sampler_count++; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1950 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | void ValidationStateTracker::PostCallRecordCreateDescriptorSetLayout(VkDevice device, |
| 1954 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1955 | const VkAllocationCallbacks *pAllocator, |
| 1956 | VkDescriptorSetLayout *pSetLayout, VkResult result) { |
| 1957 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1958 | Add(std::make_shared<cvdescriptorset::DescriptorSetLayout>(pCreateInfo, *pSetLayout)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1959 | } |
| 1960 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1961 | void ValidationStateTracker::PostCallRecordCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, |
| 1962 | const VkAllocationCallbacks *pAllocator, |
| 1963 | VkPipelineLayout *pPipelineLayout, VkResult result) { |
| 1964 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1965 | Add(std::make_shared<PIPELINE_LAYOUT_STATE>(this, *pPipelineLayout, pCreateInfo)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1966 | } |
| 1967 | |
| 1968 | void ValidationStateTracker::PostCallRecordCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
| 1969 | const VkAllocationCallbacks *pAllocator, |
| 1970 | VkDescriptorPool *pDescriptorPool, VkResult result) { |
| 1971 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 1972 | Add(std::make_shared<DESCRIPTOR_POOL_STATE>(this, *pDescriptorPool, pCreateInfo)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1973 | } |
| 1974 | |
| 1975 | void ValidationStateTracker::PostCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 1976 | VkDescriptorPoolResetFlags flags, VkResult result) { |
| 1977 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 1fbebb8 | 2021-10-27 10:27:27 -0600 | [diff] [blame] | 1978 | auto pool = Get<DESCRIPTOR_POOL_STATE>(descriptorPool); |
| 1979 | if (pool) { |
| 1980 | pool->Reset(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1981 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1982 | } |
| 1983 | |
| 1984 | bool ValidationStateTracker::PreCallValidateAllocateDescriptorSets(VkDevice device, |
| 1985 | const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1986 | VkDescriptorSet *pDescriptorSets, void *ads_state_data) const { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 1987 | // Always update common data |
| 1988 | cvdescriptorset::AllocateDescriptorSetsData *ads_state = |
| 1989 | reinterpret_cast<cvdescriptorset::AllocateDescriptorSetsData *>(ads_state_data); |
| 1990 | UpdateAllocateDescriptorSetsData(pAllocateInfo, ads_state); |
| 1991 | |
| 1992 | return false; |
| 1993 | } |
| 1994 | |
| 1995 | // Allocation state was good and call down chain was made so update state based on allocating descriptor sets |
| 1996 | void ValidationStateTracker::PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 1997 | VkDescriptorSet *pDescriptorSets, VkResult result, |
| 1998 | void *ads_state_data) { |
| 1999 | if (VK_SUCCESS != result) return; |
| 2000 | // All the updates are contained in a single cvdescriptorset function |
| 2001 | cvdescriptorset::AllocateDescriptorSetsData *ads_state = |
| 2002 | reinterpret_cast<cvdescriptorset::AllocateDescriptorSetsData *>(ads_state_data); |
Jeremy Gebben | 1fbebb8 | 2021-10-27 10:27:27 -0600 | [diff] [blame] | 2003 | auto pool_state = Get<DESCRIPTOR_POOL_STATE>(pAllocateInfo->descriptorPool); |
| 2004 | if (pool_state) { |
| 2005 | pool_state->Allocate(pAllocateInfo, pDescriptorSets, ads_state); |
| 2006 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2007 | } |
| 2008 | |
| 2009 | void ValidationStateTracker::PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, |
| 2010 | const VkDescriptorSet *pDescriptorSets) { |
Jeremy Gebben | 1fbebb8 | 2021-10-27 10:27:27 -0600 | [diff] [blame] | 2011 | auto pool_state = Get<DESCRIPTOR_POOL_STATE>(descriptorPool); |
| 2012 | if (pool_state) { |
| 2013 | pool_state->Free(count, pDescriptorSets); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2014 | } |
| 2015 | } |
| 2016 | |
| 2017 | void ValidationStateTracker::PreCallRecordUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 2018 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 2019 | uint32_t descriptorCopyCount, |
| 2020 | const VkCopyDescriptorSet *pDescriptorCopies) { |
| 2021 | cvdescriptorset::PerformUpdateDescriptorSets(this, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, |
| 2022 | pDescriptorCopies); |
| 2023 | } |
| 2024 | |
| 2025 | void ValidationStateTracker::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pCreateInfo, |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 2026 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2027 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2028 | auto pool = Get<COMMAND_POOL_STATE>(pCreateInfo->commandPool); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2029 | if (pool) { |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 2030 | pool->Allocate(pCreateInfo, pCommandBuffers); |
locke-lunarg | fc78e93 | 2020-11-19 17:06:24 -0700 | [diff] [blame] | 2031 | } |
| 2032 | } |
| 2033 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2034 | void ValidationStateTracker::PreCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, |
| 2035 | const VkCommandBufferBeginInfo *pBeginInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2036 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2037 | if (!cb_state) return; |
locke-lunarg | fc78e93 | 2020-11-19 17:06:24 -0700 | [diff] [blame] | 2038 | |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2039 | cb_state->Begin(pBeginInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2040 | } |
| 2041 | |
| 2042 | void ValidationStateTracker::PostCallRecordEndCommandBuffer(VkCommandBuffer commandBuffer, VkResult result) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2043 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2044 | if (!cb_state) return; |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2045 | |
| 2046 | cb_state->End(result); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | void ValidationStateTracker::PostCallRecordResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags, |
| 2050 | VkResult result) { |
| 2051 | if (VK_SUCCESS == result) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2052 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2053 | cb_state->Reset(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2054 | } |
| 2055 | } |
| 2056 | |
| 2057 | CBStatusFlags MakeStaticStateMask(VkPipelineDynamicStateCreateInfo const *ds) { |
| 2058 | // initially assume everything is static state |
| 2059 | CBStatusFlags flags = CBSTATUS_ALL_STATE_SET; |
| 2060 | |
| 2061 | if (ds) { |
| 2062 | for (uint32_t i = 0; i < ds->dynamicStateCount; i++) { |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 2063 | flags &= ~ConvertToCBStatusFlagBits(ds->pDynamicStates[i]); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2064 | } |
| 2065 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2066 | return flags; |
| 2067 | } |
| 2068 | |
| 2069 | // Validation cache: |
| 2070 | // CV is the bottommost implementor of this extension. Don't pass calls down. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2071 | |
| 2072 | void ValidationStateTracker::PreCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 2073 | VkPipeline pipeline) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2074 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2075 | assert(cb_state); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2076 | cb_state->RecordCmd(CMD_BINDPIPELINE); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2077 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2078 | auto pipe_state = Get<PIPELINE_STATE>(pipeline); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2079 | if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) { |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 2080 | const auto &create_info = pipe_state->create_info.graphics; |
| 2081 | bool rasterization_enabled = VK_FALSE == create_info.pRasterizationState->rasterizerDiscardEnable; |
| 2082 | const auto *viewport_state = create_info.pViewportState; |
| 2083 | const auto *dynamic_state = create_info.pDynamicState; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2084 | cb_state->status &= ~cb_state->static_status; |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 2085 | cb_state->static_status = MakeStaticStateMask(dynamic_state->ptr()); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2086 | cb_state->status |= cb_state->static_status; |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 2087 | cb_state->dynamic_status = CBSTATUS_ALL_STATE_SET & (~cb_state->static_status); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2088 | |
| 2089 | // Used to calculate CMD_BUFFER_STATE::usedViewportScissorCount upon draw command with this graphics pipeline. |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2090 | // If rasterization disabled (no viewport/scissors used), or the actual number of viewports/scissors is dynamic (unknown at |
| 2091 | // this time), then these are set to 0 to disable this checking. |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2092 | auto has_dynamic_viewport_count = cb_state->dynamic_status & CBSTATUS_VIEWPORT_WITH_COUNT_SET; |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2093 | auto has_dynamic_scissor_count = cb_state->dynamic_status & CBSTATUS_SCISSOR_WITH_COUNT_SET; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2094 | cb_state->pipelineStaticViewportCount = |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2095 | has_dynamic_viewport_count || !rasterization_enabled ? 0 : viewport_state->viewportCount; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2096 | cb_state->pipelineStaticScissorCount = |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2097 | has_dynamic_scissor_count || !rasterization_enabled ? 0 : viewport_state->scissorCount; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2098 | |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2099 | // Trash dynamic viewport/scissor state if pipeline defines static state and enabled rasterization. |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2100 | // akeley98 NOTE: There's a bit of an ambiguity in the spec, whether binding such a pipeline overwrites |
| 2101 | // the entire viewport (scissor) array, or only the subsection defined by the viewport (scissor) count. |
| 2102 | // I am taking the latter interpretation based on the implementation details of NVIDIA's Vulkan driver. |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2103 | if (!has_dynamic_viewport_count) { |
| 2104 | cb_state->trashedViewportCount = true; |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2105 | if (rasterization_enabled && (cb_state->static_status & CBSTATUS_VIEWPORT_SET)) { |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2106 | cb_state->trashedViewportMask |= (uint32_t(1) << viewport_state->viewportCount) - 1u; |
| 2107 | // should become = ~uint32_t(0) if the other interpretation is correct. |
| 2108 | } |
| 2109 | } |
| 2110 | if (!has_dynamic_scissor_count) { |
| 2111 | cb_state->trashedScissorCount = true; |
David Zhao Akeley | 5f40eb7 | 2021-05-04 21:56:14 -0700 | [diff] [blame] | 2112 | if (rasterization_enabled && (cb_state->static_status & CBSTATUS_SCISSOR_SET)) { |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2113 | cb_state->trashedScissorMask |= (uint32_t(1) << viewport_state->scissorCount) - 1u; |
| 2114 | // should become = ~uint32_t(0) if the other interpretation is correct. |
| 2115 | } |
| 2116 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2117 | } |
locke-lunarg | b8d7a7a | 2020-10-25 16:01:52 -0600 | [diff] [blame] | 2118 | const auto lv_bind_point = ConvertToLvlBindPoint(pipelineBindPoint); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2119 | cb_state->lastBound[lv_bind_point].pipeline_state = pipe_state.get(); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2120 | if (!disabled[command_buffer_state]) { |
| 2121 | cb_state->AddChild(pipe_state); |
| 2122 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2123 | } |
| 2124 | |
| 2125 | void ValidationStateTracker::PreCallRecordCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 2126 | uint32_t viewportCount, const VkViewport *pViewports) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2127 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2128 | cb_state->RecordStateCmd(CMD_SETVIEWPORT, CBSTATUS_VIEWPORT_SET); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2129 | uint32_t bits = ((1u << viewportCount) - 1u) << firstViewport; |
| 2130 | cb_state->viewportMask |= bits; |
| 2131 | cb_state->trashedViewportMask &= ~bits; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2132 | |
| 2133 | cb_state->dynamicViewports.resize(std::max(size_t(firstViewport + viewportCount), cb_state->dynamicViewports.size())); |
| 2134 | for (size_t i = 0; i < viewportCount; ++i) { |
| 2135 | cb_state->dynamicViewports[firstViewport + i] = pViewports[i]; |
| 2136 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2137 | } |
| 2138 | |
| 2139 | void ValidationStateTracker::PreCallRecordCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, |
| 2140 | uint32_t exclusiveScissorCount, |
| 2141 | const VkRect2D *pExclusiveScissors) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2142 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2143 | cb_state->RecordStateCmd(CMD_SETEXCLUSIVESCISSORNV, CBSTATUS_EXCLUSIVE_SCISSOR_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2144 | // TODO: We don't have VUIDs for validating that all exclusive scissors have been set. |
| 2145 | // cb_state->exclusiveScissorMask |= ((1u << exclusiveScissorCount) - 1u) << firstExclusiveScissor; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2146 | } |
| 2147 | |
| 2148 | void ValidationStateTracker::PreCallRecordCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer, VkImageView imageView, |
| 2149 | VkImageLayout imageLayout) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2150 | if (disabled[command_buffer_state]) return; |
| 2151 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2152 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2153 | cb_state->RecordCmd(CMD_BINDSHADINGRATEIMAGENV); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2154 | |
| 2155 | if (imageView != VK_NULL_HANDLE) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2156 | auto view_state = Get<IMAGE_VIEW_STATE>(imageView); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2157 | cb_state->AddChild(view_state); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | void ValidationStateTracker::PreCallRecordCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 2162 | uint32_t viewportCount, |
| 2163 | const VkShadingRatePaletteNV *pShadingRatePalettes) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2164 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2165 | cb_state->RecordStateCmd(CMD_SETVIEWPORTSHADINGRATEPALETTENV, CBSTATUS_SHADING_RATE_PALETTE_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2166 | // TODO: We don't have VUIDs for validating that all shading rate palettes have been set. |
| 2167 | // cb_state->shadingRatePaletteMask |= ((1u << viewportCount) - 1u) << firstViewport; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2168 | } |
| 2169 | |
| 2170 | void ValidationStateTracker::PostCallRecordCreateAccelerationStructureNV(VkDevice device, |
| 2171 | const VkAccelerationStructureCreateInfoNV *pCreateInfo, |
| 2172 | const VkAllocationCallbacks *pAllocator, |
| 2173 | VkAccelerationStructureNV *pAccelerationStructure, |
| 2174 | VkResult result) { |
| 2175 | if (VK_SUCCESS != result) return; |
Jeff Bolz | e7fc67b | 2019-10-04 12:29:31 -0500 | [diff] [blame] | 2176 | auto as_state = std::make_shared<ACCELERATION_STRUCTURE_STATE>(*pAccelerationStructure, pCreateInfo); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2177 | |
| 2178 | // Query the requirements in case the application doesn't (to avoid bind/validation time query) |
Nathaniel Cesario | fc6291e | 2021-04-06 00:22:15 -0600 | [diff] [blame] | 2179 | auto as_memory_requirements_info = LvlInitStruct<VkAccelerationStructureMemoryRequirementsInfoNV>(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2180 | as_memory_requirements_info.type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV; |
Jeremy Gebben | 14b0d1a | 2021-05-15 20:15:41 -0600 | [diff] [blame] | 2181 | as_memory_requirements_info.accelerationStructure = as_state->acceleration_structure(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2182 | DispatchGetAccelerationStructureMemoryRequirementsNV(device, &as_memory_requirements_info, &as_state->memory_requirements); |
| 2183 | |
Nathaniel Cesario | fc6291e | 2021-04-06 00:22:15 -0600 | [diff] [blame] | 2184 | auto scratch_memory_req_info = LvlInitStruct<VkAccelerationStructureMemoryRequirementsInfoNV>(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2185 | scratch_memory_req_info.type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV; |
Jeremy Gebben | 14b0d1a | 2021-05-15 20:15:41 -0600 | [diff] [blame] | 2186 | scratch_memory_req_info.accelerationStructure = as_state->acceleration_structure(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2187 | DispatchGetAccelerationStructureMemoryRequirementsNV(device, &scratch_memory_req_info, |
| 2188 | &as_state->build_scratch_memory_requirements); |
| 2189 | |
Nathaniel Cesario | fc6291e | 2021-04-06 00:22:15 -0600 | [diff] [blame] | 2190 | auto update_memory_req_info = LvlInitStruct<VkAccelerationStructureMemoryRequirementsInfoNV>(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2191 | update_memory_req_info.type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV; |
Jeremy Gebben | 14b0d1a | 2021-05-15 20:15:41 -0600 | [diff] [blame] | 2192 | update_memory_req_info.accelerationStructure = as_state->acceleration_structure(); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2193 | DispatchGetAccelerationStructureMemoryRequirementsNV(device, &update_memory_req_info, |
| 2194 | &as_state->update_scratch_memory_requirements); |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 2195 | as_state->allocator = pAllocator; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2196 | Add(std::move(as_state)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2197 | } |
| 2198 | |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2199 | void ValidationStateTracker::PostCallRecordCreateAccelerationStructureKHR(VkDevice device, |
| 2200 | const VkAccelerationStructureCreateInfoKHR *pCreateInfo, |
| 2201 | const VkAllocationCallbacks *pAllocator, |
| 2202 | VkAccelerationStructureKHR *pAccelerationStructure, |
| 2203 | VkResult result) { |
| 2204 | if (VK_SUCCESS != result) return; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2205 | auto as_state = std::make_shared<ACCELERATION_STRUCTURE_STATE_KHR>(*pAccelerationStructure, pCreateInfo); |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 2206 | as_state->allocator = pAllocator; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2207 | Add(std::move(as_state)); |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2208 | } |
| 2209 | |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 2210 | void ValidationStateTracker::PostCallRecordBuildAccelerationStructuresKHR( |
| 2211 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 2212 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 2213 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos, VkResult result) { |
| 2214 | for (uint32_t i = 0; i < infoCount; ++i) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2215 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfos[i].dstAccelerationStructure); |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 2216 | if (dst_as_state != nullptr) { |
| 2217 | dst_as_state->Build(&pInfos[i]); |
| 2218 | } |
| 2219 | } |
| 2220 | } |
| 2221 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2222 | void ValidationStateTracker::PostCallRecordCmdBuildAccelerationStructuresKHR( |
| 2223 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 2224 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2225 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2226 | if (!cb_state) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2227 | return; |
| 2228 | } |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2229 | cb_state->RecordCmd(CMD_BUILDACCELERATIONSTRUCTURESKHR); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2230 | for (uint32_t i = 0; i < infoCount; ++i) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2231 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfos[i].dstAccelerationStructure); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2232 | if (dst_as_state != nullptr) { |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 2233 | dst_as_state->Build(&pInfos[i]); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2234 | if (!disabled[command_buffer_state]) { |
| 2235 | cb_state->AddChild(dst_as_state); |
| 2236 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2237 | } |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2238 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2239 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfos[i].srcAccelerationStructure); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2240 | if (src_as_state != nullptr) { |
| 2241 | cb_state->AddChild(src_as_state); |
| 2242 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2243 | } |
| 2244 | } |
| 2245 | cb_state->hasBuildAccelerationStructureCmd = true; |
| 2246 | } |
| 2247 | |
| 2248 | void ValidationStateTracker::PostCallRecordCmdBuildAccelerationStructuresIndirectKHR( |
| 2249 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 2250 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 2251 | const uint32_t *const *ppMaxPrimitiveCounts) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2252 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2253 | if (cb_state == nullptr) { |
| 2254 | return; |
| 2255 | } |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2256 | cb_state->RecordCmd(CMD_BUILDACCELERATIONSTRUCTURESINDIRECTKHR); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2257 | for (uint32_t i = 0; i < infoCount; ++i) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2258 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfos[i].dstAccelerationStructure); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2259 | if (dst_as_state != nullptr) { |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 2260 | dst_as_state->Build(&pInfos[i]); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2261 | if (!disabled[command_buffer_state]) { |
| 2262 | cb_state->AddChild(dst_as_state); |
| 2263 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2264 | } |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2265 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2266 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfos[i].srcAccelerationStructure); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2267 | if (src_as_state != nullptr) { |
| 2268 | cb_state->AddChild(src_as_state); |
| 2269 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2270 | } |
| 2271 | } |
| 2272 | cb_state->hasBuildAccelerationStructureCmd = true; |
| 2273 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2274 | void ValidationStateTracker::PostCallRecordGetAccelerationStructureMemoryRequirementsNV( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2275 | VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoNV *pInfo, VkMemoryRequirements2 *pMemoryRequirements) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2276 | auto as_state = Get<ACCELERATION_STRUCTURE_STATE>(pInfo->accelerationStructure); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2277 | if (as_state != nullptr) { |
| 2278 | if (pInfo->type == VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV) { |
| 2279 | as_state->memory_requirements = *pMemoryRequirements; |
| 2280 | as_state->memory_requirements_checked = true; |
| 2281 | } else if (pInfo->type == VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV) { |
| 2282 | as_state->build_scratch_memory_requirements = *pMemoryRequirements; |
| 2283 | as_state->build_scratch_memory_requirements_checked = true; |
| 2284 | } else if (pInfo->type == VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV) { |
| 2285 | as_state->update_scratch_memory_requirements = *pMemoryRequirements; |
| 2286 | as_state->update_scratch_memory_requirements_checked = true; |
| 2287 | } |
| 2288 | } |
| 2289 | } |
| 2290 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2291 | void ValidationStateTracker::PostCallRecordBindAccelerationStructureMemoryNV( |
| 2292 | VkDevice device, uint32_t bindInfoCount, const VkBindAccelerationStructureMemoryInfoNV *pBindInfos, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2293 | if (VK_SUCCESS != result) return; |
| 2294 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2295 | const VkBindAccelerationStructureMemoryInfoNV &info = pBindInfos[i]; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2296 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2297 | auto as_state = Get<ACCELERATION_STRUCTURE_STATE>(info.accelerationStructure); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2298 | if (as_state) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2299 | // Track objects tied to memory |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2300 | auto mem_state = Get<DEVICE_MEMORY_STATE>(info.memory); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2301 | if (mem_state) { |
| 2302 | as_state->SetMemBinding(mem_state, info.memoryOffset); |
| 2303 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2304 | |
| 2305 | // GPU validation of top level acceleration structure building needs acceleration structure handles. |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2306 | // XXX TODO: Query device address for KHR extension |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2307 | if (enabled[gpu_validation]) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2308 | DispatchGetAccelerationStructureHandleNV(device, info.accelerationStructure, 8, &as_state->opaque_handle); |
| 2309 | } |
| 2310 | } |
| 2311 | } |
| 2312 | } |
| 2313 | |
| 2314 | void ValidationStateTracker::PostCallRecordCmdBuildAccelerationStructureNV( |
| 2315 | VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV *pInfo, VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 2316 | VkBool32 update, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkBuffer scratch, VkDeviceSize scratchOffset) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2317 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2318 | if (cb_state == nullptr) { |
| 2319 | return; |
| 2320 | } |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2321 | cb_state->RecordCmd(CMD_BUILDACCELERATIONSTRUCTURENV); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2322 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2323 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE>(dst); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2324 | if (dst_as_state != nullptr) { |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 2325 | dst_as_state->Build(pInfo); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2326 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2327 | cb_state->AddChild(dst_as_state); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2328 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2329 | } |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2330 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2331 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE>(src); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2332 | if (src_as_state != nullptr) { |
| 2333 | cb_state->AddChild(src_as_state); |
| 2334 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2335 | } |
| 2336 | cb_state->hasBuildAccelerationStructureCmd = true; |
| 2337 | } |
| 2338 | |
| 2339 | void ValidationStateTracker::PostCallRecordCmdCopyAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 2340 | VkAccelerationStructureNV dst, |
| 2341 | VkAccelerationStructureNV src, |
| 2342 | VkCopyAccelerationStructureModeNV mode) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2343 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2344 | if (cb_state) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2345 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE>(src); |
| 2346 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE>(dst); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2347 | if (!disabled[command_buffer_state]) { |
| 2348 | cb_state->RecordTransferCmd(CMD_COPYACCELERATIONSTRUCTURENV, src_as_state, dst_as_state); |
| 2349 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2350 | if (dst_as_state != nullptr && src_as_state != nullptr) { |
| 2351 | dst_as_state->built = true; |
| 2352 | dst_as_state->build_info = src_as_state->build_info; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2353 | } |
| 2354 | } |
| 2355 | } |
| 2356 | |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2357 | void ValidationStateTracker::PreCallRecordDestroyAccelerationStructureKHR(VkDevice device, |
| 2358 | VkAccelerationStructureKHR accelerationStructure, |
| 2359 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2360 | Destroy<ACCELERATION_STRUCTURE_STATE_KHR>(accelerationStructure); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2361 | } |
| 2362 | |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2363 | void ValidationStateTracker::PreCallRecordDestroyAccelerationStructureNV(VkDevice device, |
| 2364 | VkAccelerationStructureNV accelerationStructure, |
| 2365 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2366 | Destroy<ACCELERATION_STRUCTURE_STATE>(accelerationStructure); |
Jeff Bolz | 95176d0 | 2020-04-01 00:36:16 -0500 | [diff] [blame] | 2367 | } |
| 2368 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2369 | void ValidationStateTracker::PreCallRecordCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 2370 | uint32_t viewportCount, |
| 2371 | const VkViewportWScalingNV *pViewportWScalings) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2372 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2373 | cb_state->RecordStateCmd(CMD_SETVIEWPORTWSCALINGNV, CBSTATUS_VIEWPORT_W_SCALING_SET); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2374 | } |
| 2375 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2376 | void ValidationStateTracker::PreCallRecordCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2377 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2378 | cb_state->RecordStateCmd(CMD_SETLINEWIDTH, CBSTATUS_LINE_WIDTH_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2379 | } |
| 2380 | |
| 2381 | void ValidationStateTracker::PreCallRecordCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
| 2382 | uint16_t lineStipplePattern) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2383 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2384 | cb_state->RecordStateCmd(CMD_SETLINESTIPPLEEXT, CBSTATUS_LINE_STIPPLE_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2385 | } |
| 2386 | |
| 2387 | void ValidationStateTracker::PreCallRecordCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, |
| 2388 | float depthBiasClamp, float depthBiasSlopeFactor) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2389 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2390 | cb_state->RecordStateCmd(CMD_SETDEPTHBIAS, CBSTATUS_DEPTH_BIAS_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2391 | } |
| 2392 | |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 2393 | void ValidationStateTracker::PreCallRecordCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, |
| 2394 | const VkRect2D *pScissors) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2395 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2396 | cb_state->RecordStateCmd(CMD_SETSCISSOR, CBSTATUS_SCISSOR_SET); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 2397 | uint32_t bits = ((1u << scissorCount) - 1u) << firstScissor; |
| 2398 | cb_state->scissorMask |= bits; |
| 2399 | cb_state->trashedScissorMask &= ~bits; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 2400 | } |
| 2401 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2402 | void ValidationStateTracker::PreCallRecordCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2403 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2404 | cb_state->RecordStateCmd(CMD_SETBLENDCONSTANTS, CBSTATUS_BLEND_CONSTANTS_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2405 | } |
| 2406 | |
| 2407 | void ValidationStateTracker::PreCallRecordCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, |
| 2408 | float maxDepthBounds) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2409 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2410 | cb_state->RecordStateCmd(CMD_SETDEPTHBOUNDS, CBSTATUS_DEPTH_BOUNDS_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2411 | } |
| 2412 | |
| 2413 | void ValidationStateTracker::PreCallRecordCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, |
| 2414 | uint32_t compareMask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2415 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2416 | cb_state->RecordStateCmd(CMD_SETSTENCILCOMPAREMASK, CBSTATUS_STENCIL_READ_MASK_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2417 | } |
| 2418 | |
| 2419 | void ValidationStateTracker::PreCallRecordCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, |
| 2420 | uint32_t writeMask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2421 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2422 | cb_state->RecordStateCmd(CMD_SETSTENCILWRITEMASK, CBSTATUS_STENCIL_WRITE_MASK_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2423 | } |
| 2424 | |
| 2425 | void ValidationStateTracker::PreCallRecordCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, |
| 2426 | uint32_t reference) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2427 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2428 | cb_state->RecordStateCmd(CMD_SETSTENCILREFERENCE, CBSTATUS_STENCIL_REFERENCE_SET); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2429 | } |
| 2430 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2431 | // Update the bound state for the bind point, including the effects of incompatible pipeline layouts |
| 2432 | void ValidationStateTracker::PreCallRecordCmdBindDescriptorSets(VkCommandBuffer commandBuffer, |
| 2433 | VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, |
| 2434 | uint32_t firstSet, uint32_t setCount, |
| 2435 | const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, |
| 2436 | const uint32_t *pDynamicOffsets) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2437 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2438 | cb_state->RecordCmd(CMD_BINDDESCRIPTORSETS); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2439 | auto pipeline_layout = Get<PIPELINE_LAYOUT_STATE>(layout); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2440 | |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2441 | cb_state->UpdateLastBoundDescriptorSets(pipelineBindPoint, pipeline_layout.get(), firstSet, setCount, pDescriptorSets, nullptr, |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2442 | dynamicOffsetCount, pDynamicOffsets); |
Jeremy Gebben | 5570abe | 2021-05-16 18:35:13 -0600 | [diff] [blame] | 2443 | } |
| 2444 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2445 | void ValidationStateTracker::PreCallRecordCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 2446 | VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, |
| 2447 | uint32_t set, uint32_t descriptorWriteCount, |
| 2448 | const VkWriteDescriptorSet *pDescriptorWrites) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2449 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
| 2450 | auto pipeline_layout = Get<PIPELINE_LAYOUT_STATE>(layout); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2451 | cb_state->PushDescriptorSetState(pipelineBindPoint, pipeline_layout.get(), set, descriptorWriteCount, pDescriptorWrites); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2452 | } |
| 2453 | |
Tony-LunarG | 6bb1d0c | 2019-09-23 10:39:25 -0600 | [diff] [blame] | 2454 | void ValidationStateTracker::PostCallRecordCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, |
| 2455 | VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, |
| 2456 | const void *pValues) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2457 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Tony-LunarG | 6bb1d0c | 2019-09-23 10:39:25 -0600 | [diff] [blame] | 2458 | if (cb_state != nullptr) { |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2459 | cb_state->RecordCmd(CMD_PUSHCONSTANTS); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2460 | auto layout_state = Get<PIPELINE_LAYOUT_STATE>(layout); |
| 2461 | cb_state->ResetPushConstantDataIfIncompatible(layout_state.get()); |
Tony-LunarG | 6bb1d0c | 2019-09-23 10:39:25 -0600 | [diff] [blame] | 2462 | |
| 2463 | auto &push_constant_data = cb_state->push_constant_data; |
| 2464 | assert((offset + size) <= static_cast<uint32_t>(push_constant_data.size())); |
| 2465 | std::memcpy(push_constant_data.data() + offset, pValues, static_cast<std::size_t>(size)); |
locke-lunarg | de3f0fa | 2020-09-10 11:55:31 -0600 | [diff] [blame] | 2466 | cb_state->push_constant_pipeline_layout_set = layout; |
| 2467 | |
| 2468 | auto flags = stageFlags; |
| 2469 | uint32_t bit_shift = 0; |
| 2470 | while (flags) { |
| 2471 | if (flags & 1) { |
| 2472 | VkShaderStageFlagBits flag = static_cast<VkShaderStageFlagBits>(1 << bit_shift); |
| 2473 | const auto it = cb_state->push_constant_data_update.find(flag); |
| 2474 | |
| 2475 | if (it != cb_state->push_constant_data_update.end()) { |
locke-lunarg | 3d8b8f3 | 2020-10-26 17:04:16 -0600 | [diff] [blame] | 2476 | std::memset(it->second.data() + offset, PC_Byte_Updated, static_cast<std::size_t>(size)); |
locke-lunarg | de3f0fa | 2020-09-10 11:55:31 -0600 | [diff] [blame] | 2477 | } |
| 2478 | } |
| 2479 | flags = flags >> 1; |
| 2480 | ++bit_shift; |
| 2481 | } |
Tony-LunarG | 6bb1d0c | 2019-09-23 10:39:25 -0600 | [diff] [blame] | 2482 | } |
| 2483 | } |
| 2484 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2485 | void ValidationStateTracker::PreCallRecordCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 2486 | VkIndexType indexType) { |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 2487 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2488 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2489 | cb_state->RecordStateCmd(CMD_BINDINDEXBUFFER, CBSTATUS_INDEX_BUFFER_BOUND); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2490 | cb_state->index_buffer_binding.buffer_state = Get<BUFFER_STATE>(buffer); |
locke-lunarg | 1ae57d6 | 2020-11-18 10:49:19 -0700 | [diff] [blame] | 2491 | cb_state->index_buffer_binding.size = cb_state->index_buffer_binding.buffer_state->createInfo.size; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2492 | cb_state->index_buffer_binding.offset = offset; |
| 2493 | cb_state->index_buffer_binding.index_type = indexType; |
| 2494 | // Add binding for this index buffer to this commandbuffer |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2495 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2496 | cb_state->AddChild(cb_state->index_buffer_binding.buffer_state); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2497 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2498 | } |
| 2499 | |
| 2500 | void ValidationStateTracker::PreCallRecordCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 2501 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 2502 | const VkDeviceSize *pOffsets) { |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 2503 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2504 | cb_state->RecordCmd(CMD_BINDVERTEXBUFFERS); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2505 | |
| 2506 | uint32_t end = firstBinding + bindingCount; |
| 2507 | if (cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings.size() < end) { |
| 2508 | cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings.resize(end); |
| 2509 | } |
| 2510 | |
| 2511 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 2512 | auto &vertex_buffer_binding = cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings[i + firstBinding]; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2513 | vertex_buffer_binding.buffer_state = Get<BUFFER_STATE>(pBuffers[i]); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2514 | vertex_buffer_binding.offset = pOffsets[i]; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2515 | vertex_buffer_binding.size = VK_WHOLE_SIZE; |
| 2516 | vertex_buffer_binding.stride = 0; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2517 | // Add binding for this vertex buffer to this commandbuffer |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2518 | if (pBuffers[i] && !disabled[command_buffer_state]) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2519 | cb_state->AddChild(vertex_buffer_binding.buffer_state); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 2520 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2521 | } |
| 2522 | } |
| 2523 | |
| 2524 | void ValidationStateTracker::PostCallRecordCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
| 2525 | VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2526 | if (disabled[command_buffer_state]) return; |
| 2527 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 2528 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2529 | cb_state->RecordTransferCmd(CMD_UPDATEBUFFER, Get<BUFFER_STATE>(dstBuffer)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2530 | } |
| 2531 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2532 | void ValidationStateTracker::PreCallRecordCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, |
| 2533 | VkPipelineStageFlags stageMask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2534 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2535 | cb_state->RecordSetEvent(CMD_SETEVENT, event, stageMask); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2536 | } |
| 2537 | |
| 2538 | void ValidationStateTracker::PreCallRecordCmdSetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, |
| 2539 | const VkDependencyInfoKHR *pDependencyInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2540 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2541 | auto stage_masks = sync_utils::GetGlobalStageMasks(*pDependencyInfo); |
| 2542 | |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2543 | cb_state->RecordSetEvent(CMD_SETEVENT2KHR, event, stage_masks.src); |
| 2544 | cb_state->RecordBarriers(*pDependencyInfo); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2545 | } |
| 2546 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2547 | void ValidationStateTracker::PreCallRecordCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, |
| 2548 | VkPipelineStageFlags stageMask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2549 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2550 | cb_state->RecordResetEvent(CMD_RESETEVENT, event, stageMask); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | void ValidationStateTracker::PreCallRecordCmdResetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, |
| 2554 | VkPipelineStageFlags2KHR stageMask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2555 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2556 | cb_state->RecordResetEvent(CMD_RESETEVENT2KHR, event, stageMask); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2557 | } |
| 2558 | |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2559 | void ValidationStateTracker::PreCallRecordCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 2560 | VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, |
| 2561 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 2562 | uint32_t bufferMemoryBarrierCount, |
| 2563 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 2564 | uint32_t imageMemoryBarrierCount, |
| 2565 | const VkImageMemoryBarrier *pImageMemoryBarriers) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2566 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2567 | cb_state->RecordWaitEvents(CMD_WAITEVENTS, eventCount, pEvents); |
| 2568 | cb_state->RecordBarriers(memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, |
| 2569 | imageMemoryBarrierCount, pImageMemoryBarriers); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2570 | } |
| 2571 | |
| 2572 | void ValidationStateTracker::PreCallRecordCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_t eventCount, |
| 2573 | const VkEvent *pEvents, const VkDependencyInfoKHR *pDependencyInfos) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2574 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2575 | cb_state->RecordWaitEvents(CMD_WAITEVENTS2KHR, eventCount, pEvents); |
Jeremy Gebben | 7964915 | 2021-06-22 14:46:24 -0600 | [diff] [blame] | 2576 | for (uint32_t i = 0; i < eventCount; i++) { |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2577 | cb_state->RecordBarriers(pDependencyInfos[i]); |
Jeremy Gebben | 7964915 | 2021-06-22 14:46:24 -0600 | [diff] [blame] | 2578 | } |
| 2579 | } |
| 2580 | |
| 2581 | void ValidationStateTracker::PostCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 2582 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 2583 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 2584 | uint32_t bufferMemoryBarrierCount, |
| 2585 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 2586 | uint32_t imageMemoryBarrierCount, |
| 2587 | const VkImageMemoryBarrier *pImageMemoryBarriers) { |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2588 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
| 2589 | cb_state->RecordCmd(CMD_PIPELINEBARRIER); |
| 2590 | cb_state->RecordBarriers(memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, |
| 2591 | imageMemoryBarrierCount, pImageMemoryBarriers); |
Jeremy Gebben | 7964915 | 2021-06-22 14:46:24 -0600 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | void ValidationStateTracker::PreCallRecordCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, |
| 2595 | const VkDependencyInfoKHR *pDependencyInfo) { |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2596 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
| 2597 | cb_state->RecordCmd(CMD_PIPELINEBARRIER2KHR); |
| 2598 | cb_state->RecordBarriers(*pDependencyInfo); |
Jeremy Gebben | 7964915 | 2021-06-22 14:46:24 -0600 | [diff] [blame] | 2599 | } |
| 2600 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2601 | void ValidationStateTracker::PostCallRecordCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot, |
| 2602 | VkFlags flags) { |
Mark Lobodzinski | 90eea5b | 2020-05-15 12:54:00 -0600 | [diff] [blame] | 2603 | if (disabled[query_validation]) return; |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2604 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2605 | QueryObject query = {queryPool, slot}; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2606 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2607 | cb_state->RecordCmd(CMD_BEGINQUERY); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2608 | if (!disabled[query_validation]) { |
| 2609 | cb_state->BeginQuery(query); |
| 2610 | } |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2611 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2612 | auto pool_state = Get<QUERY_POOL_STATE>(query.pool); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2613 | cb_state->AddChild(pool_state); |
| 2614 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | void ValidationStateTracker::PostCallRecordCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot) { |
Mark Lobodzinski | 90eea5b | 2020-05-15 12:54:00 -0600 | [diff] [blame] | 2618 | if (disabled[query_validation]) return; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2619 | QueryObject query_obj = {queryPool, slot}; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2620 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2621 | cb_state->RecordCmd(CMD_ENDQUERY); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2622 | if (!disabled[query_validation]) { |
| 2623 | cb_state->EndQuery(query_obj); |
| 2624 | } |
| 2625 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2626 | auto pool_state = Get<QUERY_POOL_STATE>(query_obj.pool); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2627 | cb_state->AddChild(pool_state); |
| 2628 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2629 | } |
| 2630 | |
| 2631 | void ValidationStateTracker::PostCallRecordCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, |
| 2632 | uint32_t firstQuery, uint32_t queryCount) { |
Mark Lobodzinski | 90eea5b | 2020-05-15 12:54:00 -0600 | [diff] [blame] | 2633 | if (disabled[query_validation]) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2634 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2635 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2636 | cb_state->RecordCmd(CMD_RESETQUERYPOOL); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2637 | cb_state->ResetQueryPool(queryPool, firstQuery, queryCount); |
Lionel Landwerlin | b1e5a42 | 2020-02-18 16:49:09 +0200 | [diff] [blame] | 2638 | |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2639 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2640 | auto pool_state = Get<QUERY_POOL_STATE>(queryPool); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2641 | cb_state->AddChild(pool_state); |
| 2642 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2643 | } |
| 2644 | |
| 2645 | void ValidationStateTracker::PostCallRecordCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, |
| 2646 | uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, |
| 2647 | VkDeviceSize dstOffset, VkDeviceSize stride, |
| 2648 | VkQueryResultFlags flags) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2649 | if (disabled[query_validation] || disabled[command_buffer_state]) return; |
| 2650 | |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 2651 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2652 | cb_state->RecordCmd(CMD_COPYQUERYPOOLRESULTS); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2653 | auto dst_buff_state = Get<BUFFER_STATE>(dstBuffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2654 | cb_state->AddChild(dst_buff_state); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2655 | auto pool_state = Get<QUERY_POOL_STATE>(queryPool); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2656 | cb_state->AddChild(pool_state); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2657 | } |
| 2658 | |
| 2659 | void ValidationStateTracker::PostCallRecordCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
| 2660 | VkQueryPool queryPool, uint32_t slot) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2661 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2662 | cb_state->RecordWriteTimestamp(CMD_WRITETIMESTAMP, pipelineStage, queryPool, slot); |
Jeremy Gebben | 74aa762 | 2020-12-15 11:18:00 -0700 | [diff] [blame] | 2663 | } |
| 2664 | |
| 2665 | void ValidationStateTracker::PostCallRecordCmdWriteTimestamp2KHR(VkCommandBuffer commandBuffer, |
| 2666 | VkPipelineStageFlags2KHR pipelineStage, VkQueryPool queryPool, |
| 2667 | uint32_t slot) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2668 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | cefa7fd | 2021-08-17 13:44:47 -0600 | [diff] [blame] | 2669 | cb_state->RecordWriteTimestamp(CMD_WRITETIMESTAMP2KHR, pipelineStage, queryPool, slot); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2670 | } |
| 2671 | |
Marijn Suijten | 6750fdc | 2020-12-30 22:06:42 +0100 | [diff] [blame] | 2672 | void ValidationStateTracker::PostCallRecordCmdWriteAccelerationStructuresPropertiesKHR( |
| 2673 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 2674 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) { |
| 2675 | if (disabled[query_validation]) return; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2676 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2677 | cb_state->RecordCmd(CMD_WRITEACCELERATIONSTRUCTURESPROPERTIESKHR); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2678 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2679 | auto pool_state = Get<QUERY_POOL_STATE>(queryPool); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2680 | cb_state->AddChild(pool_state); |
| 2681 | } |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2682 | cb_state->EndQueries(queryPool, firstQuery, accelerationStructureCount); |
Marijn Suijten | 6750fdc | 2020-12-30 22:06:42 +0100 | [diff] [blame] | 2683 | } |
| 2684 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2685 | void ValidationStateTracker::PostCallRecordCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 2686 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer, |
| 2687 | VkResult result) { |
| 2688 | if (VK_SUCCESS != result) return; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2689 | |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 2690 | std::vector<std::shared_ptr<IMAGE_VIEW_STATE>> views; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2691 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 2692 | views.resize(pCreateInfo->attachmentCount); |
locke-lunarg | 1ae57d6 | 2020-11-18 10:49:19 -0700 | [diff] [blame] | 2693 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2694 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2695 | views[i] = Get<IMAGE_VIEW_STATE>(pCreateInfo->pAttachments[i]); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2696 | } |
| 2697 | } |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 2698 | |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2699 | Add(std::make_shared<FRAMEBUFFER_STATE>(*pFramebuffer, pCreateInfo, Get<RENDER_PASS_STATE>(pCreateInfo->renderPass), |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2700 | std::move(views))); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2701 | } |
| 2702 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2703 | void ValidationStateTracker::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
| 2704 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 2705 | VkResult result) { |
| 2706 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2707 | Add(std::make_shared<RENDER_PASS_STATE>(*pRenderPass, pCreateInfo)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2708 | } |
| 2709 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2710 | void ValidationStateTracker::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2711 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 2712 | VkResult result) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 2713 | if (VK_SUCCESS != result) return; |
| 2714 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2715 | Add(std::make_shared<RENDER_PASS_STATE>(*pRenderPass, pCreateInfo)); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2716 | } |
| 2717 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2718 | void ValidationStateTracker::PostCallRecordCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2719 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 2720 | VkResult result) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 2721 | if (VK_SUCCESS != result) return; |
| 2722 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 2723 | Add(std::make_shared<RENDER_PASS_STATE>(*pRenderPass, pCreateInfo)); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2724 | } |
| 2725 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2726 | void ValidationStateTracker::PreCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, |
| 2727 | const VkRenderPassBeginInfo *pRenderPassBegin, |
| 2728 | VkSubpassContents contents) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2729 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2730 | cb_state->BeginRenderPass(CMD_BEGINRENDERPASS, pRenderPassBegin, contents); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2731 | } |
| 2732 | |
| 2733 | void ValidationStateTracker::PreCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, |
| 2734 | const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2735 | const VkSubpassBeginInfo *pSubpassBeginInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2736 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 2737 | cb_state->BeginRenderPass(CMD_BEGINRENDERPASS2KHR, pRenderPassBegin, pSubpassBeginInfo->contents); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2738 | } |
| 2739 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 2740 | void ValidationStateTracker::PostCallRecordCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, |
| 2741 | uint32_t counterBufferCount, |
| 2742 | const VkBuffer *pCounterBuffers, |
| 2743 | const VkDeviceSize *pCounterBufferOffsets) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2744 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 2745 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2746 | cb_state->RecordCmd(CMD_BEGINTRANSFORMFEEDBACKEXT); |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 2747 | cb_state->transform_feedback_active = true; |
| 2748 | } |
| 2749 | |
| 2750 | void ValidationStateTracker::PostCallRecordCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, |
| 2751 | uint32_t counterBufferCount, const VkBuffer *pCounterBuffers, |
| 2752 | const VkDeviceSize *pCounterBufferOffsets) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2753 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 2754 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2755 | cb_state->RecordCmd(CMD_ENDTRANSFORMFEEDBACKEXT); |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 2756 | cb_state->transform_feedback_active = false; |
| 2757 | } |
| 2758 | |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2759 | void ValidationStateTracker::PostCallRecordCmdBeginConditionalRenderingEXT( |
| 2760 | VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT *pConditionalRenderingBegin) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2761 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2762 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2763 | cb_state->RecordCmd(CMD_BEGINCONDITIONALRENDERINGEXT); |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2764 | cb_state->conditional_rendering_active = true; |
ziga-lunarg | 39eeaf2 | 2021-09-03 19:12:44 +0200 | [diff] [blame] | 2765 | cb_state->conditional_rendering_inside_render_pass = cb_state->activeRenderPass != nullptr; |
| 2766 | cb_state->conditional_rendering_subpass = cb_state->activeSubpass; |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2767 | } |
| 2768 | |
| 2769 | void ValidationStateTracker::PostCallRecordCmdEndConditionalRenderingEXT(VkCommandBuffer commandBuffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2770 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2771 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2772 | cb_state->RecordCmd(CMD_ENDCONDITIONALRENDERINGEXT); |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2773 | cb_state->conditional_rendering_active = false; |
ziga-lunarg | 39eeaf2 | 2021-09-03 19:12:44 +0200 | [diff] [blame] | 2774 | cb_state->conditional_rendering_inside_render_pass = false; |
| 2775 | cb_state->conditional_rendering_subpass = 0; |
ziga-lunarg | 40f5fbc | 2021-08-14 23:06:41 +0200 | [diff] [blame] | 2776 | } |
| 2777 | |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 2778 | void ValidationStateTracker::RecordCmdEndRenderingRenderPassState(VkCommandBuffer commandBuffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2779 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 2780 | cb_state->activeRenderPass = nullptr; |
| 2781 | } |
| 2782 | |
| 2783 | void ValidationStateTracker::PreCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, |
| 2784 | const VkRenderingInfoKHR *pRenderingInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2785 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 2786 | cb_state->BeginRendering(CMD_BEGINRENDERINGKHR, pRenderingInfo); |
| 2787 | } |
| 2788 | |
| 2789 | void ValidationStateTracker::PreCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer) { |
| 2790 | RecordCmdEndRenderingRenderPassState(commandBuffer); |
| 2791 | } |
| 2792 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2793 | void ValidationStateTracker::PreCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, |
| 2794 | const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2795 | const VkSubpassBeginInfo *pSubpassBeginInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2796 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2797 | cb_state->BeginRenderPass(CMD_BEGINRENDERPASS2, pRenderPassBegin, pSubpassBeginInfo->contents); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2798 | } |
| 2799 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2800 | void ValidationStateTracker::PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2801 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2802 | cb_state->NextSubpass(CMD_NEXTSUBPASS, contents); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2803 | } |
| 2804 | |
| 2805 | void ValidationStateTracker::PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2806 | const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 2807 | const VkSubpassEndInfo *pSubpassEndInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2808 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 2809 | cb_state->NextSubpass(CMD_NEXTSUBPASS2KHR, pSubpassBeginInfo->contents); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2810 | } |
| 2811 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2812 | void ValidationStateTracker::PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2813 | const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 2814 | const VkSubpassEndInfo *pSubpassEndInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2815 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2816 | cb_state->NextSubpass(CMD_NEXTSUBPASS2, pSubpassBeginInfo->contents); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2817 | } |
| 2818 | |
| 2819 | void ValidationStateTracker::PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2820 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2821 | cb_state->EndRenderPass(CMD_ENDRENDERPASS); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2822 | } |
| 2823 | |
| 2824 | void ValidationStateTracker::PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2825 | const VkSubpassEndInfo *pSubpassEndInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2826 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 2827 | cb_state->EndRenderPass(CMD_ENDRENDERPASS2KHR); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2828 | } |
| 2829 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2830 | void ValidationStateTracker::PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2831 | const VkSubpassEndInfo *pSubpassEndInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2832 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 2833 | cb_state->EndRenderPass(CMD_ENDRENDERPASS2); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 2834 | } |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2835 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2836 | void ValidationStateTracker::PreCallRecordCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBuffersCount, |
| 2837 | const VkCommandBuffer *pCommandBuffers) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2838 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2839 | |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 2840 | cb_state->ExecuteCommands(commandBuffersCount, pCommandBuffers); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | void ValidationStateTracker::PostCallRecordMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, |
| 2844 | VkFlags flags, void **ppData, VkResult result) { |
| 2845 | if (VK_SUCCESS != result) return; |
| 2846 | RecordMappedMemory(mem, offset, size, ppData); |
| 2847 | } |
| 2848 | |
| 2849 | void ValidationStateTracker::PreCallRecordUnmapMemory(VkDevice device, VkDeviceMemory mem) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2850 | auto mem_info = Get<DEVICE_MEMORY_STATE>(mem); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2851 | if (mem_info) { |
| 2852 | mem_info->mapped_range = MemRange(); |
| 2853 | mem_info->p_driver_data = nullptr; |
| 2854 | } |
| 2855 | } |
| 2856 | |
| 2857 | void ValidationStateTracker::UpdateBindImageMemoryState(const VkBindImageMemoryInfo &bindInfo) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2858 | auto image_state = Get<IMAGE_STATE>(bindInfo.image); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2859 | if (image_state) { |
locke-lunarg | ae26eac | 2020-04-16 15:29:05 -0600 | [diff] [blame] | 2860 | // An Android sepcial image cannot get VkSubresourceLayout until the image binds a memory. |
| 2861 | // See: VUID-vkGetImageSubresourceLayout-image-01895 |
| 2862 | image_state->fragment_encoder = |
| 2863 | std::unique_ptr<const subresource_adapter::ImageRangeEncoder>(new subresource_adapter::ImageRangeEncoder(*image_state)); |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 2864 | const auto swapchain_info = LvlFindInChain<VkBindImageMemorySwapchainInfoKHR>(bindInfo.pNext); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2865 | if (swapchain_info) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2866 | auto swapchain = Get<SWAPCHAIN_NODE>(swapchain_info->swapchain); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2867 | if (swapchain) { |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 2868 | SWAPCHAIN_IMAGE &swapchain_image = swapchain->images[swapchain_info->imageIndex]; |
John Zulauf | d13b38e | 2021-03-05 08:17:38 -0700 | [diff] [blame] | 2869 | |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 2870 | if (!swapchain_image.fake_base_address) { |
| 2871 | auto size = image_state->fragment_encoder->TotalSize(); |
| 2872 | swapchain_image.fake_base_address = fake_memory.Alloc(size); |
Jeremy Gebben | 6fbf824 | 2021-06-21 09:14:46 -0600 | [diff] [blame] | 2873 | } |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 2874 | // All images bound to this swapchain and index are aliases |
| 2875 | image_state->SetSwapchain(swapchain, swapchain_info->imageIndex); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2876 | } |
| 2877 | } else { |
| 2878 | // Track bound memory range information |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 2879 | auto mem_info = Get<DEVICE_MEMORY_STATE>(bindInfo.memory); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2880 | if (mem_info) { |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 2881 | image_state->SetMemBinding(mem_info, bindInfo.memoryOffset); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2882 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2883 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2884 | } |
| 2885 | } |
| 2886 | |
| 2887 | void ValidationStateTracker::PostCallRecordBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, |
| 2888 | VkDeviceSize memoryOffset, VkResult result) { |
| 2889 | if (VK_SUCCESS != result) return; |
Nathaniel Cesario | fc6291e | 2021-04-06 00:22:15 -0600 | [diff] [blame] | 2890 | auto bind_info = LvlInitStruct<VkBindImageMemoryInfo>(); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2891 | bind_info.image = image; |
| 2892 | bind_info.memory = mem; |
| 2893 | bind_info.memoryOffset = memoryOffset; |
| 2894 | UpdateBindImageMemoryState(bind_info); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2895 | } |
| 2896 | |
| 2897 | void ValidationStateTracker::PostCallRecordBindImageMemory2(VkDevice device, uint32_t bindInfoCount, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2898 | const VkBindImageMemoryInfo *pBindInfos, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2899 | if (VK_SUCCESS != result) return; |
| 2900 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 2901 | UpdateBindImageMemoryState(pBindInfos[i]); |
| 2902 | } |
| 2903 | } |
| 2904 | |
| 2905 | void ValidationStateTracker::PostCallRecordBindImageMemory2KHR(VkDevice device, uint32_t bindInfoCount, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2906 | const VkBindImageMemoryInfo *pBindInfos, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2907 | if (VK_SUCCESS != result) return; |
| 2908 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 2909 | UpdateBindImageMemoryState(pBindInfos[i]); |
| 2910 | } |
| 2911 | } |
| 2912 | |
| 2913 | void ValidationStateTracker::PreCallRecordSetEvent(VkDevice device, VkEvent event) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2914 | auto event_state = Get<EVENT_STATE>(event); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2915 | if (event_state) { |
| 2916 | event_state->stageMask = VK_PIPELINE_STAGE_HOST_BIT; |
| 2917 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2918 | } |
| 2919 | |
| 2920 | void ValidationStateTracker::PostCallRecordImportSemaphoreFdKHR(VkDevice device, |
| 2921 | const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo, |
| 2922 | VkResult result) { |
| 2923 | if (VK_SUCCESS != result) return; |
| 2924 | RecordImportSemaphoreState(pImportSemaphoreFdInfo->semaphore, pImportSemaphoreFdInfo->handleType, |
| 2925 | pImportSemaphoreFdInfo->flags); |
| 2926 | } |
| 2927 | |
| 2928 | void ValidationStateTracker::RecordGetExternalSemaphoreState(VkSemaphore semaphore, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2929 | VkExternalSemaphoreHandleTypeFlagBits handle_type) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2930 | auto semaphore_state = Get<SEMAPHORE_STATE>(semaphore); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2931 | if (semaphore_state && handle_type != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2932 | // Cannot track semaphore state once it is exported, except for Sync FD handle types which have copy transference |
| 2933 | semaphore_state->scope = kSyncScopeExternalPermanent; |
| 2934 | } |
| 2935 | } |
| 2936 | |
| 2937 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 2938 | void ValidationStateTracker::PostCallRecordImportSemaphoreWin32HandleKHR( |
| 2939 | VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR *pImportSemaphoreWin32HandleInfo, VkResult result) { |
| 2940 | if (VK_SUCCESS != result) return; |
| 2941 | RecordImportSemaphoreState(pImportSemaphoreWin32HandleInfo->semaphore, pImportSemaphoreWin32HandleInfo->handleType, |
| 2942 | pImportSemaphoreWin32HandleInfo->flags); |
| 2943 | } |
| 2944 | |
| 2945 | void ValidationStateTracker::PostCallRecordGetSemaphoreWin32HandleKHR(VkDevice device, |
| 2946 | const VkSemaphoreGetWin32HandleInfoKHR *pGetWin32HandleInfo, |
| 2947 | HANDLE *pHandle, VkResult result) { |
| 2948 | if (VK_SUCCESS != result) return; |
| 2949 | RecordGetExternalSemaphoreState(pGetWin32HandleInfo->semaphore, pGetWin32HandleInfo->handleType); |
| 2950 | } |
| 2951 | |
| 2952 | void ValidationStateTracker::PostCallRecordImportFenceWin32HandleKHR( |
| 2953 | VkDevice device, const VkImportFenceWin32HandleInfoKHR *pImportFenceWin32HandleInfo, VkResult result) { |
| 2954 | if (VK_SUCCESS != result) return; |
| 2955 | RecordImportFenceState(pImportFenceWin32HandleInfo->fence, pImportFenceWin32HandleInfo->handleType, |
| 2956 | pImportFenceWin32HandleInfo->flags); |
| 2957 | } |
| 2958 | |
| 2959 | void ValidationStateTracker::PostCallRecordGetFenceWin32HandleKHR(VkDevice device, |
| 2960 | const VkFenceGetWin32HandleInfoKHR *pGetWin32HandleInfo, |
| 2961 | HANDLE *pHandle, VkResult result) { |
| 2962 | if (VK_SUCCESS != result) return; |
| 2963 | RecordGetExternalFenceState(pGetWin32HandleInfo->fence, pGetWin32HandleInfo->handleType); |
| 2964 | } |
| 2965 | #endif |
| 2966 | |
| 2967 | void ValidationStateTracker::PostCallRecordGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *pGetFdInfo, int *pFd, |
| 2968 | VkResult result) { |
| 2969 | if (VK_SUCCESS != result) return; |
| 2970 | RecordGetExternalSemaphoreState(pGetFdInfo->semaphore, pGetFdInfo->handleType); |
| 2971 | } |
| 2972 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2973 | void ValidationStateTracker::RecordImportFenceState(VkFence fence, VkExternalFenceHandleTypeFlagBits handle_type, |
| 2974 | VkFenceImportFlags flags) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2975 | auto fence_node = Get<FENCE_STATE>(fence); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2976 | if (fence_node && fence_node->scope != kSyncScopeExternalPermanent) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2977 | if ((handle_type == VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT || flags & VK_FENCE_IMPORT_TEMPORARY_BIT) && |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2978 | fence_node->scope == kSyncScopeInternal) { |
| 2979 | fence_node->scope = kSyncScopeExternalTemporary; |
| 2980 | } else { |
| 2981 | fence_node->scope = kSyncScopeExternalPermanent; |
| 2982 | } |
| 2983 | } |
| 2984 | } |
| 2985 | |
| 2986 | void ValidationStateTracker::PostCallRecordImportFenceFdKHR(VkDevice device, const VkImportFenceFdInfoKHR *pImportFenceFdInfo, |
| 2987 | VkResult result) { |
| 2988 | if (VK_SUCCESS != result) return; |
| 2989 | RecordImportFenceState(pImportFenceFdInfo->fence, pImportFenceFdInfo->handleType, pImportFenceFdInfo->flags); |
| 2990 | } |
| 2991 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2992 | void ValidationStateTracker::RecordGetExternalFenceState(VkFence fence, VkExternalFenceHandleTypeFlagBits handle_type) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 2993 | auto fence_state = Get<FENCE_STATE>(fence); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2994 | if (fence_state) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 2995 | if (handle_type != VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 2996 | // Export with reference transference becomes external |
| 2997 | fence_state->scope = kSyncScopeExternalPermanent; |
| 2998 | } else if (fence_state->scope == kSyncScopeInternal) { |
| 2999 | // Export with copy transference has a side effect of resetting the fence |
| 3000 | fence_state->state = FENCE_UNSIGNALED; |
| 3001 | } |
| 3002 | } |
| 3003 | } |
| 3004 | |
| 3005 | void ValidationStateTracker::PostCallRecordGetFenceFdKHR(VkDevice device, const VkFenceGetFdInfoKHR *pGetFdInfo, int *pFd, |
| 3006 | VkResult result) { |
| 3007 | if (VK_SUCCESS != result) return; |
| 3008 | RecordGetExternalFenceState(pGetFdInfo->fence, pGetFdInfo->handleType); |
| 3009 | } |
| 3010 | |
| 3011 | void ValidationStateTracker::PostCallRecordCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, |
| 3012 | const VkAllocationCallbacks *pAllocator, VkEvent *pEvent, VkResult result) { |
| 3013 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3014 | Add(std::make_shared<EVENT_STATE>(*pEvent, pCreateInfo->flags)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3015 | } |
| 3016 | |
| 3017 | void ValidationStateTracker::RecordCreateSwapchainState(VkResult result, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 3018 | VkSwapchainKHR *pSwapchain, std::shared_ptr<SURFACE_STATE> &&surface_state, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3019 | SWAPCHAIN_NODE *old_swapchain_state) { |
| 3020 | if (VK_SUCCESS == result) { |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3021 | if (surface_state->swapchain) { |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 3022 | surface_state->RemoveParent(surface_state->swapchain); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3023 | } |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 3024 | auto swapchain = CreateSwapchainState(pCreateInfo, *pSwapchain); |
| 3025 | surface_state->AddParent(swapchain.get()); |
| 3026 | surface_state->swapchain = swapchain.get(); |
| 3027 | swapchain->surface = std::move(surface_state); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3028 | Add(std::move(swapchain)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3029 | } else { |
| 3030 | surface_state->swapchain = nullptr; |
| 3031 | } |
| 3032 | // Spec requires that even if CreateSwapchainKHR fails, oldSwapchain is retired |
Jeremy Gebben | 5a542f5 | 2021-07-21 15:25:52 -0600 | [diff] [blame] | 3033 | // Retired swapchains remain associated with the surface until they are destroyed. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3034 | if (old_swapchain_state) { |
| 3035 | old_swapchain_state->retired = true; |
| 3036 | } |
| 3037 | return; |
| 3038 | } |
| 3039 | |
| 3040 | void ValidationStateTracker::PostCallRecordCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 3041 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain, |
| 3042 | VkResult result) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3043 | auto surface_state = Get<SURFACE_STATE>(pCreateInfo->surface); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3044 | auto old_swapchain_state = Get<SWAPCHAIN_NODE>(pCreateInfo->oldSwapchain); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3045 | RecordCreateSwapchainState(result, pCreateInfo, pSwapchain, std::move(surface_state), old_swapchain_state.get()); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3046 | } |
| 3047 | |
| 3048 | void ValidationStateTracker::PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 3049 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3050 | Destroy<SWAPCHAIN_NODE>(swapchain); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3051 | } |
| 3052 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 3053 | void ValidationStateTracker::PostCallRecordCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 3054 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 3055 | const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode, |
| 3056 | VkResult result) { |
| 3057 | if (VK_SUCCESS != result) return; |
| 3058 | if (!pMode) return; |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3059 | Add(std::make_shared<DISPLAY_MODE_STATE>(*pMode, physicalDevice)); |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 3060 | } |
| 3061 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3062 | void ValidationStateTracker::PostCallRecordQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo, VkResult result) { |
| 3063 | // Semaphore waits occur before error generation, if the call reached the ICD. (Confirm?) |
| 3064 | for (uint32_t i = 0; i < pPresentInfo->waitSemaphoreCount; ++i) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3065 | auto semaphore_state = Get<SEMAPHORE_STATE>(pPresentInfo->pWaitSemaphores[i]); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3066 | if (semaphore_state) { |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 3067 | semaphore_state->signaler.queue = nullptr; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3068 | semaphore_state->signaled = false; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3069 | } |
| 3070 | } |
| 3071 | |
Tony-LunarG | 6f887e5 | 2021-07-27 11:23:14 -0600 | [diff] [blame] | 3072 | const auto *present_id_info = LvlFindInChain<VkPresentIdKHR>(pPresentInfo->pNext); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3073 | for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) { |
| 3074 | // Note: this is imperfect, in that we can get confused about what did or didn't succeed-- but if the app does that, it's |
| 3075 | // confused itself just as much. |
| 3076 | auto local_result = pPresentInfo->pResults ? pPresentInfo->pResults[i] : result; |
| 3077 | if (local_result != VK_SUCCESS && local_result != VK_SUBOPTIMAL_KHR) continue; // this present didn't actually happen. |
| 3078 | // Mark the image as having been released to the WSI |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3079 | auto swapchain_data = Get<SWAPCHAIN_NODE>(pPresentInfo->pSwapchains[i]); |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3080 | if (swapchain_data) { |
| 3081 | swapchain_data->PresentImage(pPresentInfo->pImageIndices[i]); |
Tony-LunarG | 6f887e5 | 2021-07-27 11:23:14 -0600 | [diff] [blame] | 3082 | if (present_id_info) { |
| 3083 | if (i < present_id_info->swapchainCount && present_id_info->pPresentIds[i] > swapchain_data->max_present_id) { |
| 3084 | swapchain_data->max_present_id = present_id_info->pPresentIds[i]; |
| 3085 | } |
| 3086 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3087 | } |
| 3088 | } |
| 3089 | // Note: even though presentation is directed to a queue, there is no direct ordering between QP and subsequent work, so QP (and |
| 3090 | // its semaphore waits) /never/ participate in any completion proof. |
| 3091 | } |
| 3092 | |
| 3093 | void ValidationStateTracker::PostCallRecordCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 3094 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 3095 | const VkAllocationCallbacks *pAllocator, |
| 3096 | VkSwapchainKHR *pSwapchains, VkResult result) { |
| 3097 | if (pCreateInfos) { |
| 3098 | for (uint32_t i = 0; i < swapchainCount; i++) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3099 | auto surface_state = Get<SURFACE_STATE>(pCreateInfos[i].surface); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3100 | auto old_swapchain_state = Get<SWAPCHAIN_NODE>(pCreateInfos[i].oldSwapchain); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3101 | RecordCreateSwapchainState(result, &pCreateInfos[i], &pSwapchains[i], std::move(surface_state), |
| 3102 | old_swapchain_state.get()); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3103 | } |
| 3104 | } |
| 3105 | } |
| 3106 | |
| 3107 | void ValidationStateTracker::RecordAcquireNextImageState(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 3108 | VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3109 | auto fence_state = Get<FENCE_STATE>(fence); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3110 | if (fence_state && fence_state->scope == kSyncScopeInternal) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3111 | // Treat as inflight since it is valid to wait on this fence, even in cases where it is technically a temporary |
| 3112 | // import |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3113 | fence_state->state = FENCE_INFLIGHT; |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 3114 | fence_state->signaler.queue = nullptr; // ANI isn't on a queue, so this can't participate in a completion proof. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3115 | } |
| 3116 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3117 | auto semaphore_state = Get<SEMAPHORE_STATE>(semaphore); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3118 | if (semaphore_state && semaphore_state->scope == kSyncScopeInternal) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3119 | // Treat as signaled since it is valid to wait on this semaphore, even in cases where it is technically a |
| 3120 | // temporary import |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3121 | semaphore_state->signaled = true; |
Jeremy Gebben | 5764298 | 2021-09-14 14:14:55 -0600 | [diff] [blame] | 3122 | semaphore_state->signaler.queue = nullptr; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3123 | } |
| 3124 | |
| 3125 | // Mark the image as acquired. |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3126 | auto swapchain_data = Get<SWAPCHAIN_NODE>(swapchain); |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3127 | if (swapchain_data) { |
| 3128 | swapchain_data->AcquireImage(*pImageIndex); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3129 | } |
| 3130 | } |
| 3131 | |
| 3132 | void ValidationStateTracker::PostCallRecordAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 3133 | VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex, |
| 3134 | VkResult result) { |
| 3135 | if ((VK_SUCCESS != result) && (VK_SUBOPTIMAL_KHR != result)) return; |
| 3136 | RecordAcquireNextImageState(device, swapchain, timeout, semaphore, fence, pImageIndex); |
| 3137 | } |
| 3138 | |
| 3139 | void ValidationStateTracker::PostCallRecordAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 3140 | uint32_t *pImageIndex, VkResult result) { |
| 3141 | if ((VK_SUCCESS != result) && (VK_SUBOPTIMAL_KHR != result)) return; |
| 3142 | RecordAcquireNextImageState(device, pAcquireInfo->swapchain, pAcquireInfo->timeout, pAcquireInfo->semaphore, |
| 3143 | pAcquireInfo->fence, pImageIndex); |
| 3144 | } |
| 3145 | |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3146 | std::shared_ptr<PHYSICAL_DEVICE_STATE> ValidationStateTracker::CreatePhysicalDeviceState(VkPhysicalDevice phys_dev) { |
| 3147 | return std::make_shared<PHYSICAL_DEVICE_STATE>(phys_dev); |
| 3148 | } |
| 3149 | |
Jeremy Gebben | ee3a3a2 | 2021-09-30 12:27:11 -0600 | [diff] [blame] | 3150 | void ValidationStateTracker::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
| 3151 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 3152 | VkResult result) { |
| 3153 | if (result != VK_SUCCESS) { |
| 3154 | return; |
| 3155 | } |
Jeremy Gebben | 404f6ac | 2021-10-28 12:33:28 -0600 | [diff] [blame] | 3156 | instance_state = this; |
Jeremy Gebben | ee3a3a2 | 2021-09-30 12:27:11 -0600 | [diff] [blame] | 3157 | uint32_t count = 0; |
Jeremy Gebben | c491680 | 2021-10-22 16:15:16 -0600 | [diff] [blame] | 3158 | // this can fail if the allocator fails |
| 3159 | result = DispatchEnumeratePhysicalDevices(*pInstance, &count, nullptr); |
| 3160 | if (result != VK_SUCCESS) { |
| 3161 | return; |
| 3162 | } |
Jeremy Gebben | ee3a3a2 | 2021-09-30 12:27:11 -0600 | [diff] [blame] | 3163 | std::vector<VkPhysicalDevice> physdev_handles(count); |
Jeremy Gebben | c491680 | 2021-10-22 16:15:16 -0600 | [diff] [blame] | 3164 | result = DispatchEnumeratePhysicalDevices(*pInstance, &count, physdev_handles.data()); |
| 3165 | if (result != VK_SUCCESS) { |
| 3166 | return; |
| 3167 | } |
Jeremy Gebben | ee3a3a2 | 2021-09-30 12:27:11 -0600 | [diff] [blame] | 3168 | |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 3169 | physical_device_map_.reserve(count); |
Jeremy Gebben | ee3a3a2 | 2021-09-30 12:27:11 -0600 | [diff] [blame] | 3170 | for (auto physdev : physdev_handles) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3171 | Add(CreatePhysicalDeviceState(physdev)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3172 | } |
| 3173 | } |
| 3174 | |
| 3175 | // Common function to update state for GetPhysicalDeviceQueueFamilyProperties & 2KHR version |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3176 | static void StateUpdateCommonGetPhysicalDeviceQueueFamilyProperties(PHYSICAL_DEVICE_STATE *pd_state, uint32_t count) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3177 | pd_state->queue_family_known_count = std::max(pd_state->queue_family_known_count, count); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3178 | } |
| 3179 | |
| 3180 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 3181 | uint32_t *pQueueFamilyPropertyCount, |
| 3182 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3183 | auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physicalDevice); |
| 3184 | assert(pd_state); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3185 | StateUpdateCommonGetPhysicalDeviceQueueFamilyProperties(pd_state.get(), *pQueueFamilyPropertyCount); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3186 | } |
| 3187 | |
| 3188 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3189 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3190 | auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physicalDevice); |
| 3191 | assert(pd_state); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3192 | StateUpdateCommonGetPhysicalDeviceQueueFamilyProperties(pd_state.get(), *pQueueFamilyPropertyCount); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3193 | } |
| 3194 | |
| 3195 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3196 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3197 | auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physicalDevice); |
| 3198 | assert(pd_state); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3199 | StateUpdateCommonGetPhysicalDeviceQueueFamilyProperties(pd_state.get(), *pQueueFamilyPropertyCount); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3200 | } |
| 3201 | void ValidationStateTracker::PreCallRecordDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, |
| 3202 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3203 | Destroy<SURFACE_STATE>(surface); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3204 | } |
| 3205 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3206 | void ValidationStateTracker::RecordVulkanSurface(VkSurfaceKHR *pSurface) { Add(std::make_shared<SURFACE_STATE>(*pSurface)); } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3207 | |
| 3208 | void ValidationStateTracker::PostCallRecordCreateDisplayPlaneSurfaceKHR(VkInstance instance, |
| 3209 | const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 3210 | const VkAllocationCallbacks *pAllocator, |
| 3211 | VkSurfaceKHR *pSurface, VkResult result) { |
| 3212 | if (VK_SUCCESS != result) return; |
| 3213 | RecordVulkanSurface(pSurface); |
| 3214 | } |
| 3215 | |
| 3216 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 3217 | void ValidationStateTracker::PostCallRecordCreateAndroidSurfaceKHR(VkInstance instance, |
| 3218 | const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, |
| 3219 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3220 | VkResult result) { |
| 3221 | if (VK_SUCCESS != result) return; |
| 3222 | RecordVulkanSurface(pSurface); |
| 3223 | } |
| 3224 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 3225 | |
| 3226 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 3227 | void ValidationStateTracker::PostCallRecordCreateIOSSurfaceMVK(VkInstance instance, const VkIOSSurfaceCreateInfoMVK *pCreateInfo, |
| 3228 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3229 | VkResult result) { |
| 3230 | if (VK_SUCCESS != result) return; |
| 3231 | RecordVulkanSurface(pSurface); |
| 3232 | } |
| 3233 | #endif // VK_USE_PLATFORM_IOS_MVK |
| 3234 | |
| 3235 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 3236 | void ValidationStateTracker::PostCallRecordCreateMacOSSurfaceMVK(VkInstance instance, |
| 3237 | const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, |
| 3238 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3239 | VkResult result) { |
| 3240 | if (VK_SUCCESS != result) return; |
| 3241 | RecordVulkanSurface(pSurface); |
| 3242 | } |
| 3243 | #endif // VK_USE_PLATFORM_MACOS_MVK |
| 3244 | |
Jeremy Kniager | f33a67c | 2019-12-09 09:44:39 -0700 | [diff] [blame] | 3245 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 3246 | void ValidationStateTracker::PostCallRecordCreateMetalSurfaceEXT(VkInstance instance, |
| 3247 | const VkMetalSurfaceCreateInfoEXT *pCreateInfo, |
| 3248 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3249 | VkResult result) { |
| 3250 | if (VK_SUCCESS != result) return; |
| 3251 | RecordVulkanSurface(pSurface); |
| 3252 | } |
| 3253 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 3254 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3255 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 3256 | void ValidationStateTracker::PostCallRecordCreateWaylandSurfaceKHR(VkInstance instance, |
| 3257 | const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 3258 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3259 | VkResult result) { |
| 3260 | if (VK_SUCCESS != result) return; |
| 3261 | RecordVulkanSurface(pSurface); |
| 3262 | } |
| 3263 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 3264 | |
| 3265 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 3266 | void ValidationStateTracker::PostCallRecordCreateWin32SurfaceKHR(VkInstance instance, |
| 3267 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 3268 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3269 | VkResult result) { |
| 3270 | if (VK_SUCCESS != result) return; |
| 3271 | RecordVulkanSurface(pSurface); |
| 3272 | } |
| 3273 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 3274 | |
| 3275 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 3276 | void ValidationStateTracker::PostCallRecordCreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 3277 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3278 | VkResult result) { |
| 3279 | if (VK_SUCCESS != result) return; |
| 3280 | RecordVulkanSurface(pSurface); |
| 3281 | } |
| 3282 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 3283 | |
| 3284 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 3285 | void ValidationStateTracker::PostCallRecordCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 3286 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3287 | VkResult result) { |
| 3288 | if (VK_SUCCESS != result) return; |
| 3289 | RecordVulkanSurface(pSurface); |
| 3290 | } |
| 3291 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 3292 | |
Niklas Haas | 8b84af1 | 2020-04-19 22:20:11 +0200 | [diff] [blame] | 3293 | void ValidationStateTracker::PostCallRecordCreateHeadlessSurfaceEXT(VkInstance instance, |
| 3294 | const VkHeadlessSurfaceCreateInfoEXT *pCreateInfo, |
| 3295 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface, |
| 3296 | VkResult result) { |
| 3297 | if (VK_SUCCESS != result) return; |
| 3298 | RecordVulkanSurface(pSurface); |
| 3299 | } |
| 3300 | |
Jeremy Gebben | 87b2e6b | 2021-10-20 11:21:40 -0600 | [diff] [blame] | 3301 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, |
| 3302 | VkSurfaceKHR surface, |
| 3303 | VkSurfaceCapabilitiesKHR *pSurfaceCapabilities, |
| 3304 | VkResult result) { |
| 3305 | if (VK_SUCCESS != result) return; |
| 3306 | auto surface_state = Get<SURFACE_STATE>(surface); |
| 3307 | surface_state->SetCapabilities(physicalDevice, *pSurfaceCapabilities); |
| 3308 | } |
| 3309 | |
| 3310 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceCapabilities2KHR( |
| 3311 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 3312 | VkSurfaceCapabilities2KHR *pSurfaceCapabilities, VkResult result) { |
| 3313 | if (VK_SUCCESS != result) return; |
| 3314 | auto surface_state = Get<SURFACE_STATE>(pSurfaceInfo->surface); |
| 3315 | surface_state->SetCapabilities(physicalDevice, pSurfaceCapabilities->surfaceCapabilities); |
| 3316 | } |
| 3317 | |
| 3318 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, |
| 3319 | VkSurfaceKHR surface, |
| 3320 | VkSurfaceCapabilities2EXT *pSurfaceCapabilities, |
| 3321 | VkResult result) { |
| 3322 | auto surface_state = Get<SURFACE_STATE>(surface); |
| 3323 | VkSurfaceCapabilitiesKHR caps{ |
| 3324 | pSurfaceCapabilities->minImageCount, pSurfaceCapabilities->maxImageCount, |
| 3325 | pSurfaceCapabilities->currentExtent, pSurfaceCapabilities->minImageExtent, |
| 3326 | pSurfaceCapabilities->maxImageExtent, pSurfaceCapabilities->maxImageArrayLayers, |
| 3327 | pSurfaceCapabilities->supportedTransforms, pSurfaceCapabilities->currentTransform, |
| 3328 | pSurfaceCapabilities->supportedCompositeAlpha, pSurfaceCapabilities->supportedUsageFlags, |
| 3329 | }; |
| 3330 | surface_state->SetCapabilities(physicalDevice, caps); |
| 3331 | } |
| 3332 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3333 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, |
| 3334 | uint32_t queueFamilyIndex, VkSurfaceKHR surface, |
| 3335 | VkBool32 *pSupported, VkResult result) { |
| 3336 | if (VK_SUCCESS != result) return; |
Jeremy Gebben | 87b2e6b | 2021-10-20 11:21:40 -0600 | [diff] [blame] | 3337 | auto surface_state = Get<SURFACE_STATE>(surface); |
| 3338 | surface_state->SetQueueSupport(physicalDevice, queueFamilyIndex, (*pSupported == VK_TRUE)); |
| 3339 | } |
| 3340 | |
| 3341 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 3342 | VkSurfaceKHR surface, |
| 3343 | uint32_t *pPresentModeCount, |
| 3344 | VkPresentModeKHR *pPresentModes, |
| 3345 | VkResult result) { |
| 3346 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3347 | |
| 3348 | if (pPresentModes) { |
| 3349 | auto surface_state = Get<SURFACE_STATE>(surface); |
| 3350 | surface_state->SetPresentModes(physicalDevice, |
| 3351 | std::vector<VkPresentModeKHR>(pPresentModes, pPresentModes + *pPresentModeCount)); |
| 3352 | } |
| 3353 | } |
| 3354 | |
| 3355 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 3356 | uint32_t *pSurfaceFormatCount, |
| 3357 | VkSurfaceFormatKHR *pSurfaceFormats, |
| 3358 | VkResult result) { |
| 3359 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3360 | |
| 3361 | if (pSurfaceFormats) { |
| 3362 | auto surface_state = Get<SURFACE_STATE>(surface); |
| 3363 | surface_state->SetFormats(physicalDevice, |
| 3364 | std::vector<VkSurfaceFormatKHR>(pSurfaceFormats, pSurfaceFormats + *pSurfaceFormatCount)); |
| 3365 | } |
| 3366 | } |
| 3367 | |
| 3368 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, |
| 3369 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 3370 | uint32_t *pSurfaceFormatCount, |
| 3371 | VkSurfaceFormat2KHR *pSurfaceFormats, |
| 3372 | VkResult result) { |
| 3373 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3374 | |
| 3375 | if (pSurfaceFormats) { |
| 3376 | std::vector<VkSurfaceFormatKHR> fmts(*pSurfaceFormatCount); |
| 3377 | auto surface_state = Get<SURFACE_STATE>(pSurfaceInfo->surface); |
| 3378 | for (uint32_t i = 0; i < *pSurfaceFormatCount; i++) { |
| 3379 | fmts[i] = pSurfaceFormats[i].surfaceFormat; |
| 3380 | } |
| 3381 | surface_state->SetFormats(physicalDevice, std::move(fmts)); |
| 3382 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3383 | } |
| 3384 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3385 | void ValidationStateTracker::PreCallRecordCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, |
| 3386 | const VkDebugUtilsLabelEXT *pLabelInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3387 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3388 | cb_state->RecordCmd(CMD_BEGINDEBUGUTILSLABELEXT); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3389 | BeginCmdDebugUtilsLabel(report_data, commandBuffer, pLabelInfo); |
| 3390 | } |
| 3391 | |
| 3392 | void ValidationStateTracker::PostCallRecordCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3393 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3394 | cb_state->RecordCmd(CMD_ENDDEBUGUTILSLABELEXT); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3395 | EndCmdDebugUtilsLabel(report_data, commandBuffer); |
| 3396 | } |
| 3397 | |
| 3398 | void ValidationStateTracker::PreCallRecordCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, |
| 3399 | const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 3400 | InsertCmdDebugUtilsLabel(report_data, commandBuffer, pLabelInfo); |
| 3401 | |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3402 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3403 | cb_state->RecordCmd(CMD_INSERTDEBUGUTILSLABELEXT); |
| 3404 | // Squirrel away an easily accessible copy. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3405 | cb_state->debug_label = LoggingLabel(pLabelInfo); |
| 3406 | } |
| 3407 | |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3408 | void ValidationStateTracker::RecordEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCounters(VkPhysicalDevice physicalDevice, |
| 3409 | uint32_t queueFamilyIndex, |
| 3410 | uint32_t *pCounterCount, |
| 3411 | VkPerformanceCounterKHR *pCounters) { |
| 3412 | if (NULL == pCounters) return; |
| 3413 | |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3414 | auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physicalDevice); |
| 3415 | assert(pd_state); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3416 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3417 | std::unique_ptr<QUEUE_FAMILY_PERF_COUNTERS> queue_family_counters(new QUEUE_FAMILY_PERF_COUNTERS()); |
| 3418 | queue_family_counters->counters.resize(*pCounterCount); |
| 3419 | for (uint32_t i = 0; i < *pCounterCount; i++) queue_family_counters->counters[i] = pCounters[i]; |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3420 | |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3421 | pd_state->perf_counters[queueFamilyIndex] = std::move(queue_family_counters); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3422 | } |
| 3423 | |
| 3424 | void ValidationStateTracker::PostCallRecordEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( |
| 3425 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, uint32_t *pCounterCount, VkPerformanceCounterKHR *pCounters, |
| 3426 | VkPerformanceCounterDescriptionKHR *pCounterDescriptions, VkResult result) { |
| 3427 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3428 | RecordEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCounters(physicalDevice, queueFamilyIndex, pCounterCount, pCounters); |
| 3429 | } |
| 3430 | |
| 3431 | void ValidationStateTracker::PostCallRecordAcquireProfilingLockKHR(VkDevice device, const VkAcquireProfilingLockInfoKHR *pInfo, |
| 3432 | VkResult result) { |
| 3433 | if (result == VK_SUCCESS) performance_lock_acquired = true; |
| 3434 | } |
| 3435 | |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3436 | void ValidationStateTracker::PostCallRecordReleaseProfilingLockKHR(VkDevice device) { |
| 3437 | performance_lock_acquired = false; |
Jeremy Gebben | d177d92 | 2021-10-28 13:42:10 -0600 | [diff] [blame] | 3438 | for (auto &cmd_buffer : command_buffer_map_) { |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3439 | cmd_buffer.second->performance_lock_released = true; |
| 3440 | } |
| 3441 | } |
| 3442 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3443 | void ValidationStateTracker::PreCallRecordDestroyDescriptorUpdateTemplate(VkDevice device, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3444 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3445 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3446 | Destroy<UPDATE_TEMPLATE_STATE>(descriptorUpdateTemplate); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3447 | } |
| 3448 | |
| 3449 | void ValidationStateTracker::PreCallRecordDestroyDescriptorUpdateTemplateKHR(VkDevice device, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3450 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3451 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3452 | Destroy<UPDATE_TEMPLATE_STATE>(descriptorUpdateTemplate); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3453 | } |
| 3454 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3455 | void ValidationStateTracker::RecordCreateDescriptorUpdateTemplateState(const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, |
| 3456 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3457 | Add(std::make_shared<UPDATE_TEMPLATE_STATE>(*pDescriptorUpdateTemplate, pCreateInfo)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3458 | } |
| 3459 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3460 | void ValidationStateTracker::PostCallRecordCreateDescriptorUpdateTemplate(VkDevice device, |
| 3461 | const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, |
| 3462 | const VkAllocationCallbacks *pAllocator, |
| 3463 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate, |
| 3464 | VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3465 | if (VK_SUCCESS != result) return; |
| 3466 | RecordCreateDescriptorUpdateTemplateState(pCreateInfo, pDescriptorUpdateTemplate); |
| 3467 | } |
| 3468 | |
| 3469 | void ValidationStateTracker::PostCallRecordCreateDescriptorUpdateTemplateKHR( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3470 | VkDevice device, const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 3471 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate, VkResult result) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3472 | if (VK_SUCCESS != result) return; |
| 3473 | RecordCreateDescriptorUpdateTemplateState(pCreateInfo, pDescriptorUpdateTemplate); |
| 3474 | } |
| 3475 | |
| 3476 | void ValidationStateTracker::RecordUpdateDescriptorSetWithTemplateState(VkDescriptorSet descriptorSet, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3477 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3478 | const void *pData) { |
Jeremy Gebben | fc89045 | 2021-10-27 10:56:49 -0600 | [diff] [blame] | 3479 | auto const template_state = Get<UPDATE_TEMPLATE_STATE>(descriptorUpdateTemplate); |
| 3480 | assert(template_state); |
| 3481 | if (template_state) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3482 | // TODO: Record template push descriptor updates |
| 3483 | if (template_state->create_info.templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3484 | PerformUpdateDescriptorSetsWithTemplateKHR(descriptorSet, template_state.get(), pData); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3485 | } |
| 3486 | } |
| 3487 | } |
| 3488 | |
| 3489 | void ValidationStateTracker::PreCallRecordUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, |
| 3490 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
| 3491 | const void *pData) { |
| 3492 | RecordUpdateDescriptorSetWithTemplateState(descriptorSet, descriptorUpdateTemplate, pData); |
| 3493 | } |
| 3494 | |
| 3495 | void ValidationStateTracker::PreCallRecordUpdateDescriptorSetWithTemplateKHR(VkDevice device, VkDescriptorSet descriptorSet, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3496 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3497 | const void *pData) { |
| 3498 | RecordUpdateDescriptorSetWithTemplateState(descriptorSet, descriptorUpdateTemplate, pData); |
| 3499 | } |
| 3500 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3501 | void ValidationStateTracker::PreCallRecordCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer, |
| 3502 | VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
| 3503 | VkPipelineLayout layout, uint32_t set, |
| 3504 | const void *pData) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3505 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3506 | |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3507 | cb_state->RecordCmd(CMD_PUSHDESCRIPTORSETWITHTEMPLATEKHR); |
Jeremy Gebben | fc89045 | 2021-10-27 10:56:49 -0600 | [diff] [blame] | 3508 | const auto template_state = Get<UPDATE_TEMPLATE_STATE>(descriptorUpdateTemplate); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3509 | if (template_state) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3510 | auto layout_data = Get<PIPELINE_LAYOUT_STATE>(layout); |
Jeremy Gebben | adb3eb0 | 2021-06-15 12:55:19 -0600 | [diff] [blame] | 3511 | auto dsl = layout_data ? layout_data->GetDsl(set) : nullptr; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3512 | const auto &template_ci = template_state->create_info; |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 3513 | // Decode the template into a set of write updates |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3514 | cvdescriptorset::DecodedTemplateUpdate decoded_template(this, VK_NULL_HANDLE, template_state.get(), pData, |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 3515 | dsl->GetDescriptorSetLayout()); |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3516 | cb_state->PushDescriptorSetState(template_ci.pipelineBindPoint, layout_data.get(), set, |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 3517 | static_cast<uint32_t>(decoded_template.desc_writes.size()), |
| 3518 | decoded_template.desc_writes.data()); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3519 | } |
| 3520 | } |
| 3521 | |
| 3522 | void ValidationStateTracker::RecordGetPhysicalDeviceDisplayPlanePropertiesState(VkPhysicalDevice physicalDevice, |
| 3523 | uint32_t *pPropertyCount, void *pProperties) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3524 | auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physicalDevice); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3525 | if (*pPropertyCount) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3526 | pd_state->display_plane_property_count = *pPropertyCount; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3527 | } |
Nathaniel Cesario | 24184fe | 2020-10-06 12:46:12 -0600 | [diff] [blame] | 3528 | if (*pPropertyCount || pProperties) { |
Jeremy Gebben | 383b9a3 | 2021-09-08 16:31:33 -0600 | [diff] [blame] | 3529 | pd_state->vkGetPhysicalDeviceDisplayPlanePropertiesKHR_called = true; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3530 | } |
| 3531 | } |
| 3532 | |
| 3533 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, |
| 3534 | uint32_t *pPropertyCount, |
| 3535 | VkDisplayPlanePropertiesKHR *pProperties, |
| 3536 | VkResult result) { |
| 3537 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3538 | RecordGetPhysicalDeviceDisplayPlanePropertiesState(physicalDevice, pPropertyCount, pProperties); |
| 3539 | } |
| 3540 | |
| 3541 | void ValidationStateTracker::PostCallRecordGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, |
| 3542 | uint32_t *pPropertyCount, |
| 3543 | VkDisplayPlaneProperties2KHR *pProperties, |
| 3544 | VkResult result) { |
| 3545 | if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) return; |
| 3546 | RecordGetPhysicalDeviceDisplayPlanePropertiesState(physicalDevice, pPropertyCount, pProperties); |
| 3547 | } |
| 3548 | |
| 3549 | void ValidationStateTracker::PostCallRecordCmdBeginQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, |
| 3550 | uint32_t query, VkQueryControlFlags flags, uint32_t index) { |
| 3551 | QueryObject query_obj = {queryPool, query, index}; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3552 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3553 | cb_state->RecordCmd(CMD_BEGINQUERYINDEXEDEXT); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 3554 | cb_state->BeginQuery(query_obj); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | void ValidationStateTracker::PostCallRecordCmdEndQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, |
| 3558 | uint32_t query, uint32_t index) { |
| 3559 | QueryObject query_obj = {queryPool, query, index}; |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3560 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3561 | cb_state->RecordCmd(CMD_ENDQUERYINDEXEDEXT); |
Jeremy Gebben | 1ec8933 | 2021-08-05 13:51:49 -0600 | [diff] [blame] | 3562 | cb_state->EndQuery(query_obj); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | void ValidationStateTracker::RecordCreateSamplerYcbcrConversionState(const VkSamplerYcbcrConversionCreateInfo *create_info, |
| 3566 | VkSamplerYcbcrConversion ycbcr_conversion) { |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 3567 | VkFormatFeatureFlags format_features = 0; |
| 3568 | |
| 3569 | if (create_info->format != VK_FORMAT_UNDEFINED) { |
| 3570 | format_features = GetPotentialFormatFeatures(create_info->format); |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3571 | } else if (IsExtEnabled(device_extensions.vk_android_external_memory_android_hardware_buffer)) { |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 3572 | // If format is VK_FORMAT_UNDEFINED, format_features will be set by external AHB features |
| 3573 | format_features = GetExternalFormatFeaturesANDROID(create_info); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3574 | } |
Jeremy Gebben | f4fb2a0 | 2021-07-08 09:57:46 -0600 | [diff] [blame] | 3575 | |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3576 | Add(std::make_shared<SAMPLER_YCBCR_CONVERSION_STATE>(ycbcr_conversion, create_info, format_features)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3577 | } |
| 3578 | |
| 3579 | void ValidationStateTracker::PostCallRecordCreateSamplerYcbcrConversion(VkDevice device, |
| 3580 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 3581 | const VkAllocationCallbacks *pAllocator, |
| 3582 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 3583 | VkResult result) { |
| 3584 | if (VK_SUCCESS != result) return; |
| 3585 | RecordCreateSamplerYcbcrConversionState(pCreateInfo, *pYcbcrConversion); |
| 3586 | } |
| 3587 | |
| 3588 | void ValidationStateTracker::PostCallRecordCreateSamplerYcbcrConversionKHR(VkDevice device, |
| 3589 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 3590 | const VkAllocationCallbacks *pAllocator, |
| 3591 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 3592 | VkResult result) { |
| 3593 | if (VK_SUCCESS != result) return; |
| 3594 | RecordCreateSamplerYcbcrConversionState(pCreateInfo, *pYcbcrConversion); |
| 3595 | } |
| 3596 | |
| 3597 | void ValidationStateTracker::PostCallRecordDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, |
| 3598 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3599 | Destroy<SAMPLER_YCBCR_CONVERSION_STATE>(ycbcrConversion); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3600 | } |
| 3601 | |
| 3602 | void ValidationStateTracker::PostCallRecordDestroySamplerYcbcrConversionKHR(VkDevice device, |
| 3603 | VkSamplerYcbcrConversion ycbcrConversion, |
| 3604 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3605 | Destroy<SAMPLER_YCBCR_CONVERSION_STATE>(ycbcrConversion); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3606 | } |
| 3607 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3608 | void ValidationStateTracker::RecordResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 3609 | uint32_t queryCount) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3610 | // Do nothing if the feature is not enabled. |
Piers Daniell | 41b8c5d | 2020-01-10 15:42:00 -0700 | [diff] [blame] | 3611 | if (!enabled_features.core12.hostQueryReset) return; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3612 | |
| 3613 | // Do nothing if the query pool has been destroyed. |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3614 | auto query_pool_state = Get<QUERY_POOL_STATE>(queryPool); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3615 | if (!query_pool_state) return; |
| 3616 | |
| 3617 | // Reset the state of existing entries. |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3618 | const uint32_t max_query_count = std::min(queryCount, query_pool_state->createInfo.queryCount - firstQuery); |
| 3619 | for (uint32_t i = 0; i < max_query_count; ++i) { |
Jeremy Gebben | 1858ae9 | 2021-12-02 11:28:05 -0700 | [diff] [blame] | 3620 | auto query_index = firstQuery + i; |
| 3621 | query_pool_state->SetQueryState(query_index, 0, QUERYSTATE_RESET); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3622 | if (query_pool_state->createInfo.queryType == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3623 | for (uint32_t pass_index = 0; pass_index < query_pool_state->n_performance_passes; pass_index++) { |
Jeremy Gebben | 1858ae9 | 2021-12-02 11:28:05 -0700 | [diff] [blame] | 3624 | query_pool_state->SetQueryState(query_index, pass_index, QUERYSTATE_RESET); |
Lionel Landwerlin | c742091 | 2019-05-23 00:33:42 +0100 | [diff] [blame] | 3625 | } |
| 3626 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3627 | } |
| 3628 | } |
| 3629 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3630 | void ValidationStateTracker::PostCallRecordResetQueryPoolEXT(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 3631 | uint32_t queryCount) { |
| 3632 | RecordResetQueryPool(device, queryPool, firstQuery, queryCount); |
| 3633 | } |
| 3634 | |
| 3635 | void ValidationStateTracker::PostCallRecordResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, |
| 3636 | uint32_t queryCount) { |
| 3637 | RecordResetQueryPool(device, queryPool, firstQuery, queryCount); |
| 3638 | } |
| 3639 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3640 | void ValidationStateTracker::PerformUpdateDescriptorSetsWithTemplateKHR(VkDescriptorSet descriptorSet, |
Jeremy Gebben | fc89045 | 2021-10-27 10:56:49 -0600 | [diff] [blame] | 3641 | const UPDATE_TEMPLATE_STATE *template_state, |
| 3642 | const void *pData) { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3643 | // Translate the templated update into a normal update for validation... |
| 3644 | cvdescriptorset::DecodedTemplateUpdate decoded_update(this, descriptorSet, template_state, pData); |
| 3645 | cvdescriptorset::PerformUpdateDescriptorSets(this, static_cast<uint32_t>(decoded_update.desc_writes.size()), |
| 3646 | decoded_update.desc_writes.data(), 0, NULL); |
| 3647 | } |
| 3648 | |
| 3649 | // Update the common AllocateDescriptorSetsData |
| 3650 | void ValidationStateTracker::UpdateAllocateDescriptorSetsData(const VkDescriptorSetAllocateInfo *p_alloc_info, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 3651 | cvdescriptorset::AllocateDescriptorSetsData *ds_data) const { |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3652 | for (uint32_t i = 0; i < p_alloc_info->descriptorSetCount; i++) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3653 | auto layout = Get<cvdescriptorset::DescriptorSetLayout>(p_alloc_info->pSetLayouts[i]); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3654 | if (layout) { |
| 3655 | ds_data->layout_nodes[i] = layout; |
| 3656 | // Count total descriptors required per type |
| 3657 | for (uint32_t j = 0; j < layout->GetBindingCount(); ++j) { |
| 3658 | const auto &binding_layout = layout->GetDescriptorSetLayoutBindingPtrFromIndex(j); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3659 | uint32_t type_index = static_cast<uint32_t>(binding_layout->descriptorType); |
| 3660 | ds_data->required_descriptors_by_type[type_index] += binding_layout->descriptorCount; |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3661 | } |
| 3662 | } |
| 3663 | // Any unknown layouts will be flagged as errors during ValidateAllocateDescriptorSets() call |
| 3664 | } |
| 3665 | } |
| 3666 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3667 | void ValidationStateTracker::PostCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, |
| 3668 | uint32_t firstVertex, uint32_t firstInstance) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3669 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3670 | cb_state->UpdateStateCmdDrawType(CMD_DRAW, VK_PIPELINE_BIND_POINT_GRAPHICS); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3671 | } |
| 3672 | |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 3673 | void ValidationStateTracker::PostCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 3674 | const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount, |
| 3675 | uint32_t firstInstance, uint32_t stride) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3676 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3677 | cb_state->UpdateStateCmdDrawType(CMD_DRAWMULTIEXT, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 3678 | } |
| 3679 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3680 | void ValidationStateTracker::PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, |
| 3681 | uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, |
| 3682 | uint32_t firstInstance) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3683 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3684 | cb_state->UpdateStateCmdDrawType(CMD_DRAWINDEXED, VK_PIPELINE_BIND_POINT_GRAPHICS); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3685 | } |
| 3686 | |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 3687 | void ValidationStateTracker::PostCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 3688 | const VkMultiDrawIndexedInfoEXT *pIndexInfo, |
| 3689 | uint32_t instanceCount, uint32_t firstInstance, uint32_t stride, |
| 3690 | const int32_t *pVertexOffset) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3691 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3692 | cb_state->UpdateStateCmdDrawType(CMD_DRAWMULTIINDEXEDEXT, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 3693 | } |
| 3694 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3695 | void ValidationStateTracker::PostCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 3696 | uint32_t count, uint32_t stride) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3697 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
| 3698 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3699 | cb_state->UpdateStateCmdDrawType(CMD_DRAWINDIRECT, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3700 | if (!disabled[command_buffer_state]) { |
| 3701 | cb_state->AddChild(buffer_state); |
| 3702 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3703 | } |
| 3704 | |
| 3705 | void ValidationStateTracker::PostCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3706 | VkDeviceSize offset, uint32_t count, uint32_t stride) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3707 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
| 3708 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3709 | cb_state->UpdateStateCmdDrawType(CMD_DRAWINDEXEDINDIRECT, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3710 | if (!disabled[command_buffer_state]) { |
| 3711 | cb_state->AddChild(buffer_state); |
| 3712 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3713 | } |
| 3714 | |
| 3715 | void ValidationStateTracker::PostCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3716 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3717 | cb_state->UpdateStateCmdDrawDispatchType(CMD_DISPATCH, VK_PIPELINE_BIND_POINT_COMPUTE); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3718 | } |
| 3719 | |
| 3720 | void ValidationStateTracker::PostCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3721 | VkDeviceSize offset) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3722 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3723 | cb_state->UpdateStateCmdDrawDispatchType(CMD_DISPATCHINDIRECT, VK_PIPELINE_BIND_POINT_COMPUTE); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3724 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3725 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3726 | cb_state->AddChild(buffer_state); |
| 3727 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3728 | } |
| 3729 | |
Nathaniel Cesario | a1325f4 | 2021-10-26 13:18:11 -0600 | [diff] [blame] | 3730 | void ValidationStateTracker::PostCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t, uint32_t, uint32_t, uint32_t, |
| 3731 | uint32_t, uint32_t) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3732 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Nathaniel Cesario | a1325f4 | 2021-10-26 13:18:11 -0600 | [diff] [blame] | 3733 | cb_state->UpdateStateCmdDrawDispatchType(CMD_DISPATCH, VK_PIPELINE_BIND_POINT_COMPUTE); |
| 3734 | } |
| 3735 | |
| 3736 | void ValidationStateTracker::PostCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t, uint32_t, uint32_t, uint32_t, |
| 3737 | uint32_t, uint32_t) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3738 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Nathaniel Cesario | a1325f4 | 2021-10-26 13:18:11 -0600 | [diff] [blame] | 3739 | cb_state->UpdateStateCmdDrawDispatchType(CMD_DISPATCH, VK_PIPELINE_BIND_POINT_COMPUTE); |
| 3740 | } |
| 3741 | |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3742 | void ValidationStateTracker::RecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 3743 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3744 | uint32_t stride, CMD_TYPE cmd_type) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3745 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3746 | cb_state->UpdateStateCmdDrawType(cmd_type, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3747 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3748 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
| 3749 | auto count_buffer_state = Get<BUFFER_STATE>(countBuffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3750 | cb_state->AddChild(buffer_state); |
| 3751 | cb_state->AddChild(count_buffer_state); |
| 3752 | } |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3753 | } |
| 3754 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3755 | void ValidationStateTracker::PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3756 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3757 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3758 | uint32_t stride) { |
locke-lunarg | 540b225 | 2020-08-03 13:23:36 -0600 | [diff] [blame] | 3759 | RecordCmdDrawIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3760 | CMD_DRAWINDIRECTCOUNTKHR); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3761 | } |
| 3762 | |
| 3763 | void ValidationStateTracker::PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 3764 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, |
| 3765 | uint32_t maxDrawCount, uint32_t stride) { |
locke-lunarg | 540b225 | 2020-08-03 13:23:36 -0600 | [diff] [blame] | 3766 | RecordCmdDrawIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3767 | CMD_DRAWINDIRECTCOUNT); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3768 | } |
| 3769 | |
| 3770 | void ValidationStateTracker::RecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 3771 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3772 | uint32_t maxDrawCount, uint32_t stride, CMD_TYPE cmd_type) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3773 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3774 | cb_state->UpdateStateCmdDrawType(cmd_type, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3775 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3776 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
| 3777 | auto count_buffer_state = Get<BUFFER_STATE>(countBuffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3778 | cb_state->AddChild(buffer_state); |
| 3779 | cb_state->AddChild(count_buffer_state); |
| 3780 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3781 | } |
| 3782 | |
| 3783 | void ValidationStateTracker::PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3784 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3785 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3786 | uint32_t stride) { |
locke-lunarg | 540b225 | 2020-08-03 13:23:36 -0600 | [diff] [blame] | 3787 | RecordCmdDrawIndexedIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3788 | CMD_DRAWINDEXEDINDIRECTCOUNTKHR); |
Tony-LunarG | 977448c | 2019-12-02 14:52:02 -0700 | [diff] [blame] | 3789 | } |
| 3790 | |
| 3791 | void ValidationStateTracker::PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3792 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3793 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3794 | uint32_t stride) { |
locke-lunarg | 540b225 | 2020-08-03 13:23:36 -0600 | [diff] [blame] | 3795 | RecordCmdDrawIndexedIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3796 | CMD_DRAWINDEXEDINDIRECTCOUNT); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3797 | } |
| 3798 | |
| 3799 | void ValidationStateTracker::PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
| 3800 | uint32_t firstTask) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3801 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3802 | cb_state->UpdateStateCmdDrawType(CMD_DRAWMESHTASKSNV, VK_PIPELINE_BIND_POINT_GRAPHICS); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | void ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3806 | VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3807 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3808 | cb_state->UpdateStateCmdDrawType(CMD_DRAWMESHTASKSINDIRECTNV, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3809 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3810 | if (!disabled[command_buffer_state] && buffer_state) { |
| 3811 | cb_state->AddChild(buffer_state); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3812 | } |
| 3813 | } |
| 3814 | |
| 3815 | void ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3816 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3817 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3818 | uint32_t stride) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3819 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3820 | cb_state->UpdateStateCmdDrawType(CMD_DRAWMESHTASKSINDIRECTCOUNTNV, VK_PIPELINE_BIND_POINT_GRAPHICS); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3821 | if (!disabled[command_buffer_state]) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3822 | auto buffer_state = Get<BUFFER_STATE>(buffer); |
| 3823 | auto count_buffer_state = Get<BUFFER_STATE>(countBuffer); |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3824 | if (buffer_state) { |
| 3825 | cb_state->AddChild(buffer_state); |
| 3826 | } |
| 3827 | if (count_buffer_state) { |
| 3828 | cb_state->AddChild(count_buffer_state); |
| 3829 | } |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3830 | } |
| 3831 | } |
| 3832 | |
Jeremy Gebben | 252f60c | 2021-07-15 14:54:30 -0600 | [diff] [blame] | 3833 | void ValidationStateTracker::PostCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, |
| 3834 | VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, |
| 3835 | VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 3836 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, |
| 3837 | VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, |
| 3838 | VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 3839 | uint32_t width, uint32_t height, uint32_t depth) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3840 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3841 | cb_state->UpdateStateCmdDrawDispatchType(CMD_TRACERAYSNV, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV); |
Jeremy Gebben | 252f60c | 2021-07-15 14:54:30 -0600 | [diff] [blame] | 3842 | cb_state->hasTraceRaysCmd = true; |
| 3843 | } |
| 3844 | |
Jeremy Gebben | 252f60c | 2021-07-15 14:54:30 -0600 | [diff] [blame] | 3845 | void ValidationStateTracker::PostCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
| 3846 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 3847 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 3848 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 3849 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, uint32_t width, |
| 3850 | uint32_t height, uint32_t depth) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3851 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3852 | cb_state->UpdateStateCmdDrawDispatchType(CMD_TRACERAYSKHR, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR); |
Jeremy Gebben | 252f60c | 2021-07-15 14:54:30 -0600 | [diff] [blame] | 3853 | cb_state->hasTraceRaysCmd = true; |
| 3854 | } |
| 3855 | |
| 3856 | void ValidationStateTracker::PostCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, |
| 3857 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 3858 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 3859 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 3860 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
| 3861 | VkDeviceAddress indirectDeviceAddress) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3862 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 3863 | cb_state->UpdateStateCmdDrawDispatchType(CMD_TRACERAYSINDIRECTKHR, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR); |
Jeremy Gebben | 252f60c | 2021-07-15 14:54:30 -0600 | [diff] [blame] | 3864 | cb_state->hasTraceRaysCmd = true; |
| 3865 | } |
| 3866 | |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3867 | void ValidationStateTracker::PostCallRecordCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, |
| 3868 | const VkAllocationCallbacks *pAllocator, |
| 3869 | VkShaderModule *pShaderModule, VkResult result, |
| 3870 | void *csm_state_data) { |
| 3871 | if (VK_SUCCESS != result) return; |
| 3872 | create_shader_module_api_state *csm_state = reinterpret_cast<create_shader_module_api_state *>(csm_state_data); |
| 3873 | |
sfricke-samsung | 45996a4 | 2021-09-16 13:45:27 -0700 | [diff] [blame] | 3874 | spv_target_env spirv_environment = PickSpirvEnv(api_version, IsExtEnabled(device_extensions.vk_khr_spirv_1_4)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3875 | bool is_spirv = (pCreateInfo->pCode[0] == spv::MagicNumber); |
Jeff Bolz | e7fc67b | 2019-10-04 12:29:31 -0500 | [diff] [blame] | 3876 | auto new_shader_module = is_spirv ? std::make_shared<SHADER_MODULE_STATE>(pCreateInfo, *pShaderModule, spirv_environment, |
| 3877 | csm_state->unique_shader_id) |
| 3878 | : std::make_shared<SHADER_MODULE_STATE>(); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3879 | Add(std::move(new_shader_module)); |
locke-lunarg | d556cc3 | 2019-09-17 01:21:23 -0600 | [diff] [blame] | 3880 | } |
| 3881 | |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3882 | void ValidationStateTracker::PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 3883 | uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages, |
| 3884 | VkResult result) { |
| 3885 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 3886 | auto swapchain_state = Get<SWAPCHAIN_NODE>(swapchain); |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3887 | |
| 3888 | if (*pSwapchainImageCount > swapchain_state->images.size()) swapchain_state->images.resize(*pSwapchainImageCount); |
| 3889 | |
| 3890 | if (pSwapchainImages) { |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3891 | for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) { |
John Zulauf | 29d0053 | 2021-03-04 13:28:54 -0700 | [diff] [blame] | 3892 | SWAPCHAIN_IMAGE &swapchain_image = swapchain_state->images[i]; |
John Zulauf | faa7a52 | 2021-03-05 12:22:45 -0700 | [diff] [blame] | 3893 | if (swapchain_image.image_state) continue; // Already retrieved this. |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3894 | |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3895 | auto format_features = |
| 3896 | GetImageFormatFeatures(physical_device, device, pSwapchainImages[i], swapchain_state->image_create_info.format, |
| 3897 | swapchain_state->image_create_info.tiling); |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3898 | |
Jeremy Gebben | bc9aacf | 2021-09-23 11:57:37 -0600 | [diff] [blame] | 3899 | auto image_state = std::make_shared<IMAGE_STATE>(this, pSwapchainImages[i], swapchain_state->image_create_info.ptr(), |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3900 | swapchain, i, format_features); |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 3901 | if (!swapchain_image.fake_base_address) { |
| 3902 | auto size = image_state->fragment_encoder->TotalSize(); |
| 3903 | swapchain_image.fake_base_address = fake_memory.Alloc(size); |
John Zulauf | 29d0053 | 2021-03-04 13:28:54 -0700 | [diff] [blame] | 3904 | } |
| 3905 | |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 3906 | image_state->SetSwapchain(swapchain_state, i); |
Jeremy Gebben | b4d1701 | 2021-07-08 13:18:15 -0600 | [diff] [blame] | 3907 | swapchain_image.image_state = image_state.get(); |
Jeremy Gebben | 082a983 | 2021-10-28 13:40:11 -0600 | [diff] [blame] | 3908 | Add(std::move(image_state)); |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3909 | } |
| 3910 | } |
| 3911 | |
| 3912 | if (*pSwapchainImageCount) { |
John Zulauf | 22b0fbe | 2019-10-15 06:26:16 -0600 | [diff] [blame] | 3913 | swapchain_state->get_swapchain_image_count = *pSwapchainImageCount; |
| 3914 | } |
| 3915 | } |
sourav parmar | 35e7a00 | 2020-06-09 17:58:44 -0700 | [diff] [blame] | 3916 | |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 3917 | void ValidationStateTracker::PostCallRecordCopyAccelerationStructureKHR(VkDevice device, VkDeferredOperationKHR deferredOperation, |
| 3918 | const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 3919 | VkResult result) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3920 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfo->src); |
| 3921 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfo->dst); |
Lars-Ivar Hesselberg Simonsen | 0dd3a81 | 2021-10-28 14:09:01 +0200 | [diff] [blame] | 3922 | if (dst_as_state != nullptr && src_as_state != nullptr) { |
| 3923 | dst_as_state->built = true; |
| 3924 | dst_as_state->build_info_khr = src_as_state->build_info_khr; |
| 3925 | } |
| 3926 | } |
| 3927 | |
sourav parmar | 35e7a00 | 2020-06-09 17:58:44 -0700 | [diff] [blame] | 3928 | void ValidationStateTracker::PostCallRecordCmdCopyAccelerationStructureKHR(VkCommandBuffer commandBuffer, |
| 3929 | const VkCopyAccelerationStructureInfoKHR *pInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3930 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
sourav parmar | 35e7a00 | 2020-06-09 17:58:44 -0700 | [diff] [blame] | 3931 | if (cb_state) { |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3932 | cb_state->RecordCmd(CMD_COPYACCELERATIONSTRUCTUREKHR); |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3933 | auto src_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfo->src); |
| 3934 | auto dst_as_state = Get<ACCELERATION_STRUCTURE_STATE_KHR>(pInfo->dst); |
sourav parmar | 35e7a00 | 2020-06-09 17:58:44 -0700 | [diff] [blame] | 3935 | if (dst_as_state != nullptr && src_as_state != nullptr) { |
| 3936 | dst_as_state->built = true; |
| 3937 | dst_as_state->build_info_khr = src_as_state->build_info_khr; |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 3938 | if (!disabled[command_buffer_state]) { |
| 3939 | cb_state->AddChild(dst_as_state); |
| 3940 | cb_state->AddChild(src_as_state); |
| 3941 | } |
sourav parmar | 35e7a00 | 2020-06-09 17:58:44 -0700 | [diff] [blame] | 3942 | } |
| 3943 | } |
| 3944 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3945 | |
| 3946 | void ValidationStateTracker::PreCallRecordCmdSetCullModeEXT(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3947 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3948 | cb_state->RecordStateCmd(CMD_SETCULLMODEEXT, CBSTATUS_CULL_MODE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3949 | } |
| 3950 | |
| 3951 | void ValidationStateTracker::PreCallRecordCmdSetFrontFaceEXT(VkCommandBuffer commandBuffer, VkFrontFace frontFace) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3952 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3953 | cb_state->RecordStateCmd(CMD_SETFRONTFACEEXT, CBSTATUS_FRONT_FACE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3954 | } |
| 3955 | |
| 3956 | void ValidationStateTracker::PreCallRecordCmdSetPrimitiveTopologyEXT(VkCommandBuffer commandBuffer, |
| 3957 | VkPrimitiveTopology primitiveTopology) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3958 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3959 | cb_state->RecordStateCmd(CMD_SETPRIMITIVETOPOLOGYEXT, CBSTATUS_PRIMITIVE_TOPOLOGY_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3960 | cb_state->primitiveTopology = primitiveTopology; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3961 | } |
| 3962 | |
| 3963 | void ValidationStateTracker::PreCallRecordCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 3964 | const VkViewport *pViewports) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3965 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3966 | cb_state->RecordStateCmd(CMD_SETVIEWPORTWITHCOUNTEXT, CBSTATUS_VIEWPORT_WITH_COUNT_SET); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 3967 | uint32_t bits = (1u << viewportCount) - 1u; |
| 3968 | cb_state->viewportWithCountMask |= bits; |
| 3969 | cb_state->trashedViewportMask &= ~bits; |
Tobias Hector | 6663c9b | 2020-11-05 10:18:02 +0000 | [diff] [blame] | 3970 | cb_state->viewportWithCountCount = viewportCount; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 3971 | cb_state->trashedViewportCount = false; |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 3972 | |
| 3973 | cb_state->dynamicViewports.resize(std::max(size_t(viewportCount), cb_state->dynamicViewports.size())); |
| 3974 | for (size_t i = 0; i < viewportCount; ++i) { |
| 3975 | cb_state->dynamicViewports[i] = pViewports[i]; |
| 3976 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3977 | } |
| 3978 | |
| 3979 | void ValidationStateTracker::PreCallRecordCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 3980 | const VkRect2D *pScissors) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3981 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3982 | cb_state->RecordStateCmd(CMD_SETSCISSORWITHCOUNTEXT, CBSTATUS_SCISSOR_WITH_COUNT_SET); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 3983 | uint32_t bits = (1u << scissorCount) - 1u; |
| 3984 | cb_state->scissorWithCountMask |= bits; |
| 3985 | cb_state->trashedScissorMask &= ~bits; |
| 3986 | cb_state->scissorWithCountCount = scissorCount; |
| 3987 | cb_state->trashedScissorCount = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3988 | } |
| 3989 | |
| 3990 | void ValidationStateTracker::PreCallRecordCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 3991 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 3992 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 3993 | const VkDeviceSize *pStrides) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 3994 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 3995 | cb_state->RecordStateCmd(CMD_BINDVERTEXBUFFERS2EXT, pStrides ? CBSTATUS_VERTEX_INPUT_BINDING_STRIDE_SET : CBSTATUS_NONE); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 3996 | |
| 3997 | uint32_t end = firstBinding + bindingCount; |
| 3998 | if (cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings.size() < end) { |
| 3999 | cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings.resize(end); |
| 4000 | } |
| 4001 | |
| 4002 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 4003 | auto &vertex_buffer_binding = cb_state->current_vertex_buffer_binding_info.vertex_buffer_bindings[i + firstBinding]; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 4004 | vertex_buffer_binding.buffer_state = Get<BUFFER_STATE>(pBuffers[i]); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4005 | vertex_buffer_binding.offset = pOffsets[i]; |
| 4006 | vertex_buffer_binding.size = (pSizes) ? pSizes[i] : VK_WHOLE_SIZE; |
| 4007 | vertex_buffer_binding.stride = (pStrides) ? pStrides[i] : 0; |
| 4008 | // Add binding for this vertex buffer to this commandbuffer |
Jeremy Gebben | 9efe1cf | 2021-05-15 20:05:09 -0600 | [diff] [blame] | 4009 | if (!disabled[command_buffer_state] && pBuffers[i]) { |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 4010 | cb_state->AddChild(vertex_buffer_binding.buffer_state); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4011 | } |
| 4012 | } |
| 4013 | } |
| 4014 | |
| 4015 | void ValidationStateTracker::PreCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4016 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4017 | cb_state->RecordStateCmd(CMD_SETDEPTHTESTENABLEEXT, CBSTATUS_DEPTH_TEST_ENABLE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | void ValidationStateTracker::PreCallRecordCmdSetDepthWriteEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4021 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4022 | cb_state->RecordStateCmd(CMD_SETDEPTHWRITEENABLEEXT, CBSTATUS_DEPTH_WRITE_ENABLE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4023 | } |
| 4024 | |
| 4025 | void ValidationStateTracker::PreCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4026 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4027 | cb_state->RecordStateCmd(CMD_SETDEPTHCOMPAREOPEXT, CBSTATUS_DEPTH_COMPARE_OP_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | void ValidationStateTracker::PreCallRecordCmdSetDepthBoundsTestEnableEXT(VkCommandBuffer commandBuffer, |
| 4031 | VkBool32 depthBoundsTestEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4032 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4033 | cb_state->RecordStateCmd(CMD_SETDEPTHBOUNDSTESTENABLEEXT, CBSTATUS_DEPTH_BOUNDS_TEST_ENABLE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4034 | } |
| 4035 | void ValidationStateTracker::PreCallRecordCmdSetStencilTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4036 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4037 | cb_state->RecordStateCmd(CMD_SETSTENCILTESTENABLEEXT, CBSTATUS_STENCIL_TEST_ENABLE_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | void ValidationStateTracker::PreCallRecordCmdSetStencilOpEXT(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, |
| 4041 | VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, |
| 4042 | VkCompareOp compareOp) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4043 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4044 | cb_state->RecordStateCmd(CMD_SETSTENCILOPEXT, CBSTATUS_STENCIL_OP_SET); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 4045 | } |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 4046 | |
| 4047 | void ValidationStateTracker::PreCallRecordCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, |
| 4048 | uint32_t discardRectangleCount, |
| 4049 | const VkRect2D *pDiscardRectangles) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4050 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4051 | cb_state->RecordStateCmd(CMD_SETDISCARDRECTANGLEEXT, CBSTATUS_DISCARD_RECTANGLE_SET); |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 4052 | } |
| 4053 | |
| 4054 | void ValidationStateTracker::PreCallRecordCmdSetSampleLocationsEXT(VkCommandBuffer commandBuffer, |
| 4055 | const VkSampleLocationsInfoEXT *pSampleLocationsInfo) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4056 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4057 | cb_state->RecordStateCmd(CMD_SETSAMPLELOCATIONSEXT, CBSTATUS_SAMPLE_LOCATIONS_SET); |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 4058 | } |
| 4059 | |
| 4060 | void ValidationStateTracker::PreCallRecordCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, |
| 4061 | VkCoarseSampleOrderTypeNV sampleOrderType, |
| 4062 | uint32_t customSampleOrderCount, |
| 4063 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4064 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4065 | cb_state->RecordStateCmd(CMD_SETCOARSESAMPLEORDERNV, CBSTATUS_COARSE_SAMPLE_ORDER_SET); |
locke-lunarg | 4189aa2 | 2020-10-21 00:23:48 -0600 | [diff] [blame] | 4066 | } |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 4067 | |
| 4068 | void ValidationStateTracker::PreCallRecordCmdSetPatchControlPointsEXT(VkCommandBuffer commandBuffer, uint32_t patchControlPoints) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4069 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4070 | cb_state->RecordStateCmd(CMD_SETPATCHCONTROLPOINTSEXT, CBSTATUS_PATCH_CONTROL_POINTS_SET); |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 4071 | } |
| 4072 | |
| 4073 | void ValidationStateTracker::PreCallRecordCmdSetLogicOpEXT(VkCommandBuffer commandBuffer, VkLogicOp logicOp) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4074 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4075 | cb_state->RecordStateCmd(CMD_SETLOGICOPEXT, CBSTATUS_LOGIC_OP_SET); |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 4076 | } |
| 4077 | |
| 4078 | void ValidationStateTracker::PreCallRecordCmdSetRasterizerDiscardEnableEXT(VkCommandBuffer commandBuffer, |
| 4079 | VkBool32 rasterizerDiscardEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4080 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4081 | cb_state->RecordStateCmd(CMD_SETRASTERIZERDISCARDENABLEEXT, CBSTATUS_RASTERIZER_DISCARD_ENABLE_SET); |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 4082 | } |
| 4083 | |
| 4084 | void ValidationStateTracker::PreCallRecordCmdSetDepthBiasEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4085 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4086 | cb_state->RecordStateCmd(CMD_SETDEPTHBIASENABLEEXT, CBSTATUS_DEPTH_BIAS_ENABLE_SET); |
Vikram Kushwaha | a57b0c3 | 2021-04-19 12:21:46 -0700 | [diff] [blame] | 4087 | } |
| 4088 | |
| 4089 | void ValidationStateTracker::PreCallRecordCmdSetPrimitiveRestartEnableEXT(VkCommandBuffer commandBuffer, |
| 4090 | VkBool32 primitiveRestartEnable) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4091 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
Jeremy Gebben | 10a0ed1 | 2021-08-17 09:54:29 -0600 | [diff] [blame] | 4092 | cb_state->RecordStateCmd(CMD_SETPRIMITIVERESTARTENABLEEXT, CBSTATUS_PRIMITIVE_RESTART_ENABLE_SET); |
David Zhao Akeley | 44139b1 | 2021-04-26 16:16:13 -0700 | [diff] [blame] | 4093 | } |
Piers Daniell | 924cd83 | 2021-05-18 13:48:47 -0600 | [diff] [blame] | 4094 | |
| 4095 | void ValidationStateTracker::PreCallRecordCmdSetVertexInputEXT( |
| 4096 | VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount, |
| 4097 | const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount, |
| 4098 | const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4099 | auto cb_state = Get<CMD_BUFFER_STATE>(commandBuffer); |
ziga-lunarg | 4af0a8c | 2021-08-27 15:53:20 +0200 | [diff] [blame] | 4100 | CBStatusFlags status_flags = CBSTATUS_VERTEX_INPUT_SET; |
| 4101 | |
| 4102 | const auto lv_bind_point = ConvertToLvlBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS); |
| 4103 | const auto pipeline_state = cb_state->lastBound[lv_bind_point].pipeline_state; |
| 4104 | if (pipeline_state) { |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 4105 | if (pipeline_state->create_info.graphics.pDynamicState) { |
| 4106 | for (uint32_t i = 0; i < pipeline_state->create_info.graphics.pDynamicState->dynamicStateCount; ++i) { |
| 4107 | if (pipeline_state->create_info.graphics.pDynamicState->pDynamicStates[i] == |
ziga-lunarg | 4af0a8c | 2021-08-27 15:53:20 +0200 | [diff] [blame] | 4108 | VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 4109 | status_flags |= CBSTATUS_VERTEX_INPUT_BINDING_STRIDE_SET; |
| 4110 | break; |
| 4111 | } |
| 4112 | } |
| 4113 | } |
| 4114 | } |
| 4115 | cb_state->RecordStateCmd(CMD_SETVERTEXINPUTEXT, status_flags); |
Piers Daniell | 924cd83 | 2021-05-18 13:48:47 -0600 | [diff] [blame] | 4116 | } |
Nathaniel Cesario | 42ac6ca | 2021-06-15 17:23:05 -0600 | [diff] [blame] | 4117 | |
| 4118 | void ValidationStateTracker::RecordGetBufferDeviceAddress(const VkBufferDeviceAddressInfo *pInfo, VkDeviceAddress address) { |
Jeremy Gebben | b20a824 | 2021-11-05 15:14:43 -0600 | [diff] [blame] | 4119 | auto buffer_state = Get<BUFFER_STATE>(pInfo->buffer); |
Nathaniel Cesario | 42ac6ca | 2021-06-15 17:23:05 -0600 | [diff] [blame] | 4120 | if (buffer_state) { |
| 4121 | // address is used for GPU-AV and ray tracing buffer validation |
| 4122 | buffer_state->deviceAddress = address; |
Jeremy Gebben | 9f53710 | 2021-10-05 16:37:12 -0600 | [diff] [blame^] | 4123 | buffer_address_map_.emplace(address, buffer_state.get()); |
Nathaniel Cesario | 42ac6ca | 2021-06-15 17:23:05 -0600 | [diff] [blame] | 4124 | } |
| 4125 | } |
| 4126 | |
| 4127 | void ValidationStateTracker::PostCallRecordGetBufferDeviceAddress(VkDevice device, const VkBufferDeviceAddressInfo *pInfo, |
| 4128 | VkDeviceAddress address) { |
| 4129 | RecordGetBufferDeviceAddress(pInfo, address); |
| 4130 | } |
| 4131 | |
| 4132 | void ValidationStateTracker::PostCallRecordGetBufferDeviceAddressKHR(VkDevice device, const VkBufferDeviceAddressInfo *pInfo, |
| 4133 | VkDeviceAddress address) { |
| 4134 | RecordGetBufferDeviceAddress(pInfo, address); |
| 4135 | } |
| 4136 | |
| 4137 | void ValidationStateTracker::PostCallRecordGetBufferDeviceAddressEXT(VkDevice device, const VkBufferDeviceAddressInfo *pInfo, |
| 4138 | VkDeviceAddress address) { |
| 4139 | RecordGetBufferDeviceAddress(pInfo, address); |
Nathaniel Cesario | 39152e6 | 2021-07-02 13:04:16 -0600 | [diff] [blame] | 4140 | } |
| 4141 | |
| 4142 | std::shared_ptr<SWAPCHAIN_NODE> ValidationStateTracker::CreateSwapchainState(const VkSwapchainCreateInfoKHR *create_info, |
| 4143 | VkSwapchainKHR swapchain) { |
Jeremy Gebben | 62c3bf4 | 2021-07-21 15:38:24 -0600 | [diff] [blame] | 4144 | return std::make_shared<SWAPCHAIN_NODE>(this, create_info, swapchain); |
Nathaniel Cesario | 39152e6 | 2021-07-02 13:04:16 -0600 | [diff] [blame] | 4145 | } |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 4146 | |
| 4147 | std::shared_ptr<CMD_BUFFER_STATE> ValidationStateTracker::CreateCmdBufferState(VkCommandBuffer cb, |
| 4148 | const VkCommandBufferAllocateInfo *create_info, |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 4149 | const COMMAND_POOL_STATE *pool) { |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 4150 | return std::make_shared<CMD_BUFFER_STATE>(this, cb, create_info, pool); |
| 4151 | } |