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: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.h b/src/libANGLE/renderer/vulkan/CommandGraph.h
index 840f6bd..1314da5 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.h
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.h
@@ -206,37 +206,15 @@
     // Returns true if the resource is in use by the renderer.
     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
     // queries, to know if the queue they are submitted on has finished execution.
     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.
-    void addWriteDependency(RecordableGraphResource *writingResource);
+    void addWriteDependency(CommandGraphResource *writingResource);
 
     // 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
     // was not used in this set of command nodes.
@@ -297,7 +275,7 @@
     }
 
   protected:
-    explicit RecordableGraphResource(CommandGraphResourceType resourceType);
+    explicit CommandGraphResource(CommandGraphResourceType resourceType);
 
   private:
     // Returns true if this node has a current writing node with no children.
@@ -324,24 +302,15 @@
 
     void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial);
 
+    Serial mStoredQueueSerial;
+
     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;
+    // Current command graph writing node.
+    CommandGraphNode *mCurrentWritingNode;
 
-    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);
+    // Additional diagnostic information.
+    CommandGraphResourceType mResourceType;
 };
 
 // Translating OpenGL commands into Vulkan and submitting them immediately loses out on some
@@ -385,15 +354,21 @@
     bool empty() const;
     void clear();
 
-    CommandGraphNode *getLastBarrierNode(size_t *indexOut);
-
-    void setNewBarrier(CommandGraphNode *newBarrier);
+    // 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:
-    void dumpGraphDotFile(std::ostream &out) const;
-
+    CommandGraphNode *allocateBarrierNode(CommandGraphResourceType resourceType,
+                                          CommandGraphNodeFunction function);
+    void setNewBarrier(CommandGraphNode *newBarrier);
+    CommandGraphNode *getLastBarrierNode(size_t *indexOut);
     void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
 
+    void dumpGraphDotFile(std::ostream &out) const;
+
     std::vector<CommandGraphNode *> mNodes;
     bool mEnableGraphDiagnostics;