Skip to content

Commit

Permalink
add VK_KHR_maintenance5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
qbojj committed Feb 14, 2024
1 parent 226bf70 commit a49e3d1
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 4 deletions.
2 changes: 1 addition & 1 deletion renderdoc/driver/vulkan/extension_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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 @@ -235,7 +236,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
1 change: 1 addition & 0 deletions renderdoc/driver/vulkan/vk_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ enum class VulkanChunk : uint32_t
vkCmdDrawMeshTasksEXT,
vkCmdDrawMeshTasksIndirectEXT,
vkCmdDrawMeshTasksIndirectCountEXT,
vkCmdBindIndexBuffer2KHR,
Max,
};

Expand Down
4 changes: 4 additions & 0 deletions renderdoc/driver/vulkan/vk_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3989,6 +3989,10 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk)
return Serialise_vkCmdSetTessellationDomainOriginEXT(ser, VK_NULL_HANDLE,
VK_TESSELLATION_DOMAIN_ORIGIN_MAX_ENUM);

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
14 changes: 14 additions & 0 deletions renderdoc/driver/vulkan/vk_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2812,4 +2812,18 @@ class WrappedVulkan : public IFrameCapturer
VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
VkBuffer countBuffer, VkDeviceSize countBufferOffset,
uint32_t maxDrawCount, uint32_t stride);

// VK_KHR_mainenance5
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);
};
18 changes: 16 additions & 2 deletions renderdoc/driver/vulkan/vk_hookset_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@
DeclExt(EXT_scalar_block_layout); \
DeclExt(KHR_vertex_attribute_divisor); \
DeclExt(KHR_line_rasterization); \
DeclExt(KHR_calibrated_timestamps);
DeclExt(KHR_calibrated_timestamps); \
DeclExt(KHR_maintenance5);

// for simplicity and since the check itself is platform agnostic,
// these aren't protected in platform defines
Expand Down Expand Up @@ -679,7 +680,8 @@
CheckExt(EXT_scalar_block_layout, VK12); \
CheckExt(KHR_vertex_attribute_divisor, VKXX); \
CheckExt(KHR_line_rasterization, VKXX); \
CheckExt(KHR_calibrated_timestamps, VKXX);
CheckExt(KHR_calibrated_timestamps, VKXX); \
CheckExt(KHR_maintenance5, VKXX);

#define HookInitVulkanInstanceExts_PhysDev() \
HookInitExtension(KHR_surface, GetPhysicalDeviceSurfaceSupportKHR); \
Expand Down Expand Up @@ -982,6 +984,10 @@
HookInitExtension(KHR_calibrated_timestamps, GetCalibratedTimestampsKHR); \
HookInitExtension(KHR_line_rasterization, CmdSetLineStippleKHR); \
HookInitExtensionEXTtoKHR(CmdSetLineStipple); \
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(); \
Expand Down Expand Up @@ -1790,6 +1796,14 @@
uint64_t *, pMaxDeviation); \
HookDefine3(void, vkCmdSetLineStippleKHR, VkCommandBuffer, commandBuffer, uint32_t, \
lineStippleFactor, uint16_t, lineStipplePattern); \
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(); \
Expand Down
1 change: 1 addition & 0 deletions renderdoc/driver/vulkan/vk_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct VulkanRenderState
{
ResourceId buf;
VkDeviceSize offs = 0;
VkDeviceSize size = VK_WHOLE_SIZE;
int bytewidth = 0;
} ibuffer;

Expand Down
3 changes: 2 additions & 1 deletion renderdoc/driver/vulkan/vk_stringise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
template <>
rdcstr DoStringise(const VulkanChunk &el)
{
RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1201, "Chunks changed without updating names");
RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1202, "Chunks changed without updating names");

BEGIN_ENUM_STRINGISE(VulkanChunk)
{
Expand Down Expand Up @@ -233,6 +233,7 @@ rdcstr DoStringise(const VulkanChunk &el)
STRINGISE_ENUM_CLASS(vkCmdDrawMeshTasksEXT)
STRINGISE_ENUM_CLASS(vkCmdDrawMeshTasksIndirectEXT)
STRINGISE_ENUM_CLASS(vkCmdDrawMeshTasksIndirectCountEXT)
STRINGISE_ENUM_CLASS(vkCmdBindIndexBuffer2KHR)
STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk");
}
END_ENUM_STRINGISE()
Expand Down
92 changes: 92 additions & 0 deletions renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3893,6 +3893,94 @@ void WrappedVulkan::vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer
}
}

template <typename SerialiserType>
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 <typename SerialiserType>
bool WrappedVulkan::Serialise_vkCmdPushConstants(SerialiserType &ser, VkCommandBuffer commandBuffer,
VkPipelineLayout layout,
Expand Down Expand Up @@ -7733,3 +7821,7 @@ INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdBeginRendering, VkCommandBuffer comma
const VkRenderingInfo *pRenderingInfo);

INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdEndRendering, VkCommandBuffer commandBuffer);

INSTANTIATE_FUNCTION_SERIALISED(void, vkCmdBindIndexBuffer2KHR, VkCommandBuffer commandBuffer,
VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size,
VkIndexType indexType);
22 changes: 22 additions & 0 deletions renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,3 +1171,25 @@ VkResult WrappedVulkan::vkGetPhysicalDeviceFragmentShadingRatesKHR(
->GetPhysicalDeviceFragmentShadingRatesKHR(Unwrap(physicalDevice), pFragmentShadingRateCount,
pFragmentShadingRates);
}

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);
}

0 comments on commit a49e3d1

Please sign in to comment.