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