From a11b81f3fa061d1391588bdcdca08723a05d0147 Mon Sep 17 00:00:00 2001 From: qbojj <105227351+qbojj@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:03:05 +0100 Subject: [PATCH] add VK_KHR_maintenance5 support --- .../VulkanPipelineStateViewer.cpp | 4 +- renderdoc/api/replay/pipestate.inl | 2 +- renderdoc/api/replay/vk_pipestate.h | 5 +- renderdoc/driver/vulkan/extension_support.md | 2 +- renderdoc/driver/vulkan/vk_common.h | 40 +++ renderdoc/driver/vulkan/vk_core.cpp | 90 ++++++ renderdoc/driver/vulkan/vk_core.h | 25 ++ renderdoc/driver/vulkan/vk_dispatchtables.cpp | 36 +-- renderdoc/driver/vulkan/vk_hookset_defs.h | 294 +++++++++--------- renderdoc/driver/vulkan/vk_info.cpp | 7 +- renderdoc/driver/vulkan/vk_info.h | 4 +- renderdoc/driver/vulkan/vk_layer.cpp | 26 +- renderdoc/driver/vulkan/vk_next_chains.cpp | 84 ++++- renderdoc/driver/vulkan/vk_overlay.cpp | 16 +- renderdoc/driver/vulkan/vk_postvs.cpp | 9 +- renderdoc/driver/vulkan/vk_replay.cpp | 1 + renderdoc/driver/vulkan/vk_serialise.cpp | 184 ++++++++++- renderdoc/driver/vulkan/vk_shader_cache.cpp | 46 ++- renderdoc/driver/vulkan/vk_state.cpp | 15 +- renderdoc/driver/vulkan/vk_state.h | 1 + renderdoc/driver/vulkan/vk_stringise.cpp | 83 ++++- .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 93 ++++++ .../driver/vulkan/wrappers/vk_get_funcs.cpp | 31 +- .../vulkan/wrappers/vk_resource_funcs.cpp | 56 ++-- .../vulkan/wrappers/vk_shader_funcs.cpp | 43 ++- renderdoc/replay/renderdoc_serialise.inl | 7 +- 26 files changed, 935 insertions(+), 269 deletions(-) diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index c8ad70350c2..7073ef741dd 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -1905,7 +1905,7 @@ void VulkanPipelineStateViewer::setState() BufferDescription *buf = m_Ctx.GetBuffer(state.inputAssembly.indexBuffer.resourceId); if(buf) - length = buf->length; + length = qMin(buf->length, state.inputAssembly.indexBuffer.byteSize); RDTreeWidgetItem *node = new RDTreeWidgetItem( {tr("Index"), state.inputAssembly.indexBuffer.resourceId, tr("Index"), lit("-"), @@ -3453,7 +3453,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe:: if(ib) { name = m_Ctx.GetResourceName(ia.indexBuffer.resourceId); - length = ib->length; + length = qMin(ib->length, ia.indexBuffer.byteSize); } QString ifmt = lit("UNKNOWN"); diff --git a/renderdoc/api/replay/pipestate.inl b/renderdoc/api/replay/pipestate.inl index 51a93a97fd8..8faf74f9499 100644 --- a/renderdoc/api/replay/pipestate.inl +++ b/renderdoc/api/replay/pipestate.inl @@ -515,7 +515,7 @@ BoundVBuffer PipeState::GetIBuffer() const ret.resourceId = m_Vulkan->inputAssembly.indexBuffer.resourceId; ret.byteOffset = m_Vulkan->inputAssembly.indexBuffer.byteOffset; ret.byteStride = m_Vulkan->inputAssembly.indexBuffer.byteStride; - ret.byteSize = ~0ULL; + ret.byteSize = m_Vulkan->inputAssembly.indexBuffer.byteSize; } } diff --git a/renderdoc/api/replay/vk_pipestate.h b/renderdoc/api/replay/vk_pipestate.h index 091bcd4159a..a2ec0ef787c 100644 --- a/renderdoc/api/replay/vk_pipestate.h +++ b/renderdoc/api/replay/vk_pipestate.h @@ -126,7 +126,7 @@ When not using pipeline libraries, this will be identical to :data:`pipelinePreR )"); ResourceId pipelineFragmentLayoutResourceId; DOCUMENT("The flags used to create the pipeline object."); - uint32_t flags = 0; + uint64_t flags = 0; DOCUMENT(R"(The bound descriptor sets. @@ -149,6 +149,9 @@ struct IndexBuffer DOCUMENT("The byte offset from the start of the buffer to the beginning of the index data."); uint64_t byteOffset = 0; + DOCUMENT("The number of bytes in the index buffer."); + uint64_t byteSize = 0; + DOCUMENT(R"(The number of bytes for each index in the index buffer. Typically 2 or 4 bytes but it can be 0 if no index buffer is bound. )"); diff --git a/renderdoc/driver/vulkan/extension_support.md b/renderdoc/driver/vulkan/extension_support.md index 5bb5c63e1bb..af3ef9a9cad 100644 --- a/renderdoc/driver/vulkan/extension_support.md +++ b/renderdoc/driver/vulkan/extension_support.md @@ -175,6 +175,7 @@ Maintainers can update this file by updating vk.xml in this folder and running ` * `VK_KHR_maintenance2` * `VK_KHR_maintenance3` * `VK_KHR_maintenance4` +* `VK_KHR_maintenance5` * `VK_KHR_multiview` * `VK_KHR_performance_query` * `VK_KHR_pipeline_executable_properties` @@ -242,7 +243,6 @@ KHR extensions will definitely be implemented at some point, though KHR extensio * `VK_KHR_cooperative_matrix` * `VK_KHR_dynamic_rendering_local_read` -* `VK_KHR_maintenance5` * `VK_KHR_maintenance6` * `VK_KHR_map_memory2` * `VK_KHR_shader_expect_assume` diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index cffd979fd83..391033b6ca0 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -73,6 +73,8 @@ #define VkAccessFlagBits2 VkAccessFlagBits2_VkFlags64_typedef #define VkPipelineStageFlagBits2 VkPipelineStageFlagBits2_VkFlags64_typedef #define VkFormatFeatureFlagBits2 VkFormatFeatureFlagBits2_VkFlags64_typedef +#define VkBufferUsageFlagBits2KHR VkBufferUsageFlagBits2KHR_VkFlags64_typedef +#define VkPipelineCreateFlagBits2KHR VkPipelineCreateFlagBits2KHR_VkFlags64_typedef #include "core/core.h" #include "core/resource_manager.h" @@ -84,6 +86,8 @@ #undef VkAccessFlagBits2 #undef VkPipelineStageFlagBits2 #undef VkFormatFeatureFlagBits2 +#undef VkBufferUsageFlagBits2KHR +#undef VkPipelineCreateFlagBits2KHR #undef Bool #undef None @@ -129,6 +133,14 @@ int SampleIndex(VkSampleCountFlagBits countFlag); int StageIndex(VkShaderStageFlagBits stageFlag); VkShaderStageFlags ShaderMaskFromIndex(size_t index); +// VK_KHR_maintenance5 helpers +VkPipelineCreateFlags2KHR GetPipelineCreateFlags(const VkGraphicsPipelineCreateInfo *info); +VkPipelineCreateFlags2KHR GetPipelineCreateFlags(const VkComputePipelineCreateInfo *info); +VkBufferUsageFlags2KHR GetBufferUsageFlags(const VkBufferCreateInfo *info); +void SetPipelineCreateFlags(VkGraphicsPipelineCreateInfo *info, VkPipelineCreateFlags2KHR flags); +void SetPipelineCreateFlags(VkComputePipelineCreateInfo *info, VkPipelineCreateFlags2KHR flags); +void SetBufferUsageFlags(VkBufferCreateInfo *info, VkBufferUsageFlags2KHR flags); + struct PackedWindowHandle { PackedWindowHandle(WindowingSystem s, void *h) : system(s), handle(h) {} @@ -1083,6 +1095,7 @@ enum class VulkanChunk : uint32_t vkCreateAccelerationStructureKHR, vkCmdBindShadersEXT, vkCreateShadersEXT, + vkCmdBindIndexBuffer2KHR, Max, }; @@ -1571,6 +1584,14 @@ DECLARE_REFLECTION_STRUCT(VkVertexInputBindingDescription2EXT); DECLARE_REFLECTION_STRUCT(VkWriteDescriptorSet); DECLARE_REFLECTION_STRUCT(VkWriteDescriptorSetAccelerationStructureKHR); DECLARE_REFLECTION_STRUCT(VkWriteDescriptorSetInlineUniformBlock); +DECLARE_REFLECTION_STRUCT(VkPhysicalDeviceMaintenance5FeaturesKHR); +DECLARE_REFLECTION_STRUCT(VkPhysicalDeviceMaintenance5PropertiesKHR); +DECLARE_REFLECTION_STRUCT(VkRenderingAreaInfoKHR); +DECLARE_REFLECTION_STRUCT(VkDeviceImageSubresourceInfoKHR); +DECLARE_REFLECTION_STRUCT(VkPipelineCreateFlags2CreateInfoKHR); +DECLARE_REFLECTION_STRUCT(VkBufferUsageFlags2CreateInfoKHR); +DECLARE_REFLECTION_STRUCT(VkImageSubresource2KHR); +DECLARE_REFLECTION_STRUCT(VkSubresourceLayout2KHR); DECLARE_DESERIALISE_TYPE(VkAccelerationStructureBuildGeometryInfoKHR); DECLARE_DESERIALISE_TYPE(VkAccelerationStructureBuildSizesInfoKHR); @@ -2002,6 +2023,14 @@ DECLARE_DESERIALISE_TYPE(VkVertexInputBindingDescription2EXT); DECLARE_DESERIALISE_TYPE(VkWriteDescriptorSet); DECLARE_DESERIALISE_TYPE(VkWriteDescriptorSetAccelerationStructureKHR); DECLARE_DESERIALISE_TYPE(VkWriteDescriptorSetInlineUniformBlock); +DECLARE_DESERIALISE_TYPE(VkPhysicalDeviceMaintenance5FeaturesKHR); +DECLARE_DESERIALISE_TYPE(VkPhysicalDeviceMaintenance5PropertiesKHR); +DECLARE_DESERIALISE_TYPE(VkRenderingAreaInfoKHR); +DECLARE_DESERIALISE_TYPE(VkDeviceImageSubresourceInfoKHR); +DECLARE_DESERIALISE_TYPE(VkPipelineCreateFlags2CreateInfoKHR); +DECLARE_DESERIALISE_TYPE(VkBufferUsageFlags2CreateInfoKHR); +DECLARE_DESERIALISE_TYPE(VkImageSubresource2KHR); +DECLARE_DESERIALISE_TYPE(VkSubresourceLayout2KHR); // plain structs with no next chain DECLARE_REFLECTION_STRUCT(VkAabbPositionsKHR); @@ -2089,6 +2118,7 @@ DECLARE_REFLECTION_STRUCT(VkVertexInputBindingDescription); DECLARE_REFLECTION_STRUCT(VkVertexInputBindingDivisorDescriptionEXT); DECLARE_REFLECTION_STRUCT(VkViewport); DECLARE_REFLECTION_STRUCT(VkXYColorEXT); +DECLARE_REFLECTION_STRUCT(VkSubresourceLayout); // rdcarray serialisation is generic but the stringification is not DECLARE_STRINGISE_TYPE(rdcarray); @@ -2186,6 +2216,14 @@ enum VkFormatFeatureFlagBits2 : uint64_t { }; +enum VkBufferUsageFlagBits2KHR : uint64_t +{ +}; + +enum VkPipelineCreateFlagBits2KHR : uint64_t +{ +}; + // enums DECLARE_REFLECTION_ENUM(VkAccelerationStructureBuildTypeKHR); @@ -2342,6 +2380,8 @@ DECLARE_REFLECTION_ENUM(VkValidationCheckEXT); DECLARE_REFLECTION_ENUM(VkValidationFeatureDisableEXT); DECLARE_REFLECTION_ENUM(VkValidationFeatureEnableEXT); DECLARE_REFLECTION_ENUM(VkVertexInputRate); +DECLARE_REFLECTION_ENUM(VkBufferUsageFlagBits2KHR); +DECLARE_REFLECTION_ENUM(VkPipelineCreateFlagBits2KHR); // win32 only enums #ifdef VK_USE_PLATFORM_WIN32_KHR diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 43d89464be2..fbbcf1610c7 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -37,6 +37,8 @@ #include "stb/stb_image_write.h" +#include + RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording); RDOC_DEBUG_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing, false, @@ -1533,6 +1535,10 @@ static const VkExtensionProperties supportedExtensions[] = { VK_KHR_MAINTENANCE_4_EXTENSION_NAME, VK_KHR_MAINTENANCE_4_SPEC_VERSION, }, + { + VK_KHR_MAINTENANCE_5_EXTENSION_NAME, + VK_KHR_MAINTENANCE_5_SPEC_VERSION, + }, { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION, @@ -4062,6 +4068,10 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) case VulkanChunk::vkCreateShadersEXT: return Serialise_vkCreateShadersEXT(ser, VK_NULL_HANDLE, 0, NULL, NULL, NULL); + case VulkanChunk::vkCmdBindIndexBuffer2KHR: + return Serialise_vkCmdBindIndexBuffer2KHR(ser, VK_NULL_HANDLE, VK_NULL_HANDLE, 0, 0, + VK_INDEX_TYPE_MAX_ENUM); + // chunks that are reserved but not yet serialised case VulkanChunk::vkResetCommandPool: case VulkanChunk::vkCreateDepthTargetView: @@ -5707,6 +5717,86 @@ void WrappedVulkan::ReplayDraw(VkCommandBuffer cmd, const ActionDescription &act } } +VkPipelineCreateFlags2KHR WrappedVulkan::GetPipelineCreateFlags(const VkGraphicsPipelineCreateInfo *info) +{ + const VkPipelineCreateFlags2CreateInfoKHR *flags2 = + (const VkPipelineCreateFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR); + if(flags2) + return flags2->flags; + + return info->flags; +} + +VkPipelineCreateFlags2KHR WrappedVulkan::GetPipelineCreateFlags(const VkComputePipelineCreateInfo *info) +{ + const VkPipelineCreateFlags2CreateInfoKHR *flags2 = + (const VkPipelineCreateFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR); + if(flags2) + return flags2->flags; + + return info->flags; +} + +VkBufferUsageFlags2KHR WrappedVulkan::GetBufferUsageFlags(const VkBufferCreateInfo *info) +{ + const VkBufferUsageFlags2CreateInfoKHR *usage2 = + (const VkBufferUsageFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR); + if(usage2) + return usage2->usage; + + return info->usage; +} + +void WrappedVulkan::SetPipelineCreateFlags(VkGraphicsPipelineCreateInfo *info, + VkPipelineCreateFlags2KHR flags) +{ + VkPipelineCreateFlags2CreateInfoKHR *flags2 = (VkPipelineCreateFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR); + if(flags2) + { + flags2->flags = flags; + } + else + { + assert(flags <= VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM); + info->flags = (VkPipelineCreateFlags)flags; + } +} + +void WrappedVulkan::SetPipelineCreateFlags(VkComputePipelineCreateInfo *info, + VkPipelineCreateFlags2KHR flags) +{ + VkPipelineCreateFlags2CreateInfoKHR *flags2 = (VkPipelineCreateFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR); + if(flags2) + { + flags2->flags = flags; + } + else + { + assert(flags <= VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM); + info->flags = (VkPipelineCreateFlags)flags; + } +} + +void WrappedVulkan::SetBufferUsageFlags(VkBufferCreateInfo *info, VkBufferUsageFlags2KHR flags) +{ + VkBufferUsageFlags2CreateInfoKHR *usage2 = (VkBufferUsageFlags2CreateInfoKHR *)FindNextStruct( + info, VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR); + if(usage2) + { + usage2->usage = flags; + } + else + { + assert(flags <= VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM); + info->usage = (VkBufferUsageFlags)flags; + } +} + #if ENABLED(ENABLE_UNIT_TESTS) #undef None diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index f4e0b20807a..a509e54ee05 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -1424,6 +1424,17 @@ class WrappedVulkan : public IFrameCapturer return NULL; } + // VK_KHR_maintenance5 helpers + static VkPipelineCreateFlags2KHR GetPipelineCreateFlags(const VkGraphicsPipelineCreateInfo *info); + static VkPipelineCreateFlags2KHR GetPipelineCreateFlags(const VkComputePipelineCreateInfo *info); + static VkBufferUsageFlags2KHR GetBufferUsageFlags(const VkBufferCreateInfo *info); + + static void SetPipelineCreateFlags(VkGraphicsPipelineCreateInfo *info, + VkPipelineCreateFlags2KHR flags); + static void SetPipelineCreateFlags(VkComputePipelineCreateInfo *info, + VkPipelineCreateFlags2KHR flags); + static void SetBufferUsageFlags(VkBufferCreateInfo *info, VkBufferUsageFlags2KHR flags); + // Device initialization IMPLEMENT_FUNCTION_SERIALISED(VkResult, vkCreateInstance, const VkInstanceCreateInfo *pCreateInfo, @@ -2955,4 +2966,18 @@ class WrappedVulkan : public IFrameCapturer VkResult vkGetShaderBinaryDataEXT(VkDevice device, VkShaderEXT shader, size_t *pDataSize, void *pData); + + // VK_KHR_maintenance5 + IMPLEMENT_FUNCTION_SERIALISED(void, vkCmdBindIndexBuffer2KHR, VkCommandBuffer commandBuffer, + VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, + VkIndexType indexType); + IMPLEMENT_FUNCTION_SERIALISED(void, vkGetDeviceImageSubresourceLayoutKHR, VkDevice device, + const VkDeviceImageSubresourceInfoKHR *pInfo, + VkSubresourceLayout2KHR *pLayout); + IMPLEMENT_FUNCTION_SERIALISED(void, vkGetImageSubresourceLayout2KHR, VkDevice device, + VkImage image, const VkImageSubresource2KHR *pSubresource, + VkSubresourceLayout2KHR *pLayout); + IMPLEMENT_FUNCTION_SERIALISED(void, vkGetRenderingAreaGranularityKHR, VkDevice device, + const VkRenderingAreaInfoKHR *pRenderingAreaInfo, + VkExtent2D *pGranularity); }; diff --git a/renderdoc/driver/vulkan/vk_dispatchtables.cpp b/renderdoc/driver/vulkan/vk_dispatchtables.cpp index b2fcc812715..1de66ab944d 100644 --- a/renderdoc/driver/vulkan/vk_dispatchtables.cpp +++ b/renderdoc/driver/vulkan/vk_dispatchtables.cpp @@ -90,15 +90,15 @@ void InitInstanceExtensionTables(VkInstance instance, InstanceDeviceInfo *info) } #undef HookInitPromotedExtension -#define HookInitPromotedExtension(cond, func, suffix) \ - if(cond) \ - { \ - InstanceGPA(func); \ - InstanceGPA(CONCAT(func, suffix)); \ - if(table->func == NULL) \ - table->func = table->CONCAT(func, suffix); \ - if(table->CONCAT(func, suffix) == NULL) \ - table->CONCAT(func, suffix) = table->func; \ +#define HookInitPromotedExtension(cond, version, func, suffix) \ + if(cond) \ + { \ + InstanceGPA(func); \ + InstanceGPA(CONCAT(func, suffix)); \ + if(table->func == NULL) \ + table->func = table->CONCAT(func, suffix); \ + if(table->CONCAT(func, suffix) == NULL) \ + table->CONCAT(func, suffix) = table->func; \ } #undef HookInitExtensionEXTtoKHR @@ -140,15 +140,15 @@ void InitDeviceExtensionTables(VkDevice device, InstanceDeviceInfo *info) } #undef HookInitPromotedExtension -#define HookInitPromotedExtension(cond, func, suffix) \ - if(cond) \ - { \ - DeviceGPA(func); \ - DeviceGPA(CONCAT(func, suffix)); \ - if(table->func == NULL) \ - table->func = table->CONCAT(func, suffix); \ - if(table->CONCAT(func, suffix) == NULL) \ - table->CONCAT(func, suffix) = table->func; \ +#define HookInitPromotedExtension(cond, version, func, suffix) \ + if(cond) \ + { \ + DeviceGPA(func); \ + DeviceGPA(CONCAT(func, suffix)); \ + if(table->func == NULL) \ + table->func = table->CONCAT(func, suffix); \ + if(table->CONCAT(func, suffix) == NULL) \ + table->CONCAT(func, suffix) = table->func; \ } #undef HookInitExtensionEXTtoKHR diff --git a/renderdoc/driver/vulkan/vk_hookset_defs.h b/renderdoc/driver/vulkan/vk_hookset_defs.h index 8d072f86d57..fbe98f73f4d 100644 --- a/renderdoc/driver/vulkan/vk_hookset_defs.h +++ b/renderdoc/driver/vulkan/vk_hookset_defs.h @@ -555,6 +555,7 @@ DeclExt(KHR_vertex_attribute_divisor); \ DeclExt(KHR_line_rasterization); \ DeclExt(KHR_calibrated_timestamps); \ + DeclExt(KHR_maintenance5); \ DeclExt(KHR_deferred_host_operations); \ DeclExt(KHR_acceleration_structure); \ DeclExt(KHR_ray_query); \ @@ -686,6 +687,7 @@ CheckExt(KHR_vertex_attribute_divisor, VKXX); \ CheckExt(KHR_line_rasterization, VKXX); \ CheckExt(KHR_calibrated_timestamps, VKXX); \ + CheckExt(KHR_maintenance5, VKXX); \ CheckExt(KHR_deferred_host_operations, VKXX); \ CheckExt(KHR_acceleration_structure, VKXX); \ CheckExt(KHR_ray_query, VKXX); \ @@ -704,25 +706,27 @@ HookInitExtension(KHR_display, GetDisplayPlaneCapabilitiesKHR); \ HookInitExtension(NV_external_memory_capabilities, \ GetPhysicalDeviceExternalImageFormatPropertiesNV); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, GetPhysicalDeviceFeatures2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, GetPhysicalDeviceProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, GetPhysicalDeviceFeatures2, \ + KHR); \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ + GetPhysicalDeviceProperties2, KHR); \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceFormatProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceImageFormatProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceQueueFamilyProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceMemoryProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceSparseImageFormatProperties2, KHR); \ HookInitExtension(EXT_direct_mode_display, ReleaseDisplayEXT); \ HookInitExtension(EXT_display_surface_counter, GetPhysicalDeviceSurfaceCapabilities2EXT); \ - HookInitPromotedExtension(KHR_external_memory_capabilities, \ + HookInitPromotedExtension(KHR_external_memory_capabilities, VK11, \ GetPhysicalDeviceExternalBufferProperties, KHR); \ - HookInitPromotedExtension(KHR_external_semaphore_capabilities, \ + HookInitPromotedExtension(KHR_external_semaphore_capabilities, VK11, \ GetPhysicalDeviceExternalSemaphoreProperties, KHR); \ - HookInitPromotedExtension(KHR_external_fence_capabilities, \ + HookInitPromotedExtension(KHR_external_fence_capabilities, VK11, \ GetPhysicalDeviceExternalFenceProperties, KHR); \ HookInitExtension(KHR_device_group_creation &&KHR_surface, GetPhysicalDevicePresentRectanglesKHR); \ HookInitExtension(KHR_get_surface_capabilities2, GetPhysicalDeviceSurfaceFormats2KHR); \ @@ -734,7 +738,7 @@ HookInitExtension(KHR_performance_query, \ EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR); \ HookInitExtension(KHR_performance_query, GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR); \ - HookInitPromotedExtension(EXT_tooling_info, GetPhysicalDeviceToolProperties, EXT); \ + HookInitPromotedExtension(EXT_tooling_info, VK13, GetPhysicalDeviceToolProperties, EXT); \ HookInitExtension(KHR_fragment_shading_rate, GetPhysicalDeviceFragmentShadingRatesKHR); \ HookInitExtension(EXT_acquire_drm_display, AcquireDrmDisplayEXT); \ HookInitExtension(EXT_acquire_drm_display, GetDrmDisplayEXT); \ @@ -763,30 +767,32 @@ HookInitExtension(KHR_display, CreateDisplayPlaneSurfaceKHR); \ HookInitExtension(NV_external_memory_capabilities, \ GetPhysicalDeviceExternalImageFormatPropertiesNV); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, GetPhysicalDeviceFeatures2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, GetPhysicalDeviceProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, GetPhysicalDeviceFeatures2, \ + KHR); \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ + GetPhysicalDeviceProperties2, KHR); \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceFormatProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceImageFormatProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceQueueFamilyProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceMemoryProperties2, KHR); \ - HookInitPromotedExtension(KHR_get_physical_device_properties2, \ + HookInitPromotedExtension(KHR_get_physical_device_properties2, VK11, \ GetPhysicalDeviceSparseImageFormatProperties2, KHR); \ HookInitExtension(EXT_direct_mode_display, ReleaseDisplayEXT); \ HookInitExtension(EXT_display_surface_counter, GetPhysicalDeviceSurfaceCapabilities2EXT); \ - HookInitPromotedExtension(KHR_external_memory_capabilities, \ + HookInitPromotedExtension(KHR_external_memory_capabilities, VK11, \ GetPhysicalDeviceExternalBufferProperties, KHR); \ - HookInitPromotedExtension(KHR_external_semaphore_capabilities, \ + HookInitPromotedExtension(KHR_external_semaphore_capabilities, VK11, \ GetPhysicalDeviceExternalSemaphoreProperties, KHR); \ - HookInitPromotedExtension(KHR_external_fence_capabilities, \ + HookInitPromotedExtension(KHR_external_fence_capabilities, VK11, \ GetPhysicalDeviceExternalFenceProperties, KHR); \ HookInitExtension(EXT_debug_utils, CreateDebugUtilsMessengerEXT); \ HookInitExtension(EXT_debug_utils, DestroyDebugUtilsMessengerEXT); \ HookInitExtension(EXT_debug_utils, SubmitDebugUtilsMessageEXT); \ - HookInitPromotedExtension(KHR_device_group_creation, EnumeratePhysicalDeviceGroups, KHR); \ + HookInitPromotedExtension(KHR_device_group_creation, VK11, EnumeratePhysicalDeviceGroups, KHR); \ /* Not technically accurate - part of KHR_device_group - but these extensions are linked and */ \ /* should always be present/not present together. Keying from the instance extension ensures */ \ /* we'll load this function correctly when populating dispatch tables. */ \ @@ -803,7 +809,7 @@ HookInitExtension(KHR_performance_query, \ EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR); \ HookInitExtension(KHR_performance_query, GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR); \ - HookInitPromotedExtension(EXT_tooling_info, GetPhysicalDeviceToolProperties, EXT); \ + HookInitPromotedExtension(EXT_tooling_info, VK13, GetPhysicalDeviceToolProperties, EXT); \ HookInitExtension(KHR_fragment_shading_rate, GetPhysicalDeviceFragmentShadingRatesKHR); \ HookInitExtension(KHR_calibrated_timestamps, GetPhysicalDeviceCalibrateableTimeDomainsKHR); \ HookInitExtension_Instance_Win32(); \ @@ -824,7 +830,7 @@ HookInitExtension(KHR_swapchain, AcquireNextImageKHR); \ HookInitExtension(KHR_swapchain, QueuePresentKHR); \ HookInitExtension(KHR_display_swapchain, CreateSharedSwapchainsKHR); \ - HookInitPromotedExtension(KHR_maintenance1, TrimCommandPool, KHR); \ + HookInitPromotedExtension(KHR_maintenance1, VK11, TrimCommandPool, KHR); \ HookInitExtension(EXT_display_control, DisplayPowerControlEXT); \ HookInitExtension(EXT_display_control, RegisterDeviceEventEXT); \ HookInitExtension(EXT_display_control, RegisterDisplayEventEXT); \ @@ -835,19 +841,23 @@ HookInitExtension(KHR_external_semaphore_fd, GetSemaphoreFdKHR); \ HookInitExtension(KHR_external_fence_fd, ImportFenceFdKHR); \ HookInitExtension(KHR_external_fence_fd, GetFenceFdKHR); \ - HookInitPromotedExtension(KHR_get_memory_requirements2, GetBufferMemoryRequirements2, KHR); \ - HookInitPromotedExtension(KHR_get_memory_requirements2, GetImageMemoryRequirements2, KHR); \ - HookInitPromotedExtension(KHR_get_memory_requirements2, GetImageSparseMemoryRequirements2, KHR); \ + HookInitPromotedExtension(KHR_get_memory_requirements2, VK11, GetBufferMemoryRequirements2, KHR); \ + HookInitPromotedExtension(KHR_get_memory_requirements2, VK11, GetImageMemoryRequirements2, KHR); \ + HookInitPromotedExtension(KHR_get_memory_requirements2, VK11, GetImageSparseMemoryRequirements2, \ + KHR); \ HookInitExtension(AMD_shader_info, GetShaderInfoAMD); \ HookInitExtension(KHR_push_descriptor, CmdPushDescriptorSetKHR); \ - HookInitPromotedExtension(KHR_descriptor_update_template, CreateDescriptorUpdateTemplate, KHR); \ - HookInitPromotedExtension(KHR_descriptor_update_template, DestroyDescriptorUpdateTemplate, KHR); \ - HookInitPromotedExtension(KHR_descriptor_update_template, UpdateDescriptorSetWithTemplate, KHR); \ + HookInitPromotedExtension(KHR_descriptor_update_template, VK11, CreateDescriptorUpdateTemplate, \ + KHR); \ + HookInitPromotedExtension(KHR_descriptor_update_template, VK11, DestroyDescriptorUpdateTemplate, \ + KHR); \ + HookInitPromotedExtension(KHR_descriptor_update_template, VK11, UpdateDescriptorSetWithTemplate, \ + KHR); \ HookInitExtension(KHR_push_descriptor &&KHR_descriptor_update_template, \ CmdPushDescriptorSetWithTemplateKHR); \ - HookInitPromotedExtension(KHR_bind_memory2, BindBufferMemory2, KHR); \ - HookInitPromotedExtension(KHR_bind_memory2, BindImageMemory2, KHR); \ - HookInitPromotedExtension(KHR_maintenance3, GetDescriptorSetLayoutSupport, KHR); \ + HookInitPromotedExtension(KHR_bind_memory2, VK11, BindBufferMemory2, KHR); \ + HookInitPromotedExtension(KHR_bind_memory2, VK11, BindImageMemory2, KHR); \ + HookInitPromotedExtension(KHR_maintenance3, VK11, GetDescriptorSetLayoutSupport, KHR); \ HookInitExtension(AMD_buffer_marker, CmdWriteBufferMarkerAMD); \ HookInitExtension(EXT_debug_utils, SetDebugUtilsObjectNameEXT); \ HookInitExtension(EXT_debug_utils, SetDebugUtilsObjectTagEXT); \ @@ -857,26 +867,26 @@ HookInitExtension(EXT_debug_utils, CmdBeginDebugUtilsLabelEXT); \ HookInitExtension(EXT_debug_utils, CmdEndDebugUtilsLabelEXT); \ HookInitExtension(EXT_debug_utils, CmdInsertDebugUtilsLabelEXT); \ - HookInitPromotedExtension(KHR_sampler_ycbcr_conversion, CreateSamplerYcbcrConversion, KHR); \ - HookInitPromotedExtension(KHR_sampler_ycbcr_conversion, DestroySamplerYcbcrConversion, KHR); \ - HookInitPromotedExtension(KHR_device_group, GetDeviceGroupPeerMemoryFeatures, KHR); \ - HookInitPromotedExtension(KHR_device_group, CmdSetDeviceMask, KHR); \ - HookInitPromotedExtension(KHR_device_group, CmdDispatchBase, KHR); \ + HookInitPromotedExtension(KHR_sampler_ycbcr_conversion, VK11, CreateSamplerYcbcrConversion, KHR); \ + HookInitPromotedExtension(KHR_sampler_ycbcr_conversion, VK11, DestroySamplerYcbcrConversion, KHR); \ + HookInitPromotedExtension(KHR_device_group, VK11, GetDeviceGroupPeerMemoryFeatures, KHR); \ + HookInitPromotedExtension(KHR_device_group, VK11, CmdSetDeviceMask, KHR); \ + HookInitPromotedExtension(KHR_device_group, VK11, CmdDispatchBase, KHR); \ HookInitExtension(KHR_device_group &&KHR_surface, GetDeviceGroupPresentCapabilitiesKHR); \ HookInitExtension(KHR_device_group &&KHR_surface, GetDeviceGroupSurfacePresentModesKHR); \ HookInitExtension(KHR_device_group &&KHR_swapchain, AcquireNextImage2KHR); \ HookInitExtension(protected_memory, GetDeviceQueue2); \ - HookInitPromotedExtension(KHR_draw_indirect_count, CmdDrawIndirectCount, KHR); \ - HookInitPromotedExtension(KHR_draw_indirect_count, CmdDrawIndexedIndirectCount, KHR); \ + HookInitPromotedExtension(KHR_draw_indirect_count, VK12, CmdDrawIndirectCount, KHR); \ + HookInitPromotedExtension(KHR_draw_indirect_count, VK12, CmdDrawIndexedIndirectCount, KHR); \ HookInitExtension(EXT_validation_cache, CreateValidationCacheEXT); \ HookInitExtension(EXT_validation_cache, DestroyValidationCacheEXT); \ HookInitExtension(EXT_validation_cache, MergeValidationCachesEXT); \ HookInitExtension(EXT_validation_cache, GetValidationCacheDataEXT); \ HookInitExtension(KHR_shared_presentable_image, GetSwapchainStatusKHR); \ - HookInitPromotedExtension(KHR_create_renderpass2, CreateRenderPass2, KHR); \ - HookInitPromotedExtension(KHR_create_renderpass2, CmdBeginRenderPass2, KHR); \ - HookInitPromotedExtension(KHR_create_renderpass2, CmdNextSubpass2, KHR); \ - HookInitPromotedExtension(KHR_create_renderpass2, CmdEndRenderPass2, KHR); \ + HookInitPromotedExtension(KHR_create_renderpass2, VK12, CreateRenderPass2, KHR); \ + HookInitPromotedExtension(KHR_create_renderpass2, VK12, CmdBeginRenderPass2, KHR); \ + HookInitPromotedExtension(KHR_create_renderpass2, VK12, CmdNextSubpass2, KHR); \ + HookInitPromotedExtension(KHR_create_renderpass2, VK12, CmdEndRenderPass2, KHR); \ HookInitExtension(EXT_transform_feedback, CmdBindTransformFeedbackBuffersEXT); \ HookInitExtension(EXT_transform_feedback, CmdBeginTransformFeedbackEXT); \ HookInitExtension(EXT_transform_feedback, CmdEndTransformFeedbackEXT); \ @@ -888,7 +898,7 @@ HookInitExtension(EXT_sample_locations, CmdSetSampleLocationsEXT); \ HookInitExtension(EXT_discard_rectangles, CmdSetDiscardRectangleEXT); \ HookInitExtension(EXT_calibrated_timestamps, GetCalibratedTimestampsEXT); \ - HookInitPromotedExtension(EXT_host_query_reset, ResetQueryPool, EXT); \ + HookInitPromotedExtension(EXT_host_query_reset, VK12, ResetQueryPool, EXT); \ HookInitExtension(EXT_buffer_device_address, GetBufferDeviceAddressEXT); \ HookInitExtension(EXT_hdr_metadata, SetHdrMetadataEXT); \ HookInitExtension(AMD_display_native_hdr, SetLocalDimmingAMD); \ @@ -899,122 +909,94 @@ HookInitExtension(EXT_line_rasterization, CmdSetLineStippleEXT); \ HookInitExtension(GOOGLE_display_timing, GetRefreshCycleDurationGOOGLE); \ HookInitExtension(GOOGLE_display_timing, GetPastPresentationTimingGOOGLE); \ - HookInitPromotedExtension(KHR_timeline_semaphore, GetSemaphoreCounterValue, KHR); \ - HookInitPromotedExtension(KHR_timeline_semaphore, WaitSemaphores, KHR); \ - HookInitPromotedExtension(KHR_timeline_semaphore, SignalSemaphore, KHR); \ + HookInitPromotedExtension(KHR_timeline_semaphore, VK12, GetSemaphoreCounterValue, KHR); \ + HookInitPromotedExtension(KHR_timeline_semaphore, VK12, WaitSemaphores, KHR); \ + HookInitPromotedExtension(KHR_timeline_semaphore, VK12, SignalSemaphore, KHR); \ HookInitExtension(KHR_performance_query, AcquireProfilingLockKHR); \ HookInitExtension(KHR_performance_query, ReleaseProfilingLockKHR); \ - HookInitPromotedExtension(KHR_buffer_device_address, GetBufferDeviceAddress, KHR); \ - HookInitPromotedExtension(KHR_buffer_device_address, GetBufferOpaqueCaptureAddress, KHR); \ - HookInitPromotedExtension(KHR_buffer_device_address, GetDeviceMemoryOpaqueCaptureAddress, KHR); \ - HookInitPromotedExtension(EXT_private_data, CreatePrivateDataSlot, EXT); \ - HookInitPromotedExtension(EXT_private_data, DestroyPrivateDataSlot, EXT); \ - HookInitPromotedExtension(EXT_private_data, SetPrivateData, EXT); \ - HookInitPromotedExtension(EXT_private_data, GetPrivateData, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, CmdSetCullMode, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, CmdSetFrontFace, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetPrimitiveTopology, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetViewportWithCount, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetScissorWithCount, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdBindVertexBuffers2, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetDepthTestEnable, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetDepthWriteEnable, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, CmdSetDepthCompareOp, \ - EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetDepthBoundsTestEnable, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, \ - CmdSetStencilTestEnable, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, CmdSetStencilOp, EXT); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdCopyBuffer2, KHR); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdCopyImage2, KHR); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdCopyBufferToImage2, KHR); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdCopyImageToBuffer2, KHR); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdBlitImage2, KHR); \ - HookInitPromotedExtension(KHR_copy_commands2, CmdResolveImage2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, CmdSetEvent2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, CmdResetEvent2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, CmdWaitEvents2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, CmdPipelineBarrier2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, CmdWriteTimestamp2, KHR); \ - HookInitPromotedExtension(KHR_synchronization2, QueueSubmit2, KHR); \ + HookInitPromotedExtension(KHR_buffer_device_address, VK12, GetBufferDeviceAddress, KHR); \ + HookInitPromotedExtension(KHR_buffer_device_address, VK12, GetBufferOpaqueCaptureAddress, KHR); \ + HookInitPromotedExtension(KHR_buffer_device_address, VK12, GetDeviceMemoryOpaqueCaptureAddress, \ + KHR); \ + HookInitPromotedExtension(EXT_private_data, VK13, CreatePrivateDataSlot, EXT); \ + HookInitPromotedExtension(EXT_private_data, VK13, DestroyPrivateDataSlot, EXT); \ + HookInitPromotedExtension(EXT_private_data, VK13, SetPrivateData, EXT); \ + HookInitPromotedExtension(EXT_private_data, VK13, GetPrivateData, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetCullMode, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetFrontFace, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetPrimitiveTopology, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetViewportWithCount, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetScissorWithCount, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdBindVertexBuffers2, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetDepthTestEnable, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetDepthWriteEnable, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetDepthCompareOp, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetDepthBoundsTestEnable, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetStencilTestEnable, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state || EXT_shader_object, VK13, CmdSetStencilOp, EXT); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdCopyBuffer2, KHR); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdCopyImage2, KHR); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdCopyBufferToImage2, KHR); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdCopyImageToBuffer2, KHR); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdBlitImage2, KHR); \ + HookInitPromotedExtension(KHR_copy_commands2, VK13, CmdResolveImage2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, CmdSetEvent2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, CmdResetEvent2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, CmdWaitEvents2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, CmdPipelineBarrier2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, CmdWriteTimestamp2, KHR); \ + HookInitPromotedExtension(KHR_synchronization2, VK13, QueueSubmit2, KHR); \ HookInitExtension(KHR_synchronization2 &&AMD_buffer_marker, CmdWriteBufferMarker2AMD); \ /* No GetQueueCheckpointData2NV without VK_NV_device_diagnostic_checkpoints */ \ HookInitExtension(KHR_present_wait, WaitForPresentKHR); \ - HookInitPromotedExtension(KHR_maintenance4, GetDeviceBufferMemoryRequirements, KHR); \ - HookInitPromotedExtension(KHR_maintenance4, GetDeviceImageMemoryRequirements, KHR); \ - HookInitPromotedExtension(KHR_maintenance4, GetDeviceImageSparseMemoryRequirements, KHR); \ + HookInitPromotedExtension(KHR_maintenance4, VK13, GetDeviceBufferMemoryRequirements, KHR); \ + HookInitPromotedExtension(KHR_maintenance4, VK13, GetDeviceImageMemoryRequirements, KHR); \ + HookInitPromotedExtension(KHR_maintenance4, VK13, GetDeviceImageSparseMemoryRequirements, KHR); \ HookInitExtension(EXT_color_write_enable, CmdSetColorWriteEnableEXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, \ - CmdSetDepthBiasEnable, EXT); \ - HookInitExtension(EXT_extended_dynamic_state2 || EXT_shader_object, CmdSetLogicOpEXT); \ - HookInitExtension(EXT_extended_dynamic_state2 || EXT_shader_object, CmdSetPatchControlPointsEXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, \ - CmdSetPrimitiveRestartEnable, EXT); \ - HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, \ - CmdSetRasterizerDiscardEnable, EXT); \ - HookInitExtension(EXT_vertex_input_dynamic_state || EXT_shader_object, CmdSetVertexInputEXT); \ - HookInitPromotedExtension(KHR_dynamic_rendering, CmdBeginRendering, KHR); \ - HookInitPromotedExtension(KHR_dynamic_rendering, CmdEndRendering, KHR); \ + HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, VK13, CmdSetDepthBiasEnable, EXT); \ + HookInitExtension(EXT_extended_dynamic_state2 || EXT_shader_object, CmdSetLogicOpEXT); \ + HookInitExtension(EXT_extended_dynamic_state2 || EXT_shader_object, CmdSetPatchControlPointsEXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, VK13, CmdSetPrimitiveRestartEnable, EXT); \ + HookInitPromotedExtension(EXT_extended_dynamic_state2 || EXT_shader_object, VK13, CmdSetRasterizerDiscardEnable, EXT); \ + HookInitExtension(EXT_vertex_input_dynamic_state || EXT_shader_object, CmdSetVertexInputEXT); \ + HookInitPromotedExtension(KHR_dynamic_rendering, VK13, CmdBeginRendering, KHR); \ + HookInitPromotedExtension(KHR_dynamic_rendering, VK13, CmdEndRendering, KHR); \ HookInitExtension(KHR_fragment_shading_rate, CmdSetFragmentShadingRateKHR); \ HookInitExtension(EXT_pageable_device_local_memory, SetDeviceMemoryPriorityEXT); \ HookInitExtension(EXT_swapchain_maintenance1, ReleaseSwapchainImagesEXT); \ HookInitExtension(EXT_attachment_feedback_loop_dynamic_state, \ CmdSetAttachmentFeedbackLoopEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetAlphaToCoverageEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetAlphaToOneEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendAdvancedEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendEquationEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorWriteMaskEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetConservativeRasterizationModeEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageModulationModeNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageModulationTableEnableNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageModulationTableNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageReductionModeNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageToColorEnableNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetCoverageToColorLocationNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetDepthClampEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetDepthClipEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetDepthClipNegativeOneToOneEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetExtraPrimitiveOverestimationSizeEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetLineRasterizationModeEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetLineStippleEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetLogicOpEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetPolygonModeEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetProvokingVertexModeEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetRasterizationSamplesEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetRasterizationStreamEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetRepresentativeFragmentTestEnableNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetSampleLocationsEnableEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetSampleMaskEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetShadingRateImageEnableNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetTessellationDomainOriginEXT); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetViewportSwizzleNV); \ - HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, \ - CmdSetViewportWScalingEnableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetAlphaToCoverageEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetAlphaToOneEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendAdvancedEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorBlendEquationEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetColorWriteMaskEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetConservativeRasterizationModeEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageModulationModeNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageModulationTableEnableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageModulationTableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageReductionModeNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageToColorEnableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetCoverageToColorLocationNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetDepthClampEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetDepthClipEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetDepthClipNegativeOneToOneEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetExtraPrimitiveOverestimationSizeEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetLineRasterizationModeEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetLineStippleEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetLogicOpEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetPolygonModeEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetProvokingVertexModeEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetRasterizationSamplesEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetRasterizationStreamEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetRepresentativeFragmentTestEnableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetSampleLocationsEnableEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetSampleMaskEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetShadingRateImageEnableNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetTessellationDomainOriginEXT); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetViewportSwizzleNV); \ + HookInitExtension(EXT_extended_dynamic_state3 || EXT_shader_object, CmdSetViewportWScalingEnableNV); \ HookInitExtension(EXT_mesh_shader, CmdDrawMeshTasksEXT); \ HookInitExtension(EXT_mesh_shader, CmdDrawMeshTasksIndirectEXT); \ HookInitExtension(EXT_mesh_shader, CmdDrawMeshTasksIndirectCountEXT); \ @@ -1046,6 +1028,10 @@ HookInitExtension(EXT_shader_object, CreateShadersEXT); \ HookInitExtension(EXT_shader_object, DestroyShaderEXT); \ HookInitExtension(EXT_shader_object, GetShaderBinaryDataEXT); \ + HookInitExtension(KHR_maintenance5, CmdBindIndexBuffer2KHR); \ + HookInitExtension(KHR_maintenance5, GetDeviceImageSubresourceLayoutKHR); \ + HookInitExtension(KHR_maintenance5, GetImageSubresourceLayout2KHR); \ + HookInitExtension(KHR_maintenance5, GetRenderingAreaGranularityKHR); \ HookInitExtension_Device_Win32(); \ HookInitExtension_Device_Linux(); \ HookInitExtension_Device_GGP(); \ @@ -1922,6 +1908,14 @@ const VkAllocationCallbacks *, pAllocator); \ HookDefine4(VkResult, vkGetShaderBinaryDataEXT, VkDevice, device, VkShaderEXT, shader, size_t *, \ pDataSize, void *, pData); \ + HookDefine5(void, vkCmdBindIndexBuffer2KHR, VkCommandBuffer, commandBuffer, VkBuffer, buffer, \ + VkDeviceSize, offset, VkDeviceSize, size, VkIndexType, indexType); \ + HookDefine3(void, vkGetDeviceImageSubresourceLayoutKHR, VkDevice, device, \ + const VkDeviceImageSubresourceInfoKHR *, pInfo, VkSubresourceLayout2KHR *, pLayout); \ + HookDefine4(void, vkGetImageSubresourceLayout2KHR, VkDevice, device, VkImage, image, \ + const VkImageSubresource2KHR *, pSubresource, VkSubresourceLayout2KHR *, pLayout); \ + HookDefine3(void, vkGetRenderingAreaGranularityKHR, VkDevice, device, \ + const VkRenderingAreaInfoKHR *, pRenderingAreaInfo, VkExtent2D *, pGranularity); \ HookDefine_Win32(); \ HookDefine_Linux(); \ HookDefine_GGP(); \ diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 2c947081249..30e8bddafb2 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -960,7 +960,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, ResourceId id, const VkGraphicsPipelineCreateInfo *pCreateInfo) { - flags = pCreateInfo->flags; + flags = WrappedVulkan::GetPipelineCreateFlags(pCreateInfo); graphicsPipe = true; @@ -1641,8 +1641,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, ResourceId id, const VkComputePipelineCreateInfo *pCreateInfo) { - flags = pCreateInfo->flags; - + flags = WrappedVulkan::GetPipelineCreateFlags(pCreateInfo); graphicsPipe = false; compLayout = GetResID(pCreateInfo->layout); @@ -2134,7 +2133,7 @@ void VulkanCreationInfo::Buffer::Init(VulkanResourceManager *resourceMan, Vulkan const VkBufferCreateInfo *pCreateInfo, VkMemoryRequirements origMrq) { - usage = pCreateInfo->usage; + usage = WrappedVulkan::GetBufferUsageFlags(pCreateInfo); size = pCreateInfo->size; gpuAddress = 0; diff --git a/renderdoc/driver/vulkan/vk_info.h b/renderdoc/driver/vulkan/vk_info.h index c4aa4247018..e9817b82ae6 100644 --- a/renderdoc/driver/vulkan/vk_info.h +++ b/renderdoc/driver/vulkan/vk_info.h @@ -273,7 +273,7 @@ struct VulkanCreationInfo VkPipeline subpass0pipe; // VkGraphicsPipelineCreateInfo - VkPipelineCreateFlags flags; + VkPipelineCreateFlags2KHR flags; // VkPipelineShaderStageCreateInfo struct Shader @@ -563,7 +563,7 @@ struct VulkanCreationInfo void Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, const VkBufferCreateInfo *pCreateInfo, VkMemoryRequirements origMrq); - VkBufferUsageFlags usage; + VkBufferUsageFlags2KHR usage; uint64_t size; uint64_t gpuAddress; bool external; diff --git a/renderdoc/driver/vulkan/vk_layer.cpp b/renderdoc/driver/vulkan/vk_layer.cpp index c4fcef02935..13e1b1f7c91 100644 --- a/renderdoc/driver/vulkan/vk_layer.cpp +++ b/renderdoc/driver/vulkan/vk_layer.cpp @@ -396,12 +396,16 @@ VK_LAYER_RENDERDOC_CaptureEnumerateInstanceExtensionProperties( // for promoted extensions, we return the function pointer for either name as an alias. #undef HookInitPromotedExtension -#define HookInitPromotedExtension(cond, function, suffix) \ - if(!strcmp(pName, STRINGIZE(CONCAT(vk, function))) || \ - !strcmp(pName, STRINGIZE(CONCAT(vk, CONCAT(function, suffix))))) \ - { \ - if(cond) \ - return (PFN_vkVoidFunction)&CONCAT(hooked_vk, function); \ +#define HookInitPromotedExtension(cond, version, function, suffix) \ + if(!strcmp(pName, STRINGIZE(CONCAT(vk, CONCAT(function, suffix))))) \ + { \ + if(cond) \ + return (PFN_vkVoidFunction)&CONCAT(hooked_vk, function); \ + } \ + if(!strcmp(pName, STRINGIZE(CONCAT(vk, function)))) \ + { \ + if(instDevInfo->vulkanVersion >= version) \ + return (PFN_vkVoidFunction)&CONCAT(hooked_vk, function); \ } #undef HookInitExtensionEXTtoKHR @@ -412,6 +416,9 @@ VK_LAYER_RENDERDOC_CaptureEnumerateInstanceExtensionProperties( VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr(VkDevice device, const char *pName) { + if(device == VK_NULL_HANDLE || pName == NULL) + return NULL; + if(!strcmp("vkGetDeviceProcAddr", pName)) return (PFN_vkVoidFunction)&VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr; if(!strcmp("vkCreateDevice", pName)) @@ -421,9 +428,6 @@ VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr(VkDevice device, const char *pName) HookInitVulkanDevice(); - if(device == VK_NULL_HANDLE) - return NULL; - InstanceDeviceInfo *instDevInfo = GetRecord(device)->instDevInfo; DeclExts(); @@ -511,7 +515,7 @@ VK_LAYER_RENDERDOC_CaptureGetInstanceProcAddr(VkInstance instance, const char *p return (PFN_vkVoidFunction)&CONCAT(hooked_vk, function); #undef HookInitPromotedExtension -#define HookInitPromotedExtension(cond, function, suffix) \ +#define HookInitPromotedExtension(cond, version, function, suffix) \ if(!strcmp(pName, STRINGIZE(CONCAT(vk, function))) || \ !strcmp(pName, STRINGIZE(CONCAT(vk, CONCAT(function, suffix))))) \ return (PFN_vkVoidFunction)&CONCAT(hooked_vk, function); @@ -592,7 +596,7 @@ VK_LAYER_RENDERDOC_Capture_layerGetPhysicalDeviceProcAddr(VkInstance instance, c return NULL; #undef HookInitPromotedExtension -#define HookInitPromotedExtension(cond, function, suffix) \ +#define HookInitPromotedExtension(cond, version, function, suffix) \ if(!strcmp(pName, STRINGIZE(CONCAT(vk, function))) || \ !strcmp(pName, STRINGIZE(CONCAT(vk, CONCAT(function, suffix))))) \ return NULL; diff --git a/renderdoc/driver/vulkan/vk_next_chains.cpp b/renderdoc/driver/vulkan/vk_next_chains.cpp index 792fc355c21..ee2339f266c 100644 --- a/renderdoc/driver/vulkan/vk_next_chains.cpp +++ b/renderdoc/driver/vulkan/vk_next_chains.cpp @@ -790,7 +790,17 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, UNWRAP_STRUCT_CAPTURE_ONLY(VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR, VkSemaphoreGetFdInfoKHR, \ UnwrapInPlace(out->semaphore)); \ UNWRAP_STRUCT_CAPTURE_ONLY(VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, VkSwapchainCreateInfoKHR, \ - UnwrapInPlace(out->surface), UnwrapInPlace(out->oldSwapchain)); + UnwrapInPlace(out->surface), UnwrapInPlace(out->oldSwapchain)); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR, \ + VkBufferUsageFlags2CreateInfoKHR); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR, \ + VkPipelineCreateFlags2CreateInfoKHR); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR, \ + VkPhysicalDeviceMaintenance5FeaturesKHR); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR, \ + VkPhysicalDeviceMaintenance5PropertiesKHR); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR, VkImageSubresource2KHR); \ + COPY_STRUCT(VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR, VkSubresourceLayout2KHR); // define cases for structs we don't handle at all - only the body of the case needs to be defined // per-function. @@ -837,7 +847,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA: \ case VK_STRUCTURE_TYPE_BUFFER_COLLECTION_PROPERTIES_FUCHSIA: \ case VK_STRUCTURE_TYPE_BUFFER_CONSTRAINTS_INFO_FUCHSIA: \ - case VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR: \ case VK_STRUCTURE_TYPE_CHECKPOINT_DATA_2_NV: \ case VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV: \ case VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDER_PASS_TRANSFORM_INFO_QCOM: \ @@ -871,7 +880,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV: \ case VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT: \ case VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT: \ - case VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR: \ case VK_STRUCTURE_TYPE_DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT: \ case VK_STRUCTURE_TYPE_DEVICE_QUEUE_SHADER_CORE_CONTROL_CREATE_INFO_ARM: \ case VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_INFO_LUNARG: \ @@ -909,7 +917,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT: \ case VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT: \ case VK_STRUCTURE_TYPE_IMAGE_FORMAT_CONSTRAINTS_INFO_FUCHSIA: \ - case VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT: \ case VK_STRUCTURE_TYPE_IMAGE_TO_MEMORY_COPY_EXT: \ case VK_STRUCTURE_TYPE_IMAGE_VIEW_ADDRESS_PROPERTIES_NVX: \ case VK_STRUCTURE_TYPE_IMAGE_VIEW_CAPTURE_DESCRIPTOR_DATA_INFO_EXT: \ @@ -1018,8 +1025,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_DRIVER_PROPERTIES_MSFT: \ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT: \ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV: \ - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR: \ - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR: \ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_FEATURES_KHR: \ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_PROPERTIES_KHR: \ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV: \ @@ -1088,7 +1093,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV: \ case VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV: \ case VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV: \ - case VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR: \ case VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_ENUM_STATE_CREATE_INFO_NV: \ case VK_STRUCTURE_TYPE_PIPELINE_INDIRECT_DEVICE_ADDRESS_INFO_NV: \ case VK_STRUCTURE_TYPE_PIPELINE_PROPERTIES_IDENTIFIER_EXT: \ @@ -1123,7 +1127,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_SUBMIT_INFO_ARM: \ case VK_STRUCTURE_TYPE_RENDER_PASS_SUBPASS_FEEDBACK_CREATE_INFO_EXT: \ case VK_STRUCTURE_TYPE_RENDER_PASS_TRANSFORM_BEGIN_INFO_QCOM: \ - case VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR: \ case VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR: \ case VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR: \ case VK_STRUCTURE_TYPE_SAMPLER_BLOCK_MATCH_WINDOW_CREATE_INFO_QCOM: \ @@ -1139,7 +1142,6 @@ static void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, case VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT: \ case VK_STRUCTURE_TYPE_SUBPASS_SHADING_PIPELINE_CREATE_INFO_HUAWEI: \ case VK_STRUCTURE_TYPE_SUBRESOURCE_HOST_MEMCPY_SIZE_EXT: \ - case VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT: \ case VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_BARRIER_NV: \ case VK_STRUCTURE_TYPE_SWAPCHAIN_LATENCY_CREATE_INFO_NV: \ case VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV: \ @@ -1648,6 +1650,23 @@ size_t GetNextPatchSize(const void *pNext) memSize += info->accelerationStructureCount * sizeof(VkAccelerationStructureKHR); break; } + case VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR: + { + memSize += sizeof(VkDeviceImageSubresourceInfoKHR); + + VkDeviceImageSubresourceInfoKHR *info = (VkDeviceImageSubresourceInfoKHR *)next; + memSize += GetNextPatchSize(info->pCreateInfo); + memSize += GetNextPatchSize(info->pSubresource); + break; + } + case VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR: + { + memSize += sizeof(VkRenderingAreaInfoKHR); + + VkRenderingAreaInfoKHR *info = (VkRenderingAreaInfoKHR *)next; + memSize += info->colorAttachmentCount * sizeof(VkFormat); + break; + } // Android External Buffer Memory Extension #if ENABLED(RDOC_ANDROID) @@ -2862,6 +2881,46 @@ void UnwrapNextChain(CaptureState state, const char *structName, byte *&tempMem, break; } + case VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR: + { + const VkDeviceImageSubresourceInfoKHR *in = + (const VkDeviceImageSubresourceInfoKHR *)nextInput; + VkDeviceImageSubresourceInfoKHR *out = (VkDeviceImageSubresourceInfoKHR *)tempMem; + + // append immediately so tempMem is incremented + AppendModifiedChainedStruct(tempMem, out, nextChainTail); + + out->sType = VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR; + out->pNext = in->pNext; + + out->pCreateInfo = AllocStructCopy(tempMem, in->pCreateInfo); + UnwrapNextChain(state, "VkImageCreateInfo", tempMem, (VkBaseInStructure *)out->pCreateInfo); + + out->pSubresource = AllocStructCopy(tempMem, in->pSubresource); + UnwrapNextChain(state, "VkImageSubresource2KHR", tempMem, + (VkBaseInStructure *)out->pSubresource); + + break; + } + case VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR: + { + const VkRenderingAreaInfoKHR *in = (const VkRenderingAreaInfoKHR *)nextInput; + VkRenderingAreaInfoKHR *out = (VkRenderingAreaInfoKHR *)tempMem; + + // append immediately so tempMem is incremented + AppendModifiedChainedStruct(tempMem, out, nextChainTail); + + VkFormat *outFormats = (VkFormat *)tempMem; + tempMem += sizeof(VkFormat) * in->colorAttachmentCount; + + *out = *in; + + out->pColorAttachmentFormats = outFormats; + for(uint32_t i = 0; i < in->colorAttachmentCount; i++) + outFormats[i] = in->pColorAttachmentFormats[i]; + + break; + } // Android External Buffer Memory Extension #if ENABLED(RDOC_ANDROID) @@ -3187,6 +3246,13 @@ void CopyNextChainForPatching(const char *structName, byte *&tempMem, VkBaseInSt CopyNextChainedStruct(sizeof(VkWriteDescriptorSetAccelerationStructureKHR), tempMem, nextInput, nextChainTail); break; + case VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR: + CopyNextChainedStruct(sizeof(VkDeviceImageSubresourceInfoKHR), tempMem, nextInput, + nextChainTail); + break; + case VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR: + CopyNextChainedStruct(sizeof(VkRenderingAreaInfoKHR), tempMem, nextInput, nextChainTail); + break; // Android External Buffer Memory Extension #if ENABLED(RDOC_ANDROID) diff --git a/renderdoc/driver/vulkan/vk_overlay.cpp b/renderdoc/driver/vulkan/vk_overlay.cpp index 94b4cc21826..be82626e8e2 100644 --- a/renderdoc/driver/vulkan/vk_overlay.cpp +++ b/renderdoc/driver/vulkan/vk_overlay.cpp @@ -364,9 +364,19 @@ void VulkanDebugManager::PatchLineStripIndexBuffer(const ActionDescription *acti if(action->flags & ActionFlags::Indexed) { - GetBufferData(rs.ibuffer.buf, - rs.ibuffer.offs + uint64_t(action->indexOffset) * rs.ibuffer.bytewidth, - uint64_t(action->numIndices) * rs.ibuffer.bytewidth, indices); + uint64_t offset = uint64_t(action->indexOffset) * rs.ibuffer.bytewidth; + uint64_t data_len = uint64_t(action->numIndices) * rs.ibuffer.bytewidth; + + uint64_t len = RDCMIN(data_len, rs.ibuffer.size - offset); + + GetBufferData(rs.ibuffer.buf, rs.ibuffer.offs + offset, len, indices); + + if(len < data_len) + { + // fill the rest with 0s + indices.resize((size_t)data_len); + memset(indices.data() + len, 0, (size_t)(data_len - len)); + } if(rs.ibuffer.bytewidth == 4) idx32 = (uint32_t *)indices.data(); diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index c0e364ee972..1e43ef7e6b8 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -4334,8 +4334,13 @@ void VulkanReplay::FetchVSOut(uint32_t eventId, VulkanRenderState &state) // fetch ibuffer if(state.ibuffer.buf != ResourceId()) - GetBufferData(state.ibuffer.buf, state.ibuffer.offs + action->indexOffset * idxsize, - uint64_t(action->numIndices) * idxsize, idxdata); + { + uint64_t offset = uint64_t(action->indexOffset) * idxsize; + uint64_t data_len = uint64_t(action->numIndices) * idxsize; + + uint64_t len = RDCMIN(data_len, state.ibuffer.size - offset); + GetBufferData(state.ibuffer.buf, state.ibuffer.offs + offset, len, idxdata); + } // figure out what the maximum index could be, so we can clamp our index buffer to something // sane diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 4f84942cebf..aa2cf1b3df5 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -1282,6 +1282,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) ret.inputAssembly.indexBuffer.resourceId = rm->GetOriginalID(state.ibuffer.buf); ret.inputAssembly.indexBuffer.byteOffset = state.ibuffer.offs; ret.inputAssembly.indexBuffer.byteStride = state.ibuffer.bytewidth; + ret.inputAssembly.indexBuffer.byteSize = state.ibuffer.size; ret.inputAssembly.primitiveRestartEnable = state.primRestartEnable != VK_FALSE; ret.inputAssembly.topology = MakePrimitiveTopology(state.primitiveTopology, state.patchControlPoints); diff --git a/renderdoc/driver/vulkan/vk_serialise.cpp b/renderdoc/driver/vulkan/vk_serialise.cpp index 8ee87f5ae62..f6c89683bd9 100644 --- a/renderdoc/driver/vulkan/vk_serialise.cpp +++ b/renderdoc/driver/vulkan/vk_serialise.cpp @@ -172,6 +172,8 @@ DECL_VKFLAG_EXT(VkBuildAccelerationStructure, KHR); DECL_VKFLAG_EXT(VkGeometry, KHR); DECL_VKFLAG_EXT(VkGeometryInstance, KHR); DECL_VKFLAG_EXT(VkShaderCreate, EXT); +DECL_VKFLAG_EXT(VkBufferUsage, 2KHR); +DECL_VKFLAG_EXT(VkPipelineCreate, 2KHR); // serialise a member as flags - cast to the Bits enum for serialisation so the stringification // picks up the bitfield and doesn't treat it as uint32_t. Then we rename the type back to the base @@ -1459,6 +1461,20 @@ SERIALISE_VK_HANDLES(); PNEXT_STRUCT(VK_STRUCTURE_TYPE_SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM, \ VkSubpassFragmentDensityMapOffsetEndInfoQCOM) \ \ + /* VK_KHR_maintenance5 */ \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR, \ + VkPhysicalDeviceMaintenance5FeaturesKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR, \ + VkPhysicalDeviceMaintenance5PropertiesKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR, VkRenderingAreaInfoKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR, VkDeviceImageSubresourceInfoKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR, \ + VkPipelineCreateFlags2CreateInfoKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR, \ + VkBufferUsageFlags2CreateInfoKHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR, VkImageSubresource2KHR) \ + PNEXT_STRUCT(VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR, VkSubresourceLayout2KHR) \ + \ /* Surface creation structs. These would pull in dependencies on OS-specific includes. */ \ /* So treat them as unsupported. */ \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR) \ @@ -1591,8 +1607,6 @@ SERIALISE_VK_HANDLES(); /* VK_EXT_image_compression_control */ \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT) \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT) \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT) \ \ /* VK_EXT_image_compression_control_swapchain */ \ @@ -1718,14 +1732,6 @@ SERIALISE_VK_HANDLES(); PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR) \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR) \ \ - /* VK_KHR_maintenance5 */ \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR) \ - PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR) \ - \ /* VK_KHR_maintenance6 */ \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_FEATURES_KHR) \ PNEXT_UNSUPPORTED(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_PROPERTIES_KHR) \ @@ -12218,6 +12224,155 @@ void Deserialise(const VkPhysicalDeviceRayQueryFeaturesKHR &el) DeserialiseNext(el.pNext); } +template +void DoSerialise(SerialiserType &ser, VkPhysicalDeviceMaintenance5FeaturesKHR &el) +{ + RDCASSERT(ser.IsReading() || + el.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER(maintenance5); +} + +template <> +void Deserialise(const VkPhysicalDeviceMaintenance5FeaturesKHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkPhysicalDeviceMaintenance5PropertiesKHR &el) +{ + RDCASSERT(ser.IsReading() || + el.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER(earlyFragmentMultisampleCoverageAfterSampleCounting); + SERIALISE_MEMBER(earlyFragmentSampleMaskTestBeforeSampleCounting); + SERIALISE_MEMBER(depthStencilSwizzleOneSupport); + SERIALISE_MEMBER(polygonModePointSize); + SERIALISE_MEMBER(nonStrictSinglePixelWideLinesUseParallelogram); + SERIALISE_MEMBER(nonStrictWideLinesUseParallelogram); +} + +template <> +void Deserialise(const VkPhysicalDeviceMaintenance5PropertiesKHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkRenderingAreaInfoKHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER(colorAttachmentCount); + SERIALISE_MEMBER_ARRAY(pColorAttachmentFormats, colorAttachmentCount); + SERIALISE_MEMBER(depthAttachmentFormat); + SERIALISE_MEMBER(stencilAttachmentFormat); +} + +template <> +void Deserialise(const VkRenderingAreaInfoKHR &el) +{ + DeserialiseNext(el.pNext); + delete[] el.pColorAttachmentFormats; +} + +template +void DoSerialise(SerialiserType &ser, VkDeviceImageSubresourceInfoKHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER_OPT(pCreateInfo); + SERIALISE_MEMBER_OPT(pSubresource); +} + +template <> +void Deserialise(const VkDeviceImageSubresourceInfoKHR &el) +{ + DeserialiseNext(el.pNext); + delete el.pCreateInfo; + delete el.pSubresource; +} + +template +void DoSerialise(SerialiserType &ser, VkPipelineCreateFlags2CreateInfoKHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER_VKFLAGS(VkPipelineCreateFlags2KHR, flags); +} + +template <> +void Deserialise(const VkPipelineCreateFlags2CreateInfoKHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkBufferUsageFlags2CreateInfoKHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER_VKFLAGS(VkBufferUsageFlags2KHR, usage); +} + +template <> +void Deserialise(const VkBufferUsageFlags2CreateInfoKHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkImageSubresource2KHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER(imageSubresource); +} + +template <> +void Deserialise(const VkImageSubresource2KHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkSubresourceLayout2KHR &el) +{ + RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR); + SerialiseNext(ser, el.sType, el.pNext); + + SERIALISE_MEMBER(subresourceLayout); +} + +template <> +void Deserialise(const VkSubresourceLayout2KHR &el) +{ + DeserialiseNext(el.pNext); +} + +template +void DoSerialise(SerialiserType &ser, VkSubresourceLayout &el) +{ + SERIALISE_MEMBER(offset).OffsetOrSize(); + SERIALISE_MEMBER(size).OffsetOrSize(); + SERIALISE_MEMBER(rowPitch).OffsetOrSize(); + SERIALISE_MEMBER(arrayPitch).OffsetOrSize(); + SERIALISE_MEMBER(depthPitch).OffsetOrSize(); +} + +template <> +void Deserialise(const VkSubresourceLayout &el) +{ +} + // pNext structs - always have deserialise for the next chain INSTANTIATE_SERIALISE_TYPE(VkAccelerationStructureBuildGeometryInfoKHR); INSTANTIATE_SERIALISE_TYPE(VkAccelerationStructureBuildSizesInfoKHR); @@ -12652,6 +12807,14 @@ INSTANTIATE_SERIALISE_TYPE(VkVertexInputAttributeDescription2EXT); INSTANTIATE_SERIALISE_TYPE(VkVertexInputBindingDescription2EXT); INSTANTIATE_SERIALISE_TYPE(VkWriteDescriptorSet); INSTANTIATE_SERIALISE_TYPE(VkWriteDescriptorSetAccelerationStructureKHR); +INSTANTIATE_SERIALISE_TYPE(VkPhysicalDeviceMaintenance5FeaturesKHR); +INSTANTIATE_SERIALISE_TYPE(VkPhysicalDeviceMaintenance5PropertiesKHR); +INSTANTIATE_SERIALISE_TYPE(VkRenderingAreaInfoKHR); +INSTANTIATE_SERIALISE_TYPE(VkDeviceImageSubresourceInfoKHR); +INSTANTIATE_SERIALISE_TYPE(VkPipelineCreateFlags2CreateInfoKHR); +INSTANTIATE_SERIALISE_TYPE(VkBufferUsageFlags2CreateInfoKHR); +INSTANTIATE_SERIALISE_TYPE(VkImageSubresource2KHR); +INSTANTIATE_SERIALISE_TYPE(VkSubresourceLayout2KHR); // plain structs with no next chain INSTANTIATE_SERIALISE_TYPE(VkAabbPositionsKHR); @@ -12737,6 +12900,7 @@ INSTANTIATE_SERIALISE_TYPE(VkVertexInputBindingDescription); INSTANTIATE_SERIALISE_TYPE(VkVertexInputBindingDivisorDescriptionEXT); INSTANTIATE_SERIALISE_TYPE(VkViewport); INSTANTIATE_SERIALISE_TYPE(VkXYColorEXT); +INSTANTIATE_SERIALISE_TYPE(VkSubresourceLayout); INSTANTIATE_SERIALISE_TYPE(DescriptorSetSlot); INSTANTIATE_SERIALISE_TYPE(ImageRegionState); diff --git a/renderdoc/driver/vulkan/vk_shader_cache.cpp b/renderdoc/driver/vulkan/vk_shader_cache.cpp index 3615cd5f05b..9f207127dc7 100644 --- a/renderdoc/driver/vulkan/vk_shader_cache.cpp +++ b/renderdoc/driver/vulkan/vk_shader_cache.cpp @@ -902,7 +902,7 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p VkGraphicsPipelineCreateInfo ret = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, NULL, - pipeInfo.flags, + 0, stageCount, stages, &vi, @@ -1017,11 +1017,28 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p rs.pNext = &provokeSetup; } + static VkPipelineCreateFlags2CreateInfoKHR flags2 = { + VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR, + }; + + VkPipelineCreateFlags2KHR flags = pipeInfo.flags; + // never create derivatives - ret.flags &= ~VK_PIPELINE_CREATE_DERIVATIVE_BIT; + flags &= ~VK_PIPELINE_CREATE_DERIVATIVE_BIT; - ret.flags &= ~VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; - ret.flags &= ~VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT; + flags &= ~VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; + flags &= ~VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT; + + if(flags > VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM) + { + flags2.flags = pipeInfo.flags; + flags2.pNext = ret.pNext; + ret.pNext = &flags2; + } + else + { + ret.flags = (VkPipelineCreateFlags)flags; + } pipeCreateInfo = ret; } @@ -1093,15 +1110,32 @@ void VulkanShaderCache::MakeComputePipelineInfo(VkComputePipelineCreateInfo &pip VkComputePipelineCreateInfo ret = { VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, NULL, - pipeInfo.flags, + 0, stage, rm->GetCurrentHandle(pipeInfo.compLayout), VK_NULL_HANDLE, // base pipeline handle 0, // base pipeline index }; + VkPipelineCreateFlags2KHR flags = pipeInfo.flags; + // never create derivatives - ret.flags &= ~VK_PIPELINE_CREATE_DERIVATIVE_BIT; + flags &= ~VK_PIPELINE_CREATE_DERIVATIVE_BIT; + + static VkPipelineCreateFlags2CreateInfoKHR flags2 = { + VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR, + }; + + if(flags > VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM) + { + flags2.flags = pipeInfo.flags; + flags2.pNext = ret.pNext; + ret.pNext = &flags2; + } + else + { + ret.flags = (VkPipelineCreateFlags)flags; + } pipeCreateInfo = ret; } diff --git a/renderdoc/driver/vulkan/vk_state.cpp b/renderdoc/driver/vulkan/vk_state.cpp index da1576b876c..d7165a7b869 100644 --- a/renderdoc/driver/vulkan/vk_state.cpp +++ b/renderdoc/driver/vulkan/vk_state.cpp @@ -138,7 +138,6 @@ void setupRenderingInfo(const VulkanRenderState::DynamicRendering &dynamicRender VulkanRenderState::VulkanRenderState() { - RDCEraseEl(ibuffer); } void VulkanRenderState::BeginRenderPassAndApplyState(WrappedVulkan *vk, VkCommandBuffer cmd, @@ -592,9 +591,17 @@ void VulkanRenderState::BindPipeline(WrappedVulkan *vk, VkCommandBuffer cmd, else if(ibuffer.bytewidth == 1) type = VK_INDEX_TYPE_UINT8_KHR; - ObjDisp(cmd)->CmdBindIndexBuffer( - Unwrap(cmd), Unwrap(vk->GetResourceManager()->GetCurrentHandle(ibuffer.buf)), - ibuffer.offs, type); + VkBuffer idxBufferUnwrapped = + Unwrap(vk->GetResourceManager()->GetCurrentHandle(ibuffer.buf)); + if(ibuffer.size == VK_WHOLE_SIZE) + { + ObjDisp(cmd)->CmdBindIndexBuffer(Unwrap(cmd), idxBufferUnwrapped, ibuffer.offs, type); + } + else + { + ObjDisp(cmd)->CmdBindIndexBuffer2KHR(Unwrap(cmd), idxBufferUnwrapped, ibuffer.offs, + ibuffer.size, type); + } } if(vk->DynamicVertexInput() && dynamicStates[VkDynamicVertexInputEXT]) diff --git a/renderdoc/driver/vulkan/vk_state.h b/renderdoc/driver/vulkan/vk_state.h index 6390ee90248..7a7fffa720e 100644 --- a/renderdoc/driver/vulkan/vk_state.h +++ b/renderdoc/driver/vulkan/vk_state.h @@ -161,6 +161,7 @@ struct VulkanRenderState { ResourceId buf; VkDeviceSize offs = 0; + VkDeviceSize size = VK_WHOLE_SIZE; int bytewidth = 0; } ibuffer; diff --git a/renderdoc/driver/vulkan/vk_stringise.cpp b/renderdoc/driver/vulkan/vk_stringise.cpp index 5aec3886bc8..d8d07f8f078 100644 --- a/renderdoc/driver/vulkan/vk_stringise.cpp +++ b/renderdoc/driver/vulkan/vk_stringise.cpp @@ -28,7 +28,7 @@ template <> rdcstr DoStringise(const VulkanChunk &el) { - RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1209, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1210, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(VulkanChunk) { @@ -241,6 +241,7 @@ rdcstr DoStringise(const VulkanChunk &el) STRINGISE_ENUM_CLASS(vkCreateAccelerationStructureKHR) STRINGISE_ENUM_CLASS(vkCmdBindShadersEXT) STRINGISE_ENUM_CLASS(vkCreateShadersEXT) + STRINGISE_ENUM_CLASS(vkCmdBindIndexBuffer2KHR) STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk"); } END_ENUM_STRINGISE() @@ -4070,3 +4071,83 @@ rdcstr DoStringise(const VkGeometryTypeKHR &el) } END_ENUM_STRINGISE(); } + +template <> +rdcstr DoStringise(const VkBufferUsageFlagBits2KHR &el) +{ + BEGIN_BITFIELD_STRINGISE(VkBufferUsageFlagBits2KHR); + { + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_TRANSFER_SRC_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_TRANSFER_DST_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_UNIFORM_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_STORAGE_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_INDEX_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_VERTEX_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_INDIRECT_BUFFER_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_SHADER_DEVICE_ADDRESS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_VIDEO_DECODE_SRC_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_VIDEO_DECODE_DST_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_CONDITIONAL_RENDERING_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_SHADER_BINDING_TABLE_BIT_KHR); + +// until 279 those flags are errorneously requiring VK_ENABLE_BETA_EXTENSIONS to be defined. +// when we update to 279 or later, we should remove this #if +#if VK_HEADER_VERSION >= 279 + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_VIDEO_ENCODE_DST_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_VIDEO_ENCODE_SRC_BIT_KHR); +#endif + + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_BUFFER_USAGE_2_MICROMAP_STORAGE_BIT_EXT); + } + END_BITFIELD_STRINGISE(); +} + +template <> +rdcstr DoStringise(const VkPipelineCreateFlagBits2KHR &el) +{ + BEGIN_BITFIELD_STRINGISE(VkPipelineCreateFlagBits2KHR); + { + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DISABLE_OPTIMIZATION_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_ALLOW_DERIVATIVES_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DERIVATIVE_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DISPATCH_BASE_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_EARLY_RETURN_ON_FAILURE_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_AABBS_BIT_KHR); + STRINGISE_BITFIELD_BIT64( + VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DEFER_COMPILE_BIT_NV); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_CAPTURE_STATISTICS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_INDIRECT_BINDABLE_BIT_NV); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DESCRIPTOR_BUFFER_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_LINK_TIME_OPTIMIZATION_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_MOTION_BIT_NV); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_NO_PROTECTED_ACCESS_BIT_EXT); + STRINGISE_BITFIELD_BIT64(VK_PIPELINE_CREATE_2_PROTECTED_ACCESS_ONLY_BIT_EXT); + } + END_BITFIELD_STRINGISE(); +} diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 54384cc64ef..ba2e9017f55 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -3834,6 +3834,7 @@ bool WrappedVulkan::Serialise_vkCmdBindIndexBuffer(SerialiserType &ser, VulkanRenderState &renderstate = GetCmdRenderState(); renderstate.ibuffer.buf = GetResID(buffer); renderstate.ibuffer.offs = offset; + renderstate.ibuffer.size = VK_WHOLE_SIZE; if(indexType == VK_INDEX_TYPE_UINT32) renderstate.ibuffer.bytewidth = 4; @@ -3887,6 +3888,94 @@ void WrappedVulkan::vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer } } +template +bool WrappedVulkan::Serialise_vkCmdBindIndexBuffer2KHR(SerialiserType &ser, + VkCommandBuffer commandBuffer, + VkBuffer buffer, VkDeviceSize offset, + VkDeviceSize size, VkIndexType indexType) +{ + SERIALISE_ELEMENT(commandBuffer); + SERIALISE_ELEMENT(buffer).Important(); + SERIALISE_ELEMENT(offset).OffsetOrSize(); + SERIALISE_ELEMENT(size).OffsetOrSize(); + SERIALISE_ELEMENT(indexType).Important(); + + Serialise_DebugMessages(ser); + + SERIALISE_CHECK_READ_ERRORS(); + + if(IsReplayingAndReading()) + { + m_LastCmdBufferID = GetResourceManager()->GetOriginalID(GetResID(commandBuffer)); + + if(IsActiveReplaying(m_State)) + { + if(InRerecordRange(m_LastCmdBufferID)) + { + commandBuffer = RerecordCmdBuf(m_LastCmdBufferID); + ObjDisp(commandBuffer) + ->CmdBindIndexBuffer2KHR(Unwrap(commandBuffer), Unwrap(buffer), offset, size, indexType); + + { + VulkanRenderState &renderstate = GetCmdRenderState(); + renderstate.ibuffer.buf = GetResID(buffer); + renderstate.ibuffer.offs = offset; + renderstate.ibuffer.size = size; + + if(indexType == VK_INDEX_TYPE_UINT32) + renderstate.ibuffer.bytewidth = 4; + else if(indexType == VK_INDEX_TYPE_UINT8_KHR) + renderstate.ibuffer.bytewidth = 1; + else + renderstate.ibuffer.bytewidth = 2; + } + } + } + else + { + // track while reading, as we need to bind current topology & index byte width in AddAction + if(indexType == VK_INDEX_TYPE_UINT32) + m_BakedCmdBufferInfo[m_LastCmdBufferID].state.ibuffer.bytewidth = 4; + else if(indexType == VK_INDEX_TYPE_UINT8_KHR) + m_BakedCmdBufferInfo[m_LastCmdBufferID].state.ibuffer.bytewidth = 1; + else + m_BakedCmdBufferInfo[m_LastCmdBufferID].state.ibuffer.bytewidth = 2; + + // track while reading, as we need to track resource usage + m_BakedCmdBufferInfo[m_LastCmdBufferID].state.ibuffer.buf = GetResID(buffer); + + ObjDisp(commandBuffer) + ->CmdBindIndexBuffer2KHR(Unwrap(commandBuffer), Unwrap(buffer), offset, size, indexType); + } + } + + return true; +} + +void WrappedVulkan::vkCmdBindIndexBuffer2KHR(VkCommandBuffer commandBuffer, VkBuffer buffer, + VkDeviceSize offset, VkDeviceSize size, + VkIndexType indexType) +{ + SCOPED_DBG_SINK(); + + SERIALISE_TIME_CALL( + ObjDisp(commandBuffer) + ->CmdBindIndexBuffer2KHR(Unwrap(commandBuffer), Unwrap(buffer), offset, size, indexType)); + + if(IsCaptureMode(m_State)) + { + VkResourceRecord *record = GetRecord(commandBuffer); + + CACHE_THREAD_SERIALISER(); + + SCOPED_SERIALISE_CHUNK(VulkanChunk::vkCmdBindIndexBuffer2KHR); + Serialise_vkCmdBindIndexBuffer2KHR(ser, commandBuffer, buffer, offset, size, indexType); + + record->AddChunk(scope.Get(&record->cmdInfo->alloc)); + record->MarkBufferFrameReferenced(GetRecord(buffer), 0, VK_WHOLE_SIZE, eFrameRef_Read); + } +} + template bool WrappedVulkan::Serialise_vkCmdPushConstants(SerialiserType &ser, VkCommandBuffer commandBuffer, VkPipelineLayout layout, @@ -8309,3 +8398,7 @@ INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdCopyMemoryToAccelerationStructureKHR, INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdBindShadersEXT, VkCommandBuffer commandBuffer, uint32_t stageCount, const VkShaderStageFlagBits *pStages, const VkShaderEXT *pShaders); + +INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdBindIndexBuffer2KHR, VkCommandBuffer commandBuffer, + VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, + VkIndexType indexType); diff --git a/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp index d005187d71b..5dc314fb5ba 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp @@ -331,13 +331,16 @@ void WrappedVulkan::vkGetDeviceBufferMemoryRequirements(VkDevice device, VkBufferCreateInfo *info = (VkBufferCreateInfo *)unwrappedInfo->pCreateInfo; + VkBufferUsageFlags2KHR usage = GetBufferUsageFlags(info); + // patch the create info the same as we would for vkCreateBuffer - info->usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - info->usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; - if(IsCaptureMode(m_State) && (info->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)) + if(IsCaptureMode(m_State) && (usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)) info->flags |= VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT; + SetBufferUsageFlags(info, usage); ObjDisp(device)->GetDeviceBufferMemoryRequirements(Unwrap(device), unwrappedInfo, pMemoryRequirements); @@ -1268,3 +1271,25 @@ VkResult WrappedVulkan::vkGetShaderBinaryDataEXT(VkDevice device, VkShaderEXT sh // application should never provide an old binary. return VK_SUCCESS; } + +void WrappedVulkan::vkGetDeviceImageSubresourceLayoutKHR(VkDevice device, + const VkDeviceImageSubresourceInfoKHR *pInfo, + VkSubresourceLayout2KHR *pLayout) +{ + ObjDisp(device)->GetDeviceImageSubresourceLayoutKHR(Unwrap(device), pInfo, pLayout); +} + +void WrappedVulkan::vkGetImageSubresourceLayout2KHR(VkDevice device, VkImage image, + const VkImageSubresource2KHR *pSubresource, + VkSubresourceLayout2KHR *pLayout) +{ + ObjDisp(device)->GetImageSubresourceLayout2KHR(Unwrap(device), Unwrap(image), pSubresource, + pLayout); +} + +void WrappedVulkan::vkGetRenderingAreaGranularityKHR(VkDevice device, + const VkRenderingAreaInfoKHR *pRenderingAreaInfo, + VkExtent2D *pGranularity) +{ + ObjDisp(device)->GetRenderingAreaGranularityKHR(Unwrap(device), pRenderingAreaInfo, pGranularity); +} diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index b45446e67b1..35cda0bccb6 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -1676,16 +1676,6 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic { VkBuffer buf = VK_NULL_HANDLE; - VkBufferUsageFlags origusage = CreateInfo.usage; - - // ensure we can always readback from buffers - CreateInfo.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - - // we only need to add TRANSFER_DST_BIT for dedicated buffers, but there's not a reliable way to - // know if a buffer will be dedicated-allocation or not. We assume that TRANSFER_DST is - // effectively free as a usage bit for all sensible implementations so we just add it here. - CreateInfo.usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; - // remap the queue family indices if(CreateInfo.sharingMode == VK_SHARING_MODE_CONCURRENT) { @@ -1694,11 +1684,22 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic queueFamiles[q] = m_QueueRemapping[queueFamiles[q]][0].family; } - VkBufferCreateInfo patched = CreateInfo; + VkBufferUsageFlags2KHR origusage = GetBufferUsageFlags(&CreateInfo); - byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); + VkBufferUsageFlags2KHR augmented_usage = origusage; + + // ensure we can always readback from buffers + augmented_usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + // we only need to add TRANSFER_DST_BIT for dedicated buffers, but there's not a reliable way to + // know if a buffer will be dedicated-allocation or not. We assume that TRANSFER_DST is + // effectively free as a usage bit for all sensible implementations so we just add it here. + augmented_usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + + VkBufferCreateInfo patched = CreateInfo; + byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkBaseInStructure *)&patched); + SetBufferUsageFlags(&patched, augmented_usage); VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &patched, NULL, &buf); @@ -1708,7 +1709,7 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic APIProps.SparseResources = true; } - CreateInfo.usage = origusage; + SetBufferUsageFlags(&CreateInfo, origusage); if(ret != VK_SUCCESS) { @@ -1737,38 +1738,45 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo { VkBufferCreateInfo adjusted_info = *pCreateInfo; + byte *tempMem = GetTempMemory(GetNextPatchSize(adjusted_info.pNext)); + UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkBaseInStructure *)&adjusted_info); + + VkBufferUsageFlags2KHR origusage = GetBufferUsageFlags(&adjusted_info); + + VkBufferUsageFlags2KHR usage = origusage; + // if you change any properties here, ensure you also update // vkGetDeviceBufferMemoryRequirementsKHR // TEMP HACK: Until we define a portable fake hardware, need to match the requirements for usage // on replay, so that the memory requirements are the same - adjusted_info.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; // we only need to add TRANSFER_DST_BIT for dedicated buffers, but there's not a reliable way to // know if a buffer will be dedicated-allocation or not. We assume that TRANSFER_DST is // effectively free as a usage bit for all sensible implementations so we just add it here. - adjusted_info.usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; if(IsCaptureMode(m_State)) { // If we're using this buffer for AS storage we need to enable BDA - if(adjusted_info.usage & VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR) - adjusted_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; + if(usage & VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR) + usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; // If we're using this buffer for device addresses, ensure we force on capture replay bit. // We ensured the physical device can support this feature before whitelisting the extension. - if(adjusted_info.usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) + if(usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) adjusted_info.flags |= VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT; } - byte *tempMem = GetTempMemory(GetNextPatchSize(adjusted_info.pNext)); - - UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkBaseInStructure *)&adjusted_info); + SetBufferUsageFlags(&adjusted_info, usage); VkResult ret; SERIALISE_TIME_CALL( ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &adjusted_info, NULL, pBuffer)); + SetBufferUsageFlags(&adjusted_info, origusage); + if(ret == VK_SUCCESS) { ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pBuffer); @@ -1791,7 +1799,7 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo // if we're using VK_[KHR|EXT]_buffer_device_address, we fetch the device address that's been // allocated and insert it into the next chain and patch the flags so that it replays // naturally. - if((pCreateInfo->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) != 0) + if((origusage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) != 0) { VkBufferDeviceAddressInfo getInfo = { VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, @@ -1852,8 +1860,8 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo record->AddChunk(chunk); - record->storable = (pCreateInfo->usage & (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | - VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) != 0; + record->storable = (origusage & (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | + VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) != 0; bool isSparse = (pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_BINDING_BIT | VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT)) != 0; diff --git a/renderdoc/driver/vulkan/wrappers/vk_shader_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_shader_funcs.cpp index 048a257ae17..49a93a321e4 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_shader_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_shader_funcs.cpp @@ -38,7 +38,7 @@ VkComputePipelineCreateInfo *WrappedVulkan::UnwrapInfos(CaptureState state, unwrapped[i] = info[i]; unwrapped[i].stage.module = Unwrap(unwrapped[i].stage.module); unwrapped[i].layout = Unwrap(unwrapped[i].layout); - if(unwrapped[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + if(GetPipelineCreateFlags(&unwrapped[i]) & VK_PIPELINE_CREATE_DERIVATIVE_BIT) unwrapped[i].basePipelineHandle = Unwrap(unwrapped[i].basePipelineHandle); } @@ -79,7 +79,7 @@ VkGraphicsPipelineCreateInfo *WrappedVulkan::UnwrapInfos(CaptureState state, unwrappedInfos[i].pStages = unwrappedStages; unwrappedInfos[i].layout = Unwrap(unwrappedInfos[i].layout); unwrappedInfos[i].renderPass = Unwrap(unwrappedInfos[i].renderPass); - if(unwrappedInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + if(GetPipelineCreateFlags(&unwrappedInfos[i]) & VK_PIPELINE_CREATE_DERIVATIVE_BIT) unwrappedInfos[i].basePipelineHandle = Unwrap(unwrappedInfos[i].basePipelineHandle); UnwrapNextChain(state, "VkGraphicsPipelineCreateInfo", tempMem, @@ -614,22 +614,25 @@ bool WrappedVulkan::Serialise_vkCreateGraphicsPipelines( // don't use pipeline caches on replay pipelineCache = VK_NULL_HANDLE; + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(&CreateInfo); + // if we have pipeline executable properties, capture the data if(GetExtensions(NULL).ext_KHR_pipeline_executable_properties) { - CreateInfo.flags |= (VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR | - VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR); + flags |= (VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR | + VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR); } // don't fail when a compile is required because we don't currently replay caches so this will // always happen. This still allows application to use this flag at runtime where it will be // valid - CreateInfo.flags &= ~VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT; + flags &= ~VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT; VkGraphicsPipelineCreateInfo *unwrapped = UnwrapInfos(m_State, &CreateInfo, 1); + SetPipelineCreateFlags(unwrapped, flags); + VkResult ret = ObjDisp(device)->CreateGraphicsPipelines(Unwrap(device), Unwrap(pipelineCache), 1, unwrapped, NULL, &pipe); - AddResource(Pipeline, ResourceType::PipelineState, "Graphics Pipeline"); if(ret != VK_SUCCESS) @@ -734,6 +737,7 @@ bool WrappedVulkan::Serialise_vkCreateGraphicsPipelines( CreateInfo.subpass = 0; unwrapped = UnwrapInfos(m_State, &CreateInfo, 1); + SetPipelineCreateFlags(unwrapped, flags); ret = ObjDisp(device)->CreateGraphicsPipelines(Unwrap(device), Unwrap(pipelineCache), 1, unwrapped, NULL, &pipeInfo.subpass0pipe); RDCASSERTEQUAL(ret, VK_SUCCESS); @@ -750,7 +754,7 @@ bool WrappedVulkan::Serialise_vkCreateGraphicsPipelines( DerivedResource(device, Pipeline); if(origCache != VK_NULL_HANDLE) DerivedResource(origCache, Pipeline); - if(CreateInfo.flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { if(CreateInfo.basePipelineHandle != VK_NULL_HANDLE) DerivedResource(CreateInfo.basePipelineHandle, Pipeline); @@ -817,7 +821,9 @@ VkResult WrappedVulkan::vkCreateGraphicsPipelines(VkDevice device, VkPipelineCac VkGraphicsPipelineCreateInfo modifiedCreateInfo; const VkGraphicsPipelineCreateInfo *createInfo = &pCreateInfos[i]; - if(createInfo->flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(createInfo); + + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { // since we serialise one by one, we need to fixup basePipelineIndex if(createInfo->basePipelineIndex != -1 && createInfo->basePipelineIndex < (int)i) @@ -840,7 +846,9 @@ VkResult WrappedVulkan::vkCreateGraphicsPipelines(VkDevice device, VkPipelineCac VkResourceRecord *record = GetResourceManager()->AddResourceRecord(pPipelines[i]); record->AddChunk(chunk); - if(pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(&pCreateInfos[i]); + + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { if(pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { @@ -933,14 +941,17 @@ bool WrappedVulkan::Serialise_vkCreateComputePipelines(SerialiserType &ser, VkDe // don't use pipeline caches on replay pipelineCache = VK_NULL_HANDLE; + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(&CreateInfo); + // if we have pipeline executable properties, capture the data if(GetExtensions(NULL).ext_KHR_pipeline_executable_properties) { - CreateInfo.flags |= (VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR | - VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR); + flags |= (VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR | + VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR); } VkComputePipelineCreateInfo *unwrapped = UnwrapInfos(m_State, &CreateInfo, 1); + SetPipelineCreateFlags(unwrapped, flags); VkResult ret = ObjDisp(device)->CreateComputePipelines(Unwrap(device), Unwrap(pipelineCache), 1, unwrapped, NULL, &pipe); @@ -1019,7 +1030,7 @@ bool WrappedVulkan::Serialise_vkCreateComputePipelines(SerialiserType &ser, VkDe DerivedResource(device, Pipeline); if(origCache != VK_NULL_HANDLE) DerivedResource(origCache, Pipeline); - if(CreateInfo.flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { if(CreateInfo.basePipelineHandle != VK_NULL_HANDLE) DerivedResource(CreateInfo.basePipelineHandle, Pipeline); @@ -1059,7 +1070,9 @@ VkResult WrappedVulkan::vkCreateComputePipelines(VkDevice device, VkPipelineCach VkComputePipelineCreateInfo modifiedCreateInfo; const VkComputePipelineCreateInfo *createInfo = &pCreateInfos[i]; - if(createInfo->flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(createInfo); + + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { // since we serialise one by one, we need to fixup basePipelineIndex if(createInfo->basePipelineIndex != -1 && createInfo->basePipelineIndex < (int)i) @@ -1088,7 +1101,9 @@ VkResult WrappedVulkan::vkCreateComputePipelines(VkDevice device, VkPipelineCach record->AddParent(cacherecord); } - if(pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) + VkPipelineCreateFlags2KHR flags = GetPipelineCreateFlags(&pCreateInfos[i]); + + if(flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { if(pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index f55a517d501..311f8d41ce3 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -1953,9 +1953,10 @@ void DoSerialise(SerialiserType &ser, VKPipe::IndexBuffer &el) { SERIALISE_MEMBER(resourceId); SERIALISE_MEMBER(byteOffset); + SERIALISE_MEMBER(byteSize); SERIALISE_MEMBER(byteStride); - SIZE_CHECK(24); + SIZE_CHECK(32); } template @@ -1965,7 +1966,7 @@ void DoSerialise(SerialiserType &ser, VKPipe::InputAssembly &el) SERIALISE_MEMBER(indexBuffer); SERIALISE_MEMBER(topology); - SIZE_CHECK(40); + SIZE_CHECK(48); } template @@ -2286,7 +2287,7 @@ void DoSerialise(SerialiserType &ser, VKPipe::State &el) SERIALISE_MEMBER(conditionalRendering); - SIZE_CHECK(1744); + SIZE_CHECK(1752); } #pragma endregion Vulkan pipeline state