Hash :
3c424b48
Author :
Date :
2018-01-19T12:35:09
Vulkan: Add vk_cache_utils.h. This file contains the Pipeline and RenderPass cache utils. Also renames renderervk_utils.h to vk_utils.h and the format utils file. Refactoring change only. Bug: angleproject:2163 Change-Id: I5113a9a2c6f0b0960d38e6c2d8e391fa2d9f5f6a Reviewed-on: https://chromium-review.googlesource.com/876505 Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// CommandBufferNode:
// Deferred work constructed by GL calls, that will later be flushed to Vulkan.
//
#ifndef LIBANGLE_RENDERER_VULKAN_COMMAND_BUFFER_NODE_H_
#define LIBANGLE_RENDERER_VULKAN_COMMAND_BUFFER_NODE_H_
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
namespace rx
{
namespace vk
{
enum class VisitedState
{
Unvisited,
Ready,
Visited,
};
class CommandBufferNode final : angle::NonCopyable
{
public:
CommandBufferNode();
~CommandBufferNode();
// Immutable queries for when we're walking the commands tree.
CommandBuffer *getOutsideRenderPassCommands();
CommandBuffer *getInsideRenderPassCommands();
// For outside the render pass (copies, transitions, etc).
Error startRecording(VkDevice device,
const CommandPool &commandPool,
CommandBuffer **commandsOut);
// For rendering commands (draws).
Error startRenderPassRecording(RendererVk *renderer, CommandBuffer **commandsOut);
// Commands for storing info relevant to the RenderPass.
// RenderTargets must be added in order, with the depth/stencil being added last.
void storeRenderPassInfo(const Framebuffer &framebuffer,
const gl::Rectangle renderArea,
const std::vector<VkClearValue> &clearValues);
void appendColorRenderTarget(Serial serial, RenderTargetVk *colorRenderTarget);
void appendDepthStencilRenderTarget(Serial serial, RenderTargetVk *depthStencilRenderTarget);
// Commands for linking nodes in the dependency graph.
void addDependency(CommandBufferNode *node);
void addDependencies(const std::vector<CommandBufferNode *> &nodes);
bool hasDependencies() const;
bool isDependency() const;
// Used for testing only.
bool hasDependency(CommandBufferNode *searchNode);
// Commands for traversing the node on a flush operation.
VisitedState visitedState() const;
void visitDependencies(std::vector<CommandBufferNode *> *stack);
Error visitAndExecute(RendererVk *renderer, CommandBuffer *primaryCommandBuffer);
private:
void initAttachmentDesc(VkAttachmentDescription *desc);
void markAsDependency();
// 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;
// Dependency commands must finish before these command can execute.
std::vector<CommandBufferNode *> mDependencies;
bool mIsDependency;
// Used when traversing the dependency graph.
VisitedState mVisitedState;
};
} // namespace vk
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_COMMAND_BUFFER_NODE_H_