From da299d4f14046cf7d78a9794c68265677e74a9eb 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 | 11 ++- renderdoc/api/replay/pipestate.inl | 2 +- renderdoc/api/replay/vk_pipestate.h | 3 + .../shaders/spirv/spirv_debug_setup.cpp | 9 ++ renderdoc/driver/vulkan/extension_support.md | 2 +- renderdoc/driver/vulkan/vk_common.h | 1 + renderdoc/driver/vulkan/vk_core.cpp | 4 + renderdoc/driver/vulkan/vk_core.h | 14 +++ renderdoc/driver/vulkan/vk_hookset_defs.h | 18 +++- renderdoc/driver/vulkan/vk_layer.cpp | 13 ++- 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_state.cpp | 15 ++- renderdoc/driver/vulkan/vk_state.h | 1 + renderdoc/driver/vulkan/vk_stringise.cpp | 3 +- .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 92 +++++++++++++++++++ .../driver/vulkan/wrappers/vk_get_funcs.cpp | 22 +++++ renderdoc/replay/renderdoc_serialise.inl | 7 +- 19 files changed, 221 insertions(+), 22 deletions(-) diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index f1136fd5ea4..96a0a473ea9 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -41,6 +41,13 @@ Q_DECLARE_METATYPE(CombinedSamplerData); namespace { + +template +T RDCMIN(const T &a, const T &b) +{ + return a < b ? a : b; +} + QString getTextureRenderSamples(const TextureDescription *tex, const VKPipe::RenderPass &renderpass) { const uint32_t texSamples = tex ? tex->msSamp : 1; @@ -2411,7 +2418,7 @@ void VulkanPipelineStateViewer::setState() BufferDescription *buf = m_Ctx.GetBuffer(state.inputAssembly.indexBuffer.resourceId); if(buf) - length = buf->length; + length = RDCMIN(buf->length, state.inputAssembly.indexBuffer.byteSize); RDTreeWidgetItem *node = new RDTreeWidgetItem( {tr("Index"), state.inputAssembly.indexBuffer.resourceId, tr("Index"), lit("-"), @@ -3802,7 +3809,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe:: if(ib) { name = m_Ctx.GetResourceName(ia.indexBuffer.resourceId); - length = ib->length; + length = RDCMIN(ib->length, ia.indexBuffer.byteSize); } QString ifmt = lit("UNKNOWN"); diff --git a/renderdoc/api/replay/pipestate.inl b/renderdoc/api/replay/pipestate.inl index 1724d378a34..f4e23163ef7 100644 --- a/renderdoc/api/replay/pipestate.inl +++ b/renderdoc/api/replay/pipestate.inl @@ -582,7 +582,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 248f93d67b8..8c262911de0 100644 --- a/renderdoc/api/replay/vk_pipestate.h +++ b/renderdoc/api/replay/vk_pipestate.h @@ -411,6 +411,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/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index 9c9311c2223..25af6107eed 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -1009,6 +1009,15 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s outputIDs.push_back(v.id); liveGlobals.push_back(v.id); pointerIDs.push_back(THREAD_POINTER(v.id, outputs)); + + // VK_KHR_maintenance5 requires that if PointSize is not written during shader execution, it should be 1.0f + // so we will initialize it to 1.0f here (if it is not enabled then leaving it as 1.0f is harmless) + if(decorations[v.id].flags & Decorations::HasBuiltIn && + decorations[v.id].builtIn == BuiltIn::PointSize) + { + ShaderVariable &pointSize = active.outputs.back(); + pointSize.value.f32v[0] = 1.0f; + } } } diff --git a/renderdoc/driver/vulkan/extension_support.md b/renderdoc/driver/vulkan/extension_support.md index 59cc683d7f5..a49791c3687 100644 --- a/renderdoc/driver/vulkan/extension_support.md +++ b/renderdoc/driver/vulkan/extension_support.md @@ -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` @@ -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` diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index 7ad7d80b538..44f23119734 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -978,6 +978,7 @@ enum class VulkanChunk : uint32_t vkCmdDrawMeshTasksEXT, vkCmdDrawMeshTasksIndirectEXT, vkCmdDrawMeshTasksIndirectCountEXT, + vkCmdBindIndexBuffer2KHR, Max, }; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 6c9943e498a..2271ccc55d8 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -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: diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 854ba15103f..afc9d8e56c6 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -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); }; diff --git a/renderdoc/driver/vulkan/vk_hookset_defs.h b/renderdoc/driver/vulkan/vk_hookset_defs.h index 0eebcebaa29..abb7872a23b 100644 --- a/renderdoc/driver/vulkan/vk_hookset_defs.h +++ b/renderdoc/driver/vulkan/vk_hookset_defs.h @@ -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 @@ -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); \ @@ -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(); \ @@ -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(); \ diff --git a/renderdoc/driver/vulkan/vk_layer.cpp b/renderdoc/driver/vulkan/vk_layer.cpp index 487618ed0d0..09c765d12a5 100644 --- a/renderdoc/driver/vulkan/vk_layer.cpp +++ b/renderdoc/driver/vulkan/vk_layer.cpp @@ -413,6 +413,16 @@ 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; + + PFN_vkGetDeviceProcAddr gpa = GetDeviceDispatchTable(Unwrap(device))->GetDeviceProcAddr; + + // if GPA returns NULL, that means that the standard prohibits non-NULL values for this pName + // or that the return value is undefined + if(!gpa || !gpa(Unwrap(device), pName)) + return NULL; + if(!strcmp("vkGetDeviceProcAddr", pName)) return (PFN_vkVoidFunction)&VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr; if(!strcmp("vkCreateDevice", pName)) @@ -422,9 +432,6 @@ VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr(VkDevice device, const char *pName) HookInitVulkanDevice(); - if(device == VK_NULL_HANDLE) - return NULL; - InstanceDeviceInfo *instDevInfo = GetRecord(device)->instDevInfo; DeclExts(); diff --git a/renderdoc/driver/vulkan/vk_overlay.cpp b/renderdoc/driver/vulkan/vk_overlay.cpp index fdc1907db1d..a249b7748e8 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(static_cast(data_len)); + memset(indices.data() + len, 0, static_cast(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 9c6c93713aa..57ec51e7237 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -4331,8 +4331,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 107779623d8..25d04f4fd20 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -1185,6 +1185,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_state.cpp b/renderdoc/driver/vulkan/vk_state.cpp index 3ebc509c96c..e00384a9596 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, @@ -606,9 +605,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 b639a7fa44c..650a6f68487 100644 --- a/renderdoc/driver/vulkan/vk_state.h +++ b/renderdoc/driver/vulkan/vk_state.h @@ -150,6 +150,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 a046586bfb9..505330d69e8 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 == 1201, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1202, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(VulkanChunk) { @@ -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() diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 738979709cc..62773d0a7a1 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -3893,6 +3893,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, @@ -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); diff --git a/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp index 779cf784b6b..a48c856ea46 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_get_funcs.cpp @@ -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); +} diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index 1a3ca2459d4..51937c60331 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -2058,9 +2058,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 @@ -2070,7 +2071,7 @@ void DoSerialise(SerialiserType &ser, VKPipe::InputAssembly &el) SERIALISE_MEMBER(indexBuffer); SERIALISE_MEMBER(topology); - SIZE_CHECK(40); + SIZE_CHECK(48); } template @@ -2409,7 +2410,7 @@ void DoSerialise(SerialiserType &ser, VKPipe::State &el) SERIALISE_MEMBER(conditionalRendering); - SIZE_CHECK(2712); + SIZE_CHECK(2720); } #pragma endregion Vulkan pipeline state