Skip to content

Commit

Permalink
Vulkan: dump summary of commands in digraph
Browse files Browse the repository at this point in the history
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: Shahbaz Youssefi <syoussefi@chromium.org>
  • Loading branch information
ShabbyX authored and Commit Bot committed Mar 28, 2019
1 parent 02a579e commit e810ad9
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 3 deletions.
34 changes: 32 additions & 2 deletions src/libANGLE/renderer/vulkan/CommandGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/libANGLE/renderer/vulkan/CommandGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
113 changes: 113 additions & 0 deletions src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>
Expand Down

0 comments on commit e810ad9

Please sign in to comment.