Commit e810ad90 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: dump summary of commands in digraph

This is possible thanks to SecondaryCommandBuffer. Makes life easier when debugging by not just showing resource type in the nodes, but actual stream of commands recorded in each. Bug: angleproject:3136 Change-Id: I125a32ec2966a55330e60930ca088d1a3673a8ba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1538832 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 02a579e9
......@@ -158,6 +158,18 @@ void ExecuteCommands(PrimaryCommandBuffer *primCmdBuffer, priv::CommandBuffer *s
primCmdBuffer->executeCommands(1, secCmdBuffer);
}
ANGLE_MAYBE_UNUSED
std::string DumpCommands(const priv::SecondaryCommandBuffer &commandBuffer, const char *separator)
{
return commandBuffer.dumpCommands(separator);
}
ANGLE_MAYBE_UNUSED
std::string DumpCommands(const priv::CommandBuffer &commandBuffer, const char *separator)
{
return "--blob--";
}
} // anonymous namespace
// CommandGraphResource implementation.
......@@ -622,6 +634,24 @@ void CommandGraphNode::setDiagnosticInfo(CommandGraphResourceType resourceType,
mResourceID = resourceID;
}
std::string CommandGraphNode::dumpCommandsForDiagnostics(const char *separator) const
{
std::string result;
if (mOutsideRenderPassCommands.valid())
{
result += separator;
result += "Outside RP:";
result += DumpCommands(mOutsideRenderPassCommands, separator);
}
if (mInsideRenderPassCommands.valid())
{
result += separator;
result += "Inside RP:";
result += DumpCommands(mInsideRenderPassCommands, separator);
}
return result;
}
const gl::Rectangle &CommandGraphNode::getRenderPassRenderArea() const
{
return mRenderPassRenderArea;
......@@ -951,8 +981,8 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const
}
const std::string &label = strstr.str();
out << " " << nodeID << "[label =<" << label << "<BR/> <FONT POINT-SIZE=\"10\">Node ID "
<< nodeID << "</FONT>>];" << std::endl;
out << " " << nodeID << "[label =<" << label << "<BR/><FONT POINT-SIZE=\"10\">Node ID "
<< nodeID << node->dumpCommandsForDiagnostics("<BR/>") << "</FONT>>];" << std::endl;
}
for (const CommandGraphNode *node : mNodes)
......
......@@ -136,6 +136,7 @@ class CommandGraphNode final : angle::NonCopyable
CommandGraphResourceType getResourceTypeForDiagnostics() const { return mResourceType; }
uintptr_t getResourceIDForDiagnostics() const { return mResourceID; }
std::string dumpCommandsForDiagnostics(const char *separator) const;
const gl::Rectangle &getRenderPassRenderArea() const;
......
......@@ -305,6 +305,119 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
}
}
std::string SecondaryCommandBuffer::dumpCommands(const char *separator) const
{
std::string result;
for (const CommandHeader *command : mCommands)
{
for (const CommandHeader *currentCommand = command;
currentCommand->id != CommandID::Invalid; currentCommand = NextCommand(currentCommand))
{
result += separator;
switch (currentCommand->id)
{
case CommandID::BeginQuery:
result += "BeginQuery";
break;
case CommandID::BindComputeDescriptorSets:
result += "BindComputeDescriptorSets";
break;
case CommandID::BindComputePipeline:
result += "BindComputePipeline";
break;
case CommandID::BindGraphicsDescriptorSets:
result += "BindGraphicsDescriptorSets";
break;
case CommandID::BindGraphicsPipeline:
result += "BindGraphicsPipeline";
break;
case CommandID::BindIndexBuffer:
result += "BindIndexBuffer";
break;
case CommandID::BindVertexBuffers:
result += "BindVertexBuffers";
break;
case CommandID::BlitImage:
result += "BlitImage";
break;
case CommandID::ClearAttachments:
result += "ClearAttachments";
break;
case CommandID::ClearColorImage:
result += "ClearColorImage";
break;
case CommandID::ClearDepthStencilImage:
result += "ClearDepthStencilImage";
break;
case CommandID::CopyBuffer:
result += "CopyBuffer";
break;
case CommandID::CopyBufferToImage:
result += "CopyBufferToImage";
break;
case CommandID::CopyImage:
result += "CopyImage";
break;
case CommandID::CopyImageToBuffer:
result += "CopyImageToBuffer";
break;
case CommandID::Dispatch:
result += "Dispatch";
break;
case CommandID::Draw:
result += "Draw";
break;
case CommandID::DrawIndexed:
result += "DrawIndexed";
break;
case CommandID::DrawIndexedInstanced:
result += "DrawIndexedInstanced";
break;
case CommandID::DrawInstanced:
result += "DrawInstanced";
break;
case CommandID::EndQuery:
result += "EndQuery";
break;
case CommandID::ImageBarrier:
result += "ImageBarrier";
break;
case CommandID::MemoryBarrier:
result += "MemoryBarrier";
break;
case CommandID::PipelineBarrier:
result += "PipelineBarrier";
break;
case CommandID::PushConstants:
result += "PushConstants";
break;
case CommandID::ResetEvent:
result += "ResetEvent";
break;
case CommandID::ResetQueryPool:
result += "ResetQueryPool";
break;
case CommandID::SetEvent:
result += "SetEvent";
break;
case CommandID::WaitEvents:
result += "WaitEvents";
break;
case CommandID::WriteTimestamp:
result += "WriteTimestamp";
break;
default:
{
UNREACHABLE();
result += "--invalid--";
break;
}
}
}
}
return result;
}
} // namespace priv
} // namespace vk
} // namespace rx
......@@ -464,6 +464,10 @@ class SecondaryCommandBuffer final : angle::NonCopyable
// Parse the cmds in this cmd buffer into given primary cmd buffer for execution
void executeCommands(VkCommandBuffer cmdBuffer);
// Traverse the list of commands and build a summary for diagnostics.
std::string dumpCommands(const char *separator) const;
// Pool Alloc uses 16kB pages w/ 16byte header = 16368bytes. To minimize waste
// using a 16368/12 = 1364. Also better perf than 1024 due to fewer block allocations
static constexpr size_t kBlockSize = 1364;
......@@ -483,7 +487,7 @@ class SecondaryCommandBuffer final : angle::NonCopyable
// This will cause the SecondaryCommandBuffer to become invalid by clearing its allocator
void releaseHandle() { mAllocator = nullptr; }
// The SecondaryCommandBuffer is valid if it's been initialized
bool valid() { return mAllocator != nullptr; }
bool valid() const { return mAllocator != nullptr; }
private:
template <class StructType>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment