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.
5 * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
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: Courtney Goeltzenleuchter <courtneygo@google.com>
20 * Author: Tobin Ehlis <tobine@google.com>
21 * Author: Chris Forbes <chrisf@ijw.co.nz>
22 * Author: Mark Lobodzinski <mark@lunarg.com>
23 * Author: Dave Houlton <daveh@lunarg.com>
24 * Author: Tobias Hector <tobias.hector@amd.com>
25 */
26
27 #pragma once
28 #include "chassis.h"
29 #include "core_validation_error_enums.h"
30 #include "device_state.h"
31 #include "queue_state.h"
32 #include "query_state.h"
33 #include "ray_tracing_state.h"
34 #include "command_validation.h"
35 #include "layer_chassis_dispatch.h"
36 #include "vk_layer_logging.h"
37 #include "vulkan/vk_layer.h"
38 #include "vk_typemap_helper.h"
39 #include "vk_layer_data.h"
40 #include "android_ndk_types.h"
41 #include <atomic>
42 #include <functional>
43 #include <memory>
44 #include <vector>
45
46 namespace cvdescriptorset {
47 class DescriptorSet;
48 class DescriptorSetLayout;
49 struct AllocateDescriptorSetsData;
50 } // namespace cvdescriptorset
51
52 class CMD_BUFFER_STATE;
53 class DESCRIPTOR_POOL_STATE;
54 class FRAMEBUFFER_STATE;
55 class PIPELINE_STATE;
56 struct PipelineStageState;
57 class PIPELINE_LAYOUT_STATE;
58 class QUEUE_STATE;
59 class BUFFER_STATE;
60 class BUFFER_VIEW_STATE;
61 class IMAGE_STATE;
62 class IMAGE_VIEW_STATE;
63 class COMMAND_POOL_STATE;
64 class DISPLAY_MODE_STATE;
65 class RENDER_PASS_STATE;
66 class SAMPLER_STATE;
67 class SAMPLER_YCBCR_CONVERSION_STATE;
68 class EVENT_STATE;
69 class SWAPCHAIN_NODE;
70 class SURFACE_STATE;
71 class UPDATE_TEMPLATE_STATE;
72
73 // These versions allow functions that are the same to share the same logic but can use different VUs
74 // The common case are functions that were missing the pNext in Vulkan 1.0 and added via extension
75 //
76 // Added from VK_KHR_create_renderpass2
77 enum RenderPassCreateVersion { RENDER_PASS_VERSION_1 = 0, RENDER_PASS_VERSION_2 = 1 };
78 // Added from VK_KHR_copy_commands2
79 enum CopyCommandVersion { COPY_COMMAND_VERSION_1 = 0, COPY_COMMAND_VERSION_2 = 1 };
80 // Added from VK_KHR_device_group but added to VK_KHR_swapchain with Vulkan 1.1
81 enum AcquireVersion { ACQUIRE_VERSION_1 = 0, ACQUIRE_VERSION_2 = 1 };
82
83 // This structure is used to save data across the CreateGraphicsPipelines down-chain API call
84 struct create_graphics_pipeline_api_state {
85 std::vector<safe_VkGraphicsPipelineCreateInfo> gpu_create_infos;
86 std::vector<safe_VkGraphicsPipelineCreateInfo> printf_create_infos;
87 std::vector<std::shared_ptr<PIPELINE_STATE>> pipe_state;
88 const VkGraphicsPipelineCreateInfo* pCreateInfos;
89 };
90
91 // This structure is used to save data across the CreateComputePipelines down-chain API call
92 struct create_compute_pipeline_api_state {
93 std::vector<safe_VkComputePipelineCreateInfo> gpu_create_infos;
94 std::vector<safe_VkComputePipelineCreateInfo> printf_create_infos;
95 std::vector<std::shared_ptr<PIPELINE_STATE>> pipe_state;
96 const VkComputePipelineCreateInfo* pCreateInfos;
97 };
98
99 // This structure is used to save data across the CreateRayTracingPipelinesNV down-chain API call.
100 struct create_ray_tracing_pipeline_api_state {
101 std::vector<safe_VkRayTracingPipelineCreateInfoCommon> gpu_create_infos;
102 std::vector<safe_VkRayTracingPipelineCreateInfoCommon> printf_create_infos;
103 std::vector<std::shared_ptr<PIPELINE_STATE>> pipe_state;
104 const VkRayTracingPipelineCreateInfoNV* pCreateInfos;
105 };
106
107 // This structure is used to save data across the CreateRayTracingPipelinesKHR down-chain API call.
108 struct create_ray_tracing_pipeline_khr_api_state {
109 std::vector<safe_VkRayTracingPipelineCreateInfoCommon> gpu_create_infos;
110 std::vector<safe_VkRayTracingPipelineCreateInfoCommon> printf_create_infos;
111 std::vector<std::shared_ptr<PIPELINE_STATE>> pipe_state;
112 const VkRayTracingPipelineCreateInfoKHR* pCreateInfos;
113 };
114
115 // This structure is used modify parameters for the CreatePipelineLayout down-chain API call
116 struct create_pipeline_layout_api_state {
117 std::vector<VkDescriptorSetLayout> new_layouts;
118 VkPipelineLayoutCreateInfo modified_create_info;
119 };
120
121 // This structure is used modify parameters for the CreateBuffer down-chain API call
122 struct create_buffer_api_state {
123 VkBufferCreateInfo modified_create_info;
124 };
125
126 // This structure is used modify and pass parameters for the CreateShaderModule down-chain API call
127 struct create_shader_module_api_state {
128 uint32_t unique_shader_id;
129 VkShaderModuleCreateInfo instrumented_create_info;
130 std::vector<unsigned int> instrumented_pgm;
131 };
132
133 #define VALSTATETRACK_MAP_AND_TRAITS_IMPL(handle_type, state_type, map_member, instance_scope) \
134 template <typename Dummy> \
135 struct AccessorStateHandle<state_type, Dummy> { \
136 using StateType = state_type; \
137 using HandleType = handle_type; \
138 }; \
139 AccessorTraitsTypes<state_type>::MapType map_member; \
140 template <typename Dummy> \
141 struct AccessorTraits<state_type, Dummy> : AccessorTraitsTypes<state_type> { \
142 static const bool kInstanceScope = instance_scope; \
143 static MapType ValidationStateTracker::*Map() { return &ValidationStateTracker::map_member; } \
144 };
145
146 #define VALSTATETRACK_MAP_AND_TRAITS(handle_type, state_type, map_member) \
147 VALSTATETRACK_MAP_AND_TRAITS_IMPL(handle_type, state_type, map_member, false)
148 #define VALSTATETRACK_MAP_AND_TRAITS_INSTANCE_SCOPE(handle_type, state_type, map_member) \
149 VALSTATETRACK_MAP_AND_TRAITS_IMPL(handle_type, state_type, map_member, true)
150
151 // For image copies between compressed/uncompressed formats, the extent is provided in source image texels
152 // Destination image texel extents must be adjusted by block size for the dest validation checks
GetAdjustedDestImageExtent(VkFormat src_format,VkFormat dst_format,VkExtent3D extent)153 static inline VkExtent3D GetAdjustedDestImageExtent(VkFormat src_format, VkFormat dst_format, VkExtent3D extent) {
154 VkExtent3D adjusted_extent = extent;
155 if (FormatIsBlockedImage(src_format) && !FormatIsBlockedImage(dst_format)) {
156 VkExtent3D block_size = FormatTexelBlockExtent(src_format);
157 adjusted_extent.width /= block_size.width;
158 adjusted_extent.height /= block_size.height;
159 adjusted_extent.depth /= block_size.depth;
160 } else if (!FormatIsBlockedImage(src_format) && FormatIsBlockedImage(dst_format)) {
161 VkExtent3D block_size = FormatTexelBlockExtent(dst_format);
162 adjusted_extent.width *= block_size.width;
163 adjusted_extent.height *= block_size.height;
164 adjusted_extent.depth *= block_size.depth;
165 }
166 return adjusted_extent;
167 }
168
169 // Test if the extent argument has any dimensions set to 0.
IsExtentSizeZero(const VkExtent3D * extent)170 static inline bool IsExtentSizeZero(const VkExtent3D* extent) {
171 return ((extent->width == 0) || (extent->height == 0) || (extent->depth == 0));
172 }
173
174 // Get buffer size from vkBufferImageCopy / vkBufferImageCopy2KHR structure, for a given format
175 template <typename BufferImageCopyRegionType>
GetBufferSizeFromCopyImage(const BufferImageCopyRegionType & region,VkFormat image_format)176 static inline VkDeviceSize GetBufferSizeFromCopyImage(const BufferImageCopyRegionType& region, VkFormat image_format) {
177 VkDeviceSize buffer_size = 0;
178 VkExtent3D copy_extent = region.imageExtent;
179 VkDeviceSize buffer_width = (0 == region.bufferRowLength ? copy_extent.width : region.bufferRowLength);
180 VkDeviceSize buffer_height = (0 == region.bufferImageHeight ? copy_extent.height : region.bufferImageHeight);
181
182 VkDeviceSize unit_size = 0;
183 if (region.imageSubresource.aspectMask & (VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT)) {
184 // Spec in vkBufferImageCopy section list special cases for each format
185 if (region.imageSubresource.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
186 unit_size = 1;
187 } else {
188 // VK_IMAGE_ASPECT_DEPTH_BIT
189 switch (image_format) {
190 case VK_FORMAT_D16_UNORM:
191 case VK_FORMAT_D16_UNORM_S8_UINT:
192 unit_size = 2;
193 break;
194 case VK_FORMAT_D32_SFLOAT:
195 case VK_FORMAT_D32_SFLOAT_S8_UINT:
196 // packed with the D24 value in the LSBs of the word, and undefined values in the eight MSBs
197 case VK_FORMAT_X8_D24_UNORM_PACK32:
198 case VK_FORMAT_D24_UNORM_S8_UINT:
199 unit_size = 4;
200 break;
201 default:
202 // Any misuse of formats vs aspect mask should be caught before here
203 return 0;
204 }
205 }
206 } else {
207 // size (bytes) of texel or block
208 unit_size = FormatElementSize(image_format, region.imageSubresource.aspectMask);
209 }
210
211 if (FormatIsBlockedImage(image_format)) {
212 // Switch to texel block units, rounding up for any partially-used blocks
213 auto block_dim = FormatTexelBlockExtent(image_format);
214 buffer_width = (buffer_width + block_dim.width - 1) / block_dim.width;
215 buffer_height = (buffer_height + block_dim.height - 1) / block_dim.height;
216
217 copy_extent.width = (copy_extent.width + block_dim.width - 1) / block_dim.width;
218 copy_extent.height = (copy_extent.height + block_dim.height - 1) / block_dim.height;
219 copy_extent.depth = (copy_extent.depth + block_dim.depth - 1) / block_dim.depth;
220 }
221
222 // Either depth or layerCount may be greater than 1 (not both). This is the number of 'slices' to copy
223 uint32_t z_copies = std::max(copy_extent.depth, region.imageSubresource.layerCount);
224 if (IsExtentSizeZero(©_extent) || (0 == z_copies)) {
225 // TODO: Issue warning here? Already warned in ValidateImageBounds()...
226 } else {
227 // Calculate buffer offset of final copied byte, + 1.
228 buffer_size = (z_copies - 1) * buffer_height * buffer_width; // offset to slice
229 buffer_size += ((copy_extent.height - 1) * buffer_width) + copy_extent.width; // add row,col
230 buffer_size *= unit_size; // convert to bytes
231 }
232 return buffer_size;
233 }
234
235 enum PushConstantByteState {
236 PC_Byte_Updated = 0,
237 PC_Byte_Not_Set = 1,
238 PC_Byte_Not_Updated = 2,
239 };
240
241 struct SHADER_MODULE_STATE;
242
243 class ValidationStateTracker : public ValidationObject {
244 private:
245 // Traits for State function resolution. Specializations defined in the macro.
246 // NOTE: The Dummy argument allows for *partial* specialization at class scope, as full specialization at class scope
247 // isn't supported until C++17. Since the Dummy has a default all instantiations of the template can ignore it, but all
248 // specializations of the template must list it (and not give it a default).
249 // These must be declared at the same access level as the map declarations (below).
250 template <typename StateType, typename Dummy = int>
251 struct AccessorStateHandle {};
252 template <typename StateType, typename Dummy = int>
253 struct AccessorTraits {};
254 template <typename StateType_>
255 struct AccessorTraitsTypes {
256 using StateType = StateType_;
257 using HandleType = typename AccessorStateHandle<StateType>::HandleType;
258 using ReturnType = StateType*;
259 using SharedType = std::shared_ptr<StateType>;
260 using ConstSharedType = std::shared_ptr<const StateType>;
261 using MappedType = std::shared_ptr<StateType>;
262 using MapType = layer_data::unordered_map<HandleType, MappedType>;
263 };
264
265 template <typename State, typename Traits = AccessorTraits<State>>
GetStateMap()266 typename Traits::MapType& GetStateMap() {
267 auto map_member = Traits::Map();
268 return (Traits::kInstanceScope && (this->*map_member).size() == 0) ? instance_state->*map_member : this->*map_member;
269 }
270 template <typename State, typename Traits = AccessorTraits<State>>
GetStateMap()271 const typename Traits::MapType& GetStateMap() const {
272 auto map_member = Traits::Map();
273 return (Traits::kInstanceScope && (this->*map_member).size() == 0) ? instance_state->*map_member : this->*map_member;
274 }
275
276 public:
277 // Override base class, we have some extra work to do here
278 void InitDeviceValidationObject(bool add_obj, ValidationObject* inst_obj, ValidationObject* dev_obj) override;
279
280 template <typename State>
Add(std::shared_ptr<State> && state_object)281 void Add(std::shared_ptr<State>&& state_object) {
282 auto& map = GetStateMap<State>();
283 using KeyType = typename AccessorTraits<State>::MapType::key_type;
284
285 auto handle = state_object->Handle().template Cast<KeyType>();
286 auto result = map.emplace(handle, state_object);
287 // there shouldn't be anything in the map. If there is, we missed a destroy and then the driver reused the handle.
288 assert(result.second);
289 if (!result.second) {
290 result.first->second = std::move(state_object);
291 }
292 }
293
294 template <typename State>
Destroy(typename AccessorTraits<State>::HandleType handle)295 void Destroy(typename AccessorTraits<State>::HandleType handle) {
296 auto& map = GetStateMap<State>();
297 auto iter = map.find(handle);
298 if (iter != map.end()) {
299 iter->second->Destroy();
300 map.erase(iter);
301 }
302 }
303
304 template <typename State>
Count()305 size_t Count() const {
306 return GetStateMap<State>().size();
307 }
308
309 template <typename State>
ForEach(std::function<void (const State & s)> fn)310 void ForEach(std::function<void(const State& s)> fn) const {
311 const auto& map = GetStateMap<State>();
312 for (const auto& entry : map) {
313 fn(*entry.second);
314 }
315 }
316
317 template <typename State>
AnyOf(std::function<bool (const State & s)> fn)318 bool AnyOf(std::function<bool(const State& s)> fn) const {
319 const auto& map = GetStateMap<State>();
320 for (const auto& entry : map) {
321 if (fn(*entry.second)) {
322 return true;
323 }
324 }
325 return false;
326 }
327
328 template <typename State>
Get(typename AccessorTraits<State>::HandleType handle)329 typename AccessorTraits<State>::SharedType Get(typename AccessorTraits<State>::HandleType handle) {
330 const auto& map = GetStateMap<State>();
331 const auto found_it = map.find(handle);
332 if (found_it == map.end()) {
333 return nullptr;
334 }
335 return found_it->second;
336 };
337
338 template <typename State>
Get(typename AccessorTraits<State>::HandleType handle)339 typename AccessorTraits<State>::ConstSharedType Get(typename AccessorTraits<State>::HandleType handle) const {
340 const auto& map = GetStateMap<State>();
341 const auto found_it = map.find(handle);
342 if (found_it == map.cend()) {
343 return nullptr;
344 }
345 return found_it->second;
346 };
347
348 // When needing to share ownership, control over constness of access with another object (i.e. adding references while
349 // not modifying the contents of the ValidationStateTracker)
350 template <typename State>
GetConstCastShared(typename AccessorTraits<State>::HandleType handle)351 typename AccessorTraits<State>::SharedType GetConstCastShared(typename AccessorTraits<State>::HandleType handle) const {
352 const auto& map = GetStateMap<State>();
353 const auto found_it = map.find(handle);
354 if (found_it == map.cend()) {
355 return nullptr;
356 }
357 return found_it->second;
358 };
359
360 using CommandBufferResetCallback = std::function<void(VkCommandBuffer)>;
361 template <typename Fn>
SetCommandBufferResetCallback(Fn && fn)362 void SetCommandBufferResetCallback(Fn&& fn) {
363 command_buffer_reset_callback.reset(new CommandBufferResetCallback(std::forward<Fn>(fn)));
364 }
365
366 using CommandBufferFreeCallback = std::function<void(VkCommandBuffer)>;
367 template <typename Fn>
SetCommandBufferFreeCallback(Fn && fn)368 void SetCommandBufferFreeCallback(Fn&& fn) {
369 command_buffer_free_callback.reset(new CommandBufferFreeCallback(std::forward<Fn>(fn)));
370 }
371
372 using SetImageViewInitialLayoutCallback = std::function<void(CMD_BUFFER_STATE*, const IMAGE_VIEW_STATE&, VkImageLayout)>;
373 template <typename Fn>
SetSetImageViewInitialLayoutCallback(Fn && fn)374 void SetSetImageViewInitialLayoutCallback(Fn&& fn) {
375 set_image_view_initial_layout_callback.reset(new SetImageViewInitialLayoutCallback(std::forward<Fn>(fn)));
376 }
377
CallSetImageViewInitialLayoutCallback(CMD_BUFFER_STATE * cb_node,const IMAGE_VIEW_STATE & iv_state,VkImageLayout layout)378 void CallSetImageViewInitialLayoutCallback(CMD_BUFFER_STATE* cb_node, const IMAGE_VIEW_STATE& iv_state, VkImageLayout layout) {
379 if (set_image_view_initial_layout_callback) {
380 (*set_image_view_initial_layout_callback)(cb_node, iv_state, layout);
381 }
382 }
383
384 // State update functions
385 // Gets/Enumerations
386 virtual std::shared_ptr<PHYSICAL_DEVICE_STATE> CreatePhysicalDeviceState(VkPhysicalDevice phys_dev);
387 void PostCallRecordCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
388 VkInstance* pInstance, VkResult result) override;
389 void PostCallRecordEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
390 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, uint32_t* pCounterCount, VkPerformanceCounterKHR* pCounters,
391 VkPerformanceCounterDescriptionKHR* pCounterDescriptions, VkResult result) override;
392 void PostCallRecordGetAccelerationStructureMemoryRequirementsNV(VkDevice device,
393 const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo,
394 VkMemoryRequirements2* pMemoryRequirements) override;
395 void PostCallRecordGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer,
396 VkMemoryRequirements* pMemoryRequirements) override;
397 void PostCallRecordGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo,
398 VkMemoryRequirements2* pMemoryRequirements) override;
399 void PostCallRecordGetBufferMemoryRequirements2KHR(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo,
400 VkMemoryRequirements2* pMemoryRequirements) override;
401 void PostCallRecordGetFenceFdKHR(VkDevice device, const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd, VkResult result) override;
402 void PostCallRecordGetFenceStatus(VkDevice device, VkFence fence, VkResult result) override;
403 #ifdef VK_USE_PLATFORM_WIN32_KHR
404 void PostCallRecordGetFenceWin32HandleKHR(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
405 HANDLE* pHandle, VkResult result) override;
406 #endif // VK_USE_PLATFORM_WIN32_KHR
407 void PostCallRecordGetImageMemoryRequirements(VkDevice device, VkImage image,
408 VkMemoryRequirements* pMemoryRequirements) override;
409 void PostCallRecordGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo,
410 VkMemoryRequirements2* pMemoryRequirements) override;
411 void PostCallRecordGetImageMemoryRequirements2KHR(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo,
412 VkMemoryRequirements2* pMemoryRequirements) override;
413 void PostCallRecordGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount,
414 VkSparseImageMemoryRequirements* pSparseMemoryRequirements) override;
415 void PostCallRecordGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo,
416 uint32_t* pSparseMemoryRequirementCount,
417 VkSparseImageMemoryRequirements2* pSparseMemoryRequirements) override;
418 void PostCallRecordGetImageSparseMemoryRequirements2KHR(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo,
419 uint32_t* pSparseMemoryRequirementCount,
420 VkSparseImageMemoryRequirements2* pSparseMemoryRequirements) override;
421 void PostCallRecordGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount,
422 VkDisplayPlanePropertiesKHR* pProperties,
423 VkResult result) override;
424 void PostCallRecordGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount,
425 VkDisplayPlaneProperties2KHR* pProperties,
426 VkResult result) override;
427 void PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount,
428 VkQueueFamilyProperties* pQueueFamilyProperties) override;
429 void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount,
430 VkQueueFamilyProperties2* pQueueFamilyProperties) override;
431 void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice,
432 uint32_t* pQueueFamilyPropertyCount,
433 VkQueueFamilyProperties2* pQueueFamilyProperties) override;
434 void PostCallRecordGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
435 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities,
436 VkResult result) override;
437 void PostCallRecordGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
438 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
439 VkSurfaceCapabilities2KHR* pSurfaceCapabilities,
440 VkResult result) override;
441 void PostCallRecordGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
442 VkSurfaceCapabilities2EXT* pSurfaceCapabilities,
443 VkResult result) override;
444 void PostCallRecordGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
445 uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats,
446 VkResult result) override;
447 void PostCallRecordGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
448 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
449 uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats,
450 VkResult result) override;
451 void PostCallRecordGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
452 uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes,
453 VkResult result) override;
454 void PostCallRecordGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
455 VkSurfaceKHR surface, VkBool32* pSupported, VkResult result) override;
456 void PostCallRecordGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd,
457 VkResult result) override;
458 #ifdef VK_USE_PLATFORM_WIN32_KHR
459 void PostCallRecordGetSemaphoreWin32HandleKHR(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
460 HANDLE* pHandle, VkResult result) override;
461 #endif // VK_USE_PLATFORM_WIN32_KHR
462 void PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount,
463 VkImage* pSwapchainImages, VkResult result) override;
464 void PostCallRecordImportFenceFdKHR(VkDevice device, const VkImportFenceFdInfoKHR* pImportFenceFdInfo,
465 VkResult result) override;
466 #ifdef VK_USE_PLATFORM_WIN32_KHR
467 void PostCallRecordImportFenceWin32HandleKHR(VkDevice device,
468 const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo,
469 VkResult result) override;
470 #endif // VK_USE_PLATFORM_WIN32_KHR
471 void PostCallRecordImportSemaphoreFdKHR(VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo,
472 VkResult result) override;
473 #ifdef VK_USE_PLATFORM_WIN32_KHR
474 void PostCallRecordImportSemaphoreWin32HandleKHR(VkDevice device,
475 const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo,
476 VkResult result) override;
477 #endif // VK_USE_PLATFORM_WIN32_KHR
478 void PostCallRecordSignalSemaphoreKHR(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo, VkResult result) override;
479
480 // Create/Destroy/Bind
481 void PostCallRecordBindAccelerationStructureMemoryNV(VkDevice device, uint32_t bindInfoCount,
482 const VkBindAccelerationStructureMemoryInfoNV* pBindInfos,
483 VkResult result) override;
484 void PostCallRecordBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memoryOffset,
485 VkResult result) override;
486 void PostCallRecordBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos,
487 VkResult result) override;
488 void PostCallRecordBindBufferMemory2KHR(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos,
489 VkResult result) override;
490 void PostCallRecordBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memoryOffset,
491 VkResult result) override;
492 void PostCallRecordBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos,
493 VkResult result) override;
494 void PostCallRecordBindImageMemory2KHR(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos,
495 VkResult result) override;
496
497 void PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo,
498 const VkAllocationCallbacks* pAllocator, VkDevice* pDevice, VkResult result) override;
499 void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) override;
500
501 void PostCallRecordCreateAccelerationStructureNV(VkDevice device, const VkAccelerationStructureCreateInfoNV* pCreateInfo,
502 const VkAllocationCallbacks* pAllocator,
503 VkAccelerationStructureNV* pAccelerationStructure, VkResult result) override;
504 void PreCallRecordDestroyAccelerationStructureNV(VkDevice device, VkAccelerationStructureNV accelerationStructure,
505 const VkAllocationCallbacks* pAllocator) override;
506
507 void PostCallRecordCreateAccelerationStructureKHR(VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
508 const VkAllocationCallbacks* pAllocator,
509 VkAccelerationStructureKHR* pAccelerationStructure, VkResult result) override;
510 void PostCallRecordBuildAccelerationStructuresKHR(VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
511 const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
512 const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos,
513 VkResult result) override;
514 void PostCallRecordCmdBuildAccelerationStructuresKHR(
515 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
516 const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos) override;
517
518 void PostCallRecordCmdBuildAccelerationStructuresIndirectKHR(VkCommandBuffer commandBuffer, uint32_t infoCount,
519 const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
520 const VkDeviceAddress* pIndirectDeviceAddresses,
521 const uint32_t* pIndirectStrides,
522 const uint32_t* const* ppMaxPrimitiveCounts) override;
523 void PreCallRecordDestroyAccelerationStructureKHR(VkDevice device, VkAccelerationStructureKHR accelerationStructure,
524 const VkAllocationCallbacks* pAllocator) override;
525
526 void PostCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
527 VkBuffer* pBuffer, VkResult result) override;
528 void PreCallRecordDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator) override;
529 void PostCallRecordCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo,
530 const VkAllocationCallbacks* pAllocator, VkBufferView* pView, VkResult result) override;
531 void PreCallRecordDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) override;
532 void PostCallRecordCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo,
533 const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool,
534 VkResult result) override;
535 void PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
536 const VkAllocationCallbacks* pAllocator) override;
537 void PostCallRecordCreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo,
538 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
539 VkResult result) override;
540 void PostCallRecordCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
541 VkEvent* pEvent, VkResult result) override;
542 void PreCallRecordDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator) override;
543 void PostCallRecordCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo,
544 const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool,
545 VkResult result) override;
546 void PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
547 const VkAllocationCallbacks* pAllocator) override;
548 void PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
549 const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout,
550 VkResult result) override;
551 void PostCallRecordResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags, VkResult result) override;
552 void PostCallRecordResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags,
553 VkResult result) override;
554 bool PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
555 const VkComputePipelineCreateInfo* pCreateInfos,
556 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
557 void* pipe_state) const override;
558 void PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
559 const VkComputePipelineCreateInfo* pCreateInfos,
560 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
561 void* pipe_state) override;
562 void PostCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags,
563 VkResult result) override;
564 bool PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo,
565 VkDescriptorSet* pDescriptorSets, void* ads_state_data) const override;
566 void PreCallRecordDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout,
567 const VkAllocationCallbacks* pAllocator) override;
568 void PostCallRecordCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
569 const VkAllocationCallbacks* pAllocator,
570 VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate,
571 VkResult result) override;
572 void PostCallRecordCreateDescriptorUpdateTemplateKHR(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
573 const VkAllocationCallbacks* pAllocator,
574 VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate,
575 VkResult result) override;
576 void PreCallRecordDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate,
577 const VkAllocationCallbacks* pAllocator) override;
578 void PreCallRecordDestroyDescriptorUpdateTemplateKHR(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate,
579 const VkAllocationCallbacks* pAllocator) override;
580 void PostCallRecordCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
581 VkFence* pFence, VkResult result) override;
582 void PreCallRecordDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator) override;
583 void PostCallRecordResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkResult result) override;
584 void PostCallRecordCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo,
585 const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer,
586 VkResult result) override;
587 void PreCallRecordDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer,
588 const VkAllocationCallbacks* pAllocator) override;
589 bool PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
590 const VkGraphicsPipelineCreateInfo* pCreateInfos,
591 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
592 void* cgpl_state) const override;
593 void PostCallRecordCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
594 const VkGraphicsPipelineCreateInfo* pCreateInfos,
595 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
596 void* cgpl_state) override;
597 void PostCallRecordCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
598 VkImage* pImage, VkResult result) override;
599 void PreCallRecordDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator) override;
600 void PostCallRecordCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo,
601 const VkAllocationCallbacks* pAllocator, VkImageView* pView, VkResult result) override;
602 void PreCallRecordDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator) override;
603
604 void PreCallRecordDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator) override;
605 void PostCallRecordCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo,
606 const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout,
607 VkResult result) override;
608 void PreCallRecordDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout,
609 const VkAllocationCallbacks* pAllocator) override;
610 void PostCallRecordCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo,
611 const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool, VkResult result) override;
612 void PreCallRecordDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator) override;
613 void RecordResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
614 void PostCallRecordResetQueryPoolEXT(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) override;
615 void PostCallRecordResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) override;
616 bool PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
617 const VkRayTracingPipelineCreateInfoNV* pCreateInfos,
618 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
619 void* pipe_state) const override;
620 void PostCallRecordCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t count,
621 const VkRayTracingPipelineCreateInfoNV* pCreateInfos,
622 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines, VkResult result,
623 void* pipe_state) override;
624 bool PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
625 VkPipelineCache pipelineCache, uint32_t count,
626 const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
627 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
628 void* pipe_state) const override;
629 void PostCallRecordCreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
630 VkPipelineCache pipelineCache, uint32_t count,
631 const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
632 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines,
633 VkResult result, void* pipe_state) override;
634 void PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo,
635 const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass,
636 VkResult result) override;
637 void PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo,
638 const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass,
639 VkResult result) override;
640 void PostCallRecordCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo,
641 const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass,
642 VkResult result) override;
643 void PreCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator) override;
644 void PostCallRecordCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo,
645 const VkAllocationCallbacks* pAllocator, VkSampler* pSampler, VkResult result) override;
646 void PreCallRecordDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator) override;
647 void PostCallRecordCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo,
648 const VkAllocationCallbacks* pAllocator,
649 VkSamplerYcbcrConversion* pYcbcrConversion, VkResult result) override;
650 void PostCallRecordDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion,
651 const VkAllocationCallbacks* pAllocator) override;
652 void PostCallRecordCreateSamplerYcbcrConversionKHR(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo,
653 const VkAllocationCallbacks* pAllocator,
654 VkSamplerYcbcrConversion* pYcbcrConversion, VkResult result) override;
655 void PostCallRecordDestroySamplerYcbcrConversionKHR(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion,
656 const VkAllocationCallbacks* pAllocator) override;
657 void PostCallRecordCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo,
658 const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore, VkResult result) override;
659 void PreCallRecordDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) override;
660 void PostCallRecordCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo,
661 const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule, VkResult result,
662 void* csm_state) override;
663 void PreCallRecordDestroyShaderModule(VkDevice device, VkShaderModule shaderModule,
664 const VkAllocationCallbacks* pAllocator) override;
665 void PreCallRecordDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
666 const VkAllocationCallbacks* pAllocator) override;
667 void PostCallRecordCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
668 const VkSwapchainCreateInfoKHR* pCreateInfos,
669 const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains,
670 VkResult result) override;
671 void PostCallRecordCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo,
672 const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain,
673 VkResult result) override;
674 void PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
675 const VkAllocationCallbacks* pAllocator) override;
676 void PostCallRecordCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
677 const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator,
678 VkDisplayModeKHR* pMode, VkResult result) override;
679
680 // CommandBuffer/Queue Control
681 void PreCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo) override;
682 void PostCallRecordDeviceWaitIdle(VkDevice device, VkResult result) override;
683 void PostCallRecordEndCommandBuffer(VkCommandBuffer commandBuffer, VkResult result) override;
684 void PostCallRecordQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence,
685 VkResult result) override;
686 void PostCallRecordQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo, VkResult result) override;
687 void PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence,
688 VkResult result) override;
689 void PostCallRecordQueueWaitIdle(VkQueue queue, VkResult result) override;
690 void PreCallRecordSetEvent(VkDevice device, VkEvent event) override;
691 void PostCallRecordWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll,
692 uint64_t timeout, VkResult result) override;
693 void PostCallRecordWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout,
694 VkResult result) override;
695 void PostCallRecordWaitSemaphoresKHR(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout,
696 VkResult result) override;
697 void PostCallRecordGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t* pValue, VkResult result) override;
698 void PostCallRecordGetSemaphoreCounterValueKHR(VkDevice device, VkSemaphore semaphore, uint64_t* pValue,
699 VkResult result) override;
700 void PostCallRecordAcquireProfilingLockKHR(VkDevice device, const VkAcquireProfilingLockInfoKHR* pInfo,
701 VkResult result) override;
702 void PostCallRecordReleaseProfilingLockKHR(VkDevice device) override;
703
704 virtual std::shared_ptr<CMD_BUFFER_STATE> CreateCmdBufferState(VkCommandBuffer cb,
705 const VkCommandBufferAllocateInfo* create_info,
706 const COMMAND_POOL_STATE* pool);
707 // Allocate/Free
708 void PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pCreateInfo,
709 VkCommandBuffer* pCommandBuffer, VkResult result) override;
710 void PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo,
711 VkDescriptorSet* pDescriptorSets, VkResult result, void* ads_state) override;
712 void PostCallRecordAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo,
713 const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory, VkResult result) override;
714 void PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
715 const VkCommandBuffer* pCommandBuffers) override;
716 void PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count,
717 const VkDescriptorSet* pDescriptorSets) override;
718 void PreCallRecordFreeMemory(VkDevice device, VkDeviceMemory mem, const VkAllocationCallbacks* pAllocator) override;
719 void PreCallRecordUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
720 const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount,
721 const VkCopyDescriptorSet* pDescriptorCopies) override;
722 void PreCallRecordUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet,
723 VkDescriptorUpdateTemplate descriptorUpdateTemplate,
724 const void* pData) override;
725 void PreCallRecordUpdateDescriptorSetWithTemplateKHR(VkDevice device, VkDescriptorSet descriptorSet,
726 VkDescriptorUpdateTemplate descriptorUpdateTemplate,
727 const void* pData) override;
728
729 // Memory mapping
730 void PostCallRecordMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags,
731 void** ppData, VkResult result) override;
732 void PreCallRecordUnmapMemory(VkDevice device, VkDeviceMemory mem) override;
733
734 // Recorded Commands
735 void PreCallRecordCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) override;
736 void PostCallRecordCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags) override;
737 void PostCallRecordCmdBeginQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query,
738 VkQueryControlFlags flags, uint32_t index) override;
739 void PreCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin,
740 VkSubpassContents contents) override;
741 void PreCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, const VkRenderingInfoKHR* pRenderingInfo) override;
742 void PreCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer) override;
743 void PreCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin,
744 const VkSubpassBeginInfo* pSubpassBeginInfo) override;
745 void PreCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin,
746 const VkSubpassBeginInfo* pSubpassBeginInfo) override;
747 void PostCallRecordCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer,
748 uint32_t counterBufferCount, const VkBuffer* pCounterBuffers,
749 const VkDeviceSize* pCounterBufferOffsets) override;
750 void PostCallRecordCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer,
751 uint32_t counterBufferCount, const VkBuffer* pCounterBuffers,
752 const VkDeviceSize* pCounterBufferOffsets) override;
753 void PostCallRecordCmdBeginConditionalRenderingEXT(
754 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) override;
755 void PostCallRecordCmdEndConditionalRenderingEXT(VkCommandBuffer commandBuffer) override;
756 void PreCallRecordCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
757 VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount,
758 const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount,
759 const uint32_t* pDynamicOffsets) override;
760 void PreCallRecordCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
761 VkIndexType indexType) override;
762 void PreCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
763 VkPipeline pipeline) override;
764 void PreCallRecordCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer, VkImageView imageView,
765 VkImageLayout imageLayout) override;
766 void PreCallRecordCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
767 const VkBuffer* pBuffers, const VkDeviceSize* pOffsets) override;
768 void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
769 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions,
770 VkFilter filter) override;
771 void PreCallRecordCmdBlitImage2KHR(VkCommandBuffer commandBuffer, const VkBlitImageInfo2KHR* pBlitImageInfo) override;
772 void PostCallRecordCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo,
773 VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update,
774 VkAccelerationStructureNV dst, VkAccelerationStructureNV src,
775 VkBuffer scratch, VkDeviceSize scratchOffset) override;
776 void PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout,
777 const VkClearColorValue* pColor, uint32_t rangeCount,
778 const VkImageSubresourceRange* pRanges) override;
779 void PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout,
780 const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount,
781 const VkImageSubresourceRange* pRanges) override;
782 void PostCallRecordCmdCopyAccelerationStructureNV(VkCommandBuffer commandBuffer, VkAccelerationStructureNV dst,
783 VkAccelerationStructureNV src,
784 VkCopyAccelerationStructureModeNV mode) override;
785 void PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount,
786 const VkBufferCopy* pRegions) override;
787 void PreCallRecordCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR* pCopyBufferInfos) override;
788 void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage,
789 VkImageLayout dstImageLayout, uint32_t regionCount,
790 const VkBufferImageCopy* pRegions) override;
791 void PreCallRecordCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer,
792 const VkCopyBufferToImageInfo2KHR* pCopyBufferToImageInfo) override;
793 void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
794 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions) override;
795 void PreCallRecordCmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR* pCopyImageInfo) override;
796 void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
797 VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions) override;
798 void PreCallRecordCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer,
799 const VkCopyImageToBufferInfo2KHR* pCopyImageToBufferInfo) override;
800 void PostCallRecordCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery,
801 uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride,
802 VkQueryResultFlags flags) override;
803 void PostCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) override;
804 void PostCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) override;
805 void PostCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t base_x, uint32_t base_y, uint32_t base_z,
806 uint32_t x, uint32_t y, uint32_t z) override;
807 void PostCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t base_x, uint32_t base_y, uint32_t base_z, uint32_t x,
808 uint32_t y, uint32_t z) override;
809 void PostCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
810 uint32_t firstInstance) override;
811 void PostCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo,
812 uint32_t instanceCount, uint32_t firstInstance, uint32_t stride) override;
813 void PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount,
814 uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override;
815 void PostCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
816 const VkMultiDrawIndexedInfoEXT* pIndexInfo, uint32_t instanceCount,
817 uint32_t firstInstance, uint32_t stride, const int32_t* pVertexOffset) override;
818 void PostCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
819 uint32_t stride) override;
820 void PostCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
821 uint32_t stride) override;
822 void RecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
823 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
824 uint32_t stride, CMD_TYPE cmd_type);
825 void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
826 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
827 uint32_t stride) override;
828 void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
829 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
830 uint32_t stride) override;
831 void RecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer,
832 VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, CMD_TYPE cmd_type);
833 void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
834 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
835 uint32_t stride) override;
836 void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
837 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
838 uint32_t stride) override;
839 void PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
840 VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
841 uint32_t stride) override;
842 void PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
843 uint32_t drawCount, uint32_t stride) override;
844 void PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) override;
845 void PostCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer,
846 VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer,
847 VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
848 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset,
849 VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer,
850 VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
851 uint32_t width, uint32_t height, uint32_t depth) override;
852 void PostCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
853 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
854 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
855 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
856 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, uint32_t width,
857 uint32_t height, uint32_t depth) override;
858 void PostCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
859 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
860 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
861 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
862 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
863 VkDeviceAddress indirectDeviceAddress) override;
864 void PostCallRecordCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) override;
865 void PostCallRecordCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot) override;
866 void PostCallRecordCmdEndQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query,
867 uint32_t index) override;
868 void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer) override;
869 void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo) override;
870 void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo) override;
871 void PreCallRecordCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBuffersCount,
872 const VkCommandBuffer* pCommandBuffers) override;
873 void PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size,
874 uint32_t data) override;
875 void PreCallRecordCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) override;
876 void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) override;
877 void PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo,
878 const VkSubpassEndInfo* pSubpassEndInfo) override;
879 void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo,
880 const VkSubpassEndInfo* pSubpassEndInfo) override;
881 void PreCallRecordCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
882 VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount,
883 const VkWriteDescriptorSet* pDescriptorWrites) override;
884 void PreCallRecordCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer,
885 VkDescriptorUpdateTemplate descriptorUpdateTemplate,
886 VkPipelineLayout layout, uint32_t set, const void* pData) override;
887 void PostCallRecordCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags,
888 uint32_t offset, uint32_t size, const void* pValues) override;
889 void PreCallRecordCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override;
890 void PostCallRecordCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery,
891 uint32_t queryCount) override;
892 void PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
893 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
894 const VkImageResolve* pRegions) override;
895 void PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR* pResolveImageInfo) override;
896 void PreCallRecordCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) override;
897 void PreCallRecordCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp,
898 float depthBiasSlopeFactor) override;
899 void PreCallRecordCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds) override;
900 void PreCallRecordCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override;
901 void PreCallRecordCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor,
902 uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors) override;
903 void PreCallRecordCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) override;
904 void PreCallRecordCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
905 uint16_t lineStipplePattern) override;
906 void PreCallRecordCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount,
907 const VkRect2D* pScissors) override;
908 void PreCallRecordCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask,
909 uint32_t compareMask) override;
910 void PreCallRecordCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask,
911 uint32_t reference) override;
912 void PreCallRecordCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask,
913 uint32_t writeMask) override;
914 void PreCallRecordCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
915 const VkViewport* pViewports) override;
916 void PreCallRecordCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
917 uint32_t viewportCount,
918 const VkShadingRatePaletteNV* pShadingRatePalettes) override;
919 void PostCallRecordCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
920 VkDeviceSize dataSize, const void* pData) override;
921 void PreCallRecordCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
922 VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask,
923 uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers,
924 uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers,
925 uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) override;
926 void PostCallRecordCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage,
927 VkQueryPool queryPool, uint32_t slot) override;
928 void PostCallRecordCmdWriteAccelerationStructuresPropertiesKHR(VkCommandBuffer commandBuffer,
929 uint32_t accelerationStructureCount,
930 const VkAccelerationStructureKHR* pAccelerationStructures,
931 VkQueryType queryType, VkQueryPool queryPool,
932 uint32_t firstQuery) override;
933 void PreCallRecordCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
934 const VkViewportWScalingNV* pViewportWScalings) override;
935 void PreCallRecordCmdSetVertexInputEXT(VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
936 const VkVertexInputBindingDescription2EXT* pVertexBindingDescriptions,
937 uint32_t vertexAttributeDescriptionCount,
938 const VkVertexInputAttributeDescription2EXT* pVertexAttributeDescriptions) override;
939 template <typename CreateInfo>
940 VkFormatFeatureFlags GetExternalFormatFeaturesANDROID(const CreateInfo* create_info) const;
941 #ifdef VK_USE_PLATFORM_ANDROID_KHR
942 void PostCallRecordGetAndroidHardwareBufferPropertiesANDROID(VkDevice device, const struct AHardwareBuffer* buffer,
943 VkAndroidHardwareBufferPropertiesANDROID* pProperties,
944 VkResult result) override;
945 #endif // VK_USE_PLATFORM_ANDROID_KHR
946
947 // WSI
948 void PostCallRecordAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore,
949 VkFence fence, uint32_t* pImageIndex, VkResult result) override;
950 void PostCallRecordAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR* pAcquireInfo, uint32_t* pImageIndex,
951 VkResult result) override;
952 #ifdef VK_USE_PLATFORM_ANDROID_KHR
953 void PostCallRecordCreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
954 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
955 VkResult result) override;
956 #endif // VK_USE_PLATFORM_ANDROID_KHR
957 #ifdef VK_USE_PLATFORM_IOS_MVK
958 void PostCallRecordCreateIOSSurfaceMVK(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
959 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
960 VkResult result) override;
961 #endif // VK_USE_PLATFORM_IOS_MVK
962 #ifdef VK_USE_PLATFORM_MACOS_MVK
963 void PostCallRecordCreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
964 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
965 VkResult result) override;
966 #endif // VK_USE_PLATFORM_MACOS_MVK
967 #ifdef VK_USE_PLATFORM_METAL_EXT
968 void PostCallRecordCreateMetalSurfaceEXT(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
969 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
970 VkResult result) override;
971 #endif // VK_USE_PLATFORM_METAL_EXT
972 #ifdef VK_USE_PLATFORM_WIN32_KHR
973 void PostCallRecordCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
974 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
975 VkResult result) override;
976 #endif // VK_USE_PLATFORM_WIN32_KHR
977 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
978 void PostCallRecordCreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
979 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
980 VkResult result) override;
981 #endif // VK_USE_PLATFORM_WAYLAND_KHR
982 #ifdef VK_USE_PLATFORM_XCB_KHR
983 void PostCallRecordCreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
984 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
985 VkResult result) override;
986 #endif // VK_USE_PLATFORM_XCB_KHR
987 #ifdef VK_USE_PLATFORM_XLIB_KHR
988 void PostCallRecordCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
989 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
990 VkResult result) override;
991 #endif // VK_USE_PLATFORM_XLIB_KHR
992 void PostCallRecordCreateHeadlessSurfaceEXT(VkInstance instance, const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo,
993 const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface,
994 VkResult result) override;
995
996 // State Utilty functions
997 std::vector<std::shared_ptr<const IMAGE_VIEW_STATE>> GetAttachmentViews(const VkRenderPassBeginInfo& rp_begin,
998 const FRAMEBUFFER_STATE& fb_state) const;
999
1000 VkFormatFeatureFlags GetPotentialFormatFeatures(VkFormat format) const;
1001 void PerformUpdateDescriptorSetsWithTemplateKHR(VkDescriptorSet descriptorSet, const UPDATE_TEMPLATE_STATE* template_state,
1002 const void* pData);
1003 void RecordAcquireNextImageState(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore,
1004 VkFence fence, uint32_t* pImageIndex);
1005 void RecordCreateSamplerYcbcrConversionState(const VkSamplerYcbcrConversionCreateInfo* create_info,
1006 VkSamplerYcbcrConversion ycbcr_conversion);
1007 virtual std::shared_ptr<SWAPCHAIN_NODE> CreateSwapchainState(const VkSwapchainCreateInfoKHR* create_info,
1008 VkSwapchainKHR swapchain);
1009 void RecordCreateSwapchainState(VkResult result, const VkSwapchainCreateInfoKHR* pCreateInfo, VkSwapchainKHR* pSwapchain,
1010 std::shared_ptr<SURFACE_STATE>&& surface_state, SWAPCHAIN_NODE* old_swapchain_state);
1011 void RecordDestroySamplerYcbcrConversionState(VkSamplerYcbcrConversion ycbcr_conversion);
1012 void RecordEnumeratePhysicalDeviceGroupsState(uint32_t* pPhysicalDeviceGroupCount,
1013 VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties);
1014 void RecordEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCounters(VkPhysicalDevice physicalDevice,
1015 uint32_t queueFamilyIndex, uint32_t* pCounterCount,
1016 VkPerformanceCounterKHR* pCounters);
1017 void RecordGetBufferMemoryRequirementsState(VkBuffer buffer);
1018 void RecordGetExternalFenceState(VkFence fence, VkExternalFenceHandleTypeFlagBits handle_type);
1019 void RecordGetImageMemoryRequirementsState(VkImage image, const VkImageMemoryRequirementsInfo2* pInfo);
1020 void RecordImportSemaphoreState(VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBits handle_type,
1021 VkSemaphoreImportFlags flags);
1022 void RecordGetPhysicalDeviceDisplayPlanePropertiesState(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount,
1023 void* pProperties);
1024 void RecordGetExternalSemaphoreState(VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBits handle_type);
1025 void RecordImportFenceState(VkFence fence, VkExternalFenceHandleTypeFlagBits handle_type, VkFenceImportFlags flags);
1026 void RecordUpdateDescriptorSetWithTemplateState(VkDescriptorSet descriptorSet,
1027 VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData);
1028 void RecordCreateDescriptorUpdateTemplateState(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
1029 VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate);
1030 void RecordMappedMemory(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, void** ppData);
1031 void RecordCmdEndRenderingRenderPassState(VkCommandBuffer commandBuffer);
1032 void RecordVulkanSurface(VkSurfaceKHR* pSurface);
1033 void RecordWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout, VkResult result);
1034 void RecordGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t* pValue, VkResult result);
1035 void UpdateBindBufferMemoryState(VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memoryOffset);
1036 void UpdateBindImageMemoryState(const VkBindImageMemoryInfo& bindInfo);
1037 void UpdateAllocateDescriptorSetsData(const VkDescriptorSetAllocateInfo*, cvdescriptorset::AllocateDescriptorSetsData*) const;
1038
1039 void PostCallRecordCopyAccelerationStructureKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
1040 const VkCopyAccelerationStructureInfoKHR* pInfo, VkResult result) override;
1041 void PostCallRecordCmdCopyAccelerationStructureKHR(VkCommandBuffer commandBuffer,
1042 const VkCopyAccelerationStructureInfoKHR* pInfo) override;
1043
1044 void PreCallRecordCmdSetCullModeEXT(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode) override;
1045 void PreCallRecordCmdSetFrontFaceEXT(VkCommandBuffer commandBuffer, VkFrontFace frontFace) override;
1046 void PreCallRecordCmdSetPrimitiveTopologyEXT(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology) override;
1047 void PreCallRecordCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
1048 const VkViewport* pViewports) override;
1049 void PreCallRecordCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
1050 const VkRect2D* pScissors) override;
1051 void PreCallRecordCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
1052 const VkBuffer* pBuffers, const VkDeviceSize* pOffsets, const VkDeviceSize* pSizes,
1053 const VkDeviceSize* pStrides) override;
1054 void PreCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable) override;
1055 void PreCallRecordCmdSetDepthWriteEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable) override;
1056 void PreCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp) override;
1057 void PreCallRecordCmdSetDepthBoundsTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthBoundsTestEnable) override;
1058 void PreCallRecordCmdSetStencilTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable) override;
1059 void PreCallRecordCmdSetStencilOpEXT(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp,
1060 VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp) override;
1061 void PreCallRecordCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle,
1062 uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles) override;
1063 void PreCallRecordCmdSetSampleLocationsEXT(VkCommandBuffer commandBuffer,
1064 const VkSampleLocationsInfoEXT* pSampleLocationsInfo) override;
1065 void PreCallRecordCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType,
1066 uint32_t customSampleOrderCount,
1067 const VkCoarseSampleOrderCustomNV* pCustomSampleOrders) override;
1068
1069 void PreCallRecordCmdSetPatchControlPointsEXT(VkCommandBuffer commandBuffer, uint32_t patchControlPoints) override;
1070 void PreCallRecordCmdSetLogicOpEXT(VkCommandBuffer commandBuffer, VkLogicOp logicOp) override;
1071 void PreCallRecordCmdSetRasterizerDiscardEnableEXT(VkCommandBuffer commandBuffer, VkBool32 rasterizerDiscardEnable) override;
1072 void PreCallRecordCmdSetDepthBiasEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable) override;
1073 void PreCallRecordCmdSetPrimitiveRestartEnableEXT(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable) override;
1074
1075 void PostCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask,
1076 VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags,
1077 uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers,
1078 uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers,
1079 uint32_t imageMemoryBarrierCount,
1080 const VkImageMemoryBarrier* pImageMemoryBarriers) override;
1081
1082 void PreCallRecordCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, const VkDependencyInfoKHR* pDependencyInfo) override;
1083
1084 void PreCallRecordCmdSetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event,
1085 const VkDependencyInfoKHR* pDependencyInfo) override;
1086 void PreCallRecordCmdResetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2KHR stageMask) override;
1087 void PreCallRecordCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
1088 const VkDependencyInfoKHR* pDependencyInfos) override;
1089 void PostCallRecordCmdWriteTimestamp2KHR(VkCommandBuffer commandBuffer, VkPipelineStageFlags2KHR stage, VkQueryPool queryPool,
1090 uint32_t query) override;
1091 void PostCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR* pSubmits, VkFence fence,
1092 VkResult result) override;
1093
1094 void RecordGetBufferDeviceAddress(const VkBufferDeviceAddressInfo* pInfo, VkDeviceAddress address);
1095 void PostCallRecordGetBufferDeviceAddress(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
1096 VkDeviceAddress address) override;
1097 void PostCallRecordGetBufferDeviceAddressKHR(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
1098 VkDeviceAddress address) override;
1099 void PostCallRecordGetBufferDeviceAddressEXT(VkDevice device, const VkBufferDeviceAddressInfo* pInfo,
1100 VkDeviceAddress address) override;
1101 template <typename ExtProp>
GetPhysicalDeviceExtProperties(VkPhysicalDevice gpu,ExtEnabled enabled,ExtProp * ext_prop)1102 void GetPhysicalDeviceExtProperties(VkPhysicalDevice gpu, ExtEnabled enabled, ExtProp* ext_prop) {
1103 assert(ext_prop);
1104 if (IsExtEnabled(enabled)) {
1105 *ext_prop = LvlInitStruct<ExtProp>();
1106 if (api_version < VK_API_VERSION_1_1) {
1107 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(ext_prop);
1108 DispatchGetPhysicalDeviceProperties2KHR(gpu, &prop2);
1109 } else {
1110 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(ext_prop);
1111 DispatchGetPhysicalDeviceProperties2(gpu, &prop2);
1112 }
1113 }
1114 }
1115
1116 // Link to the device's physical-device data
1117 PHYSICAL_DEVICE_STATE* physical_device_state;
1118
1119 // Link for derived device objects back to their parent instance object
1120 ValidationStateTracker* instance_state;
1121
1122 std::unique_ptr<CommandBufferResetCallback> command_buffer_reset_callback;
1123 std::unique_ptr<CommandBufferFreeCallback> command_buffer_free_callback;
1124 std::unique_ptr<SetImageViewInitialLayoutCallback> set_image_view_initial_layout_callback;
1125
1126 DeviceFeatures enabled_features = {};
1127 // Device specific data
1128 VkPhysicalDeviceMemoryProperties phys_dev_mem_props = {};
1129 VkPhysicalDeviceProperties phys_dev_props = {};
1130 VkPhysicalDeviceVulkan11Properties phys_dev_props_core11 = {};
1131 VkPhysicalDeviceVulkan12Properties phys_dev_props_core12 = {};
1132 VkDeviceGroupDeviceCreateInfo device_group_create_info = {};
1133 uint32_t physical_device_count;
1134 uint32_t custom_border_color_sampler_count = 0;
1135
1136 // Device extension properties -- storing properties gathered from VkPhysicalDeviceProperties2::pNext chain
1137 struct DeviceExtensionProperties {
1138 VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_props;
1139 VkPhysicalDeviceShadingRateImagePropertiesNV shading_rate_image_props;
1140 VkPhysicalDeviceMeshShaderPropertiesNV mesh_shader_props;
1141 VkPhysicalDeviceInlineUniformBlockPropertiesEXT inline_uniform_block_props;
1142 VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT vtx_attrib_divisor_props;
1143 VkPhysicalDeviceCooperativeMatrixPropertiesNV cooperative_matrix_props;
1144 VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback_props;
1145 VkPhysicalDeviceRayTracingPropertiesNV ray_tracing_propsNV;
1146 VkPhysicalDeviceRayTracingPipelinePropertiesKHR ray_tracing_propsKHR;
1147 VkPhysicalDeviceAccelerationStructurePropertiesKHR acc_structure_props;
1148 VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT texel_buffer_alignment_props;
1149 VkPhysicalDeviceFragmentDensityMapPropertiesEXT fragment_density_map_props;
1150 VkPhysicalDeviceFragmentDensityMap2PropertiesEXT fragment_density_map2_props;
1151 VkPhysicalDevicePerformanceQueryPropertiesKHR performance_query_props;
1152 VkPhysicalDeviceSampleLocationsPropertiesEXT sample_locations_props;
1153 VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color_props;
1154 VkPhysicalDeviceMultiviewProperties multiview_props;
1155 VkPhysicalDevicePortabilitySubsetPropertiesKHR portability_props;
1156 VkPhysicalDeviceFragmentShadingRatePropertiesKHR fragment_shading_rate_props;
1157 VkPhysicalDeviceProvokingVertexPropertiesEXT provoking_vertex_props;
1158 VkPhysicalDeviceMultiDrawPropertiesEXT multi_draw_props;
1159 VkPhysicalDeviceDiscardRectanglePropertiesEXT discard_rectangle_props;
1160 VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT blend_operation_advanced_props;
1161 VkPhysicalDeviceConservativeRasterizationPropertiesEXT conservative_rasterization_props;
1162 VkPhysicalDeviceSubgroupSizeControlPropertiesEXT subgroup_size_control_props;
1163 };
1164 DeviceExtensionProperties phys_dev_ext_props = {};
1165 std::vector<VkCooperativeMatrixPropertiesNV> cooperative_matrix_properties;
1166
1167 bool performance_lock_acquired = false;
1168
1169 protected:
1170 // tracks which queue family index were used when creating the device for quick lookup
1171 layer_data::unordered_set<uint32_t> queue_family_index_set;
1172 // The queue count can different for the same queueFamilyIndex if the create flag are different
1173 struct DeviceQueueInfo {
1174 uint32_t index; // from VkDeviceCreateInfo
1175 uint32_t queue_family_index;
1176 VkDeviceQueueCreateFlags flags;
1177 uint32_t queue_count;
1178 };
1179 std::vector<DeviceQueueInfo> device_queue_info_list;
1180 // If vkGetBufferDeviceAddress is called, keep track of buffer <-> address mapping.
1181 // TODO is it sufficient to track a pointer, or do we need a std::shared_ptr<BUFFER_STATE>?
1182 layer_data::unordered_map<VkDeviceAddress, BUFFER_STATE*> buffer_address_map_;
1183 layer_data::unordered_map<uint64_t, VkFormatFeatureFlags> ahb_ext_formats_map;
1184
1185 private:
1186 VALSTATETRACK_MAP_AND_TRAITS(VkQueue, QUEUE_STATE, queue_map_)
1187 VALSTATETRACK_MAP_AND_TRAITS(VkAccelerationStructureNV, ACCELERATION_STRUCTURE_STATE, acceleration_structure_nv_map_)
1188 VALSTATETRACK_MAP_AND_TRAITS(VkRenderPass, RENDER_PASS_STATE, render_pass_map_)
1189 VALSTATETRACK_MAP_AND_TRAITS(VkDescriptorSetLayout, cvdescriptorset::DescriptorSetLayout, descriptor_set_layout_map_)
1190 VALSTATETRACK_MAP_AND_TRAITS(VkSampler, SAMPLER_STATE, sampler_map_)
1191 VALSTATETRACK_MAP_AND_TRAITS(VkImageView, IMAGE_VIEW_STATE, image_view_map_)
1192 VALSTATETRACK_MAP_AND_TRAITS(VkImage, IMAGE_STATE, image_map_)
1193 VALSTATETRACK_MAP_AND_TRAITS(VkBufferView, BUFFER_VIEW_STATE, buffer_view_map_)
1194 VALSTATETRACK_MAP_AND_TRAITS(VkBuffer, BUFFER_STATE, buffer_map_)
1195 VALSTATETRACK_MAP_AND_TRAITS(VkPipeline, PIPELINE_STATE, pipeline_map_)
1196 VALSTATETRACK_MAP_AND_TRAITS(VkDeviceMemory, DEVICE_MEMORY_STATE, mem_obj_map_)
1197 VALSTATETRACK_MAP_AND_TRAITS(VkFramebuffer, FRAMEBUFFER_STATE, frame_buffer_map_)
1198 VALSTATETRACK_MAP_AND_TRAITS(VkShaderModule, SHADER_MODULE_STATE, shader_module_map_)
1199 VALSTATETRACK_MAP_AND_TRAITS(VkDescriptorUpdateTemplate, UPDATE_TEMPLATE_STATE, desc_template_map_)
1200 VALSTATETRACK_MAP_AND_TRAITS(VkSwapchainKHR, SWAPCHAIN_NODE, swapchain_map_)
1201 VALSTATETRACK_MAP_AND_TRAITS(VkDescriptorPool, DESCRIPTOR_POOL_STATE, descriptor_pool_map_)
1202 VALSTATETRACK_MAP_AND_TRAITS(VkDescriptorSet, cvdescriptorset::DescriptorSet, descriptor_set_map_)
1203 VALSTATETRACK_MAP_AND_TRAITS(VkCommandBuffer, CMD_BUFFER_STATE, command_buffer_map_)
1204 VALSTATETRACK_MAP_AND_TRAITS(VkCommandPool, COMMAND_POOL_STATE, command_pool_map_)
1205 VALSTATETRACK_MAP_AND_TRAITS(VkPipelineLayout, PIPELINE_LAYOUT_STATE, pipeline_layout_map_)
1206 VALSTATETRACK_MAP_AND_TRAITS(VkFence, FENCE_STATE, fence_map_)
1207 VALSTATETRACK_MAP_AND_TRAITS(VkQueryPool, QUERY_POOL_STATE, query_pool_map_)
1208 VALSTATETRACK_MAP_AND_TRAITS(VkSemaphore, SEMAPHORE_STATE, semaphore_map_)
1209 VALSTATETRACK_MAP_AND_TRAITS(VkEvent, EVENT_STATE, event_map_)
1210 VALSTATETRACK_MAP_AND_TRAITS(VkSamplerYcbcrConversion, SAMPLER_YCBCR_CONVERSION_STATE, sampler_ycbcr_conversion_map_)
1211 VALSTATETRACK_MAP_AND_TRAITS(VkAccelerationStructureKHR, ACCELERATION_STRUCTURE_STATE_KHR, acceleration_structure_khr_map_)
1212 VALSTATETRACK_MAP_AND_TRAITS_INSTANCE_SCOPE(VkSurfaceKHR, SURFACE_STATE, surface_map_)
1213 VALSTATETRACK_MAP_AND_TRAITS_INSTANCE_SCOPE(VkDisplayModeKHR, DISPLAY_MODE_STATE, display_mode_map_)
1214 VALSTATETRACK_MAP_AND_TRAITS_INSTANCE_SCOPE(VkPhysicalDevice, PHYSICAL_DEVICE_STATE, physical_device_map_);
1215
1216 // Simple base address allocator allow allow VkDeviceMemory allocations to appear to exist in a common address space.
1217 // At 256GB allocated/sec ( > 8GB at 30Hz), will overflow in just over 2 years
1218 class FakeAllocator {
1219 public:
Free(VkDeviceSize fake_address)1220 void Free(VkDeviceSize fake_address){}; // Define the interface just in case we ever need to be cleverer.
Alloc(VkDeviceSize size)1221 VkDeviceSize Alloc(VkDeviceSize size) {
1222 const auto alloc = free_;
1223 assert(std::numeric_limits<VkDeviceSize>::max() - size >= free_); // 776.722963 days later...
1224 free_ = free_ + size;
1225 return alloc;
1226 }
1227
1228 private:
1229 VkDeviceSize free_ = 1U << 20; // start at 1mb to leave room for a NULL address
1230 };
1231 FakeAllocator fake_memory;
1232 };
1233