зеркало из https://github.com/AvaloniaUI/angle.git
Vulkan: Split vk::CommandGraphResource.
This adds two subclasses: RecordableGraphResource and QueryGraphResource. Each specializes for Buffer/Image/Frambuffer use cases and Query use cases respectively. No virtual functions are added to keep best performance. We also change the CommandGraph API slightly to optimize away the check for a barrier resource. This requires exposing the set current barrier API on the CommandGraph. Bug: angleproject:2828 Change-Id: I1c23f52bfe04cc682a00b245d63c3ac9a651615d Reviewed-on: https://chromium-review.googlesource.com/c/1305994 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
557a1ee4f4
Коммит
193a284d34
|
@ -82,24 +82,12 @@ const char *GetResourceTypeName(CommandGraphResourceType resourceType,
|
||||||
|
|
||||||
// CommandGraphResource implementation.
|
// CommandGraphResource implementation.
|
||||||
CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType)
|
CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType)
|
||||||
: mCurrentWritingNode(nullptr), mResourceType(resourceType)
|
: mResourceType(resourceType), mCurrentWritingNode(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandGraphResource::~CommandGraphResource() = default;
|
CommandGraphResource::~CommandGraphResource() = default;
|
||||||
|
|
||||||
void CommandGraphResource::updateQueueSerial(Serial queueSerial)
|
|
||||||
{
|
|
||||||
ASSERT(queueSerial >= mStoredQueueSerial);
|
|
||||||
|
|
||||||
if (queueSerial > mStoredQueueSerial)
|
|
||||||
{
|
|
||||||
mCurrentWritingNode = nullptr;
|
|
||||||
mCurrentReadingNodes.clear();
|
|
||||||
mStoredQueueSerial = queueSerial;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
|
bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
|
||||||
{
|
{
|
||||||
return renderer->isSerialInUse(mStoredQueueSerial);
|
return renderer->isSerialInUse(mStoredQueueSerial);
|
||||||
|
@ -117,14 +105,34 @@ Serial CommandGraphResource::getStoredQueueSerial() const
|
||||||
return mStoredQueueSerial;
|
return mStoredQueueSerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle::Result CommandGraphResource::recordCommands(Context *context,
|
// RecordableGraphResource implementation.
|
||||||
CommandBuffer **commandBufferOut)
|
RecordableGraphResource::RecordableGraphResource(CommandGraphResourceType resourceType)
|
||||||
|
: CommandGraphResource(resourceType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordableGraphResource::~RecordableGraphResource() = default;
|
||||||
|
|
||||||
|
void RecordableGraphResource::updateQueueSerial(Serial queueSerial)
|
||||||
|
{
|
||||||
|
ASSERT(queueSerial >= mStoredQueueSerial);
|
||||||
|
|
||||||
|
if (queueSerial > mStoredQueueSerial)
|
||||||
|
{
|
||||||
|
mCurrentWritingNode = nullptr;
|
||||||
|
mCurrentReadingNodes.clear();
|
||||||
|
mStoredQueueSerial = queueSerial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
angle::Result RecordableGraphResource::recordCommands(Context *context,
|
||||||
|
CommandBuffer **commandBufferOut)
|
||||||
{
|
{
|
||||||
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
|
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
|
||||||
|
|
||||||
if (!hasChildlessWritingNode() || hasStartedRenderPass())
|
if (!hasChildlessWritingNode() || hasStartedRenderPass())
|
||||||
{
|
{
|
||||||
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::Generic);
|
startNewCommands(context->getRenderer());
|
||||||
return mCurrentWritingNode->beginOutsideRenderPassRecording(
|
return mCurrentWritingNode->beginOutsideRenderPassRecording(
|
||||||
context, context->getRenderer()->getCommandPool(), commandBufferOut);
|
context, context->getRenderer()->getCommandPool(), commandBufferOut);
|
||||||
}
|
}
|
||||||
|
@ -143,8 +151,8 @@ angle::Result CommandGraphResource::recordCommands(Context *context,
|
||||||
return angle::Result::Continue();
|
return angle::Result::Continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandGraphResource::appendToStartedRenderPass(RendererVk *renderer,
|
bool RecordableGraphResource::appendToStartedRenderPass(RendererVk *renderer,
|
||||||
CommandBuffer **commandBufferOut)
|
CommandBuffer **commandBufferOut)
|
||||||
{
|
{
|
||||||
updateQueueSerial(renderer->getCurrentQueueSerial());
|
updateQueueSerial(renderer->getCurrentQueueSerial());
|
||||||
if (hasStartedRenderPass())
|
if (hasStartedRenderPass())
|
||||||
|
@ -158,23 +166,23 @@ bool CommandGraphResource::appendToStartedRenderPass(RendererVk *renderer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gl::Rectangle &CommandGraphResource::getRenderPassRenderArea() const
|
const gl::Rectangle &RecordableGraphResource::getRenderPassRenderArea() const
|
||||||
{
|
{
|
||||||
ASSERT(hasStartedRenderPass());
|
ASSERT(hasStartedRenderPass());
|
||||||
return mCurrentWritingNode->getRenderPassRenderArea();
|
return mCurrentWritingNode->getRenderPassRenderArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
angle::Result CommandGraphResource::beginRenderPass(Context *context,
|
angle::Result RecordableGraphResource::beginRenderPass(Context *context,
|
||||||
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())
|
||||||
{
|
{
|
||||||
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::Generic);
|
startNewCommands(context->getRenderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hard-code RenderPass to clear the first render target to the current clear value.
|
// Hard-code RenderPass to clear the first render target to the current clear value.
|
||||||
|
@ -184,44 +192,7 @@ angle::Result CommandGraphResource::beginRenderPass(Context *context,
|
||||||
return mCurrentWritingNode->beginInsideRenderPassRecording(context, commandBufferOut);
|
return mCurrentWritingNode->beginInsideRenderPassRecording(context, commandBufferOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandGraphResource::beginQuery(Context *context,
|
void RecordableGraphResource::addWriteDependency(RecordableGraphResource *writingResource)
|
||||||
const QueryPool *queryPool,
|
|
||||||
uint32_t queryIndex)
|
|
||||||
{
|
|
||||||
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::BeginQuery);
|
|
||||||
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandGraphResource::endQuery(Context *context,
|
|
||||||
const QueryPool *queryPool,
|
|
||||||
uint32_t queryIndex)
|
|
||||||
{
|
|
||||||
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::EndQuery);
|
|
||||||
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandGraphResource::writeTimestamp(Context *context,
|
|
||||||
const QueryPool *queryPool,
|
|
||||||
uint32_t queryIndex)
|
|
||||||
{
|
|
||||||
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::WriteTimestamp);
|
|
||||||
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandGraphResource::finishCurrentCommands(RendererVk *renderer)
|
|
||||||
{
|
|
||||||
startNewCommands(renderer, CommandGraphNodeFunction::Generic);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandGraphResource::startNewCommands(RendererVk *renderer, CommandGraphNodeFunction function)
|
|
||||||
{
|
|
||||||
bool isBarrier = function != CommandGraphNodeFunction::Generic;
|
|
||||||
CommandGraphNode *newCommands = renderer->getCommandGraph()->allocateNode(isBarrier, function);
|
|
||||||
newCommands->setDiagnosticInfo(mResourceType, reinterpret_cast<uintptr_t>(this));
|
|
||||||
onWriteImpl(newCommands, renderer->getCurrentQueueSerial());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandGraphResource::addWriteDependency(CommandGraphResource *writingResource)
|
|
||||||
{
|
{
|
||||||
CommandGraphNode *writingNode = writingResource->mCurrentWritingNode;
|
CommandGraphNode *writingNode = writingResource->mCurrentWritingNode;
|
||||||
ASSERT(writingNode);
|
ASSERT(writingNode);
|
||||||
|
@ -229,7 +200,37 @@ void CommandGraphResource::addWriteDependency(CommandGraphResource *writingResou
|
||||||
onWriteImpl(writingNode, writingResource->getStoredQueueSerial());
|
onWriteImpl(writingNode, writingResource->getStoredQueueSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial)
|
void RecordableGraphResource::addReadDependency(RecordableGraphResource *readingResource)
|
||||||
|
{
|
||||||
|
updateQueueSerial(readingResource->getStoredQueueSerial());
|
||||||
|
|
||||||
|
CommandGraphNode *readingNode = readingResource->mCurrentWritingNode;
|
||||||
|
ASSERT(readingNode);
|
||||||
|
|
||||||
|
if (hasChildlessWritingNode())
|
||||||
|
{
|
||||||
|
// Ensure 'readingNode' happens after the current writing node.
|
||||||
|
CommandGraphNode::SetHappensBeforeDependency(mCurrentWritingNode, readingNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the read node to the list of nodes currently reading this resource.
|
||||||
|
mCurrentReadingNodes.push_back(readingNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordableGraphResource::finishCurrentCommands(RendererVk *renderer)
|
||||||
|
{
|
||||||
|
startNewCommands(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordableGraphResource::startNewCommands(RendererVk *renderer)
|
||||||
|
{
|
||||||
|
CommandGraphNode *newCommands =
|
||||||
|
renderer->getCommandGraph()->allocateNode(CommandGraphNodeFunction::Generic);
|
||||||
|
newCommands->setDiagnosticInfo(mResourceType, reinterpret_cast<uintptr_t>(this));
|
||||||
|
onWriteImpl(newCommands, renderer->getCurrentQueueSerial());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordableGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial)
|
||||||
{
|
{
|
||||||
updateQueueSerial(currentSerial);
|
updateQueueSerial(currentSerial);
|
||||||
|
|
||||||
|
@ -249,21 +250,44 @@ void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial cur
|
||||||
mCurrentWritingNode = writingNode;
|
mCurrentWritingNode = writingNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandGraphResource::addReadDependency(CommandGraphResource *readingResource)
|
// QueryGraphResource implementation.
|
||||||
|
QueryGraphResource::QueryGraphResource() : CommandGraphResource(CommandGraphResourceType::Query)
|
||||||
{
|
{
|
||||||
updateQueueSerial(readingResource->getStoredQueueSerial());
|
}
|
||||||
|
|
||||||
CommandGraphNode *readingNode = readingResource->mCurrentWritingNode;
|
QueryGraphResource::~QueryGraphResource() = default;
|
||||||
ASSERT(readingNode);
|
|
||||||
|
|
||||||
if (hasChildlessWritingNode())
|
void QueryGraphResource::beginQuery(Context *context,
|
||||||
{
|
const QueryPool *queryPool,
|
||||||
// Ensure 'readingNode' happens after the current writing node.
|
uint32_t queryIndex)
|
||||||
CommandGraphNode::SetHappensBeforeDependency(mCurrentWritingNode, readingNode);
|
{
|
||||||
}
|
startNewCommands(context->getRenderer(), CommandGraphNodeFunction::BeginQuery);
|
||||||
|
mCurrentWritingNode->setQueryPool(queryPool, queryIndex);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the read node to the list of nodes currently reading this resource.
|
void QueryGraphResource::endQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex)
|
||||||
mCurrentReadingNodes.push_back(readingNode);
|
{
|
||||||
|
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.
|
||||||
|
@ -555,17 +579,11 @@ CommandGraph::~CommandGraph()
|
||||||
ASSERT(empty());
|
ASSERT(empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandGraphNode *CommandGraph::allocateNode(bool isBarrier, CommandGraphNodeFunction function)
|
CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function)
|
||||||
{
|
{
|
||||||
// TODO(jmadill): Use a pool allocator for the CPU node allocations.
|
// TODO(jmadill): Use a pool allocator for the CPU node allocations.
|
||||||
CommandGraphNode *newCommands = new CommandGraphNode(function);
|
CommandGraphNode *newCommands = new CommandGraphNode(function);
|
||||||
mNodes.emplace_back(newCommands);
|
mNodes.emplace_back(newCommands);
|
||||||
|
|
||||||
if (isBarrier)
|
|
||||||
{
|
|
||||||
setNewBarrier(newCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newCommands;
|
return newCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,11 +161,34 @@ class CommandGraphResource : angle::NonCopyable
|
||||||
// Returns true if the resource has unsubmitted work pending.
|
// Returns true if the resource has unsubmitted work pending.
|
||||||
bool hasPendingWork(RendererVk *renderer) const;
|
bool hasPendingWork(RendererVk *renderer) const;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
Serial getStoredQueueSerial() const;
|
||||||
|
|
||||||
|
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(CommandGraphResource *writingResource);
|
void addWriteDependency(RecordableGraphResource *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(CommandGraphResource *readingResource);
|
void addReadDependency(RecordableGraphResource *readingResource);
|
||||||
|
|
||||||
// Allocates a write node via getNewWriteNode and returns a started command buffer.
|
// Allocates a write node via getNewWriteNode and returns a started command buffer.
|
||||||
// The started command buffer will render outside of a RenderPass.
|
// The started command buffer will render outside of a RenderPass.
|
||||||
|
@ -181,10 +204,6 @@ class CommandGraphResource : angle::NonCopyable
|
||||||
const std::vector<VkClearValue> &clearValues,
|
const std::vector<VkClearValue> &clearValues,
|
||||||
CommandBuffer **commandBufferOut);
|
CommandBuffer **commandBufferOut);
|
||||||
|
|
||||||
void beginQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
|
|
||||||
void endQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
|
|
||||||
void writeTimestamp(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
|
|
||||||
|
|
||||||
// Checks if we're in a RenderPass, returning true if so. Updates serial internally.
|
// Checks if we're in a RenderPass, returning true if so. Updates serial internally.
|
||||||
// Returns the started command buffer in commandBufferOut.
|
// Returns the started command buffer in commandBufferOut.
|
||||||
bool appendToStartedRenderPass(RendererVk *renderer, CommandBuffer **commandBufferOut);
|
bool appendToStartedRenderPass(RendererVk *renderer, CommandBuffer **commandBufferOut);
|
||||||
|
@ -195,17 +214,10 @@ class CommandGraphResource : angle::NonCopyable
|
||||||
// Called when 'this' object changes, but we'd like to start a new command buffer later.
|
// Called when 'this' object changes, but we'd like to start a new command buffer later.
|
||||||
void finishCurrentCommands(RendererVk *renderer);
|
void finishCurrentCommands(RendererVk *renderer);
|
||||||
|
|
||||||
// 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.
|
|
||||||
Serial getStoredQueueSerial() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CommandGraphResource(CommandGraphResourceType resourceType);
|
explicit RecordableGraphResource(CommandGraphResourceType resourceType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startNewCommands(RendererVk *renderer, CommandGraphNodeFunction function);
|
|
||||||
|
|
||||||
void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial);
|
|
||||||
|
|
||||||
// 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.
|
||||||
bool hasChildlessWritingNode() const
|
bool hasChildlessWritingNode() const
|
||||||
|
@ -231,12 +243,28 @@ class CommandGraphResource : angle::NonCopyable
|
||||||
// was not used in this set of command nodes.
|
// was not used in this set of command nodes.
|
||||||
void updateQueueSerial(Serial queueSerial);
|
void updateQueueSerial(Serial queueSerial);
|
||||||
|
|
||||||
Serial mStoredQueueSerial;
|
void startNewCommands(RendererVk *renderer);
|
||||||
std::vector<CommandGraphNode *> mCurrentReadingNodes;
|
|
||||||
CommandGraphNode *mCurrentWritingNode;
|
|
||||||
|
|
||||||
// Additional diagnostic information.
|
void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial);
|
||||||
CommandGraphResourceType mResourceType;
|
|
||||||
|
std::vector<CommandGraphNode *> mCurrentReadingNodes;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
void endQuery(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
|
||||||
|
void writeTimestamp(Context *context, const QueryPool *queryPool, uint32_t queryIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QueryGraphResource();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void startNewCommands(RendererVk *renderer, CommandGraphNodeFunction function);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -270,7 +298,7 @@ class CommandGraph final : angle::NonCopyable
|
||||||
// relations exist in the node by default. Call CommandGraphNode::SetHappensBeforeDependency
|
// relations exist in the node by default. Call CommandGraphNode::SetHappensBeforeDependency
|
||||||
// to set up dependency relations. If the node is a barrier, it will automatically add
|
// to set up dependency relations. If the node is a barrier, it will automatically add
|
||||||
// dependencies between the previous barrier, the new barrier and all nodes in between.
|
// dependencies between the previous barrier, the new barrier and all nodes in between.
|
||||||
CommandGraphNode *allocateNode(bool isBarrier, CommandGraphNodeFunction function);
|
CommandGraphNode *allocateNode(CommandGraphNodeFunction function);
|
||||||
|
|
||||||
angle::Result submitCommands(Context *context,
|
angle::Result submitCommands(Context *context,
|
||||||
Serial serial,
|
Serial serial,
|
||||||
|
@ -281,10 +309,11 @@ class CommandGraph final : angle::NonCopyable
|
||||||
|
|
||||||
CommandGraphNode *getLastBarrierNode(size_t *indexOut);
|
CommandGraphNode *getLastBarrierNode(size_t *indexOut);
|
||||||
|
|
||||||
|
void setNewBarrier(CommandGraphNode *newBarrier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void dumpGraphDotFile(std::ostream &out) const;
|
void dumpGraphDotFile(std::ostream &out) const;
|
||||||
|
|
||||||
void setNewBarrier(CommandGraphNode *newBarrier);
|
|
||||||
void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
|
void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
|
||||||
|
|
||||||
std::vector<CommandGraphNode *> mNodes;
|
std::vector<CommandGraphNode *> mNodes;
|
||||||
|
|
|
@ -446,7 +446,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
|
||||||
mVertexArray->getCurrentElementArrayBufferOffset(),
|
mVertexArray->getCurrentElementArrayBufferOffset(),
|
||||||
gl_vk::GetIndexType(mCurrentDrawElementsType));
|
gl_vk::GetIndexType(mCurrentDrawElementsType));
|
||||||
|
|
||||||
vk::CommandGraphResource *elementArrayBufferResource =
|
vk::RecordableGraphResource *elementArrayBufferResource =
|
||||||
mVertexArray->getCurrentElementArrayBufferResource();
|
mVertexArray->getCurrentElementArrayBufferResource();
|
||||||
if (elementArrayBufferResource)
|
if (elementArrayBufferResource)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ RenderTargetVk::RenderTargetVk(RenderTargetVk &&other)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTargetVk::onColorDraw(vk::CommandGraphResource *framebufferVk,
|
void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
|
||||||
vk::CommandBuffer *commandBuffer,
|
vk::CommandBuffer *commandBuffer,
|
||||||
vk::RenderPassDesc *renderPassDesc)
|
vk::RenderPassDesc *renderPassDesc)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ void RenderTargetVk::onColorDraw(vk::CommandGraphResource *framebufferVk,
|
||||||
mImage->addWriteDependency(framebufferVk);
|
mImage->addWriteDependency(framebufferVk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTargetVk::onDepthStencilDraw(vk::CommandGraphResource *framebufferVk,
|
void RenderTargetVk::onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
|
||||||
vk::CommandBuffer *commandBuffer,
|
vk::CommandBuffer *commandBuffer,
|
||||||
vk::RenderPassDesc *renderPassDesc)
|
vk::RenderPassDesc *renderPassDesc)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView
|
||||||
mImageView = imageView;
|
mImageView = imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource,
|
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::RecordableGraphResource *readingResource,
|
||||||
VkImageLayout layout,
|
VkImageLayout layout,
|
||||||
vk::CommandBuffer *commandBuffer)
|
vk::CommandBuffer *commandBuffer)
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,8 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi
|
||||||
return mImage;
|
return mImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::ImageHelper *RenderTargetVk::getImageForWrite(vk::CommandGraphResource *writingResource) const
|
vk::ImageHelper *RenderTargetVk::getImageForWrite(
|
||||||
|
vk::RecordableGraphResource *writingResource) const
|
||||||
{
|
{
|
||||||
ASSERT(mImage && mImage->valid());
|
ASSERT(mImage && mImage->valid());
|
||||||
mImage->addWriteDependency(writingResource);
|
mImage->addWriteDependency(writingResource);
|
||||||
|
|
|
@ -20,10 +20,11 @@ namespace rx
|
||||||
namespace vk
|
namespace vk
|
||||||
{
|
{
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
class CommandGraphResource;
|
|
||||||
struct Format;
|
struct Format;
|
||||||
|
class FramebufferHelper;
|
||||||
class ImageHelper;
|
class ImageHelper;
|
||||||
class ImageView;
|
class ImageView;
|
||||||
|
class RecordableGraphResource;
|
||||||
class RenderPassDesc;
|
class RenderPassDesc;
|
||||||
} // namespace vk
|
} // namespace vk
|
||||||
|
|
||||||
|
@ -42,20 +43,20 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
|
||||||
RenderTargetVk(RenderTargetVk &&other);
|
RenderTargetVk(RenderTargetVk &&other);
|
||||||
|
|
||||||
// Note: RenderTargets should be called in order, with the depth/stencil onRender last.
|
// Note: RenderTargets should be called in order, with the depth/stencil onRender last.
|
||||||
void onColorDraw(vk::CommandGraphResource *framebufferVk,
|
void onColorDraw(vk::FramebufferHelper *framebufferVk,
|
||||||
vk::CommandBuffer *commandBuffer,
|
vk::CommandBuffer *commandBuffer,
|
||||||
vk::RenderPassDesc *renderPassDesc);
|
vk::RenderPassDesc *renderPassDesc);
|
||||||
void onDepthStencilDraw(vk::CommandGraphResource *framebufferVk,
|
void onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
|
||||||
vk::CommandBuffer *commandBuffer,
|
vk::CommandBuffer *commandBuffer,
|
||||||
vk::RenderPassDesc *renderPassDesc);
|
vk::RenderPassDesc *renderPassDesc);
|
||||||
|
|
||||||
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::CommandGraphResource *readingResource,
|
vk::ImageHelper *getImageForRead(vk::RecordableGraphResource *readingResource,
|
||||||
VkImageLayout layout,
|
VkImageLayout layout,
|
||||||
vk::CommandBuffer *commandBuffer);
|
vk::CommandBuffer *commandBuffer);
|
||||||
vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const;
|
vk::ImageHelper *getImageForWrite(vk::RecordableGraphResource *writingResource) const;
|
||||||
vk::ImageView *getImageView() const;
|
vk::ImageView *getImageView() const;
|
||||||
|
|
||||||
const vk::Format &getImageFormat() const;
|
const vk::Format &getImageFormat() const;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BufferVk;
|
||||||
|
|
||||||
namespace vk
|
namespace vk
|
||||||
{
|
{
|
||||||
class CommandGraphResource;
|
class RecordableGraphResource;
|
||||||
} // namespace vk
|
} // namespace vk
|
||||||
|
|
||||||
class VertexArrayVk : public VertexArrayImpl
|
class VertexArrayVk : public VertexArrayImpl
|
||||||
|
@ -65,7 +65,7 @@ class VertexArrayVk : public VertexArrayImpl
|
||||||
return mCurrentArrayBufferOffsets;
|
return mCurrentArrayBufferOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gl::AttribArray<vk::CommandGraphResource *> &getCurrentArrayBufferResources() const
|
const gl::AttribArray<vk::RecordableGraphResource *> &getCurrentArrayBufferResources() const
|
||||||
{
|
{
|
||||||
return mCurrentArrayBufferResources;
|
return mCurrentArrayBufferResources;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class VertexArrayVk : public VertexArrayImpl
|
||||||
mCurrentElementArrayBufferOffset = reinterpret_cast<VkDeviceSize>(offset);
|
mCurrentElementArrayBufferOffset = reinterpret_cast<VkDeviceSize>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::CommandGraphResource *getCurrentElementArrayBufferResource() const
|
vk::RecordableGraphResource *getCurrentElementArrayBufferResource() const
|
||||||
{
|
{
|
||||||
return mCurrentElementArrayBufferResource;
|
return mCurrentElementArrayBufferResource;
|
||||||
}
|
}
|
||||||
|
@ -121,14 +121,14 @@ class VertexArrayVk : public VertexArrayImpl
|
||||||
|
|
||||||
gl::AttribArray<VkBuffer> mCurrentArrayBufferHandles;
|
gl::AttribArray<VkBuffer> mCurrentArrayBufferHandles;
|
||||||
gl::AttribArray<VkDeviceSize> mCurrentArrayBufferOffsets;
|
gl::AttribArray<VkDeviceSize> mCurrentArrayBufferOffsets;
|
||||||
gl::AttribArray<vk::CommandGraphResource *> mCurrentArrayBufferResources;
|
gl::AttribArray<vk::RecordableGraphResource *> mCurrentArrayBufferResources;
|
||||||
gl::AttribArray<const vk::Format *> mCurrentArrayBufferFormats;
|
gl::AttribArray<const vk::Format *> mCurrentArrayBufferFormats;
|
||||||
gl::AttribArray<GLuint> mCurrentArrayBufferStrides;
|
gl::AttribArray<GLuint> mCurrentArrayBufferStrides;
|
||||||
gl::AttribArray<vk::DynamicBuffer> mCurrentArrayBufferConversion;
|
gl::AttribArray<vk::DynamicBuffer> mCurrentArrayBufferConversion;
|
||||||
gl::AttribArray<bool> mCurrentArrayBufferConversionCanRelease;
|
gl::AttribArray<bool> mCurrentArrayBufferConversionCanRelease;
|
||||||
VkBuffer mCurrentElementArrayBufferHandle;
|
VkBuffer mCurrentElementArrayBufferHandle;
|
||||||
VkDeviceSize mCurrentElementArrayBufferOffset;
|
VkDeviceSize mCurrentElementArrayBufferOffset;
|
||||||
vk::CommandGraphResource *mCurrentElementArrayBufferResource;
|
vk::RecordableGraphResource *mCurrentElementArrayBufferResource;
|
||||||
|
|
||||||
// Keep a cache of binding and attribute descriptions for easy pipeline updates.
|
// Keep a cache of binding and attribute descriptions for easy pipeline updates.
|
||||||
// This is copied out of here into the pipeline description on a Context state change.
|
// This is copied out of here into the pipeline description on a Context state change.
|
||||||
|
|
|
@ -592,10 +592,7 @@ angle::Result DynamicQueryPool::allocateNewPool(Context *context)
|
||||||
|
|
||||||
// QueryHelper implementation
|
// QueryHelper implementation
|
||||||
QueryHelper::QueryHelper()
|
QueryHelper::QueryHelper()
|
||||||
: CommandGraphResource(CommandGraphResourceType::Query),
|
: QueryGraphResource(), mDynamicQueryPool(nullptr), mQueryPoolIndex(0), mQuery(0)
|
||||||
mDynamicQueryPool(nullptr),
|
|
||||||
mQueryPoolIndex(0),
|
|
||||||
mQuery(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,7 +873,7 @@ void LineLoopHelper::Draw(uint32_t count, CommandBuffer *commandBuffer)
|
||||||
|
|
||||||
// BufferHelper implementation.
|
// BufferHelper implementation.
|
||||||
BufferHelper::BufferHelper()
|
BufferHelper::BufferHelper()
|
||||||
: CommandGraphResource(CommandGraphResourceType::Buffer), mMemoryPropertyFlags{}
|
: RecordableGraphResource(CommandGraphResourceType::Buffer), mMemoryPropertyFlags{}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,7 +896,7 @@ void BufferHelper::release(RendererVk *renderer)
|
||||||
|
|
||||||
// ImageHelper implementation.
|
// ImageHelper implementation.
|
||||||
ImageHelper::ImageHelper()
|
ImageHelper::ImageHelper()
|
||||||
: CommandGraphResource(CommandGraphResourceType::Image),
|
: RecordableGraphResource(CommandGraphResourceType::Image),
|
||||||
mFormat(nullptr),
|
mFormat(nullptr),
|
||||||
mSamples(0),
|
mSamples(0),
|
||||||
mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED),
|
mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED),
|
||||||
|
@ -908,7 +905,7 @@ ImageHelper::ImageHelper()
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageHelper::ImageHelper(ImageHelper &&other)
|
ImageHelper::ImageHelper(ImageHelper &&other)
|
||||||
: CommandGraphResource(CommandGraphResourceType::Image),
|
: RecordableGraphResource(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),
|
||||||
|
@ -1389,7 +1386,8 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
|
||||||
}
|
}
|
||||||
|
|
||||||
// FramebufferHelper implementation.
|
// FramebufferHelper implementation.
|
||||||
FramebufferHelper::FramebufferHelper() : CommandGraphResource(CommandGraphResourceType::Framebuffer)
|
FramebufferHelper::FramebufferHelper()
|
||||||
|
: RecordableGraphResource(CommandGraphResourceType::Framebuffer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ 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 CommandGraphResource
|
class QueryHelper final : public QueryGraphResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QueryHelper();
|
QueryHelper();
|
||||||
|
@ -373,7 +373,7 @@ class LineLoopHelper final : angle::NonCopyable
|
||||||
DynamicBuffer mDynamicIndexBuffer;
|
DynamicBuffer mDynamicIndexBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferHelper final : public CommandGraphResource
|
class BufferHelper final : public RecordableGraphResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferHelper();
|
BufferHelper();
|
||||||
|
@ -397,7 +397,7 @@ class BufferHelper final : public CommandGraphResource
|
||||||
VkMemoryPropertyFlags mMemoryPropertyFlags;
|
VkMemoryPropertyFlags mMemoryPropertyFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageHelper final : public CommandGraphResource
|
class ImageHelper final : public RecordableGraphResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageHelper();
|
ImageHelper();
|
||||||
|
@ -507,7 +507,7 @@ class ImageHelper final : public CommandGraphResource
|
||||||
uint32_t mLayerCount;
|
uint32_t mLayerCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FramebufferHelper : public CommandGraphResource
|
class FramebufferHelper : public RecordableGraphResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FramebufferHelper();
|
FramebufferHelper();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче