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