Vulkan: Move the CommandGraphNode class to the cpp.
This totally hides the details of the CommandGraphNode implementation
from the rest of the back-end. This continues the simplification of
the graph/resource APIs.
Refactoring change only.
Bug: angleproject:2539
Change-Id: I7e0f286c387599624cfdff6c8972a8e082fe05d3
Reviewed-on: https://chromium-review.googlesource.com/1052069
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.cpp b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
index 788376d..c63b81a 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.cpp
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
@@ -52,6 +52,77 @@
} // anonymous namespace
+class CommandGraphNode final : angle::NonCopyable
+{
+ public:
+ CommandGraphNode();
+ ~CommandGraphNode();
+
+ // Immutable queries for when we're walking the commands tree.
+ CommandBuffer *getOutsideRenderPassCommands();
+ CommandBuffer *getInsideRenderPassCommands();
+
+ // For outside the render pass (copies, transitions, etc).
+ Error beginOutsideRenderPassRecording(VkDevice device,
+ const CommandPool &commandPool,
+ CommandBuffer **commandsOut);
+
+ // For rendering commands (draws).
+ Error beginInsideRenderPassRecording(RendererVk *renderer, CommandBuffer **commandsOut);
+
+ // storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass.
+ void storeRenderPassInfo(const Framebuffer &framebuffer,
+ const gl::Rectangle renderArea,
+ const vk::RenderPassDesc &renderPassDesc,
+ const std::vector<VkClearValue> &clearValues);
+
+ // Dependency commands order node execution in the command graph.
+ // Once a node has commands that must happen after it, recording is stopped and the node is
+ // frozen forever.
+ static void SetHappensBeforeDependency(CommandGraphNode *beforeNode,
+ CommandGraphNode *afterNode);
+ static void SetHappensBeforeDependencies(const std::vector<CommandGraphNode *> &beforeNodes,
+ CommandGraphNode *afterNode);
+ bool hasParents() const;
+ bool hasChildren() const;
+
+ // Commands for traversing the node on a flush operation.
+ VisitedState visitedState() const;
+ void visitParents(std::vector<CommandGraphNode *> *stack);
+ Error visitAndExecute(VkDevice device,
+ Serial serial,
+ RenderPassCache *renderPassCache,
+ CommandBuffer *primaryCommandBuffer);
+
+ const gl::Rectangle &getRenderPassRenderArea() const;
+
+ private:
+ void setHasChildren();
+
+ // Used for testing only.
+ bool isChildOf(CommandGraphNode *parent);
+
+ // Only used if we need a RenderPass for these commands.
+ RenderPassDesc mRenderPassDesc;
+ Framebuffer mRenderPassFramebuffer;
+ gl::Rectangle mRenderPassRenderArea;
+ gl::AttachmentArray<VkClearValue> mRenderPassClearValues;
+
+ // Keep a separate buffers for commands inside and outside a RenderPass.
+ // TODO(jmadill): We might not need inside and outside RenderPass commands separate.
+ CommandBuffer mOutsideRenderPassCommands;
+ CommandBuffer mInsideRenderPassCommands;
+
+ // Parents are commands that must be submitted before 'this' CommandNode can be submitted.
+ std::vector<CommandGraphNode *> mParents;
+
+ // If this is true, other commands exist that must be submitted after 'this' command.
+ bool mHasChildren;
+
+ // Used when traversing the dependency graph.
+ VisitedState mVisitedState;
+};
+
// CommandGraphResource implementation.
CommandGraphResource::CommandGraphResource() : mCurrentWritingNode(nullptr)
{
@@ -83,7 +154,7 @@
CommandGraphNode *CommandGraphResource::getNewWritingNode(RendererVk *renderer)
{
- CommandGraphNode *newCommands = renderer->allocateCommandNode();
+ CommandGraphNode *newCommands = renderer->getCommandGraph()->allocateNode();
onWriteImpl(newCommands, renderer->getCurrentQueueSerial());
return newCommands;
}
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.h b/src/libANGLE/renderer/vulkan/CommandGraph.h
index 84469ce..c4f7122 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.h
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.h
@@ -17,6 +17,7 @@
namespace vk
{
+class CommandGraphNode;
// This is a helper class for back-end objects used in Vk command buffers. It records a serial
// at command recording times indicating an order in the queue. We use Fences to detect when
@@ -114,78 +115,7 @@
// and outside RenderPasses as necessary, filled with the right load/store operations. Once
// the primary CommandBuffer has recorded all of the secondary CommandBuffers from all the open
// CommandGraphNodes, we submit the primary CommandBuffer to the VkQueue on the device.
-
-class CommandGraphNode final : angle::NonCopyable
-{
- public:
- CommandGraphNode();
- ~CommandGraphNode();
-
- // Immutable queries for when we're walking the commands tree.
- CommandBuffer *getOutsideRenderPassCommands();
- CommandBuffer *getInsideRenderPassCommands();
-
- // For outside the render pass (copies, transitions, etc).
- Error beginOutsideRenderPassRecording(VkDevice device,
- const CommandPool &commandPool,
- CommandBuffer **commandsOut);
-
- // For rendering commands (draws).
- Error beginInsideRenderPassRecording(RendererVk *renderer, CommandBuffer **commandsOut);
-
- // storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass.
- void storeRenderPassInfo(const Framebuffer &framebuffer,
- const gl::Rectangle renderArea,
- const vk::RenderPassDesc &renderPassDesc,
- const std::vector<VkClearValue> &clearValues);
-
- // Dependency commands order node execution in the command graph.
- // Once a node has commands that must happen after it, recording is stopped and the node is
- // frozen forever.
- static void SetHappensBeforeDependency(CommandGraphNode *beforeNode,
- CommandGraphNode *afterNode);
- static void SetHappensBeforeDependencies(const std::vector<CommandGraphNode *> &beforeNodes,
- CommandGraphNode *afterNode);
- bool hasParents() const;
- bool hasChildren() const;
-
- // Commands for traversing the node on a flush operation.
- VisitedState visitedState() const;
- void visitParents(std::vector<CommandGraphNode *> *stack);
- Error visitAndExecute(VkDevice device,
- Serial serial,
- RenderPassCache *renderPassCache,
- CommandBuffer *primaryCommandBuffer);
-
- const gl::Rectangle &getRenderPassRenderArea() const;
-
- private:
- void setHasChildren();
-
- // Used for testing only.
- bool isChildOf(CommandGraphNode *parent);
-
- // Only used if we need a RenderPass for these commands.
- RenderPassDesc mRenderPassDesc;
- Framebuffer mRenderPassFramebuffer;
- gl::Rectangle mRenderPassRenderArea;
- gl::AttachmentArray<VkClearValue> mRenderPassClearValues;
-
- // Keep a separate buffers for commands inside and outside a RenderPass.
- // TODO(jmadill): We might not need inside and outside RenderPass commands separate.
- CommandBuffer mOutsideRenderPassCommands;
- CommandBuffer mInsideRenderPassCommands;
-
- // Parents are commands that must be submitted before 'this' CommandNode can be submitted.
- std::vector<CommandGraphNode *> mParents;
-
- // If this is true, other commands exist that must be submitted after 'this' command.
- bool mHasChildren;
-
- // Used when traversing the dependency graph.
- VisitedState mVisitedState;
-};
-
+//
// The Command Graph consists of an array of open Command Graph Nodes. It supports allocating new
// nodes for the graph, which are linked via dependency relation calls in CommandGraphNode, and
// also submitting the whole command graph via submitCommands.
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index c945e44..00cfb26 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -390,7 +390,7 @@
renderer->releaseResource(*this, &mFramebuffer);
// Will freeze the current set of dependencies on this FBO. The next time we render we will
- // create a new vk::CommandGraphNode.
+ // create a new entry in the command graph.
onResourceChanged(renderer);
contextVk->invalidateCurrentPipeline();
diff --git a/src/libANGLE/renderer/vulkan/RenderTargetVk.h b/src/libANGLE/renderer/vulkan/RenderTargetVk.h
index c59aef1..1b3f1e3 100644
--- a/src/libANGLE/renderer/vulkan/RenderTargetVk.h
+++ b/src/libANGLE/renderer/vulkan/RenderTargetVk.h
@@ -20,7 +20,6 @@
namespace vk
{
class CommandBuffer;
-class CommandGraphNode;
class CommandGraphResource;
struct Format;
class ImageHelper;
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 175ce65..a94e3d3 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -820,9 +820,9 @@
renderPassOut);
}
-vk::CommandGraphNode *RendererVk::allocateCommandNode()
+vk::CommandGraph *RendererVk::getCommandGraph()
{
- return mCommandGraph.allocateNode();
+ return &mCommandGraph;
}
vk::Error RendererVk::flushCommandGraph(const gl::Context *context, vk::CommandBuffer *commandBatch)
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.h b/src/libANGLE/renderer/vulkan/RendererVk.h
index 1caa59e..3c7ef83 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.h
+++ b/src/libANGLE/renderer/vulkan/RendererVk.h
@@ -129,7 +129,7 @@
// This should only be called from ResourceVk.
// TODO(jmadill): Keep in ContextVk to enable threaded rendering.
- vk::CommandGraphNode *allocateCommandNode();
+ vk::CommandGraph *getCommandGraph();
const vk::PipelineLayout &getGraphicsPipelineLayout() const;
const std::vector<vk::DescriptorSetLayout> &getGraphicsDescriptorSetLayouts() const;
diff --git a/src/libANGLE/renderer/vulkan/vk_utils.h b/src/libANGLE/renderer/vulkan/vk_utils.h
index 3ab6064..0f315c0 100644
--- a/src/libANGLE/renderer/vulkan/vk_utils.h
+++ b/src/libANGLE/renderer/vulkan/vk_utils.h
@@ -82,7 +82,6 @@
namespace vk
{
-class CommandGraphNode;
struct Format;
template <typename T>