Tony-LunarG | 4c25337 | 2022-01-18 13:51:07 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2018-2022 The Khronos Group Inc. |
| 2 | * Copyright (c) 2018-2022 Valve Corporation |
| 3 | * Copyright (c) 2018-2022 LunarG, Inc. |
Karl Schultz | 7b024b4 | 2018-08-30 16:18:18 -0600 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 17 | * Author: Karl Schultz <karl@lunarg.com> |
| 18 | * Author: Tony Barbour <tony@lunarg.com> |
Karl Schultz | 7b024b4 | 2018-08-30 16:18:18 -0600 | [diff] [blame] | 19 | */ |
| 20 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 21 | #pragma once |
| 22 | |
Tony-LunarG | b5fae46 | 2020-03-05 12:43:25 -0700 | [diff] [blame] | 23 | #include "gpu_utils.h" |
Jeremy Gebben | 5160e03 | 2022-03-28 14:57:43 -0600 | [diff] [blame] | 24 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 25 | class GpuAssisted; |
Tony-LunarG | 0e56472 | 2019-03-19 16:09:14 -0600 | [diff] [blame] | 26 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 27 | struct GpuAssistedDeviceMemoryBlock { |
Mark Lobodzinski | 2a3ee4a | 2019-03-13 13:11:39 -0600 | [diff] [blame] | 28 | VkBuffer buffer; |
Tony-LunarG | 0e56472 | 2019-03-19 16:09:14 -0600 | [diff] [blame] | 29 | VmaAllocation allocation; |
Jeremy Gebben | f4816f7 | 2022-07-15 08:56:06 -0600 | [diff] [blame] | 30 | layer_data::unordered_map<uint32_t, const cvdescriptorset::DescriptorBinding*> update_at_submit; |
Mark Lobodzinski | 2a3ee4a | 2019-03-13 13:11:39 -0600 | [diff] [blame] | 31 | }; |
| 32 | |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 33 | struct GpuAssistedPreDrawResources { |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 34 | VkDescriptorPool desc_pool = VK_NULL_HANDLE; |
| 35 | VkDescriptorSet desc_set = VK_NULL_HANDLE; |
| 36 | VkBuffer buffer = VK_NULL_HANDLE; |
| 37 | VkDeviceSize offset = 0; |
| 38 | uint32_t stride = 0; |
| 39 | VkDeviceSize buf_size = 0; |
| 40 | static const uint32_t push_constant_words = 4; |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 41 | }; |
| 42 | |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 43 | struct GpuAssistedPreDispatchResources { |
| 44 | VkDescriptorPool desc_pool = VK_NULL_HANDLE; |
| 45 | VkDescriptorSet desc_set = VK_NULL_HANDLE; |
| 46 | VkBuffer buffer = VK_NULL_HANDLE; |
| 47 | VkDeviceSize offset = 0; |
| 48 | static const uint32_t push_constant_words = 4; |
| 49 | }; |
| 50 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 51 | struct GpuAssistedBufferInfo { |
| 52 | GpuAssistedDeviceMemoryBlock output_mem_block; |
| 53 | GpuAssistedDeviceMemoryBlock di_input_mem_block; // Descriptor Indexing input |
| 54 | GpuAssistedDeviceMemoryBlock bda_input_mem_block; // Buffer Device Address input |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 55 | GpuAssistedPreDrawResources pre_draw_resources; |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 56 | GpuAssistedPreDispatchResources pre_dispatch_resources; |
Mark Lobodzinski | 2a3ee4a | 2019-03-13 13:11:39 -0600 | [diff] [blame] | 57 | VkDescriptorSet desc_set; |
| 58 | VkDescriptorPool desc_pool; |
Jason Macnak | 67407e7 | 2019-07-11 11:05:09 -0700 | [diff] [blame] | 59 | VkPipelineBindPoint pipeline_bind_point; |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 60 | CMD_TYPE cmd_type; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 61 | GpuAssistedBufferInfo(GpuAssistedDeviceMemoryBlock output_mem_block, GpuAssistedDeviceMemoryBlock di_input_mem_block, |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 62 | GpuAssistedDeviceMemoryBlock bda_input_mem_block, GpuAssistedPreDrawResources pre_draw_resources, |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 63 | GpuAssistedPreDispatchResources pre_dispatch_resources, VkDescriptorSet desc_set, |
| 64 | VkDescriptorPool desc_pool, VkPipelineBindPoint pipeline_bind_point, CMD_TYPE cmd_type) |
Jason Macnak | 67407e7 | 2019-07-11 11:05:09 -0700 | [diff] [blame] | 65 | : output_mem_block(output_mem_block), |
Tony-LunarG | 8eb5a00 | 2019-07-25 16:49:00 -0600 | [diff] [blame] | 66 | di_input_mem_block(di_input_mem_block), |
| 67 | bda_input_mem_block(bda_input_mem_block), |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 68 | pre_draw_resources(pre_draw_resources), |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 69 | pre_dispatch_resources(pre_dispatch_resources), |
Jason Macnak | 67407e7 | 2019-07-11 11:05:09 -0700 | [diff] [blame] | 70 | desc_set(desc_set), |
| 71 | desc_pool(desc_pool), |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 72 | pipeline_bind_point(pipeline_bind_point), |
| 73 | cmd_type(cmd_type){}; |
Mark Lobodzinski | 2a3ee4a | 2019-03-13 13:11:39 -0600 | [diff] [blame] | 74 | }; |
| 75 | |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 76 | struct GpuVuid { |
| 77 | const char* uniform_access_oob = kVUIDUndefined; |
| 78 | const char* storage_access_oob = kVUIDUndefined; |
Tony-LunarG | 64aeaf7 | 2021-04-14 11:13:35 -0600 | [diff] [blame] | 79 | const char* count_exceeds_bufsize_1 = kVUIDUndefined; |
| 80 | const char* count_exceeds_bufsize = kVUIDUndefined; |
Tony-LunarG | 1a7c9f9 | 2021-04-29 16:04:42 -0600 | [diff] [blame] | 81 | const char* count_exceeds_device_limit = kVUIDUndefined; |
Tony-LunarG | 3723a3a | 2021-05-04 14:52:39 -0600 | [diff] [blame] | 82 | const char* first_instance_not_zero = kVUIDUndefined; |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 83 | const char* group_exceeds_device_limit_x = kVUIDUndefined; |
| 84 | const char* group_exceeds_device_limit_y = kVUIDUndefined; |
| 85 | const char* group_exceeds_device_limit_z = kVUIDUndefined; |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 88 | struct GpuAssistedAccelerationStructureBuildValidationBufferInfo { |
Jason Macnak | 83cfd58 | 2019-07-31 10:14:24 -0700 | [diff] [blame] | 89 | // The acceleration structure that is being built. |
| 90 | VkAccelerationStructureNV acceleration_structure = VK_NULL_HANDLE; |
| 91 | |
| 92 | // The descriptor pool and descriptor set being used to validate a given build. |
| 93 | VkDescriptorPool descriptor_pool = VK_NULL_HANDLE; |
| 94 | VkDescriptorSet descriptor_set = VK_NULL_HANDLE; |
| 95 | |
| 96 | // The storage buffer used by the validating compute shader whichcontains info about |
| 97 | // the valid handles and which is written to communicate found invalid handles. |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 98 | VkBuffer buffer = VK_NULL_HANDLE; |
| 99 | VmaAllocation buffer_allocation = VK_NULL_HANDLE; |
Jason Macnak | 83cfd58 | 2019-07-31 10:14:24 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 102 | struct GpuAssistedAccelerationStructureBuildValidationState { |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 103 | // some resources can be used each time so only to need to create once |
Jason Macnak | 83cfd58 | 2019-07-31 10:14:24 -0700 | [diff] [blame] | 104 | bool initialized = false; |
| 105 | |
| 106 | VkPipeline pipeline = VK_NULL_HANDLE; |
| 107 | VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; |
| 108 | |
| 109 | VkAccelerationStructureNV replacement_as = VK_NULL_HANDLE; |
| 110 | VmaAllocation replacement_as_allocation = VK_NULL_HANDLE; |
| 111 | uint64_t replacement_as_handle = 0; |
| 112 | |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 113 | void Destroy(VkDevice device, VmaAllocator& vmaAllocator); |
Jason Macnak | 83cfd58 | 2019-07-31 10:14:24 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 116 | struct GpuAssistedPreDrawValidationState { |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 117 | // some resources can be used each time so only to need to create once |
| 118 | bool initialized = false; |
| 119 | |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 120 | VkShaderModule shader_module = VK_NULL_HANDLE; |
| 121 | VkDescriptorSetLayout ds_layout = VK_NULL_HANDLE; |
| 122 | VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; |
Jeremy Gebben | bba3921 | 2022-03-29 16:39:06 -0600 | [diff] [blame] | 123 | vl_concurrent_unordered_map <VkRenderPass, VkPipeline> renderpass_to_pipeline; |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 124 | |
| 125 | void Destroy(VkDevice device); |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 126 | }; |
| 127 | |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 128 | struct GpuAssistedPreDispatchValidationState { |
| 129 | // some resources can be used each time so only to need to create once |
| 130 | bool initialized = false; |
| 131 | |
| 132 | VkShaderModule shader_module = VK_NULL_HANDLE; |
| 133 | VkDescriptorSetLayout ds_layout = VK_NULL_HANDLE; |
| 134 | VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; |
| 135 | VkPipeline pipeline = VK_NULL_HANDLE; |
| 136 | |
| 137 | void Destroy(VkDevice device); |
| 138 | }; |
| 139 | |
| 140 | // Used for draws/dispatch/traceRays indirect |
| 141 | struct GpuAssistedCmdIndirectState { |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 142 | VkBuffer buffer; |
| 143 | VkDeviceSize offset; |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 144 | uint32_t draw_count; |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 145 | uint32_t stride; |
| 146 | VkBuffer count_buffer; |
| 147 | VkDeviceSize count_buffer_offset; |
| 148 | }; |
| 149 | |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 150 | namespace gpuav_state { |
Jeremy Gebben | 5ca80b3 | 2022-04-11 10:58:39 -0600 | [diff] [blame] | 151 | class CommandBuffer : public gpu_utils_state::CommandBuffer { |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 152 | public: |
| 153 | std::vector<GpuAssistedBufferInfo> gpuav_buffer_list; |
| 154 | std::vector<GpuAssistedAccelerationStructureBuildValidationBufferInfo> as_validation_buffers; |
| 155 | |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 156 | CommandBuffer(GpuAssisted* ga, VkCommandBuffer cb, const VkCommandBufferAllocateInfo* pCreateInfo, |
| 157 | const COMMAND_POOL_STATE* pool); |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 158 | |
sjfricke | 52defd4 | 2022-08-08 16:37:46 +0900 | [diff] [blame] | 159 | bool NeedsProcessing() const final { return !gpuav_buffer_list.empty() || has_build_as_cmd; } |
Jeremy Gebben | 5ca80b3 | 2022-04-11 10:58:39 -0600 | [diff] [blame] | 160 | |
| 161 | void Process(VkQueue queue) final; |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 162 | void Reset() final; |
Jeremy Gebben | 5ca80b3 | 2022-04-11 10:58:39 -0600 | [diff] [blame] | 163 | |
| 164 | private: |
| 165 | void ProcessAccelerationStructure(VkQueue queue); |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 166 | }; |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 167 | }; // namespace gpuav_state |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 168 | |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 169 | VALSTATETRACK_DERIVED_STATE_OBJECT(VkCommandBuffer, gpuav_state::CommandBuffer, CMD_BUFFER_STATE); |
Jeremy Gebben | 78684b1 | 2022-02-23 17:31:56 -0700 | [diff] [blame] | 170 | |
Jeremy Gebben | 5160e03 | 2022-03-28 14:57:43 -0600 | [diff] [blame] | 171 | class GpuAssisted : public GpuAssistedBase { |
Tony-LunarG | 1dce239 | 2019-10-23 16:49:29 -0600 | [diff] [blame] | 172 | public: |
Jeremy Gebben | 5160e03 | 2022-03-28 14:57:43 -0600 | [diff] [blame] | 173 | GpuAssisted() { |
| 174 | setup_vuid = "UNASSIGNED-GPU-Assisted-Validation"; |
| 175 | container_type = LayerObjectTypeGpuAssisted; |
| 176 | desired_features.vertexPipelineStoresAndAtomics = true; |
| 177 | desired_features.fragmentStoresAndAtomics = true; |
| 178 | desired_features.shaderInt64 = true; |
| 179 | } |
Mark Lobodzinski | 0dcb87d | 2020-03-30 16:09:24 -0600 | [diff] [blame] | 180 | |
Tony-LunarG | 5c38b18 | 2020-06-10 16:15:32 -0600 | [diff] [blame] | 181 | bool CheckForDescriptorIndexing(DeviceFeatures enabled_features) const; |
Jeremy Gebben | 36a3b83 | 2022-03-23 10:54:18 -0600 | [diff] [blame] | 182 | void CreateDevice(const VkDeviceCreateInfo* pCreateInfo) override; |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 183 | void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 184 | void PostCallRecordBindAccelerationStructureMemoryNV(VkDevice device, uint32_t bindInfoCount, |
| 185 | const VkBindAccelerationStructureMemoryInfoNV* pBindInfos, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 186 | VkResult result) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 187 | void PreCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 188 | VkBuffer* pBuffer, void* cb_state_data) override; |
Jeremy Gebben | 2178201 | 2022-03-15 16:23:27 -0600 | [diff] [blame] | 189 | void CreateAccelerationStructureBuildValidationState(); |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 190 | void PreCallRecordCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo, |
| 191 | VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update, |
| 192 | VkAccelerationStructureNV dst, VkAccelerationStructureNV src, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 193 | VkBuffer scratch, VkDeviceSize scratchOffset) override; |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 194 | void ProcessAccelerationStructureBuildValidationBuffer(VkQueue queue, gpuav_state::CommandBuffer* cb_node); |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 195 | void PreCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) override; |
sfricke-samsung | 7fac88a | 2022-01-26 11:44:22 -0800 | [diff] [blame] | 196 | bool InstrumentShader(const VkShaderModuleCreateInfo* pCreateInfo, std::vector<uint32_t>& new_pgm, uint32_t* unique_shader_id); |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 197 | void PreCallRecordCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, |
| 198 | const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 199 | void* csm_state_data) override; |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 200 | void AnalyzeAndGenerateMessages(VkCommandBuffer command_buffer, VkQueue queue, GpuAssistedBufferInfo &buffer_info, |
| 201 | uint32_t operation_index, uint32_t* const debug_output_buffer); |
sfricke-samsung | 7fac88a | 2022-01-26 11:44:22 -0800 | [diff] [blame] | 202 | |
Jeremy Gebben | f4816f7 | 2022-07-15 08:56:06 -0600 | [diff] [blame] | 203 | void SetBindingState(uint32_t* data, uint32_t index, const cvdescriptorset::DescriptorBinding* binding); |
Jeremy Gebben | 135550d | 2022-03-21 07:15:07 -0600 | [diff] [blame] | 204 | void UpdateInstrumentationBuffer(gpuav_state::CommandBuffer* cb_node); |
Tony-LunarG | 7de10e8 | 2020-11-24 11:31:55 -0700 | [diff] [blame] | 205 | const GpuVuid& GetGpuVuid(CMD_TYPE cmd_type) const; |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 206 | void PreCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) override; |
Jeremy Gebben | a3705f4 | 2021-01-19 16:47:43 -0700 | [diff] [blame] | 207 | void PreCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, |
| 208 | VkFence fence) override; |
Tony-LunarG | 26fe284 | 2021-11-16 14:07:59 -0700 | [diff] [blame] | 209 | void PreCallRecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 210 | void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 211 | uint32_t firstInstance) override; |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 212 | void PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo, |
| 213 | uint32_t instanceCount, uint32_t firstInstance, uint32_t stride) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 214 | void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 215 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override; |
Tony-LunarG | 745150c | 2021-07-02 15:07:31 -0600 | [diff] [blame] | 216 | void PreCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, |
| 217 | const VkMultiDrawIndexedInfoEXT* pIndexInfo, uint32_t instanceCount, |
| 218 | uint32_t firstInstance, uint32_t stride, const int32_t* pVertexOffset) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 219 | void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 220 | uint32_t stride) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 221 | void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 222 | uint32_t stride) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 223 | void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 224 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 225 | uint32_t stride) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 226 | void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 227 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 228 | uint32_t stride) override; |
Tony-LunarG | 54176fb | 2020-12-02 10:47:22 -0700 | [diff] [blame] | 229 | void PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance, |
| 230 | VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 231 | uint32_t vertexStride) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 232 | void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 233 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 234 | uint32_t stride) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 235 | void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 236 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 237 | uint32_t stride) override; |
| 238 | void PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 239 | void PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 240 | uint32_t drawCount, uint32_t stride) override; |
Tony-LunarG | 2fb8ff0 | 2020-06-11 12:45:07 -0600 | [diff] [blame] | 241 | void PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 242 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 243 | uint32_t stride) override; |
| 244 | void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) override; |
| 245 | void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) override; |
Tony-LunarG | d13f9b5 | 2020-09-08 15:45:45 -0600 | [diff] [blame] | 246 | void PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 247 | uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) override; |
Tony-LunarG | 52c8c60 | 2020-09-10 16:29:56 -0600 | [diff] [blame] | 248 | void PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 249 | uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, |
| 250 | uint32_t groupCountZ) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 251 | void PreCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, |
| 252 | VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, |
| 253 | VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 254 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, |
| 255 | VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, |
| 256 | VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 257 | uint32_t width, uint32_t height, uint32_t depth) override; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 258 | void PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
| 259 | const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, |
| 260 | const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, |
| 261 | const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, |
| 262 | const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 263 | uint32_t height, uint32_t depth) override; |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 264 | void PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 265 | const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, |
| 266 | const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, |
| 267 | const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, |
Shannon McPherson | 54e1f89 | 2020-11-27 11:04:19 -0700 | [diff] [blame] | 268 | const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 269 | VkDeviceAddress indirectDeviceAddress) override; |
sfricke-samsung | f91881c | 2022-03-31 01:12:00 -0500 | [diff] [blame] | 270 | void PreCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress) override; |
sjfricke | 43b340c | 2022-08-04 22:18:38 +0900 | [diff] [blame] | 271 | void AllocateValidationResources(const VkCommandBuffer cmd_buffer, const VkPipelineBindPoint bind_point, CMD_TYPE cmd, |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 272 | const GpuAssistedCmdIndirectState* indirect_state = nullptr); |
Tony-LunarG | a3ec16c | 2021-04-06 12:19:57 -0600 | [diff] [blame] | 273 | void AllocatePreDrawValidationResources(GpuAssistedDeviceMemoryBlock output_block, GpuAssistedPreDrawResources& resources, |
Tony-LunarG | 56f0d0f | 2022-08-17 12:04:17 -0600 | [diff] [blame] | 274 | const VkRenderPass render_pass, VkPipeline* pPipeline, |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 275 | const GpuAssistedCmdIndirectState* indirect_state); |
| 276 | void AllocatePreDispatchValidationResources(GpuAssistedDeviceMemoryBlock output_block, |
| 277 | GpuAssistedPreDispatchResources& resources, |
| 278 | const GpuAssistedCmdIndirectState* indirect_state); |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 279 | void PostCallRecordGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 280 | VkPhysicalDeviceProperties* pPhysicalDeviceProperties) override; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 281 | void PostCallRecordGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, |
Mark Lobodzinski | b8e22b5 | 2020-12-03 15:22:35 -0700 | [diff] [blame] | 282 | VkPhysicalDeviceProperties2* pPhysicalDeviceProperties2) override; |
Jeremy Gebben | 3d22d58 | 2021-08-11 15:37:58 -0600 | [diff] [blame] | 283 | |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 284 | std::shared_ptr<CMD_BUFFER_STATE> CreateCmdBufferState(VkCommandBuffer cb, const VkCommandBufferAllocateInfo* create_info, |
Jeremy Gebben | cd7fa28 | 2021-10-27 10:25:32 -0600 | [diff] [blame] | 285 | const COMMAND_POOL_STATE* pool) final; |
Jeremy Gebben | f6bb4bb | 2021-08-11 15:41:09 -0600 | [diff] [blame] | 286 | |
| 287 | void DestroyBuffer(GpuAssistedBufferInfo& buffer_info); |
| 288 | void DestroyBuffer(GpuAssistedAccelerationStructureBuildValidationBufferInfo& buffer_info); |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 289 | |
| 290 | private: |
| 291 | void PreRecordCommandBuffer(VkCommandBuffer command_buffer); |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 292 | VkPipeline GetValidationPipeline(VkRenderPass render_pass); |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 293 | |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 294 | VkBool32 shaderInt64; |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 295 | bool buffer_oob_enabled; |
| 296 | bool validate_draw_indirect; |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 297 | bool validate_dispatch_indirect; |
Tony-LunarG | 20d18a7 | 2022-04-19 11:01:47 -0600 | [diff] [blame] | 298 | VmaPool output_buffer_pool = VK_NULL_HANDLE; |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 299 | GpuAssistedAccelerationStructureBuildValidationState acceleration_structure_validation_state; |
| 300 | GpuAssistedPreDrawValidationState pre_draw_validation_state; |
sjfricke | ca9a480 | 2022-08-10 14:27:51 +0900 | [diff] [blame] | 301 | GpuAssistedPreDispatchValidationState pre_dispatch_validation_state; |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 302 | |
Jeremy Gebben | 14499e8 | 2022-03-17 11:03:10 -0600 | [diff] [blame] | 303 | bool descriptor_indexing = false; |
Tony-LunarG | 2ba1cb3 | 2019-09-25 15:16:11 -0600 | [diff] [blame] | 304 | }; |