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