Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add VK_KHR_maintenance5 support #3251

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,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("-"),
Expand Down Expand Up @@ -3461,7 +3461,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");
Expand Down
2 changes: 1 addition & 1 deletion renderdoc/api/replay/pipestate.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
5 changes: 4 additions & 1 deletion renderdoc/api/replay/vk_pipestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
)");
Expand Down
2 changes: 1 addition & 1 deletion renderdoc/driver/vulkan/extension_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,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`
Expand Down Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions renderdoc/driver/vulkan/vk_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void GPUBuffer::Create(WrappedVulkan *driver, VkDevice dev, VkDeviceSize size, u
else
allocInfo.memoryTypeIndex = driver->GetUploadMemoryIndex(mrq.memoryTypeBits);

bool useBufferAddressKHR = driver->GetExtensions(NULL).ext_KHR_buffer_device_address;
bool useBufferAddressKHR = driver->GetExtensions(NULL).ext_KHR_buffer_device_address != 0;

VkMemoryAllocateFlagsInfo memFlags = {VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO};
if(useBufferAddressKHR && (flags & eGPUBufferAddressable))
Expand Down Expand Up @@ -931,7 +931,7 @@ rdcstr HumanDriverName(VkDriverId driverId)
return "";
}

BASIC_TYPE_SERIALISE_STRINGIFY(VkPackedVersion, (uint32_t &)el, SDBasic::UnsignedInteger, 4);
BASIC_TYPE_SERIALISE_STRINGIFY(VkPackedVersion, el.version, SDBasic::UnsignedInteger, 4);

INSTANTIATE_SERIALISE_TYPE(VkPackedVersion);

Expand Down
40 changes: 40 additions & 0 deletions renderdoc/driver/vulkan/vk_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -84,6 +86,8 @@
#undef VkAccessFlagBits2
#undef VkPipelineStageFlagBits2
#undef VkFormatFeatureFlagBits2
#undef VkBufferUsageFlagBits2KHR
#undef VkPipelineCreateFlagBits2KHR

#undef Bool
#undef None
Expand Down Expand Up @@ -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) {}
Expand Down Expand Up @@ -1087,6 +1099,7 @@ enum class VulkanChunk : uint32_t
vkCmdTraceRaysIndirectKHR,
vkCmdTraceRaysKHR,
vkCreateRayTracingPipelinesKHR,
vkCmdBindIndexBuffer2KHR,
Max,
};

Expand Down Expand Up @@ -1581,6 +1594,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);
Expand Down Expand Up @@ -2018,6 +2039,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);
Expand Down Expand Up @@ -2106,6 +2135,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<VkAccelerationStructureBuildRangeInfoKHR>);
Expand Down Expand Up @@ -2196,6 +2226,14 @@ enum VkFormatFeatureFlagBits2 : uint64_t
{
};

enum VkBufferUsageFlagBits2KHR : uint64_t
{
};

enum VkPipelineCreateFlagBits2KHR : uint64_t
{
};

// enums

DECLARE_REFLECTION_ENUM(VkAccelerationStructureBuildTypeKHR);
Expand Down Expand Up @@ -2353,6 +2391,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
Expand Down
90 changes: 90 additions & 0 deletions renderdoc/driver/vulkan/vk_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "stb/stb_image_write.h"

#include <assert.h>

RDOC_EXTERN_CONFIG(bool, Replay_Debug_PrintChunkTimings);

RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording);
Expand Down Expand Up @@ -1538,6 +1540,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,
Expand Down Expand Up @@ -4159,6 +4165,10 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk)
return Serialise_vkCreateRayTracingPipelinesKHR(ser, VK_NULL_HANDLE, VK_NULL_HANDLE,
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:
Expand Down Expand Up @@ -5824,6 +5834,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
Expand Down
25 changes: 25 additions & 0 deletions renderdoc/driver/vulkan/vk_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,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,
Expand Down Expand Up @@ -2995,4 +3006,18 @@ class WrappedVulkan : public IFrameCapturer
VkDeviceSize vkGetRayTracingShaderGroupStackSizeKHR(VkDevice device, VkPipeline pipeline,
uint32_t group,
VkShaderGroupShaderKHR groupShader);

// 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);
};
4 changes: 2 additions & 2 deletions renderdoc/driver/vulkan/vk_dispatchtables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void InitInstanceExtensionTables(VkInstance instance, InstanceDeviceInfo *info)
instance = Unwrap(instance);

#undef DeclExt
#define DeclExt(name) \
bool name = false; \
#define DeclExt(name) \
ExtensionStatusFlags name = ExtensionStatusFlagBits::NotEnabled; \
(void)name;

#undef CheckExt
Expand Down
13 changes: 12 additions & 1 deletion renderdoc/driver/vulkan/vk_dispatchtables.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

// layer includes

#include <cstdint>
#if ENABLED(RDOC_WIN32)
// undefined clashing windows #defines
#undef CreateEvent
Expand All @@ -37,10 +38,20 @@

void InitReplayTables(void *vulkanModule);

// bitmask of extension enabled status
enum ExtensionStatusFlagBits
{
NotEnabled = 0,
ExplicitEnabled = 1 << 0,
PromotionEnabled = 1 << 1,
};

typedef uint8_t ExtensionStatusFlags;

struct InstanceDeviceInfo
{
#undef DeclExt
#define DeclExt(name) bool ext_##name = false;
#define DeclExt(name) ExtensionStatusFlags ext_##name = ExtensionStatusFlagBits::NotEnabled;

bool brokenGetDeviceProcAddr = false;

Expand Down
Loading