blob: 0298b55f6eb0701077b83d2473521cd680b7bb6a [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
23#include "chassis.h"
24#include "state_tracker.h"
Tony-LunarG0e564722019-03-19 16:09:14 -060025#include "vk_mem_alloc.h"
Tony-LunarGb5fae462020-03-05 12:43:25 -070026#include "gpu_utils.h"
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060027class GpuAssisted;
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -060028class CMD_BUFFER_STATE_GPUAV;
Tony-LunarG0e564722019-03-19 16:09:14 -060029
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060030struct GpuAssistedDeviceMemoryBlock {
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060031 VkBuffer buffer;
Tony-LunarG0e564722019-03-19 16:09:14 -060032 VmaAllocation allocation;
Jeremy Gebbencbf22862021-03-03 12:01:22 -070033 layer_data::unordered_map<uint32_t, const cvdescriptorset::Descriptor*> update_at_submit;
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060034};
35
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060036struct GpuAssistedPreDrawResources {
37 VkDescriptorPool desc_pool;
38 VkDescriptorSet desc_set;
Tony-LunarGf0d4e2b2021-04-14 11:52:28 -060039 VkBuffer buffer;
40 VkDeviceSize offset;
41 uint32_t stride;
42 VkDeviceSize buf_size;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060043};
44
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060045struct GpuAssistedBufferInfo {
46 GpuAssistedDeviceMemoryBlock output_mem_block;
47 GpuAssistedDeviceMemoryBlock di_input_mem_block; // Descriptor Indexing input
48 GpuAssistedDeviceMemoryBlock bda_input_mem_block; // Buffer Device Address input
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060049 GpuAssistedPreDrawResources pre_draw_resources;
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060050 VkDescriptorSet desc_set;
51 VkDescriptorPool desc_pool;
Jason Macnak67407e72019-07-11 11:05:09 -070052 VkPipelineBindPoint pipeline_bind_point;
Tony-LunarG7de10e82020-11-24 11:31:55 -070053 CMD_TYPE cmd_type;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060054 GpuAssistedBufferInfo(GpuAssistedDeviceMemoryBlock output_mem_block, GpuAssistedDeviceMemoryBlock di_input_mem_block,
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060055 GpuAssistedDeviceMemoryBlock bda_input_mem_block, GpuAssistedPreDrawResources pre_draw_resources,
56 VkDescriptorSet desc_set, VkDescriptorPool desc_pool, VkPipelineBindPoint pipeline_bind_point,
57 CMD_TYPE cmd_type)
Jason Macnak67407e72019-07-11 11:05:09 -070058 : output_mem_block(output_mem_block),
Tony-LunarG8eb5a002019-07-25 16:49:00 -060059 di_input_mem_block(di_input_mem_block),
60 bda_input_mem_block(bda_input_mem_block),
Tony-LunarGa3ec16c2021-04-06 12:19:57 -060061 pre_draw_resources(pre_draw_resources),
Jason Macnak67407e72019-07-11 11:05:09 -070062 desc_set(desc_set),
63 desc_pool(desc_pool),
Tony-LunarG7de10e82020-11-24 11:31:55 -070064 pipeline_bind_point(pipeline_bind_point),
65 cmd_type(cmd_type){};
Mark Lobodzinski2a3ee4a2019-03-13 13:11:39 -060066};
67
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060068struct GpuAssistedShaderTracker {
69 VkPipeline pipeline;
70 VkShaderModule shader_module;
71 std::vector<unsigned int> pgm;
72};
73
Tony-LunarG7de10e82020-11-24 11:31:55 -070074struct GpuVuid {
75 const char* uniform_access_oob = kVUIDUndefined;
76 const char* storage_access_oob = kVUIDUndefined;
Tony-LunarG64aeaf72021-04-14 11:13:35 -060077 const char* count_exceeds_bufsize_1 = kVUIDUndefined;
78 const char* count_exceeds_bufsize = kVUIDUndefined;
Tony-LunarG1a7c9f92021-04-29 16:04:42 -060079 const char* count_exceeds_device_limit = kVUIDUndefined;
Tony-LunarG3723a3a2021-05-04 14:52:39 -060080 const char* first_instance_not_zero = kVUIDUndefined;
Tony-LunarG7de10e82020-11-24 11:31:55 -070081};
82
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060083struct GpuAssistedAccelerationStructureBuildValidationBufferInfo {
Jason Macnak83cfd582019-07-31 10:14:24 -070084 // The acceleration structure that is being built.
85 VkAccelerationStructureNV acceleration_structure = VK_NULL_HANDLE;
86
87 // The descriptor pool and descriptor set being used to validate a given build.
88 VkDescriptorPool descriptor_pool = VK_NULL_HANDLE;
89 VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
90
91 // The storage buffer used by the validating compute shader whichcontains info about
92 // the valid handles and which is written to communicate found invalid handles.
93 VkBuffer validation_buffer = VK_NULL_HANDLE;
94 VmaAllocation validation_buffer_allocation = VK_NULL_HANDLE;
95};
96
Tony-LunarG2ba1cb32019-09-25 15:16:11 -060097struct GpuAssistedAccelerationStructureBuildValidationState {
Jason Macnak83cfd582019-07-31 10:14:24 -070098 bool initialized = false;
99
100 VkPipeline pipeline = VK_NULL_HANDLE;
101 VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
102
103 VkAccelerationStructureNV replacement_as = VK_NULL_HANDLE;
104 VmaAllocation replacement_as_allocation = VK_NULL_HANDLE;
105 uint64_t replacement_as_handle = 0;
106
Jason Macnak83cfd582019-07-31 10:14:24 -0700107};
108
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600109struct GpuAssistedPreDrawValidationState {
110 bool globals_created = false;
111 VkShaderModule validation_shader_module = VK_NULL_HANDLE;
112 VkDescriptorSetLayout validation_ds_layout = VK_NULL_HANDLE;
113 VkPipelineLayout validation_pipeline_layout = VK_NULL_HANDLE;
114 layer_data::unordered_map <VkRenderPass, VkPipeline> renderpass_to_pipeline;
115};
116
117struct GpuAssistedCmdDrawIndirectState {
118 VkBuffer buffer;
119 VkDeviceSize offset;
Tony-LunarG3723a3a2021-05-04 14:52:39 -0600120 uint32_t drawCount;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600121 uint32_t stride;
122 VkBuffer count_buffer;
123 VkDeviceSize count_buffer_offset;
124};
125
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600126class CMD_BUFFER_STATE_GPUAV : public CMD_BUFFER_STATE {
127 public:
128 std::vector<GpuAssistedBufferInfo> gpuav_buffer_list;
129 std::vector<GpuAssistedAccelerationStructureBuildValidationBufferInfo> as_validation_buffers;
130
131 CMD_BUFFER_STATE_GPUAV(GpuAssisted* ga, VkCommandBuffer cb, const VkCommandBufferAllocateInfo* pCreateInfo,
Jeremy Gebbencd7fa282021-10-27 10:25:32 -0600132 const COMMAND_POOL_STATE* pool);
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600133
134 void Reset() final;
135};
136
Tony-LunarG99b880b2019-09-26 11:19:52 -0600137class GpuAssisted : public ValidationStateTracker {
Tony-LunarG1dce2392019-10-23 16:49:29 -0600138 VkPhysicalDeviceFeatures supported_features;
Tony-LunarG8eb5a002019-07-25 16:49:00 -0600139 VkBool32 shaderInt64;
Tony-LunarG99b880b2019-09-26 11:19:52 -0600140 uint32_t unique_shader_module_id = 0;
Tony-LunarG0e564722019-03-19 16:09:14 -0600141 uint32_t output_buffer_size;
Tony-LunarGc28e28a2020-08-14 10:37:48 -0600142 bool buffer_oob_enabled;
Tony-LunarG3723a3a2021-05-04 14:52:39 -0600143 bool validate_draw_indirect;
Tony-LunarG8eb5a002019-07-25 16:49:00 -0600144 std::map<VkDeviceAddress, VkDeviceSize> buffer_map;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600145 GpuAssistedAccelerationStructureBuildValidationState acceleration_structure_validation_state;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600146 GpuAssistedPreDrawValidationState pre_draw_validation_state;
Tony-LunarG1dce2392019-10-23 16:49:29 -0600147
Jeremy Gebbena3705f42021-01-19 16:47:43 -0700148 void PreRecordCommandBuffer(VkCommandBuffer command_buffer);
149 bool CommandBufferNeedsProcessing(VkCommandBuffer command_buffer);
150 void ProcessCommandBuffer(VkQueue queue, VkCommandBuffer command_buffer);
151
Tony-LunarG1dce2392019-10-23 16:49:29 -0600152 public:
Mark Lobodzinski0dcb87d2020-03-30 16:09:24 -0600153 GpuAssisted() { container_type = LayerObjectTypeGpuAssisted; }
154
Tony-LunarG1dce2392019-10-23 16:49:29 -0600155 bool aborted = false;
Tony-LunarG5c38b182020-06-10 16:15:32 -0600156 bool descriptor_indexing = false;
Tony-LunarG1dce2392019-10-23 16:49:29 -0600157 VkDevice device;
158 VkPhysicalDevice physicalDevice;
159 uint32_t adjusted_max_desc_sets;
160 uint32_t desc_set_bind_index;
Tony-LunarG57ada962020-05-01 16:21:00 -0600161 VkDescriptorSetLayout debug_desc_layout = VK_NULL_HANDLE;
162 VkDescriptorSetLayout dummy_desc_layout = VK_NULL_HANDLE;
Tony-LunarGb5fae462020-03-05 12:43:25 -0700163 std::unique_ptr<UtilDescriptorSetManager> desc_set_manager;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700164 layer_data::unordered_map<uint32_t, GpuAssistedShaderTracker> shader_map;
Tony-LunarG1dce2392019-10-23 16:49:29 -0600165 PFN_vkSetDeviceLoaderData vkSetDeviceLoaderData;
166 VmaAllocator vmaAllocator = {};
Tony-LunarGb5fae462020-03-05 12:43:25 -0700167 std::map<VkQueue, UtilQueueBarrierCommandInfo> queue_barrier_command_infos;
Tony-LunarG1dce2392019-10-23 16:49:29 -0600168 public:
Mark Lobodzinskia8151b02020-02-27 13:38:08 -0700169 template <typename T>
170 void ReportSetupProblem(T object, const char* const specific_message) const;
Tony-LunarG5c38b182020-06-10 16:15:32 -0600171 bool CheckForDescriptorIndexing(DeviceFeatures enabled_features) const;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600172 void PreCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700173 const VkAllocationCallbacks* pAllocator, VkDevice* pDevice, void* modified_create_info) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600174 void PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700175 const VkAllocationCallbacks* pAllocator, VkDevice* pDevice, VkResult result) override;
Mike Schuchardt2df08912020-12-15 16:28:09 -0800176 void PostCallRecordGetBufferDeviceAddress(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700177 VkDeviceAddress address) override;
Mike Schuchardt2df08912020-12-15 16:28:09 -0800178 void PostCallRecordGetBufferDeviceAddressKHR(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700179 VkDeviceAddress address) override;
Mike Schuchardt2df08912020-12-15 16:28:09 -0800180 void PostCallRecordGetBufferDeviceAddressEXT(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700181 VkDeviceAddress address) override;
182 void PreCallRecordDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator) override;
183 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 PreCallRecordCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo,
188 const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700189 void* cpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600190 void PostCallRecordCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo,
191 const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700192 VkResult result) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600193 bool PreCallValidateCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
194 VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask,
195 uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers,
196 uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700197 uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) const override;
Jeremy Gebbena3705f42021-01-19 16:47:43 -0700198 bool PreCallValidateCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
199 const VkDependencyInfoKHR* pDependencyInfos) const override;
Tony-LunarG1364cf52021-11-17 16:10:11 -0700200 bool PreCallValidateCmdWaitEvents2(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
201 const VkDependencyInfo* pDependencyInfos) const override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600202 void PreCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700203 VkBuffer* pBuffer, void* cb_state_data) override;
James Rumble2f6e7bb2021-07-13 15:21:20 +0100204 void PostCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
205 VkBuffer* pBuffer, VkResult result) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600206 void CreateAccelerationStructureBuildValidationState(GpuAssisted* device_GpuAssisted);
207 void DestroyAccelerationStructureBuildValidationState();
208 void PreCallRecordCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo,
209 VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update,
210 VkAccelerationStructureNV dst, VkAccelerationStructureNV src,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700211 VkBuffer scratch, VkDeviceSize scratchOffset) override;
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600212 void ProcessAccelerationStructureBuildValidationBuffer(VkQueue queue, CMD_BUFFER_STATE_GPUAV* cb_node);
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600213 void PreCallRecordCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
214 const VkGraphicsPipelineCreateInfo* pCreateInfos,
215 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700216 void* cgpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600217 void PreCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
218 const VkComputePipelineCreateInfo* pCreateInfos,
219 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700220 void* ccpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600221 void PreCallRecordCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
222 const VkRayTracingPipelineCreateInfoNV* pCreateInfos,
223 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700224 void* crtpl_state_data) override;
sourav parmarcd5fb182020-07-17 12:58:44 -0700225 void PreCallRecordCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
226 VkPipelineCache pipelineCache, uint32_t count,
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500227 const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
228 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700229 void* crtpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600230 void PostCallRecordCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
231 const VkGraphicsPipelineCreateInfo* pCreateInfos,
232 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700233 void* cgpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600234 void PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
235 const VkComputePipelineCreateInfo* pCreateInfos,
236 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700237 void* ccpl_state_data) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600238 void PostCallRecordCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
239 const VkRayTracingPipelineCreateInfoNV* pCreateInfos,
240 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700241 void* crtpl_state_data) override;
sourav parmarcd5fb182020-07-17 12:58:44 -0700242 void PostCallRecordCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
243 VkPipelineCache pipelineCache, uint32_t count,
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500244 const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
245 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700246 VkResult result, void* crtpl_state_data) override;
247 void PreCallRecordDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator) override;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600248 void PreCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600249 bool InstrumentShader(const VkShaderModuleCreateInfo* pCreateInfo, std::vector<unsigned int>& new_pgm,
250 uint32_t* unique_shader_id);
251 void PreCallRecordCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo,
252 const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700253 void* csm_state_data) override;
Tony-LunarG7de10e82020-11-24 11:31:55 -0700254 void AnalyzeAndGenerateMessages(VkCommandBuffer command_buffer, VkQueue queue, GpuAssistedBufferInfo &buffer_info,
255 uint32_t operation_index, uint32_t* const debug_output_buffer);
256
Tony-LunarGc28e28a2020-08-14 10:37:48 -0600257 void SetDescriptorInitialized(uint32_t* pData, uint32_t index, const cvdescriptorset::Descriptor* descriptor);
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600258 void UpdateInstrumentationBuffer(CMD_BUFFER_STATE_GPUAV* cb_node);
Tony-LunarG7de10e82020-11-24 11:31:55 -0700259 const GpuVuid& GetGpuVuid(CMD_TYPE cmd_type) const;
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700260 void PreCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600261 void PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700262 VkResult result) override;
Jeremy Gebbena3705f42021-01-19 16:47:43 -0700263 void PreCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits,
264 VkFence fence) override;
Tony-LunarG26fe2842021-11-16 14:07:59 -0700265 void PreCallRecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence) override;
266 void RecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, VkFence fence, VkResult result);
Jeremy Gebbena3705f42021-01-19 16:47:43 -0700267 void PostCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, VkFence fence,
268 VkResult result) override;
Tony-LunarG26fe2842021-11-16 14:07:59 -0700269 void PostCallRecordQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence,
270 VkResult result) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600271 void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700272 uint32_t firstInstance) override;
Tony-LunarG745150c2021-07-02 15:07:31 -0600273 void PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo,
274 uint32_t instanceCount, uint32_t firstInstance, uint32_t stride) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600275 void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700276 uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override;
Tony-LunarG745150c2021-07-02 15:07:31 -0600277 void PreCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
278 const VkMultiDrawIndexedInfoEXT* pIndexInfo, uint32_t instanceCount,
279 uint32_t firstInstance, uint32_t stride, const int32_t* pVertexOffset) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600280 void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700281 uint32_t stride) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600282 void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700283 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600284 void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
285 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700286 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600287 void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
288 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700289 uint32_t stride) override;
Tony-LunarG54176fb2020-12-02 10:47:22 -0700290 void PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance,
291 VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700292 uint32_t vertexStride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600293 void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
294 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700295 uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600296 void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
297 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700298 uint32_t stride) override;
299 void PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600300 void PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700301 uint32_t drawCount, uint32_t stride) override;
Tony-LunarG2fb8ff02020-06-11 12:45:07 -0600302 void PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
303 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700304 uint32_t stride) override;
305 void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) override;
306 void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) override;
Tony-LunarGd13f9b52020-09-08 15:45:45 -0600307 void PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700308 uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) override;
Tony-LunarG52c8c602020-09-10 16:29:56 -0600309 void PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700310 uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY,
311 uint32_t groupCountZ) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600312 void PreCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer,
313 VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer,
314 VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
315 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset,
316 VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer,
317 VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700318 uint32_t width, uint32_t height, uint32_t depth) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600319 void PostCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer,
320 VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer,
321 VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
322 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset,
323 VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer,
324 VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700325 uint32_t width, uint32_t height, uint32_t depth) override;
sourav parmarcd5fb182020-07-17 12:58:44 -0700326 void PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
327 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
328 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
329 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
330 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700331 uint32_t height, uint32_t depth) override;
sourav parmarcd5fb182020-07-17 12:58:44 -0700332 void PostCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
333 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
334 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
335 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
336 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700337 uint32_t height, uint32_t depth) override;
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500338 void PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -0700339 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
340 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
341 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
Shannon McPherson54e1f892020-11-27 11:04:19 -0700342 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700343 VkDeviceAddress indirectDeviceAddress) override;
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500344 void PostCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -0700345 const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable,
346 const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable,
347 const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable,
Shannon McPherson54e1f892020-11-27 11:04:19 -0700348 const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700349 VkDeviceAddress indirectDeviceAddress) override;
Tony-LunarGa3ec16c2021-04-06 12:19:57 -0600350 void AllocateValidationResources(const VkCommandBuffer cmd_buffer, const VkPipelineBindPoint bind_point, CMD_TYPE cmd, const GpuAssistedCmdDrawIndirectState *cdic_state = nullptr);
351 void AllocatePreDrawValidationResources(GpuAssistedDeviceMemoryBlock output_block, GpuAssistedPreDrawResources& resources,
352 const LAST_BOUND_STATE& state, VkPipeline *pPipeline, const GpuAssistedCmdDrawIndirectState *cdic_state);
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600353 void PostCallRecordGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700354 VkPhysicalDeviceProperties* pPhysicalDeviceProperties) override;
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600355 void PostCallRecordGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
Mark Lobodzinskib8e22b52020-12-03 15:22:35 -0700356 VkPhysicalDeviceProperties2* pPhysicalDeviceProperties2) override;
Jeremy Gebben3d22d582021-08-11 15:37:58 -0600357
Jeremy Gebben9f537102021-10-05 16:37:12 -0600358 std::shared_ptr<CMD_BUFFER_STATE_GPUAV> GetCBState(VkCommandBuffer commandBuffer) {
359 return std::static_pointer_cast<CMD_BUFFER_STATE_GPUAV>(Get<CMD_BUFFER_STATE>(commandBuffer));
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600360 }
Jeremy Gebben9f537102021-10-05 16:37:12 -0600361 const std::shared_ptr<const CMD_BUFFER_STATE_GPUAV> GetCBState(VkCommandBuffer commandBuffer) const {
362 return std::static_pointer_cast<const CMD_BUFFER_STATE_GPUAV>(Get<CMD_BUFFER_STATE>(commandBuffer));
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600363 }
Jeremy Gebben9f537102021-10-05 16:37:12 -0600364 std::shared_ptr<SHADER_MODULE_STATE> GetShaderModuleState(VkShaderModule shader_module) {
365 return Get<SHADER_MODULE_STATE>(shader_module);
366 }
367 std::shared_ptr<const SHADER_MODULE_STATE> GetShaderModuleState(VkShaderModule shader_module) const {
368 return Get<SHADER_MODULE_STATE>(shader_module);
369 }
370 std::shared_ptr<const PIPELINE_STATE> GetPipelineState(VkPipeline pipeline) const { return Get<PIPELINE_STATE>(pipeline); }
371 std::shared_ptr<PIPELINE_STATE> GetPipelineState(VkPipeline pipeline) { return Get<PIPELINE_STATE>(pipeline); }
372
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600373 const std::vector<GpuAssistedBufferInfo>& GetBufferInfo(const CMD_BUFFER_STATE* cb_node) const {
374 assert(cb_node);
375 return static_cast<const CMD_BUFFER_STATE_GPUAV*>(cb_node)->gpuav_buffer_list;
376 }
377
378 std::vector<GpuAssistedBufferInfo>& GetBufferInfo(CMD_BUFFER_STATE* cb_node) {
379 assert(cb_node);
380 return static_cast<CMD_BUFFER_STATE_GPUAV*>(cb_node)->gpuav_buffer_list;
381 }
382
383 std::shared_ptr<CMD_BUFFER_STATE> CreateCmdBufferState(VkCommandBuffer cb, const VkCommandBufferAllocateInfo* create_info,
Jeremy Gebbencd7fa282021-10-27 10:25:32 -0600384 const COMMAND_POOL_STATE* pool) final;
Jeremy Gebbenf6bb4bb2021-08-11 15:41:09 -0600385
386 void DestroyBuffer(GpuAssistedBufferInfo& buffer_info);
387 void DestroyBuffer(GpuAssistedAccelerationStructureBuildValidationBufferInfo& buffer_info);
Tony-LunarG2ba1cb32019-09-25 15:16:11 -0600388};