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