Add debug option to log command buffer recording on vulkan

This commit is contained in:
baldurk
2021-01-19 16:35:02 +00:00
parent ed50a0e01a
commit d607c7dfaa
3 changed files with 55 additions and 1 deletions
+12 -1
View File
@@ -25,6 +25,7 @@
#include "vk_core.h"
#include <ctype.h>
#include <algorithm>
#include "core/settings.h"
#include "driver/ihv/amd/amd_rgp.h"
#include "driver/shaders/spirv/spirv_compile.h"
#include "jpeg-compressor/jpge.h"
@@ -36,6 +37,8 @@
#include "stb/stb_image_write.h"
RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording);
uint64_t VkInitParams::GetSerialiseSize()
{
// misc bytes and fixed integer members
@@ -2055,8 +2058,16 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
// otherwise order must be preserved (vs. queue submits and desc set updates)
for(size_t i = 0; i < m_CmdBufferRecords.size(); i++)
{
RDCDEBUG("Adding chunks from command buffer %s",
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("Adding chunks from command buffer %s",
ToStr(m_CmdBufferRecords[i]->GetResourceID()).c_str());
}
else
{
RDCDEBUG("Adding chunks from command buffer %s",
ToStr(m_CmdBufferRecords[i]->GetResourceID()).c_str());
}
size_t prevSize = recordlist.size();
(void)prevSize;
@@ -24,6 +24,11 @@
#include "../vk_core.h"
#include "../vk_debug.h"
#include "core/settings.h"
RDOC_DEBUG_CONFIG(
bool, Vulkan_Debug_VerboseCommandRecording, false,
"Add verbose logging around recording and submission of command buffers in vulkan.");
static rdcstr ToHumanStr(const VkAttachmentLoadOp &el)
{
@@ -544,6 +549,11 @@ VkResult WrappedVulkan::vkCreateCommandPool(VkDevice device,
VkResult WrappedVulkan::vkResetCommandPool(VkDevice device, VkCommandPool cmdPool,
VkCommandPoolResetFlags flags)
{
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("Reset command pool %s", ToStr(GetResID(cmdPool)).c_str());
}
if(Atomic::CmpExch32(&m_ReuseEnabled, 1, 1) == 1)
GetRecord(cmdPool)->cmdPoolInfo->pool.Reset();
@@ -672,6 +682,12 @@ VkResult WrappedVulkan::vkAllocateCommandBuffers(VkDevice device,
record->pool = GetRecord(pAllocateInfo->commandPool);
allocRecord->AddParent(record->pool);
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("Allocate command buffer %s from pool %s", ToStr(record->GetResourceID()).c_str(),
ToStr(record->pool->GetResourceID()).c_str());
}
{
record->pool->LockChunks();
record->pool->pooledChildren.push_back(record);
@@ -1033,6 +1049,12 @@ VkResult WrappedVulkan::vkBeginCommandBuffer(VkCommandBuffer commandBuffer,
record->bakedCommands->cmdInfo->beginCapture = false;
record->bakedCommands->cmdInfo->endCapture = false;
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("Begin command buffer %s baked to %s", ToStr(record->GetResourceID()).c_str(),
ToStr(record->bakedCommands->GetResourceID()).c_str());
}
{
CACHE_THREAD_SERIALISER();
@@ -1232,6 +1254,12 @@ VkResult WrappedVulkan::vkEndCommandBuffer(VkCommandBuffer commandBuffer)
// ensure that we have a matching begin
RDCASSERT(record->bakedCommands);
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("End command buffer %s baked to %s", ToStr(record->GetResourceID()).c_str(),
ToStr(record->bakedCommands->GetResourceID()).c_str());
}
{
CACHE_THREAD_SERIALISER();
ser.SetDrawChunk();
@@ -1255,6 +1283,13 @@ VkResult WrappedVulkan::vkResetCommandBuffer(VkCommandBuffer commandBuffer,
if(record)
{
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG(
"Reset command buffer %s (baked was %s)", ToStr(record->GetResourceID()).c_str(),
ToStr(record->bakedCommands ? record->bakedCommands->GetResourceID() : ResourceId()).c_str());
}
// all we need to do is remove the existing baked commands.
// The application will still need to call begin command buffer itself.
// this function is essentially a driver hint as it cleans up implicitly
@@ -29,6 +29,7 @@
RDOC_CONFIG(bool, Vulkan_HideCommandBoundaries, false,
"Hides the auto-generated submitted command buffer boundaries.");
RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording);
template <typename SerialiserType>
bool WrappedVulkan::Serialise_vkGetDeviceQueue(SerialiserType &ser, VkDevice device,
@@ -934,6 +935,13 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
UpdateImageStates(record->bakedCommands->cmdInfo->imageStates);
if(Vulkan_Debug_VerboseCommandRecording())
{
RDCLOG("vkQueueSubmit() to queue %s, submit %u / cmd %u: %s baked to %s",
ToStr(GetResID(queue)).c_str(), s, i, ToStr(record->GetResourceID()).c_str(),
ToStr(record->bakedCommands->GetResourceID()).c_str());
}
if(capframe)
{
// add the bound descriptor sets