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;
 }