blob: e174c0ac432887bf262c3c2a13febc43099df825 [file] [log] [blame]
Tony-LunarG4c253372022-01-18 13:51:07 -07001/* Copyright (c) 2018-2022 The Khronos Group Inc.
2 * Copyright (c) 2018-2022 Valve Corporation
3 * Copyright (c) 2018-2022 LunarG, Inc.
Karl Schultz7b024b42018-08-30 16:18:18 -06004 *
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-LunarG2ba1cb32019-09-25 15:16:11 -060017 * Author: Karl Schultz <karl@lunarg.com>
18 * Author: Tony Barbour <tony@lunarg.com>
Karl Schultz7b024b42018-08-30 16:18:18 -060019 */
20
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060021#pragma once
22
Tony-LunarGb5fae462020-03-05 12:43:25 -070023#include "gpu_utils.h"
Jeremy Gebben5160e032022-03-28 14:57:43 -060024
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060025class GpuAssisted;
Tony-LunarG0e564722019-03-19 16:09:14 -060026
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060027struct GpuAssistedDeviceMemoryBlock {
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060028 VkBuffer buffer;
Tony-LunarG0e564722019-03-19 16:09:14 -060029 VmaAllocation allocation;
Jeremy Gebbenf4816f72022-07-15 08:56:06 -060030 layer_data::unordered_map<uint32_t, const cvdescriptorset::DescriptorBinding*> update_at_submit;
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060031};
32
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060033struct GpuAssistedPreDrawResources {
sjfricke43b340c2022-08-04 22:18:38 +090034 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-LunarGa3ec16c2021-04-06 12:19:57 -060041};
42
sjfrickeca9a4802022-08-10 14:27:51 +090043struct 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-LunarG2ba1cb32019-09-25 15:16:11 -060051struct 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-LunarGa3ec16c2021-04-06 12:19:57 -060055 GpuAssistedPreDrawResources pre_draw_resources;
sjfrickeca9a4802022-08-10 14:27:51 +090056 GpuAssistedPreDispatchResources pre_dispatch_resources;
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060057 VkDescriptorSet desc_set;
58 VkDescriptorPool desc_pool;
Jason Macnak67407e72019-07-11 11:05:09 -070059 VkPipelineBindPoint pipeline_bind_point;
Tony-LunarG7de10e82020-11-24 11:31:55 -070060 CMD_TYPE cmd_type;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060061 GpuAssistedBufferInfo(GpuAssistedDeviceMemoryBlock output_mem_block, GpuAssistedDeviceMemoryBlock di_input_mem_block,
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060062 GpuAssistedDeviceMemoryBlock bda_input_mem_block, GpuAssistedPreDrawResources pre_draw_resources,
sjfrickeca9a4802022-08-10 14:27:51 +090063 GpuAssistedPreDispatchResources pre_dispatch_resources, VkDescriptorSet desc_set,
64 VkDescriptorPool desc_pool, VkPipelineBindPoint pipeline_bind_point, CMD_TYPE cmd_type)
Jason Macnak67407e72019-07-11 11:05:09 -070065 : output_mem_block(output_mem_block),
Tony-LunarG8eb5a002019-07-25 16:49:00 -060066 di_input_mem_block(di_input_mem_block),
67 bda_input_mem_block(bda_input_mem_block),
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060068 pre_draw_resources(pre_draw_resources),
sjfrickeca9a4802022-08-10 14:27:51 +090069 pre_dispatch_resources(pre_dispatch_resources),
Jason Macnak67407e72019-07-11 11:05:09 -070070 desc_set(desc_set),
71 desc_pool(desc_pool),
Tony-LunarG7de10e82020-11-24 11:31:55 -070072 pipeline_bind_point(pipeline_bind_point),
73 cmd_type(cmd_type){};
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060074};
75
Tony-LunarG7de10e82020-11-24 11:31:55 -070076struct GpuVuid {
77 const char* uniform_access_oob = kVUIDUndefined;
78 const char* storage_access_oob = kVUIDUndefined;
Tony-LunarG64aeaf72021-04-14 11:13:35 -060079 const char* count_exceeds_bufsize_1 = kVUIDUndefined;
80 const char* count_exceeds_bufsize = kVUIDUndefined;
Tony-LunarG1a7c9f92021-04-29 16:04:42 -060081 const char* count_exceeds_device_limit = kVUIDUndefined;
Tony-LunarG3723a3a2021-05-04 14:52:39 -060082 const char* first_instance_not_zero = kVUIDUndefined;
sjfrickeca9a4802022-08-10 14:27:51 +090083 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-LunarG7de10e82020-11-24 11:31:55 -070086};
87
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060088struct GpuAssistedAccelerationStructureBuildValidationBufferInfo {
Jason Macnak83cfd582019-07-31 10:14:24 -070089 // 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.
sjfricke43b340c2022-08-04 22:18:38 +090098 VkBuffer buffer = VK_NULL_HANDLE;
99 VmaAllocation buffer_allocation = VK_NULL_HANDLE;
Jason Macnak83cfd582019-07-31 10:14:24 -0700100};
101
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600102struct GpuAssistedAccelerationStructureBuildValidationState {
sjfrickeca9a4802022-08-10 14:27:51 +0900103 // some resources can be used each time so only to need to create once
Jason Macnak83cfd582019-07-31 10:14:24 -0700104 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
sjfrickeca9a4802022-08-10 14:27:51 +0900113 void Destroy(VkDevice device, VmaAllocator& vmaAllocator);
Jason Macnak83cfd582019-07-31 10:14:24 -0700114};
115
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600116struct GpuAssistedPreDrawValidationState {
sjfrickeca9a4802022-08-10 14:27:51 +0900117 // some resources can be used each time so only to need to create once
118 bool initialized = false;
119
sjfricke43b340c2022-08-04 22:18:38 +0900120 VkShaderModule shader_module = VK_NULL_HANDLE;
121 VkDescriptorSetLayout ds_layout = VK_NULL_HANDLE;
122 VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
Jeremy Gebbenbba39212022-03-29 16:39:06 -0600123 vl_concurrent_unordered_map <VkRenderPass, VkPipeline> renderpass_to_pipeline;
sjfricke43b340c2022-08-04 22:18:38 +0900124
125 void Destroy(VkDevice device);
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600126};
127
sjfrickeca9a4802022-08-10 14:27:51 +0900128struct 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
141struct GpuAssistedCmdIndirectState {
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600142 VkBuffer buffer;
143 VkDeviceSize offset;
sjfricke43b340c2022-08-04 22:18:38 +0900144 uint32_t draw_count;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600145 uint32_t stride;
146 VkBuffer count_buffer;
147 VkDeviceSize count_buffer_offset;
148};
149
Jeremy Gebben135550d2022-03-21 07:15:07 -0600150namespace gpuav_state {
Jeremy Gebben5ca80b32022-04-11 10:58:39 -0600151class CommandBuffer : public gpu_utils_state::CommandBuffer {
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600152 public:
153 std::vector<GpuAssistedBufferInfo> gpuav_buffer_list;
154 std::vector<GpuAssistedAccelerationStructureBuildValidationBufferInfo> as_validation_buffers;
155
Jeremy Gebben135550d2022-03-21 07:15:07 -0600156 CommandBuffer(GpuAssisted* ga, VkCommandBuffer cb, const VkCommandBufferAllocateInfo* pCreateInfo,
157 const COMMAND_POOL_STATE* pool);
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600158
sjfricke52defd42022-08-08 16:37:46 +0900159 bool NeedsProcessing() const final { return !gpuav_buffer_list.empty() || has_build_as_cmd; }
Jeremy Gebben5ca80b32022-04-11 10:58:39 -0600160
161 void Process(VkQueue queue) final;
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600162 void Reset() final;
Jeremy Gebben5ca80b32022-04-11 10:58:39 -0600163
164 private:
165 void ProcessAccelerationStructure(VkQueue queue);
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600166};
Jeremy Gebben135550d2022-03-21 07:15:07 -0600167}; // namespace gpuav_state
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600168
Jeremy Gebben135550d2022-03-21 07:15:07 -0600169VALSTATETRACK_DERIVED_STATE_OBJECT(VkCommandBuffer, gpuav_state::CommandBuffer, CMD_BUFFER_STATE);
Jeremy Gebben78684b12022-02-23 17:31:56 -0700170
Jeremy Gebben5160e032022-03-28 14:57:43 -0600171class GpuAssisted : public GpuAssistedBase {
Tony-LunarG1dce2392019-10-23 16:49:29 -0600172 public:
Jeremy Gebben5160e032022-03-28 14:57:43 -0600173 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 Lobodzinski0dcb87d2020-03-30 16:09:24 -0600180
Tony-LunarG5c38b182020-06-10 16:15:32 -0600181 bool CheckForDescriptorIndexing(DeviceFeatures enabled_features) const;
Jeremy Gebben36a3b832022-03-23 10:54:18 -0600182 void CreateDevice(const VkDeviceCreateInfo* pCreateInfo) override;
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700183 void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600184 void PostCallRecordBindAccelerationStructureMemoryNV(VkDevice device, uint32_t bindInfoCount,
185 const VkBindAccelerationStructureMemoryInfoNV* pBindInfos,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700186 VkResult result) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600187 void PreCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700188 VkBuffer* pBuffer, void* cb_state_data) override;
Jeremy Gebben21782012022-03-15 16:23:27 -0600189 void CreateAccelerationStructureBuildValidationState();
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600190 void PreCallRecordCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo,
191 VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update,
192 VkAccelerationStructureNV dst, VkAccelerationStructureNV src,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700193 VkBuffer scratch, VkDeviceSize scratchOffset) override;
Jeremy Gebben135550d2022-03-21 07:15:07 -0600194 void ProcessAccelerationStructureBuildValidationBuffer(VkQueue queue, gpuav_state::CommandBuffer* cb_node);
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600195 void PreCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) override;
sfricke-samsung7fac88a2022-01-26 11:44:22 -0800196 bool InstrumentShader(const VkShaderModuleCreateInfo* pCreateInfo, std::vector<uint32_t>& new_pgm, uint32_t* unique_shader_id);
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600197 void PreCallRecordCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo,
198 const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700199 void* csm_state_data) override;
Tony-LunarG7de10e82020-11-24 11:31:55 -0700200 void AnalyzeAndGenerateMessages(VkCommandBuffer command_buffer, VkQueue queue, GpuAssistedBufferInfo &buffer_info,
201 uint32_t operation_index, uint32_t* const debug_output_buffer);
sfricke-samsung7fac88a2022-01-26 11:44:22 -0800202
Jeremy Gebbenf4816f72022-07-15 08:56:06 -0600203 void SetBindingState(uint32_t* data, uint32_t index, const cvdescriptorset::DescriptorBinding* binding);
Jeremy Gebben135550d2022-03-21 07:15:07 -0600204 void UpdateInstrumentationBuffer(gpuav_state::CommandBuffer* cb_node);
Tony-LunarG7de10e82020-11-24 11:31:55 -0700205 const GpuVuid& GetGpuVuid(CMD_TYPE cmd_type) const;
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700206 void PreCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) override;
Jeremy Gebbena3705f42021-01-19 16:47:43 -0700207 void PreCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits,
208 VkFence fence) override;
Tony-LunarG26fe2842021-11-16 14:07:59 -0700209 void PreCallRecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600210 void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700211 uint32_t firstInstance) override;
Tony-LunarG745150c2021-07-02 15:07:31 -0600212 void PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo,
213 uint32_t instanceCount, uint32_t firstInstance, uint32_t stride) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600214 void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700215 uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override;
Tony-LunarG745150c2021-07-02 15:07:31 -0600216 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-LunarG2ba1cb32019-09-25 15:16:11 -0600219 void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700220 uint32_t stride) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600221 void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700222 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600223 void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
224 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700225 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600226 void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
227 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700228 uint32_t stride) override;
Tony-LunarG54176fb2020-12-02 10:47:22 -0700229 void PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance,
230 VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700231 uint32_t vertexStride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600232 void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
233 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700234 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600235 void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
236 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700237 uint32_t stride) override;
238 void PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600239 void PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700240 uint32_t drawCount, uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600241 void PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
242 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700243 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-LunarGd13f9b52020-09-08 15:45:45 -0600246 void PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700247 uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) override;
Tony-LunarG52c8c602020-09-10 16:29:56 -0600248 void PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700249 uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY,
250 uint32_t groupCountZ) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600251 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 Lobodzinskib8e22b52020-12-03 15:22:35 -0700257 uint32_t width, uint32_t height, uint32_t depth) override;
sourav parmarcd5fb182020-07-17 12:58:44 -0700258 void PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
259 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
260 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
261 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
262 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700263 uint32_t height, uint32_t depth) override;
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500264 void PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -0700265 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
266 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
267 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
Shannon McPherson54e1f892020-11-27 11:04:19 -0700268 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700269 VkDeviceAddress indirectDeviceAddress) override;
sfricke-samsungf91881c2022-03-31 01:12:00 -0500270 void PreCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress) override;
sjfricke43b340c2022-08-04 22:18:38 +0900271 void AllocateValidationResources(const VkCommandBuffer cmd_buffer, const VkPipelineBindPoint bind_point, CMD_TYPE cmd,
sjfrickeca9a4802022-08-10 14:27:51 +0900272 const GpuAssistedCmdIndirectState* indirect_state = nullptr);
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600273 void AllocatePreDrawValidationResources(GpuAssistedDeviceMemoryBlock output_block, GpuAssistedPreDrawResources& resources,
Tony-LunarG56f0d0f2022-08-17 12:04:17 -0600274 const VkRenderPass render_pass, VkPipeline* pPipeline,
sjfrickeca9a4802022-08-10 14:27:51 +0900275 const GpuAssistedCmdIndirectState* indirect_state);
276 void AllocatePreDispatchValidationResources(GpuAssistedDeviceMemoryBlock output_block,
277 GpuAssistedPreDispatchResources& resources,
278 const GpuAssistedCmdIndirectState* indirect_state);
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600279 void PostCallRecordGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700280 VkPhysicalDeviceProperties* pPhysicalDeviceProperties) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600281 void PostCallRecordGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700282 VkPhysicalDeviceProperties2* pPhysicalDeviceProperties2) override;
Jeremy Gebben3d22d582021-08-11 15:37:58 -0600283
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600284 std::shared_ptr<CMD_BUFFER_STATE> CreateCmdBufferState(VkCommandBuffer cb, const VkCommandBufferAllocateInfo* create_info,
Jeremy Gebbencd7fa282021-10-27 10:25:32 -0600285 const COMMAND_POOL_STATE* pool) final;
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600286
287 void DestroyBuffer(GpuAssistedBufferInfo& buffer_info);
288 void DestroyBuffer(GpuAssistedAccelerationStructureBuildValidationBufferInfo& buffer_info);
Jeremy Gebben14499e82022-03-17 11:03:10 -0600289
290 private:
291 void PreRecordCommandBuffer(VkCommandBuffer command_buffer);
sjfrickeca9a4802022-08-10 14:27:51 +0900292 VkPipeline GetValidationPipeline(VkRenderPass render_pass);
Jeremy Gebben14499e82022-03-17 11:03:10 -0600293
Jeremy Gebben14499e82022-03-17 11:03:10 -0600294 VkBool32 shaderInt64;
Jeremy Gebben14499e82022-03-17 11:03:10 -0600295 bool buffer_oob_enabled;
296 bool validate_draw_indirect;
sjfrickeca9a4802022-08-10 14:27:51 +0900297 bool validate_dispatch_indirect;
Tony-LunarG20d18a72022-04-19 11:01:47 -0600298 VmaPool output_buffer_pool = VK_NULL_HANDLE;
Jeremy Gebben14499e82022-03-17 11:03:10 -0600299 GpuAssistedAccelerationStructureBuildValidationState acceleration_structure_validation_state;
300 GpuAssistedPreDrawValidationState pre_draw_validation_state;
sjfrickeca9a4802022-08-10 14:27:51 +0900301 GpuAssistedPreDispatchValidationState pre_dispatch_validation_state;
Jeremy Gebben14499e82022-03-17 11:03:10 -0600302
Jeremy Gebben14499e82022-03-17 11:03:10 -0600303 bool descriptor_indexing = false;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600304};