Commit a5e06071 by Jamie Madill Committed by Commit Bot

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: 's avatarLuc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent b4a3f65f
......@@ -52,6 +52,77 @@ Error InitAndBeginCommandBuffer(VkDevice device,
} // 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 @@ bool CommandGraphResource::hasChildlessWritingNode() const
CommandGraphNode *CommandGraphResource::getNewWritingNode(RendererVk *renderer)
{
CommandGraphNode *newCommands = renderer->allocateCommandNode();
CommandGraphNode *newCommands = renderer->getCommandGraph()->allocateNode();
onWriteImpl(newCommands, renderer->getCurrentQueueSerial());
return newCommands;
}
......
......@@ -17,6 +17,7 @@ namespace rx
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 @@ enum class VisitedState
// 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.
......
......@@ -390,7 +390,7 @@ gl::Error FramebufferVk::syncState(const gl::Context *context,
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();
......
......@@ -20,7 +20,6 @@ namespace rx
namespace vk
{
class CommandBuffer;
class CommandGraphNode;
class CommandGraphResource;
struct Format;
class ImageHelper;
......
......@@ -820,9 +820,9 @@ vk::Error RendererVk::getRenderPassWithOps(const vk::RenderPassDesc &desc,
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)
......
......@@ -129,7 +129,7 @@ class RendererVk : angle::NonCopyable
// 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;
......
......@@ -82,7 +82,6 @@ enum class TextureDimension
namespace vk
{
class CommandGraphNode;
struct Format;
template <typename T>
......
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