Commit de52ca37 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix GraphViz dump in presence of queries and fences

A previous refactor made queries no longer a graph resource. This in turn meant that the query nodes no longer had an ID, which tripped up the ID assignment when dumping the graph. This affected fences as well. Bug: angleproject:2853 Change-Id: I359f8145dca068edaa5fcd5bcb0a231ee050ab76 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1520990 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 2fb6563b
...@@ -617,11 +617,12 @@ CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function) ...@@ -617,11 +617,12 @@ CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function)
return newCommands; return newCommands;
} }
CommandGraphNode *CommandGraph::allocateBarrierNode(CommandGraphResourceType resourceType, CommandGraphNode *CommandGraph::allocateBarrierNode(CommandGraphNodeFunction function,
CommandGraphNodeFunction function) CommandGraphResourceType resourceType,
uintptr_t resourceID)
{ {
CommandGraphNode *newNode = allocateNode(function); CommandGraphNode *newNode = allocateNode(function);
newNode->setDiagnosticInfo(resourceType, 0); newNode->setDiagnosticInfo(resourceType, resourceID);
setNewBarrier(newNode); setNewBarrier(newNode);
return newNode; return newNode;
...@@ -754,65 +755,68 @@ void CommandGraph::clear() ...@@ -754,65 +755,68 @@ void CommandGraph::clear()
void CommandGraph::beginQuery(const QueryPool *queryPool, uint32_t queryIndex) void CommandGraph::beginQuery(const QueryPool *queryPool, uint32_t queryIndex)
{ {
CommandGraphNode *newNode = CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::BeginQuery,
allocateBarrierNode(CommandGraphResourceType::Query, CommandGraphNodeFunction::BeginQuery); CommandGraphResourceType::Query, 0);
newNode->setQueryPool(queryPool, queryIndex); newNode->setQueryPool(queryPool, queryIndex);
} }
void CommandGraph::endQuery(const QueryPool *queryPool, uint32_t queryIndex) void CommandGraph::endQuery(const QueryPool *queryPool, uint32_t queryIndex)
{ {
CommandGraphNode *newNode = CommandGraphNode *newNode =
allocateBarrierNode(CommandGraphResourceType::Query, CommandGraphNodeFunction::EndQuery); allocateBarrierNode(CommandGraphNodeFunction::EndQuery, CommandGraphResourceType::Query, 0);
newNode->setQueryPool(queryPool, queryIndex); newNode->setQueryPool(queryPool, queryIndex);
} }
void CommandGraph::writeTimestamp(const QueryPool *queryPool, uint32_t queryIndex) void CommandGraph::writeTimestamp(const QueryPool *queryPool, uint32_t queryIndex)
{ {
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::Query, CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::WriteTimestamp,
CommandGraphNodeFunction::WriteTimestamp); CommandGraphResourceType::Query, 0);
newNode->setQueryPool(queryPool, queryIndex); newNode->setQueryPool(queryPool, queryIndex);
} }
void CommandGraph::setFenceSync(const vk::Event &event) void CommandGraph::setFenceSync(const vk::Event &event)
{ {
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::FenceSync, CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::SetFenceSync,
CommandGraphNodeFunction::SetFenceSync); CommandGraphResourceType::FenceSync,
reinterpret_cast<uintptr_t>(&event));
newNode->setFenceSync(event); newNode->setFenceSync(event);
} }
void CommandGraph::waitFenceSync(const vk::Event &event) void CommandGraph::waitFenceSync(const vk::Event &event)
{ {
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::FenceSync, CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::WaitFenceSync,
CommandGraphNodeFunction::WaitFenceSync); CommandGraphResourceType::FenceSync,
reinterpret_cast<uintptr_t>(&event));
newNode->setFenceSync(event); newNode->setFenceSync(event);
} }
void CommandGraph::insertDebugMarker(GLenum source, std::string &&marker) void CommandGraph::insertDebugMarker(GLenum source, std::string &&marker)
{ {
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::DebugMarker, CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::InsertDebugMarker,
CommandGraphNodeFunction::InsertDebugMarker); CommandGraphResourceType::DebugMarker, 0);
newNode->setDebugMarker(source, std::move(marker)); newNode->setDebugMarker(source, std::move(marker));
} }
void CommandGraph::pushDebugMarker(GLenum source, std::string &&marker) void CommandGraph::pushDebugMarker(GLenum source, std::string &&marker)
{ {
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::DebugMarker, CommandGraphNode *newNode = allocateBarrierNode(CommandGraphNodeFunction::PushDebugMarker,
CommandGraphNodeFunction::PushDebugMarker); CommandGraphResourceType::DebugMarker, 0);
newNode->setDebugMarker(source, std::move(marker)); newNode->setDebugMarker(source, std::move(marker));
} }
void CommandGraph::popDebugMarker() void CommandGraph::popDebugMarker()
{ {
allocateBarrierNode(CommandGraphResourceType::DebugMarker, allocateBarrierNode(CommandGraphNodeFunction::PopDebugMarker,
CommandGraphNodeFunction::PopDebugMarker); CommandGraphResourceType::DebugMarker, 0);
} }
// Dumps the command graph into a dot file that works with graphviz. // Dumps the command graph into a dot file that works with graphviz.
void CommandGraph::dumpGraphDotFile(std::ostream &out) const void CommandGraph::dumpGraphDotFile(std::ostream &out) const
{ {
// This ID maps a node pointer to a monatonic ID. It allows us to look up parent node IDs. // This ID maps a node pointer to a monotonic ID. It allows us to look up parent node IDs.
std::map<const CommandGraphNode *, int> nodeIDMap; std::map<const CommandGraphNode *, int> nodeIDMap;
std::map<uintptr_t, int> objectIDMap; std::map<uintptr_t, int> objectIDMap;
std::map<std::pair<VkQueryPool, uint32_t>, int> queryIDMap;
// Map nodes to ids. // Map nodes to ids.
for (size_t nodeIndex = 0; nodeIndex < mNodes.size(); ++nodeIndex) for (size_t nodeIndex = 0; nodeIndex < mNodes.size(); ++nodeIndex)
...@@ -825,6 +829,7 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const ...@@ -825,6 +829,7 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const
int framebufferIDCounter = 1; int framebufferIDCounter = 1;
int imageIDCounter = 1; int imageIDCounter = 1;
int queryIDCounter = 1; int queryIDCounter = 1;
int fenceIDCounter = 1;
out << "digraph {" << std::endl; out << "digraph {" << std::endl;
...@@ -843,6 +848,29 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const ...@@ -843,6 +848,29 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const
strstr << " " << node->getDebugMarker(); strstr << " " << node->getDebugMarker();
} }
} }
else if (node->getResourceTypeForDiagnostics() == CommandGraphResourceType::Query)
{
// Special case for queries as they cannot generate a resource ID at creation time that
// would reliably fit in a uintptr_t.
strstr << " ";
ASSERT(node->getResourceIDForDiagnostics() == 0);
auto queryID = std::make_pair(node->getQueryPool(), node->getQueryIndex());
auto it = queryIDMap.find(queryID);
if (it != queryIDMap.end())
{
strstr << it->second;
}
else
{
int id = queryIDCounter++;
queryIDMap[queryID] = id;
strstr << id;
}
}
else else
{ {
strstr << " "; strstr << " ";
...@@ -870,8 +898,8 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const ...@@ -870,8 +898,8 @@ void CommandGraph::dumpGraphDotFile(std::ostream &out) const
case CommandGraphResourceType::Image: case CommandGraphResourceType::Image:
id = imageIDCounter++; id = imageIDCounter++;
break; break;
case CommandGraphResourceType::Query: case CommandGraphResourceType::FenceSync:
id = queryIDCounter++; id = fenceIDCounter++;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
......
...@@ -134,6 +134,8 @@ class CommandGraphNode final : angle::NonCopyable ...@@ -134,6 +134,8 @@ class CommandGraphNode final : angle::NonCopyable
CommandGraphNodeFunction getFunction() const { return mFunction; } CommandGraphNodeFunction getFunction() const { return mFunction; }
void setQueryPool(const QueryPool *queryPool, uint32_t queryIndex); void setQueryPool(const QueryPool *queryPool, uint32_t queryIndex);
VkQueryPool getQueryPool() const { return mQueryPool; }
uint32_t getQueryIndex() const { return mQueryIndex; }
void setFenceSync(const vk::Event &event); void setFenceSync(const vk::Event &event);
void setDebugMarker(GLenum source, std::string &&marker); void setDebugMarker(GLenum source, std::string &&marker);
const std::string &getDebugMarker() const { return mDebugMarker; } const std::string &getDebugMarker() const { return mDebugMarker; }
...@@ -384,8 +386,9 @@ class CommandGraph final : angle::NonCopyable ...@@ -384,8 +386,9 @@ class CommandGraph final : angle::NonCopyable
void popDebugMarker(); void popDebugMarker();
private: private:
CommandGraphNode *allocateBarrierNode(CommandGraphResourceType resourceType, CommandGraphNode *allocateBarrierNode(CommandGraphNodeFunction function,
CommandGraphNodeFunction function); CommandGraphResourceType resourceType,
uintptr_t resourceID);
void setNewBarrier(CommandGraphNode *newBarrier); void setNewBarrier(CommandGraphNode *newBarrier);
CommandGraphNode *getLastBarrierNode(size_t *indexOut); CommandGraphNode *getLastBarrierNode(size_t *indexOut);
void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier); void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
......
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