Commit c81e7bfe by Shahbaz Youssefi Committed by Commit Bot

Vulkan: refactor CommandGraphResource

Merged back RecordableGraphResource into CommandGraphResource. Queries didn't really need to be a resource, as they always inserted separate single-command nodes in the graph. The CommandGraph class is augmented with a few functions that generate such nodes. This is in preparation for debug markers, as they too require such nodes. Bug: angleproject:2853 Change-Id: I5251a0e0fdd42ed1126921b4acc13687a14af9cd Reviewed-on: https://chromium-review.googlesource.com/c/1422549 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 37d2e606
...@@ -83,7 +83,7 @@ const char *GetResourceTypeName(CommandGraphResourceType resourceType, ...@@ -83,7 +83,7 @@ const char *GetResourceTypeName(CommandGraphResourceType resourceType,
// CommandGraphResource implementation. // CommandGraphResource implementation.
CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType) CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType)
: mResourceType(resourceType), mCurrentWritingNode(nullptr) : mCurrentWritingNode(nullptr), mResourceType(resourceType)
{} {}
CommandGraphResource::~CommandGraphResource() = default; CommandGraphResource::~CommandGraphResource() = default;
...@@ -93,22 +93,8 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const ...@@ -93,22 +93,8 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
return renderer->isSerialInUse(mStoredQueueSerial); return renderer->isSerialInUse(mStoredQueueSerial);
} }
bool CommandGraphResource::hasPendingWork(RendererVk *renderer) const angle::Result CommandGraphResource::recordCommands(Context *context,
{ CommandBuffer **commandBufferOut)
// If the renderer has a queue serial higher than the stored one, the command buffers recorded
// by this resource have already been submitted, so there is no pending work.
return mStoredQueueSerial == renderer->getCurrentQueueSerial();
}
// RecordableGraphResource implementation.
RecordableGraphResource::RecordableGraphResource(CommandGraphResourceType resourceType)
: CommandGraphResource(resourceType)
{}
RecordableGraphResource::~RecordableGraphResource() = default;
angle::Result RecordableGraphResource::recordCommands(Context *context,
CommandBuffer **commandBufferOut)
{ {
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial()); updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
...@@ -133,18 +119,18 @@ angle::Result RecordableGraphResource::recordCommands(Context *context, ...@@ -133,18 +119,18 @@ angle::Result RecordableGraphResource::recordCommands(Context *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
const gl::Rectangle &RecordableGraphResource::getRenderPassRenderArea() const const gl::Rectangle &CommandGraphResource::getRenderPassRenderArea() const
{ {
ASSERT(hasStartedRenderPass()); ASSERT(hasStartedRenderPass());
return mCurrentWritingNode->getRenderPassRenderArea(); return mCurrentWritingNode->getRenderPassRenderArea();
} }
angle::Result RecordableGraphResource::beginRenderPass(ContextVk *contextVk, angle::Result CommandGraphResource::beginRenderPass(ContextVk *contextVk,
const Framebuffer &framebuffer, const Framebuffer &framebuffer,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc, const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues, const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut) CommandBuffer **commandBufferOut)
{ {
// If a barrier has been inserted in the meantime, stop the command buffer. // If a barrier has been inserted in the meantime, stop the command buffer.
if (!hasChildlessWritingNode()) if (!hasChildlessWritingNode())
...@@ -161,7 +147,7 @@ angle::Result RecordableGraphResource::beginRenderPass(ContextVk *contextVk, ...@@ -161,7 +147,7 @@ angle::Result RecordableGraphResource::beginRenderPass(ContextVk *contextVk,
return mCurrentWritingNode->beginInsideRenderPassRecording(contextVk, commandBufferOut); return mCurrentWritingNode->beginInsideRenderPassRecording(contextVk, commandBufferOut);
} }
void RecordableGraphResource::addWriteDependency(RecordableGraphResource *writingResource) void CommandGraphResource::addWriteDependency(CommandGraphResource *writingResource)
{ {
CommandGraphNode *writingNode = writingResource->mCurrentWritingNode; CommandGraphNode *writingNode = writingResource->mCurrentWritingNode;
ASSERT(writingNode); ASSERT(writingNode);
...@@ -169,7 +155,7 @@ void RecordableGraphResource::addWriteDependency(RecordableGraphResource *writin ...@@ -169,7 +155,7 @@ void RecordableGraphResource::addWriteDependency(RecordableGraphResource *writin
onWriteImpl(writingNode, writingResource->getStoredQueueSerial()); onWriteImpl(writingNode, writingResource->getStoredQueueSerial());
} }
void RecordableGraphResource::addReadDependency(RecordableGraphResource *readingResource) void CommandGraphResource::addReadDependency(CommandGraphResource *readingResource)
{ {
updateQueueSerial(readingResource->getStoredQueueSerial()); updateQueueSerial(readingResource->getStoredQueueSerial());
...@@ -186,12 +172,12 @@ void RecordableGraphResource::addReadDependency(RecordableGraphResource *reading ...@@ -186,12 +172,12 @@ void RecordableGraphResource::addReadDependency(RecordableGraphResource *reading
mCurrentReadingNodes.push_back(readingNode); mCurrentReadingNodes.push_back(readingNode);
} }
void RecordableGraphResource::finishCurrentCommands(RendererVk *renderer) void CommandGraphResource::finishCurrentCommands(RendererVk *renderer)
{ {
startNewCommands(renderer); startNewCommands(renderer);
} }
void RecordableGraphResource::startNewCommands(RendererVk *renderer) void CommandGraphResource::startNewCommands(RendererVk *renderer)
{ {
CommandGraphNode *newCommands = CommandGraphNode *newCommands =
renderer->getCommandGraph()->allocateNode(CommandGraphNodeFunction::Generic); renderer->getCommandGraph()->allocateNode(CommandGraphNodeFunction::Generic);
...@@ -199,7 +185,7 @@ void RecordableGraphResource::startNewCommands(RendererVk *renderer) ...@@ -199,7 +185,7 @@ void RecordableGraphResource::startNewCommands(RendererVk *renderer)
onWriteImpl(newCommands, renderer->getCurrentQueueSerial()); onWriteImpl(newCommands, renderer->getCurrentQueueSerial());
} }
void RecordableGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial) void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial)
{ {
updateQueueSerial(currentSerial); updateQueueSerial(currentSerial);
...@@ -219,44 +205,6 @@ void RecordableGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial ...@@ -219,44 +205,6 @@ void RecordableGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial
mCurrentWritingNode = writingNode; mCurrentWritingNode = writingNode;
} }
// QueryGraphResource implementation.
QueryGraphResource::QueryGraphResource() : CommandGraphResource(CommandGraphResourceType::Query) {}
QueryGraphResource::~QueryGraphResource() = default;
void QueryGraphResource::beginQuery(Context *context,
const QueryPool *queryPool,
uint32_t queryIndex)
{
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::BeginQuery);
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
}
void QueryGraphResource::endQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex)
{
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::EndQuery);
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
}
void QueryGraphResource::writeTimestamp(Context *context,
const QueryPool *queryPool,
uint32_t queryIndex)
{
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::WriteTimestamp);
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
}
void QueryGraphResource::startNewCommands(RendererVk *renderer, CommandGraphNodeFunction function)
{
CommandGraph *commandGraph = renderer->getCommandGraph();
CommandGraphNode *newNode = commandGraph->allocateNode(function);
newNode->setDiagnosticInfo(mResourceType, reinterpret_cast<uintptr_t>(this));
commandGraph->setNewBarrier(newNode);
mStoredQueueSerial = renderer->getCurrentQueueSerial();
mCurrentWritingNode = newNode;
}
// CommandGraphNode implementation. // CommandGraphNode implementation.
CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function) CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function)
: mRenderPassClearValues{}, : mRenderPassClearValues{},
...@@ -556,6 +504,16 @@ CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function) ...@@ -556,6 +504,16 @@ CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function)
return newCommands; return newCommands;
} }
CommandGraphNode *CommandGraph::allocateBarrierNode(CommandGraphResourceType resourceType,
CommandGraphNodeFunction function)
{
CommandGraphNode *newNode = allocateNode(function);
newNode->setDiagnosticInfo(resourceType, 0);
setNewBarrier(newNode);
return newNode;
}
void CommandGraph::setNewBarrier(CommandGraphNode *newBarrier) void CommandGraph::setNewBarrier(CommandGraphNode *newBarrier)
{ {
size_t previousBarrierIndex = 0; size_t previousBarrierIndex = 0;
...@@ -681,6 +639,27 @@ void CommandGraph::clear() ...@@ -681,6 +639,27 @@ void CommandGraph::clear()
mNodes.clear(); mNodes.clear();
} }
void CommandGraph::beginQuery(const QueryPool *queryPool, uint32_t queryIndex)
{
CommandGraphNode *newNode =
allocateBarrierNode(CommandGraphResourceType::Query, CommandGraphNodeFunction::BeginQuery);
newNode->setQueryPool(queryPool, queryIndex);
}
void CommandGraph::endQuery(const QueryPool *queryPool, uint32_t queryIndex)
{
CommandGraphNode *newNode =
allocateBarrierNode(CommandGraphResourceType::Query, CommandGraphNodeFunction::EndQuery);
newNode->setQueryPool(queryPool, queryIndex);
}
void CommandGraph::writeTimestamp(const QueryPool *queryPool, uint32_t queryIndex)
{
CommandGraphNode *newNode = allocateBarrierNode(CommandGraphResourceType::Query,
CommandGraphNodeFunction::WriteTimestamp);
newNode->setQueryPool(queryPool, queryIndex);
}
// 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
{ {
......
...@@ -206,37 +206,15 @@ class CommandGraphResource : angle::NonCopyable ...@@ -206,37 +206,15 @@ class CommandGraphResource : angle::NonCopyable
// Returns true if the resource is in use by the renderer. // Returns true if the resource is in use by the renderer.
bool isResourceInUse(RendererVk *renderer) const; bool isResourceInUse(RendererVk *renderer) const;
// Returns true if the resource has unsubmitted work pending.
bool hasPendingWork(RendererVk *renderer) const;
// Get the current queue serial for this resource. Used to release resources, and for // Get the current queue serial for this resource. Used to release resources, and for
// queries, to know if the queue they are submitted on has finished execution. // queries, to know if the queue they are submitted on has finished execution.
Serial getStoredQueueSerial() const { return mStoredQueueSerial; } Serial getStoredQueueSerial() const { return mStoredQueueSerial; }
protected:
explicit CommandGraphResource(CommandGraphResourceType resourceType);
Serial mStoredQueueSerial;
// Additional diagnostic information.
CommandGraphResourceType mResourceType;
// Current command graph writing node.
CommandGraphNode *mCurrentWritingNode;
};
// Subclass of graph resources that can record command buffers. Images/Buffers/Framebuffers.
// Does not include Query graph resources.
class RecordableGraphResource : public CommandGraphResource
{
public:
~RecordableGraphResource() override;
// Sets up dependency relations. 'this' resource is the resource being written to. // Sets up dependency relations. 'this' resource is the resource being written to.
void addWriteDependency(RecordableGraphResource *writingResource); void addWriteDependency(CommandGraphResource *writingResource);
// Sets up dependency relations. 'this' resource is the resource being read. // Sets up dependency relations. 'this' resource is the resource being read.
void addReadDependency(RecordableGraphResource *readingResource); void addReadDependency(CommandGraphResource *readingResource);
// Updates the in-use serial tracked for this resource. Will clear dependencies if the resource // Updates the in-use serial tracked for this resource. Will clear dependencies if the resource
// was not used in this set of command nodes. // was not used in this set of command nodes.
...@@ -297,7 +275,7 @@ class RecordableGraphResource : public CommandGraphResource ...@@ -297,7 +275,7 @@ class RecordableGraphResource : public CommandGraphResource
} }
protected: protected:
explicit RecordableGraphResource(CommandGraphResourceType resourceType); explicit CommandGraphResource(CommandGraphResourceType resourceType);
private: private:
// Returns true if this node has a current writing node with no children. // Returns true if this node has a current writing node with no children.
...@@ -324,24 +302,15 @@ class RecordableGraphResource : public CommandGraphResource ...@@ -324,24 +302,15 @@ class RecordableGraphResource : public CommandGraphResource
void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial); void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial);
std::vector<CommandGraphNode *> mCurrentReadingNodes; Serial mStoredQueueSerial;
};
// Specialized command graph node for queries. Not for use with any exposed command buffers.
class QueryGraphResource : public CommandGraphResource
{
public:
~QueryGraphResource() override;
void beginQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex); std::vector<CommandGraphNode *> mCurrentReadingNodes;
void endQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
void writeTimestamp(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
protected: // Current command graph writing node.
QueryGraphResource(); CommandGraphNode *mCurrentWritingNode;
private: // Additional diagnostic information.
void startNewCommands(RendererVk *renderer, CommandGraphNodeFunction function); CommandGraphResourceType mResourceType;
}; };
// Translating OpenGL commands into Vulkan and submitting them immediately loses out on some // Translating OpenGL commands into Vulkan and submitting them immediately loses out on some
...@@ -385,15 +354,21 @@ class CommandGraph final : angle::NonCopyable ...@@ -385,15 +354,21 @@ class CommandGraph final : angle::NonCopyable
bool empty() const; bool empty() const;
void clear(); void clear();
CommandGraphNode *getLastBarrierNode(size_t *indexOut); // The following create special-function nodes that don't require a graph resource.
// Queries:
void beginQuery(const QueryPool *queryPool, uint32_t queryIndex);
void endQuery(const QueryPool *queryPool, uint32_t queryIndex);
void writeTimestamp(const QueryPool *queryPool, uint32_t queryIndex);
private:
CommandGraphNode *allocateBarrierNode(CommandGraphResourceType resourceType,
CommandGraphNodeFunction function);
void setNewBarrier(CommandGraphNode *newBarrier); void setNewBarrier(CommandGraphNode *newBarrier);
CommandGraphNode *getLastBarrierNode(size_t *indexOut);
void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
private:
void dumpGraphDotFile(std::ostream &out) const; void dumpGraphDotFile(std::ostream &out) const;
void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
std::vector<CommandGraphNode *> mNodes; std::vector<CommandGraphNode *> mNodes;
bool mEnableGraphDiagnostics; bool mEnableGraphDiagnostics;
......
...@@ -50,13 +50,11 @@ angle::Result QueryVk::begin(const gl::Context *context) ...@@ -50,13 +50,11 @@ angle::Result QueryVk::begin(const gl::Context *context)
contextVk, &mQueryHelperTimeElapsedBegin)); contextVk, &mQueryHelperTimeElapsedBegin));
} }
mQueryHelperTimeElapsedBegin.writeTimestamp(contextVk, mQueryHelperTimeElapsedBegin.writeTimestamp(contextVk);
mQueryHelperTimeElapsedBegin.getQueryPool(),
mQueryHelperTimeElapsedBegin.getQuery());
} }
else else
{ {
mQueryHelper.beginQuery(contextVk, mQueryHelper.getQueryPool(), mQueryHelper.getQuery()); mQueryHelper.beginQuery(contextVk);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -68,12 +66,11 @@ angle::Result QueryVk::end(const gl::Context *context) ...@@ -68,12 +66,11 @@ angle::Result QueryVk::end(const gl::Context *context)
if (getType() == gl::QueryType::TimeElapsed) if (getType() == gl::QueryType::TimeElapsed)
{ {
mQueryHelper.writeTimestamp(contextVk, mQueryHelper.getQueryPool(), mQueryHelper.writeTimestamp(contextVk);
mQueryHelper.getQuery());
} }
else else
{ {
mQueryHelper.endQuery(contextVk, mQueryHelper.getQueryPool(), mQueryHelper.getQuery()); mQueryHelper.endQuery(contextVk);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -92,7 +89,7 @@ angle::Result QueryVk::queryCounter(const gl::Context *context) ...@@ -92,7 +89,7 @@ angle::Result QueryVk::queryCounter(const gl::Context *context)
ASSERT(getType() == gl::QueryType::Timestamp); ASSERT(getType() == gl::QueryType::Timestamp);
mQueryHelper.writeTimestamp(contextVk, mQueryHelper.getQueryPool(), mQueryHelper.getQuery()); mQueryHelper.writeTimestamp(contextVk);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -123,7 +120,7 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait) ...@@ -123,7 +120,7 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
// may not have been performed by the GPU yet. To avoid a race condition in this case, wait // may not have been performed by the GPU yet. To avoid a race condition in this case, wait
// for the batch to finish first before querying (or return not-ready if not waiting). // for the batch to finish first before querying (or return not-ready if not waiting).
ANGLE_TRY(renderer->checkCompletedCommands(contextVk)); ANGLE_TRY(renderer->checkCompletedCommands(contextVk));
if (mQueryHelper.isResourceInUse(renderer)) if (renderer->isSerialInUse(mQueryHelper.getStoredQueueSerial()))
{ {
if (!wait) if (!wait)
{ {
......
...@@ -117,7 +117,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView ...@@ -117,7 +117,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView
mOwner = nullptr; mOwner = nullptr;
} }
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::RecordableGraphResource *readingResource, vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource,
VkImageLayout layout, VkImageLayout layout,
vk::CommandBuffer *commandBuffer) vk::CommandBuffer *commandBuffer)
{ {
...@@ -133,8 +133,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::RecordableGraphResource *re ...@@ -133,8 +133,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::RecordableGraphResource *re
return mImage; return mImage;
} }
vk::ImageHelper *RenderTargetVk::getImageForWrite( vk::ImageHelper *RenderTargetVk::getImageForWrite(vk::CommandGraphResource *writingResource) const
vk::RecordableGraphResource *writingResource) const
{ {
ASSERT(mImage && mImage->valid()); ASSERT(mImage && mImage->valid());
mImage->addWriteDependency(writingResource); mImage->addWriteDependency(writingResource);
......
...@@ -24,7 +24,7 @@ struct Format; ...@@ -24,7 +24,7 @@ struct Format;
class FramebufferHelper; class FramebufferHelper;
class ImageHelper; class ImageHelper;
class ImageView; class ImageView;
class RecordableGraphResource; class CommandGraphResource;
class RenderPassDesc; class RenderPassDesc;
} // namespace vk } // namespace vk
...@@ -58,10 +58,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget ...@@ -58,10 +58,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
const vk::ImageHelper &getImage() const; const vk::ImageHelper &getImage() const;
// getImageForRead will also transition the resource to the given layout. // getImageForRead will also transition the resource to the given layout.
vk::ImageHelper *getImageForRead(vk::RecordableGraphResource *readingResource, vk::ImageHelper *getImageForRead(vk::CommandGraphResource *readingResource,
VkImageLayout layout, VkImageLayout layout,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
vk::ImageHelper *getImageForWrite(vk::RecordableGraphResource *writingResource) const; vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const;
vk::ImageView *getDrawImageView() const; vk::ImageView *getDrawImageView() const;
vk::ImageView *getReadImageView() const; vk::ImageView *getReadImageView() const;
......
...@@ -18,11 +18,6 @@ namespace rx ...@@ -18,11 +18,6 @@ namespace rx
{ {
class BufferVk; class BufferVk;
namespace vk
{
class RecordableGraphResource;
} // namespace vk
class VertexArrayVk : public VertexArrayImpl class VertexArrayVk : public VertexArrayImpl
{ {
public: public:
......
...@@ -629,9 +629,7 @@ angle::Result DynamicQueryPool::allocateNewPool(Context *context) ...@@ -629,9 +629,7 @@ angle::Result DynamicQueryPool::allocateNewPool(Context *context)
} }
// QueryHelper implementation // QueryHelper implementation
QueryHelper::QueryHelper() QueryHelper::QueryHelper() : mDynamicQueryPool(nullptr), mQueryPoolIndex(0), mQuery(0) {}
: QueryGraphResource(), mDynamicQueryPool(nullptr), mQueryPoolIndex(0), mQuery(0)
{}
QueryHelper::~QueryHelper() {} QueryHelper::~QueryHelper() {}
...@@ -651,6 +649,34 @@ void QueryHelper::deinit() ...@@ -651,6 +649,34 @@ void QueryHelper::deinit()
mQuery = 0; mQuery = 0;
} }
void QueryHelper::beginQuery(vk::Context *context)
{
RendererVk *renderer = context->getRenderer();
renderer->getCommandGraph()->beginQuery(getQueryPool(), getQuery());
mMostRecentSerial = renderer->getCurrentQueueSerial();
}
void QueryHelper::endQuery(vk::Context *context)
{
RendererVk *renderer = context->getRenderer();
renderer->getCommandGraph()->endQuery(getQueryPool(), getQuery());
mMostRecentSerial = renderer->getCurrentQueueSerial();
}
void QueryHelper::writeTimestamp(vk::Context *context)
{
RendererVk *renderer = context->getRenderer();
renderer->getCommandGraph()->writeTimestamp(getQueryPool(), getQuery());
mMostRecentSerial = renderer->getCurrentQueueSerial();
}
bool QueryHelper::hasPendingWork(RendererVk *renderer)
{
// If the renderer has a queue serial higher than the stored one, the command buffers that
// recorded this query have already been submitted, so there is no pending work.
return mMostRecentSerial == renderer->getCurrentQueueSerial();
}
// DynamicSemaphorePool implementation // DynamicSemaphorePool implementation
DynamicSemaphorePool::DynamicSemaphorePool() = default; DynamicSemaphorePool::DynamicSemaphorePool() = default;
...@@ -912,7 +938,7 @@ void LineLoopHelper::Draw(uint32_t count, CommandBuffer *commandBuffer) ...@@ -912,7 +938,7 @@ void LineLoopHelper::Draw(uint32_t count, CommandBuffer *commandBuffer)
// BufferHelper implementation. // BufferHelper implementation.
BufferHelper::BufferHelper() BufferHelper::BufferHelper()
: RecordableGraphResource(CommandGraphResourceType::Buffer), : CommandGraphResource(CommandGraphResourceType::Buffer),
mMemoryPropertyFlags{}, mMemoryPropertyFlags{},
mSize(0), mSize(0),
mMappedMemory(nullptr), mMappedMemory(nullptr),
...@@ -1068,7 +1094,7 @@ angle::Result BufferHelper::invalidate(Context *context, size_t offset, size_t s ...@@ -1068,7 +1094,7 @@ angle::Result BufferHelper::invalidate(Context *context, size_t offset, size_t s
// ImageHelper implementation. // ImageHelper implementation.
ImageHelper::ImageHelper() ImageHelper::ImageHelper()
: RecordableGraphResource(CommandGraphResourceType::Image), : CommandGraphResource(CommandGraphResourceType::Image),
mFormat(nullptr), mFormat(nullptr),
mSamples(0), mSamples(0),
mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED), mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED),
...@@ -1077,7 +1103,7 @@ ImageHelper::ImageHelper() ...@@ -1077,7 +1103,7 @@ ImageHelper::ImageHelper()
{} {}
ImageHelper::ImageHelper(ImageHelper &&other) ImageHelper::ImageHelper(ImageHelper &&other)
: RecordableGraphResource(CommandGraphResourceType::Image), : CommandGraphResource(CommandGraphResourceType::Image),
mImage(std::move(other.mImage)), mImage(std::move(other.mImage)),
mDeviceMemory(std::move(other.mDeviceMemory)), mDeviceMemory(std::move(other.mDeviceMemory)),
mExtents(other.mExtents), mExtents(other.mExtents),
...@@ -1549,8 +1575,7 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint ...@@ -1549,8 +1575,7 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
} }
// FramebufferHelper implementation. // FramebufferHelper implementation.
FramebufferHelper::FramebufferHelper() FramebufferHelper::FramebufferHelper() : CommandGraphResource(CommandGraphResourceType::Framebuffer)
: RecordableGraphResource(CommandGraphResourceType::Framebuffer)
{} {}
FramebufferHelper::~FramebufferHelper() = default; FramebufferHelper::~FramebufferHelper() = default;
......
...@@ -251,11 +251,11 @@ class DynamicQueryPool final : public DynamicallyGrowingPool<QueryPool> ...@@ -251,11 +251,11 @@ class DynamicQueryPool final : public DynamicallyGrowingPool<QueryPool>
// of a fixed size as needed and allocates indices within those pools. // of a fixed size as needed and allocates indices within those pools.
// //
// The QueryHelper class below keeps the pool and index pair together. // The QueryHelper class below keeps the pool and index pair together.
class QueryHelper final : public QueryGraphResource class QueryHelper final
{ {
public: public:
QueryHelper(); QueryHelper();
~QueryHelper() override; ~QueryHelper();
void init(const DynamicQueryPool *dynamicQueryPool, void init(const DynamicQueryPool *dynamicQueryPool,
const size_t queryPoolIndex, const size_t queryPoolIndex,
...@@ -271,10 +271,18 @@ class QueryHelper final : public QueryGraphResource ...@@ -271,10 +271,18 @@ class QueryHelper final : public QueryGraphResource
// Used only by DynamicQueryPool. // Used only by DynamicQueryPool.
size_t getQueryPoolIndex() const { return mQueryPoolIndex; } size_t getQueryPoolIndex() const { return mQueryPoolIndex; }
void beginQuery(vk::Context *context);
void endQuery(vk::Context *context);
void writeTimestamp(vk::Context *context);
Serial getStoredQueueSerial() { return mMostRecentSerial; }
bool hasPendingWork(RendererVk *renderer);
private: private:
const DynamicQueryPool *mDynamicQueryPool; const DynamicQueryPool *mDynamicQueryPool;
size_t mQueryPoolIndex; size_t mQueryPoolIndex;
uint32_t mQuery; uint32_t mQuery;
Serial mMostRecentSerial;
}; };
// DynamicSemaphorePool allocates semaphores as needed. It uses a std::vector // DynamicSemaphorePool allocates semaphores as needed. It uses a std::vector
...@@ -375,7 +383,7 @@ class LineLoopHelper final : angle::NonCopyable ...@@ -375,7 +383,7 @@ class LineLoopHelper final : angle::NonCopyable
class FramebufferHelper; class FramebufferHelper;
class BufferHelper final : public RecordableGraphResource class BufferHelper final : public CommandGraphResource
{ {
public: public:
BufferHelper(); BufferHelper();
...@@ -392,7 +400,7 @@ class BufferHelper final : public RecordableGraphResource ...@@ -392,7 +400,7 @@ class BufferHelper final : public RecordableGraphResource
const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; } const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; }
// Helpers for setting the graph dependencies *and* setting the appropriate barrier. // Helpers for setting the graph dependencies *and* setting the appropriate barrier.
ANGLE_INLINE void onRead(RecordableGraphResource *reader, VkAccessFlagBits readAccessType) ANGLE_INLINE void onRead(CommandGraphResource *reader, VkAccessFlagBits readAccessType)
{ {
addReadDependency(reader); addReadDependency(reader);
...@@ -462,7 +470,7 @@ class BufferHelper final : public RecordableGraphResource ...@@ -462,7 +470,7 @@ class BufferHelper final : public RecordableGraphResource
VkFlags mCurrentReadAccess; VkFlags mCurrentReadAccess;
}; };
class ImageHelper final : public RecordableGraphResource class ImageHelper final : public CommandGraphResource
{ {
public: public:
ImageHelper(); ImageHelper();
...@@ -583,7 +591,7 @@ class ImageHelper final : public RecordableGraphResource ...@@ -583,7 +591,7 @@ class ImageHelper final : public RecordableGraphResource
uint32_t mLevelCount; uint32_t mLevelCount;
}; };
class FramebufferHelper : public RecordableGraphResource class FramebufferHelper : public CommandGraphResource
{ {
public: public:
FramebufferHelper(); FramebufferHelper();
......
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