Commit 134425c7 by Tobin Ehlis Committed by Commit Bot

Vulkan:Integrate SecondaryCommandBuffers

Integrate the custom SecondaryCommandBuffer type into the CommandGraph nodes by adding new ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS define that can be set in the BUILD gn args with angle_enable_custom_vulkan_cmd_buffers set to "true." Initially the custom cmd buffers are disabled by default. This adds some support functions to SecondaryCommandBuffer to make the integration easier by matching the wrapped cmd buffer interface: initialize(), end(), valid(). Bug: angleproject:3136 Change-Id: Ib910554583192550757bb8ce89914e3ea8737988 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1526556 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3a0e5beb
...@@ -474,6 +474,9 @@ config("libANGLE_config") { ...@@ -474,6 +474,9 @@ config("libANGLE_config") {
} }
if (angle_enable_vulkan) { if (angle_enable_vulkan) {
defines += [ "ANGLE_ENABLE_VULKAN" ] defines += [ "ANGLE_ENABLE_VULKAN" ]
if (angle_enable_custom_vulkan_cmd_buffers) {
defines += [ "ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS=1" ]
}
} }
if (angle_enable_null) { if (angle_enable_null) {
defines += [ "ANGLE_ENABLE_NULL" ] defines += [ "ANGLE_ENABLE_NULL" ]
......
...@@ -84,6 +84,9 @@ declare_args() { ...@@ -84,6 +84,9 @@ declare_args() {
# Disallow non-conformant configurations in official builds. # Disallow non-conformant configurations in official builds.
angle_vulkan_conformant_configs_only = is_official_build angle_vulkan_conformant_configs_only = is_official_build
# Enable custom (cpu-side) secondary command buffers
angle_enable_custom_vulkan_cmd_buffers = false
} }
} }
......
...@@ -324,4 +324,10 @@ std::string ToString(const T &value) ...@@ -324,4 +324,10 @@ std::string ToString(const T &value)
# define ANGLE_NO_DISCARD # define ANGLE_NO_DISCARD
#endif // __has_cpp_attribute(nodiscard) #endif // __has_cpp_attribute(nodiscard)
#if __has_cpp_attribute(maybe_unused)
# define ANGLE_MAYBE_UNUSED [[maybe_unused]]
#else
# define ANGLE_MAYBE_UNUSED
#endif // __has_cpp_attribute(maybe_unused)
#endif // COMMON_ANGLEUTILS_H_ #endif // COMMON_ANGLEUTILS_H_
...@@ -246,7 +246,7 @@ angle::Result BufferVk::copyToBuffer(ContextVk *contextVk, ...@@ -246,7 +246,7 @@ angle::Result BufferVk::copyToBuffer(ContextVk *contextVk,
uint32_t copyCount, uint32_t copyCount,
const VkBufferCopy *copies) const VkBufferCopy *copies)
{ {
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer));
commandBuffer->copyBuffer(mBuffer.getBuffer(), destBuffer->getBuffer(), copyCount, copies); commandBuffer->copyBuffer(mBuffer.getBuffer(), destBuffer->getBuffer(), copyCount, copies);
......
...@@ -25,14 +25,28 @@ namespace vk ...@@ -25,14 +25,28 @@ namespace vk
{ {
namespace namespace
{ {
ANGLE_MAYBE_UNUSED
angle::Result InitAndBeginCommandBuffer(vk::Context *context, angle::Result InitAndBeginCommandBuffer(vk::Context *context,
const CommandPool &commandPool, const CommandPool &commandPool,
const VkCommandBufferInheritanceInfo &inheritanceInfo, const VkCommandBufferInheritanceInfo &inheritanceInfo,
VkCommandBufferUsageFlags flags, VkCommandBufferUsageFlags flags,
CommandBuffer *commandBuffer) angle::PoolAllocator *poolAllocator,
SecondaryCommandBuffer *commandBuffer)
{ {
ASSERT(!commandBuffer->valid()); ASSERT(!commandBuffer->valid());
commandBuffer->initialize(poolAllocator);
return angle::Result::Continue;
}
ANGLE_MAYBE_UNUSED
angle::Result InitAndBeginCommandBuffer(vk::Context *context,
const CommandPool &commandPool,
const VkCommandBufferInheritanceInfo &inheritanceInfo,
VkCommandBufferUsageFlags flags,
angle::PoolAllocator *poolAllocator,
CommandBuffer *commandBuffer)
{
ASSERT(!commandBuffer->valid());
VkCommandBufferAllocateInfo createInfo = {}; VkCommandBufferAllocateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
createInfo.commandPool = commandPool.getHandle(); createInfo.commandPool = commandPool.getHandle();
...@@ -124,6 +138,26 @@ void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT ...@@ -124,6 +138,26 @@ void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT
kLabelColors[colorIndex].writeData(label->color); kLabelColors[colorIndex].writeData(label->color);
} }
#if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS
static constexpr VkSubpassContents kRenderPassContents = VK_SUBPASS_CONTENTS_INLINE;
#else
static constexpr VkSubpassContents kRenderPassContents =
VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
#endif
// Helpers to unify executeCommands call based on underlying cmd buffer type
ANGLE_MAYBE_UNUSED
void ExecuteCommands(CommandBuffer *primCmdBuffer, SecondaryCommandBuffer *secCmdBuffer)
{
secCmdBuffer->executeCommands(primCmdBuffer->getHandle());
}
ANGLE_MAYBE_UNUSED
void ExecuteCommands(CommandBuffer *primCmdBuffer, CommandBuffer *secCmdBuffer)
{
primCmdBuffer->executeCommands(1, secCmdBuffer);
}
} // anonymous namespace } // anonymous namespace
// CommandGraphResource implementation. // CommandGraphResource implementation.
...@@ -139,7 +173,7 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const ...@@ -139,7 +173,7 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
} }
angle::Result CommandGraphResource::recordCommands(Context *context, angle::Result CommandGraphResource::recordCommands(Context *context,
CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial()); updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
...@@ -150,7 +184,7 @@ angle::Result CommandGraphResource::recordCommands(Context *context, ...@@ -150,7 +184,7 @@ angle::Result CommandGraphResource::recordCommands(Context *context,
context, context->getRenderer()->getCommandPool(), commandBufferOut); context, context->getRenderer()->getCommandPool(), commandBufferOut);
} }
CommandBuffer *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands(); CommandBufferT *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands();
if (!outsideRenderPassCommands->valid()) if (!outsideRenderPassCommands->valid())
{ {
ANGLE_TRY(mCurrentWritingNode->beginOutsideRenderPassRecording( ANGLE_TRY(mCurrentWritingNode->beginOutsideRenderPassRecording(
...@@ -175,7 +209,7 @@ angle::Result CommandGraphResource::beginRenderPass(ContextVk *contextVk, ...@@ -175,7 +209,7 @@ angle::Result CommandGraphResource::beginRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc, const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues, const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
// If a barrier has been inserted in the meantime, stop the command buffer. // If a barrier has been inserted in the meantime, stop the command buffer.
if (!hasChildlessWritingNode()) if (!hasChildlessWritingNode())
...@@ -251,9 +285,11 @@ void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial cur ...@@ -251,9 +285,11 @@ void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial cur
} }
// CommandGraphNode implementation. // CommandGraphNode implementation.
CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function) CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function,
angle::PoolAllocator *poolAllocator)
: mRenderPassClearValues{}, : mRenderPassClearValues{},
mFunction(function), mFunction(function),
mPoolAllocator(poolAllocator),
mQueryPool(VK_NULL_HANDLE), mQueryPool(VK_NULL_HANDLE),
mQueryIndex(0), mQueryIndex(0),
mFenceSyncEvent(VK_NULL_HANDLE), mFenceSyncEvent(VK_NULL_HANDLE),
...@@ -273,15 +309,9 @@ CommandGraphNode::~CommandGraphNode() ...@@ -273,15 +309,9 @@ CommandGraphNode::~CommandGraphNode()
mInsideRenderPassCommands.releaseHandle(); mInsideRenderPassCommands.releaseHandle();
} }
CommandBuffer *CommandGraphNode::getOutsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mOutsideRenderPassCommands;
}
angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context, angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool, const CommandPool &commandPool,
CommandBuffer **commandsOut) CommandBufferT **commandsOut)
{ {
ASSERT(!mHasChildren); ASSERT(!mHasChildren);
...@@ -295,7 +325,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context ...@@ -295,7 +325,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context
inheritanceInfo.queryFlags = 0; inheritanceInfo.queryFlags = 0;
inheritanceInfo.pipelineStatistics = 0; inheritanceInfo.pipelineStatistics = 0;
ANGLE_TRY(InitAndBeginCommandBuffer(context, commandPool, inheritanceInfo, 0, ANGLE_TRY(InitAndBeginCommandBuffer(context, commandPool, inheritanceInfo, 0, mPoolAllocator,
&mOutsideRenderPassCommands)); &mOutsideRenderPassCommands));
*commandsOut = &mOutsideRenderPassCommands; *commandsOut = &mOutsideRenderPassCommands;
...@@ -303,7 +333,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context ...@@ -303,7 +333,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context
} }
angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context, angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context,
CommandBuffer **commandsOut) CommandBufferT **commandsOut)
{ {
ASSERT(!mHasChildren); ASSERT(!mHasChildren);
...@@ -323,9 +353,10 @@ angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context, ...@@ -323,9 +353,10 @@ angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context,
inheritanceInfo.queryFlags = 0; inheritanceInfo.queryFlags = 0;
inheritanceInfo.pipelineStatistics = 0; inheritanceInfo.pipelineStatistics = 0;
ANGLE_TRY(InitAndBeginCommandBuffer( ANGLE_TRY(InitAndBeginCommandBuffer(context, context->getRenderer()->getCommandPool(),
context, context->getRenderer()->getCommandPool(), inheritanceInfo, inheritanceInfo,
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, &mInsideRenderPassCommands)); VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT,
mPoolAllocator, &mInsideRenderPassCommands));
*commandsOut = &mInsideRenderPassCommands; *commandsOut = &mInsideRenderPassCommands;
return angle::Result::Continue; return angle::Result::Continue;
...@@ -462,7 +493,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context, ...@@ -462,7 +493,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
if (mOutsideRenderPassCommands.valid()) if (mOutsideRenderPassCommands.valid())
{ {
ANGLE_VK_TRY(context, mOutsideRenderPassCommands.end()); ANGLE_VK_TRY(context, mOutsideRenderPassCommands.end());
primaryCommandBuffer->executeCommands(1, &mOutsideRenderPassCommands); ExecuteCommands(primaryCommandBuffer, &mOutsideRenderPassCommands);
} }
if (mInsideRenderPassCommands.valid()) if (mInsideRenderPassCommands.valid())
...@@ -488,9 +519,8 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context, ...@@ -488,9 +519,8 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
beginInfo.clearValueCount = mRenderPassDesc.attachmentCount(); beginInfo.clearValueCount = mRenderPassDesc.attachmentCount();
beginInfo.pClearValues = mRenderPassClearValues.data(); beginInfo.pClearValues = mRenderPassClearValues.data();
primaryCommandBuffer->beginRenderPass( primaryCommandBuffer->beginRenderPass(beginInfo, kRenderPassContents);
beginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); ExecuteCommands(primaryCommandBuffer, &mInsideRenderPassCommands);
primaryCommandBuffer->executeCommands(1, &mInsideRenderPassCommands);
primaryCommandBuffer->endRenderPass(); primaryCommandBuffer->endRenderPass();
} }
break; break;
...@@ -600,8 +630,10 @@ const gl::Rectangle &CommandGraphNode::getRenderPassRenderArea() const ...@@ -600,8 +630,10 @@ const gl::Rectangle &CommandGraphNode::getRenderPassRenderArea() const
} }
// CommandGraph implementation. // CommandGraph implementation.
CommandGraph::CommandGraph(bool enableGraphDiagnostics) CommandGraph::CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *poolAllocator)
: mEnableGraphDiagnostics(enableGraphDiagnostics), mLastBarrierIndex(kInvalidNodeIndex) : mEnableGraphDiagnostics(enableGraphDiagnostics),
mPoolAllocator(poolAllocator),
mLastBarrierIndex(kInvalidNodeIndex)
{} {}
CommandGraph::~CommandGraph() CommandGraph::~CommandGraph()
...@@ -612,7 +644,7 @@ CommandGraph::~CommandGraph() ...@@ -612,7 +644,7 @@ CommandGraph::~CommandGraph()
CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function) CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function)
{ {
// TODO(jmadill): Use a pool allocator for the CPU node allocations. // TODO(jmadill): Use a pool allocator for the CPU node allocations.
CommandGraphNode *newCommands = new CommandGraphNode(function); CommandGraphNode *newCommands = new CommandGraphNode(function, mPoolAllocator);
mNodes.emplace_back(newCommands); mNodes.emplace_back(newCommands);
return newCommands; return newCommands;
} }
......
...@@ -10,8 +10,15 @@ ...@@ -10,8 +10,15 @@
#ifndef LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_ #ifndef LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_
#define LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_ #define LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_
#include "libANGLE/renderer/vulkan/SecondaryCommandBuffer.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
#if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS
using CommandBufferT = rx::vk::SecondaryCommandBuffer;
#else
using CommandBufferT = rx::vk::CommandBuffer;
#endif
namespace rx namespace rx
{ {
...@@ -61,20 +68,24 @@ class CommandBufferOwner ...@@ -61,20 +68,24 @@ class CommandBufferOwner
ANGLE_INLINE void onCommandBufferFinished() { mCommandBuffer = nullptr; } ANGLE_INLINE void onCommandBufferFinished() { mCommandBuffer = nullptr; }
protected: protected:
vk::CommandBuffer *mCommandBuffer = nullptr; CommandBufferT *mCommandBuffer = nullptr;
}; };
// Only used internally in the command graph. Kept in the header for better inlining performance. // Only used internally in the command graph. Kept in the header for better inlining performance.
class CommandGraphNode final : angle::NonCopyable class CommandGraphNode final : angle::NonCopyable
{ {
public: public:
CommandGraphNode(CommandGraphNodeFunction function); CommandGraphNode(CommandGraphNodeFunction function, angle::PoolAllocator *poolAllocator);
~CommandGraphNode(); ~CommandGraphNode();
// Immutable queries for when we're walking the commands tree. // Immutable queries for when we're walking the commands tree.
CommandBuffer *getOutsideRenderPassCommands(); CommandBufferT *getOutsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mOutsideRenderPassCommands;
}
CommandBuffer *getInsideRenderPassCommands() CommandBufferT *getInsideRenderPassCommands()
{ {
ASSERT(!mHasChildren); ASSERT(!mHasChildren);
return &mInsideRenderPassCommands; return &mInsideRenderPassCommands;
...@@ -83,10 +94,10 @@ class CommandGraphNode final : angle::NonCopyable ...@@ -83,10 +94,10 @@ class CommandGraphNode final : angle::NonCopyable
// For outside the render pass (copies, transitions, etc). // For outside the render pass (copies, transitions, etc).
angle::Result beginOutsideRenderPassRecording(Context *context, angle::Result beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool, const CommandPool &commandPool,
CommandBuffer **commandsOut); CommandBufferT **commandsOut);
// For rendering commands (draws). // For rendering commands (draws).
angle::Result beginInsideRenderPassRecording(Context *context, CommandBuffer **commandsOut); angle::Result beginInsideRenderPassRecording(Context *context, CommandBufferT **commandsOut);
// storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass. // storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass.
void storeRenderPassInfo(const Framebuffer &framebuffer, void storeRenderPassInfo(const Framebuffer &framebuffer,
...@@ -173,11 +184,11 @@ class CommandGraphNode final : angle::NonCopyable ...@@ -173,11 +184,11 @@ class CommandGraphNode final : angle::NonCopyable
gl::AttachmentArray<VkClearValue> mRenderPassClearValues; gl::AttachmentArray<VkClearValue> mRenderPassClearValues;
CommandGraphNodeFunction mFunction; CommandGraphNodeFunction mFunction;
angle::PoolAllocator *mPoolAllocator;
// Keep separate buffers for commands inside and outside a RenderPass. // Keep separate buffers for commands inside and outside a RenderPass.
// TODO(jmadill): We might not need inside and outside RenderPass commands separate. // TODO(jmadill): We might not need inside and outside RenderPass commands separate.
CommandBuffer mOutsideRenderPassCommands; CommandBufferT mOutsideRenderPassCommands;
CommandBuffer mInsideRenderPassCommands; CommandBufferT mInsideRenderPassCommands;
// Special-function additional data: // Special-function additional data:
// Queries: // Queries:
...@@ -251,7 +262,7 @@ class CommandGraphResource : angle::NonCopyable ...@@ -251,7 +262,7 @@ class CommandGraphResource : angle::NonCopyable
// Allocates a write node via getNewWriteNode and returns a started command buffer. // Allocates a write node via getNewWriteNode and returns a started command buffer.
// The started command buffer will render outside of a RenderPass. // The started command buffer will render outside of a RenderPass.
// Will append to an existing command buffer/graph node if possible. // Will append to an existing command buffer/graph node if possible.
angle::Result recordCommands(Context *context, CommandBuffer **commandBufferOut); angle::Result recordCommands(Context *context, CommandBufferT **commandBufferOut);
// Begins a command buffer on the current graph node for in-RenderPass rendering. // Begins a command buffer on the current graph node for in-RenderPass rendering.
// Called from FramebufferVk::startNewRenderPass and UtilsVk functions. // Called from FramebufferVk::startNewRenderPass and UtilsVk functions.
...@@ -260,12 +271,12 @@ class CommandGraphResource : angle::NonCopyable ...@@ -260,12 +271,12 @@ class CommandGraphResource : angle::NonCopyable
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc, const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues, const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut); CommandBufferT **commandBufferOut);
// Checks if we're in a RenderPass, returning true if so. Updates serial internally. // Checks if we're in a RenderPass, returning true if so. Updates serial internally.
// Returns the started command buffer in commandBufferOut. // Returns the started command buffer in commandBufferOut.
ANGLE_INLINE bool appendToStartedRenderPass(Serial currentQueueSerial, ANGLE_INLINE bool appendToStartedRenderPass(Serial currentQueueSerial,
CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
updateQueueSerial(currentQueueSerial); updateQueueSerial(currentQueueSerial);
if (hasStartedRenderPass()) if (hasStartedRenderPass())
...@@ -340,13 +351,13 @@ class CommandGraphResource : angle::NonCopyable ...@@ -340,13 +351,13 @@ class CommandGraphResource : angle::NonCopyable
// ANGLE's CommandGraph (and CommandGraphNode) attempt to solve these problems using deferred // ANGLE's CommandGraph (and CommandGraphNode) attempt to solve these problems using deferred
// command submission. We also sometimes call this command re-ordering. A brief summary: // command submission. We also sometimes call this command re-ordering. A brief summary:
// //
// During GL command processing, we record Vulkan commands into secondary command buffers, which // During GL command processing, we record Vulkan commands into SecondaryCommandBuffers, which
// are stored in CommandGraphNodes, and these nodes are chained together via dependencies to // are stored in CommandGraphNodes, and these nodes are chained together via dependencies to
// for a directed acyclic CommandGraph. When we need to submit the CommandGraph, say during a // form a directed acyclic CommandGraph. When we need to submit the CommandGraph, say during a
// SwapBuffers or ReadPixels call, we begin a primary Vulkan CommandBuffer, and walk the // SwapBuffers or ReadPixels call, we begin a primary Vulkan CommandBuffer, and walk the
// CommandGraph, starting at the most senior nodes, recording secondary CommandBuffers inside // CommandGraph, starting at the most senior nodes, recording SecondaryCommandBuffers inside
// and outside RenderPasses as necessary, filled with the right load/store operations. Once // 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 // the primary CommandBuffer has recorded all of the SecondaryCommandBuffers from all the open
// CommandGraphNodes, we submit the primary CommandBuffer to the VkQueue on the device. // CommandGraphNodes, we submit the primary CommandBuffer to the VkQueue on the device.
// //
// The Command Graph consists of an array of open Command Graph Nodes. It supports allocating new // The Command Graph consists of an array of open Command Graph Nodes. It supports allocating new
...@@ -355,7 +366,7 @@ class CommandGraphResource : angle::NonCopyable ...@@ -355,7 +366,7 @@ class CommandGraphResource : angle::NonCopyable
class CommandGraph final : angle::NonCopyable class CommandGraph final : angle::NonCopyable
{ {
public: public:
explicit CommandGraph(bool enableGraphDiagnostics); explicit CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *poolAllocator);
~CommandGraph(); ~CommandGraph();
// Allocates a new CommandGraphNode and adds it to the list of current open nodes. No ordering // Allocates a new CommandGraphNode and adds it to the list of current open nodes. No ordering
...@@ -397,6 +408,7 @@ class CommandGraph final : angle::NonCopyable ...@@ -397,6 +408,7 @@ class CommandGraph final : angle::NonCopyable
std::vector<CommandGraphNode *> mNodes; std::vector<CommandGraphNode *> mNodes;
bool mEnableGraphDiagnostics; bool mEnableGraphDiagnostics;
angle::PoolAllocator *mPoolAllocator;
// A set of nodes (eventually) exist that act as barriers to guarantee submission order. For // A set of nodes (eventually) exist that act as barriers to guarantee submission order. For
// example, a glMemoryBarrier() calls would lead to such a barrier or beginning and ending a // example, a glMemoryBarrier() calls would lead to such a barrier or beginning and ending a
......
...@@ -206,7 +206,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context, ...@@ -206,7 +206,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
gl::DrawElementsType indexTypeOrNone, gl::DrawElementsType indexTypeOrNone,
const void *indices, const void *indices,
DirtyBits dirtyBitMask, DirtyBits dirtyBitMask,
vk::CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
// Set any dirty bits that depend on draw call parameters or other objects. // Set any dirty bits that depend on draw call parameters or other objects.
if (mode != mCurrentDrawMode) if (mode != mCurrentDrawMode)
...@@ -273,7 +273,7 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context, ...@@ -273,7 +273,7 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context,
GLsizei instanceCount, GLsizei instanceCount,
gl::DrawElementsType indexType, gl::DrawElementsType indexType,
const void *indices, const void *indices,
vk::CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
if (indexType != mCurrentDrawElementsType) if (indexType != mCurrentDrawElementsType)
{ {
...@@ -312,7 +312,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context, ...@@ -312,7 +312,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
GLsizei vertexOrIndexCount, GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid, gl::DrawElementsType indexTypeOrInvalid,
const void *indices, const void *indices,
vk::CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
ANGLE_TRY(mVertexArray->handleLineLoop(this, firstVertex, vertexOrIndexCount, ANGLE_TRY(mVertexArray->handleLineLoop(this, firstVertex, vertexOrIndexCount,
indexTypeOrInvalid, indices)); indexTypeOrInvalid, indices));
...@@ -325,7 +325,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context, ...@@ -325,7 +325,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context, angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(mDirtyDefaultAttribsMask.any()); ASSERT(mDirtyDefaultAttribsMask.any());
...@@ -339,7 +339,7 @@ angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context, ...@@ -339,7 +339,7 @@ angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context, angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
if (!mCurrentPipeline) if (!mCurrentPipeline)
{ {
...@@ -379,7 +379,7 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context, ...@@ -379,7 +379,7 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyTextures(const gl::Context *context, angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ANGLE_TRY(updateActiveTextures(context)); ANGLE_TRY(updateActiveTextures(context));
...@@ -391,7 +391,7 @@ angle::Result ContextVk::handleDirtyTextures(const gl::Context *context, ...@@ -391,7 +391,7 @@ angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context, angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
uint32_t maxAttrib = mProgram->getState().getMaxActiveAttribLocation(); uint32_t maxAttrib = mProgram->getState().getMaxActiveAttribLocation();
const gl::AttribArray<VkBuffer> &bufferHandles = mVertexArray->getCurrentArrayBufferHandles(); const gl::AttribArray<VkBuffer> &bufferHandles = mVertexArray->getCurrentArrayBufferHandles();
...@@ -417,12 +417,12 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context, ...@@ -417,12 +417,12 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context, angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
vk::BufferHelper *elementArrayBuffer = mVertexArray->getCurrentElementArrayBuffer(); vk::BufferHelper *elementArrayBuffer = mVertexArray->getCurrentElementArrayBuffer();
ASSERT(elementArrayBuffer != nullptr); ASSERT(elementArrayBuffer != nullptr);
commandBuffer->bindIndexBuffer(elementArrayBuffer->getBuffer().getHandle(), commandBuffer->bindIndexBuffer(elementArrayBuffer->getBuffer(),
mVertexArray->getCurrentElementArrayBufferOffset(), mVertexArray->getCurrentElementArrayBufferOffset(),
gl_vk::kIndexTypeMap[mCurrentDrawElementsType]); gl_vk::kIndexTypeMap[mCurrentDrawElementsType]);
...@@ -433,7 +433,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context, ...@@ -433,7 +433,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
} }
angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context, angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ANGLE_TRY(mProgram->updateDescriptorSets(this, commandBuffer)); ANGLE_TRY(mProgram->updateDescriptorSets(this, commandBuffer));
...@@ -449,7 +449,7 @@ angle::Result ContextVk::drawArrays(const gl::Context *context, ...@@ -449,7 +449,7 @@ angle::Result ContextVk::drawArrays(const gl::Context *context,
GLint first, GLint first,
GLsizei count) GLsizei count)
{ {
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
uint32_t clampedVertexCount = gl::GetClampedVertexCount<uint32_t>(count); uint32_t clampedVertexCount = gl::GetClampedVertexCount<uint32_t>(count);
if (mode == gl::PrimitiveMode::LineLoop) if (mode == gl::PrimitiveMode::LineLoop)
...@@ -481,7 +481,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context, ...@@ -481,7 +481,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context,
return angle::Result::Stop; return angle::Result::Stop;
} }
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum, ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum,
nullptr, mNonIndexedDirtyBitsMask, &commandBuffer)); nullptr, mNonIndexedDirtyBitsMask, &commandBuffer));
commandBuffer->draw(gl::GetClampedVertexCount<uint32_t>(count), instances, first, 0); commandBuffer->draw(gl::GetClampedVertexCount<uint32_t>(count), instances, first, 0);
...@@ -494,7 +494,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context, ...@@ -494,7 +494,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context,
gl::DrawElementsType type, gl::DrawElementsType type,
const void *indices) const void *indices)
{ {
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
if (mode == gl::PrimitiveMode::LineLoop) if (mode == gl::PrimitiveMode::LineLoop)
{ {
ANGLE_TRY(setupLineLoopDraw(context, mode, 0, count, type, indices, &commandBuffer)); ANGLE_TRY(setupLineLoopDraw(context, mode, 0, count, type, indices, &commandBuffer));
...@@ -523,7 +523,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context, ...@@ -523,7 +523,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context,
return angle::Result::Stop; return angle::Result::Stop;
} }
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer)); ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer));
commandBuffer->drawIndexed(count, instances, 0, 0, 0); commandBuffer->drawIndexed(count, instances, 0, 0, 0);
return angle::Result::Continue; return angle::Result::Continue;
...@@ -1157,7 +1157,7 @@ VkColorComponentFlags ContextVk::getClearColorMask() const ...@@ -1157,7 +1157,7 @@ VkColorComponentFlags ContextVk::getClearColorMask() const
} }
angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context, angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
// Release any previously retained buffers. // Release any previously retained buffers.
mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer); mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer);
......
...@@ -167,6 +167,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -167,6 +167,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
ANGLE_INLINE void invalidateVertexAndIndexBuffers() ANGLE_INLINE void invalidateVertexAndIndexBuffers()
{ {
// TODO: Make the pipeline invalidate more fine-grained. Only need to dirty here if PSO
// VtxInput state (stride, fmt, inputRate...) has changed. http://anglebug.com/3256
invalidateCurrentPipeline(); invalidateCurrentPipeline();
mDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS); mDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
mDirtyBits.set(DIRTY_BIT_INDEX_BUFFER); mDirtyBits.set(DIRTY_BIT_INDEX_BUFFER);
...@@ -224,7 +226,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -224,7 +226,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
using DirtyBitHandler = angle::Result (ContextVk::*)(const gl::Context *, using DirtyBitHandler = angle::Result (ContextVk::*)(const gl::Context *,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mDirtyBitHandlers;
...@@ -236,21 +238,21 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -236,21 +238,21 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
gl::DrawElementsType indexTypeOrInvalid, gl::DrawElementsType indexTypeOrInvalid,
const void *indices, const void *indices,
DirtyBits dirtyBitMask, DirtyBits dirtyBitMask,
vk::CommandBuffer **commandBufferOut); CommandBufferT **commandBufferOut);
angle::Result setupIndexedDraw(const gl::Context *context, angle::Result setupIndexedDraw(const gl::Context *context,
gl::PrimitiveMode mode, gl::PrimitiveMode mode,
GLsizei indexCount, GLsizei indexCount,
GLsizei instanceCount, GLsizei instanceCount,
gl::DrawElementsType indexType, gl::DrawElementsType indexType,
const void *indices, const void *indices,
vk::CommandBuffer **commandBufferOut); CommandBufferT **commandBufferOut);
angle::Result setupLineLoopDraw(const gl::Context *context, angle::Result setupLineLoopDraw(const gl::Context *context,
gl::PrimitiveMode mode, gl::PrimitiveMode mode,
GLint firstVertex, GLint firstVertex,
GLsizei vertexOrIndexCount, GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid, gl::DrawElementsType indexTypeOrInvalid,
const void *indices, const void *indices,
vk::CommandBuffer **commandBufferOut); CommandBufferT **commandBufferOut);
void updateViewport(FramebufferVk *framebufferVk, void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport, const gl::Rectangle &viewport,
...@@ -271,17 +273,16 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -271,17 +273,16 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
void invalidateDriverUniforms(); void invalidateDriverUniforms();
angle::Result handleDirtyDefaultAttribs(const gl::Context *context, angle::Result handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, vk::CommandBuffer *commandBuffer); angle::Result handleDirtyPipeline(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, vk::CommandBuffer *commandBuffer); angle::Result handleDirtyTextures(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyVertexBuffers(const gl::Context *context, angle::Result handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context, angle::Result handleDirtyIndexBuffer(const gl::Context *context, CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyDriverUniforms(const gl::Context *context, angle::Result handleDirtyDriverUniforms(const gl::Context *context,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
angle::Result handleDirtyDescriptorSets(const gl::Context *context, angle::Result handleDirtyDescriptorSets(const gl::Context *context,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
vk::PipelineHelper *mCurrentPipeline; vk::PipelineHelper *mCurrentPipeline;
gl::PrimitiveMode mCurrentDrawMode; gl::PrimitiveMode mCurrentDrawMode;
......
...@@ -166,7 +166,7 @@ angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -166,7 +166,7 @@ angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
// This command buffer is only started once. // This command buffer is only started once.
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
const gl::FramebufferAttachment *depthAttachment = mState.getDepthAttachment(); const gl::FramebufferAttachment *depthAttachment = mState.getDepthAttachment();
bool clearDepth = (depthAttachment && (mask & GL_DEPTH_BUFFER_BIT) != 0); bool clearDepth = (depthAttachment && (mask & GL_DEPTH_BUFFER_BIT) != 0);
...@@ -424,7 +424,7 @@ angle::Result FramebufferVk::blitWithCopy(ContextVk *contextVk, ...@@ -424,7 +424,7 @@ angle::Result FramebufferVk::blitWithCopy(ContextVk *contextVk,
VkImageAspectFlags aspectMask = VkImageAspectFlags aspectMask =
vk::GetDepthStencilAspectFlagsForCopy(blitDepthBuffer, blitStencilBuffer); vk::GetDepthStencilAspectFlagsForCopy(blitDepthBuffer, blitStencilBuffer);
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
...@@ -509,7 +509,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk, ...@@ -509,7 +509,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
// Reinitialize the commandBuffer after a read pixels because it calls // Reinitialize the commandBuffer after a read pixels because it calls
// renderer->finish which makes command buffers obsolete. // renderer->finish which makes command buffers obsolete.
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// We read the bytes of the image in a buffer, now we have to copy them into the // We read the bytes of the image in a buffer, now we have to copy them into the
...@@ -669,7 +669,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk, ...@@ -669,7 +669,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
const vk::Format &readImageFormat = readRenderTarget->getImageFormat(); const vk::Format &readImageFormat = readRenderTarget->getImageFormat();
...@@ -903,7 +903,7 @@ angle::Result FramebufferVk::clearWithClearAttachments( ...@@ -903,7 +903,7 @@ angle::Result FramebufferVk::clearWithClearAttachments(
// This command can only happen inside a render pass, so obtain one if its already happening // This command can only happen inside a render pass, so obtain one if its already happening
// or create a new one if not. // or create a new one if not.
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
vk::RecordingMode mode = vk::RecordingMode::Start; vk::RecordingMode mode = vk::RecordingMode::Start;
ANGLE_TRY(getCommandBufferForDraw(contextVk, &commandBuffer, &mode)); ANGLE_TRY(getCommandBufferForDraw(contextVk, &commandBuffer, &mode));
...@@ -1032,7 +1032,7 @@ angle::Result FramebufferVk::getSamplePosition(const gl::Context *context, ...@@ -1032,7 +1032,7 @@ angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
} }
angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk, angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut, CommandBufferT **commandBufferOut,
vk::RecordingMode *modeOut) vk::RecordingMode *modeOut)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
...@@ -1048,7 +1048,7 @@ angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk, ...@@ -1048,7 +1048,7 @@ angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
} }
angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
vk::Framebuffer *framebuffer = nullptr; vk::Framebuffer *framebuffer = nullptr;
ANGLE_TRY(getFramebuffer(contextVk, &framebuffer)); ANGLE_TRY(getFramebuffer(contextVk, &framebuffer));
...@@ -1056,7 +1056,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -1056,7 +1056,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
// TODO(jmadill): Proper clear value implementation. http://anglebug.com/2361 // TODO(jmadill): Proper clear value implementation. http://anglebug.com/2361
std::vector<VkClearValue> attachmentClearValues; std::vector<VkClearValue> attachmentClearValues;
vk::CommandBuffer *writeCommands = nullptr; CommandBufferT *writeCommands = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands));
vk::RenderPassDesc renderPassDesc; vk::RenderPassDesc renderPassDesc;
...@@ -1112,7 +1112,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1112,7 +1112,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
ANGLE_TRY(renderTarget->ensureImageInitialized(contextVk)); ANGLE_TRY(renderTarget->ensureImageInitialized(contextVk));
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// Note that although we're reading from the image, we need to update the layout below. // Note that although we're reading from the image, we need to update the layout below.
......
...@@ -106,14 +106,14 @@ class FramebufferVk : public FramebufferImpl ...@@ -106,14 +106,14 @@ class FramebufferVk : public FramebufferImpl
RenderTargetVk *getColorReadRenderTarget() const; RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete. // This will clear the current write operation if it is complete.
bool appendToStartedRenderPass(Serial currentQueueSerial, vk::CommandBuffer **commandBufferOut) bool appendToStartedRenderPass(Serial currentQueueSerial, CommandBufferT **commandBufferOut)
{ {
return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, commandBufferOut); return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, commandBufferOut);
} }
vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; } vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; }
angle::Result startNewRenderPass(ContextVk *context, vk::CommandBuffer **commandBufferOut); angle::Result startNewRenderPass(ContextVk *context, CommandBufferT **commandBufferOut);
RenderTargetVk *getFirstRenderTarget() const; RenderTargetVk *getFirstRenderTarget() const;
GLint getSamples() const; GLint getSamples() const;
...@@ -127,7 +127,7 @@ class FramebufferVk : public FramebufferImpl ...@@ -127,7 +127,7 @@ class FramebufferVk : public FramebufferImpl
// Helper for appendToStarted/else startNewRenderPass. // Helper for appendToStarted/else startNewRenderPass.
angle::Result getCommandBufferForDraw(ContextVk *contextVk, angle::Result getCommandBufferForDraw(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut, CommandBufferT **commandBufferOut,
vk::RecordingMode *modeOut); vk::RecordingMode *modeOut);
// The 'in' rectangles must be clipped to the scissor and FBO. The clipping is done in 'blit'. // The 'in' rectangles must be clipped to the scissor and FBO. The clipping is done in 'blit'.
......
...@@ -862,7 +862,7 @@ angle::Result ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk, ...@@ -862,7 +862,7 @@ angle::Result ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk,
// Ensure the image is in read-only layout // Ensure the image is in read-only layout
if (image.isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly)) if (image.isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly))
{ {
vk::CommandBuffer *srcLayoutChange; CommandBufferT *srcLayoutChange;
ANGLE_TRY(image.recordCommands(contextVk, &srcLayoutChange)); ANGLE_TRY(image.recordCommands(contextVk, &srcLayoutChange));
image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT,
...@@ -910,8 +910,7 @@ void ProgramVk::setDefaultUniformBlocksMinSizeForTesting(size_t minSize) ...@@ -910,8 +910,7 @@ void ProgramVk::setDefaultUniformBlocksMinSizeForTesting(size_t minSize)
} }
} }
angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk, angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk, CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{ {
// Can probably use better dirty bits here. // Can probably use better dirty bits here.
......
...@@ -108,7 +108,7 @@ class ProgramVk : public ProgramImpl ...@@ -108,7 +108,7 @@ class ProgramVk : public ProgramImpl
angle::Result updateTexturesDescriptorSet(ContextVk *contextVk, angle::Result updateTexturesDescriptorSet(ContextVk *contextVk,
vk::FramebufferHelper *framebuffer); vk::FramebufferHelper *framebuffer);
angle::Result updateDescriptorSets(ContextVk *contextVk, vk::CommandBuffer *commandBuffer); angle::Result updateDescriptorSets(ContextVk *contextVk, CommandBufferT *commandBuffer);
// For testing only. // For testing only.
void setDefaultUniformBlocksMinSizeForTesting(size_t minSize); void setDefaultUniformBlocksMinSizeForTesting(size_t minSize);
......
...@@ -53,7 +53,7 @@ void RenderTargetVk::reset() ...@@ -53,7 +53,7 @@ void RenderTargetVk::reset()
} }
void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk, void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer, CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc) vk::RenderPassDesc *renderPassDesc)
{ {
ASSERT(commandBuffer->valid()); ASSERT(commandBuffer->valid());
...@@ -71,7 +71,7 @@ void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk, ...@@ -71,7 +71,7 @@ void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
} }
void RenderTargetVk::onDepthStencilDraw(vk::FramebufferHelper *framebufferVk, void RenderTargetVk::onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer, CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc) vk::RenderPassDesc *renderPassDesc)
{ {
ASSERT(commandBuffer->valid()); ASSERT(commandBuffer->valid());
...@@ -135,7 +135,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView ...@@ -135,7 +135,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource, vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource,
vk::ImageLayout layout, vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(mImage && mImage->valid()); ASSERT(mImage && mImage->valid());
...@@ -145,7 +145,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi ...@@ -145,7 +145,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi
// //
// if (mImage->isLayoutChangeNecessary(layout) // if (mImage->isLayoutChangeNecessary(layout)
// { // {
// vk::CommandBuffer *srcLayoutChange; // CommandBufferT *srcLayoutChange;
// ANGLE_TRY(mImage->recordCommands(contextVk, &srcLayoutChange)); // ANGLE_TRY(mImage->recordCommands(contextVk, &srcLayoutChange));
// mImage->changeLayout(mImage->getAspectFlags(), layout, srcLayoutChange); // mImage->changeLayout(mImage->getAspectFlags(), layout, srcLayoutChange);
// } // }
......
...@@ -53,10 +53,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget ...@@ -53,10 +53,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
// Note: RenderTargets should be called in order, with the depth/stencil onRender last. // Note: RenderTargets should be called in order, with the depth/stencil onRender last.
void onColorDraw(vk::FramebufferHelper *framebufferVk, void onColorDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer, CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc); vk::RenderPassDesc *renderPassDesc);
void onDepthStencilDraw(vk::FramebufferHelper *framebufferVk, void onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer, CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc); vk::RenderPassDesc *renderPassDesc);
vk::ImageHelper &getImage(); vk::ImageHelper &getImage();
...@@ -65,7 +65,7 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget ...@@ -65,7 +65,7 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
// getImageForRead will also transition the resource to the given layout. // getImageForRead will also transition the resource to the given layout.
vk::ImageHelper *getImageForRead(vk::CommandGraphResource *readingResource, vk::ImageHelper *getImageForRead(vk::CommandGraphResource *readingResource,
vk::ImageLayout layout, vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const; vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const;
vk::ImageView *getDrawImageView() const; vk::ImageView *getDrawImageView() const;
......
...@@ -93,7 +93,7 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context, ...@@ -93,7 +93,7 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context,
&mImageView, 0, 1)); &mImageView, 0, 1));
// TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361 // TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
if (isDepthOrStencilFormat) if (isDepthOrStencilFormat)
...@@ -143,7 +143,7 @@ angle::Result RenderbufferVk::setStorageEGLImageTarget(const gl::Context *contex ...@@ -143,7 +143,7 @@ angle::Result RenderbufferVk::setStorageEGLImageTarget(const gl::Context *contex
uint32_t rendererQueueFamilyIndex = contextVk->getRenderer()->getQueueFamilyIndex(); uint32_t rendererQueueFamilyIndex = contextVk->getRenderer()->getQueueFamilyIndex();
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex)) if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{ {
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
mImage->changeLayoutAndQueue(aspect, vk::ImageLayout::ColorAttachment, mImage->changeLayoutAndQueue(aspect, vk::ImageLayout::ColorAttachment,
rendererQueueFamilyIndex, commandBuffer); rendererQueueFamilyIndex, commandBuffer);
......
...@@ -41,6 +41,7 @@ const uint32_t kMockDeviceID = 0xf005ba11; ...@@ -41,6 +41,7 @@ const uint32_t kMockDeviceID = 0xf005ba11;
constexpr char kMockDeviceName[] = "Vulkan Mock Device"; constexpr char kMockDeviceName[] = "Vulkan Mock Device";
constexpr size_t kInFlightCommandsLimit = 100u; constexpr size_t kInFlightCommandsLimit = 100u;
constexpr VkFormatFeatureFlags kInvalidFormatFeatureFlags = static_cast<VkFormatFeatureFlags>(-1); constexpr VkFormatFeatureFlags kInvalidFormatFeatureFlags = static_cast<VkFormatFeatureFlags>(-1);
constexpr size_t kDefaultPoolAllocatorPageSize = 16 * 1024;
} // anonymous namespace } // anonymous namespace
namespace rx namespace rx
...@@ -505,7 +506,8 @@ RendererVk::RendererVk() ...@@ -505,7 +506,8 @@ RendererVk::RendererVk()
mCurrentQueueSerial(mQueueSerialFactory.generate()), mCurrentQueueSerial(mQueueSerialFactory.generate()),
mDeviceLost(false), mDeviceLost(false),
mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod), mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod),
mCommandGraph(kEnableCommandGraphDiagnostics), mPoolAllocator(kDefaultPoolAllocatorPageSize),
mCommandGraph(kEnableCommandGraphDiagnostics, &mPoolAllocator),
mGpuEventsEnabled(false), mGpuEventsEnabled(false),
mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()}, mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()},
mGpuEventTimestampOrigin(0) mGpuEventTimestampOrigin(0)
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <memory> #include <memory>
#include "common/PoolAlloc.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/BlobCache.h" #include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
...@@ -334,6 +335,9 @@ class RendererVk : angle::NonCopyable ...@@ -334,6 +335,9 @@ class RendererVk : angle::NonCopyable
// http://anglebug.com/2701 // http://anglebug.com/2701
vk::Shared<vk::Fence> mSubmitFence; vk::Shared<vk::Fence> mSubmitFence;
// Pool allocator used for command graph but may be expanded to other allocations
angle::PoolAllocator mPoolAllocator;
// See CommandGraph.h for a desription of the Command Graph. // See CommandGraph.h for a desription of the Command Graph.
vk::CommandGraph mCommandGraph; vk::CommandGraph mCommandGraph;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "common/PoolAlloc.h" #include "common/PoolAlloc.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
namespace rx namespace rx
{ {
...@@ -295,56 +296,54 @@ struct CommandHeader ...@@ -295,56 +296,54 @@ struct CommandHeader
class SecondaryCommandBuffer final : angle::NonCopyable class SecondaryCommandBuffer final : angle::NonCopyable
{ {
public: public:
SecondaryCommandBuffer(angle::PoolAllocator *allocator) SecondaryCommandBuffer() : mHead(nullptr), mLast(nullptr), mAllocator(nullptr) {}
: mHead(nullptr), mLast(nullptr), mAllocator(allocator)
{}
~SecondaryCommandBuffer() {} ~SecondaryCommandBuffer() {}
// Add commands // Add commands
void bindDescriptorSets(VkPipelineBindPoint bindPoint, void bindDescriptorSets(VkPipelineBindPoint bindPoint,
VkPipelineLayout layout, const PipelineLayout &layout,
uint32_t firstSet, uint32_t firstSet,
uint32_t descriptorSetCount, uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets, const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount, uint32_t dynamicOffsetCount,
const uint32_t *dynamicOffsets); const uint32_t *dynamicOffsets);
void bindIndexBuffer(const VkBuffer &buffer, VkDeviceSize offset, VkIndexType indexType); void bindIndexBuffer(const Buffer &buffer, VkDeviceSize offset, VkIndexType indexType);
void bindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); void bindPipeline(VkPipelineBindPoint pipelineBindPoint, const Pipeline &pipeline);
void bindVertexBuffers(uint32_t firstBinding, void bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount, uint32_t bindingCount,
const VkBuffer *buffers, const VkBuffer *buffers,
const VkDeviceSize *offsets); const VkDeviceSize *offsets);
void blitImage(VkImage srcImage, void blitImage(const Image &srcImage,
VkImageLayout srcImageLayout, VkImageLayout srcImageLayout,
VkImage dstImage, const Image &dstImage,
VkImageLayout dstImageLayout, VkImageLayout dstImageLayout,
uint32_t regionCount, uint32_t regionCount,
const VkImageBlit *pRegions, const VkImageBlit *pRegions,
VkFilter filter); VkFilter filter);
void copyBuffer(const VkBuffer &srcBuffer, void copyBuffer(const Buffer &srcBuffer,
const VkBuffer &destBuffer, const Buffer &destBuffer,
uint32_t regionCount, uint32_t regionCount,
const VkBufferCopy *regions); const VkBufferCopy *regions);
void copyBufferToImage(VkBuffer srcBuffer, void copyBufferToImage(VkBuffer srcBuffer,
VkImage dstImage, const Image &dstImage,
VkImageLayout dstImageLayout, VkImageLayout dstImageLayout,
uint32_t regionCount, uint32_t regionCount,
const VkBufferImageCopy *regions); const VkBufferImageCopy *regions);
void copyImage(VkImage srcImage, void copyImage(const Image &srcImage,
VkImageLayout srcImageLayout, VkImageLayout srcImageLayout,
VkImage dstImage, const Image &dstImage,
VkImageLayout dstImageLayout, VkImageLayout dstImageLayout,
uint32_t regionCount, uint32_t regionCount,
const VkImageCopy *regions); const VkImageCopy *regions);
void copyImageToBuffer(VkImage srcImage, void copyImageToBuffer(const Image &srcImage,
VkImageLayout srcImageLayout, VkImageLayout srcImageLayout,
VkBuffer dstBuffer, VkBuffer dstBuffer,
uint32_t regionCount, uint32_t regionCount,
...@@ -355,24 +354,24 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -355,24 +354,24 @@ class SecondaryCommandBuffer final : angle::NonCopyable
uint32_t rectCount, uint32_t rectCount,
const VkClearRect *rects); const VkClearRect *rects);
void clearColorImage(VkImage image, void clearColorImage(const Image &image,
VkImageLayout imageLayout, VkImageLayout imageLayout,
const VkClearColorValue &color, const VkClearColorValue &color,
uint32_t rangeCount, uint32_t rangeCount,
const VkImageSubresourceRange *ranges); const VkImageSubresourceRange *ranges);
void clearDepthStencilImage(VkImage image, void clearDepthStencilImage(const Image &image,
VkImageLayout imageLayout, VkImageLayout imageLayout,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
uint32_t rangeCount, uint32_t rangeCount,
const VkImageSubresourceRange *ranges); const VkImageSubresourceRange *ranges);
void updateBuffer(VkBuffer buffer, void updateBuffer(const Buffer &buffer,
VkDeviceSize dstOffset, VkDeviceSize dstOffset,
VkDeviceSize dataSize, VkDeviceSize dataSize,
const void *data); const void *data);
void pushConstants(VkPipelineLayout layout, void pushConstants(const PipelineLayout &layout,
VkShaderStageFlags flag, VkShaderStageFlags flag,
uint32_t offset, uint32_t offset,
uint32_t size, uint32_t size,
...@@ -423,9 +422,17 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -423,9 +422,17 @@ class SecondaryCommandBuffer final : angle::NonCopyable
void writeTimestamp(VkPipelineStageFlagBits pipelineStage, void writeTimestamp(VkPipelineStageFlagBits pipelineStage,
VkQueryPool queryPool, VkQueryPool queryPool,
uint32_t query); uint32_t query);
// No-op for compatibility
VkResult end() { return VK_SUCCESS; }
// Parse the cmds in this cmd buffer into given primary cmd buffer for execution // Parse the cmds in this cmd buffer into given primary cmd buffer for execution
void executeCommands(VkCommandBuffer cmdBuffer); void executeCommands(VkCommandBuffer cmdBuffer);
// Initialize the SecondaryCommandBuffer by setting the allocator it will use
void initialize(angle::PoolAllocator *allocator) { mAllocator = allocator; }
// This will cause the SecondaryCommandBuffer to become invalid by clearing its allocator
void releaseHandle() { mAllocator = nullptr; }
// The SecondaryCommandBuffer is valid if it's been initialized
bool valid() { return mAllocator != nullptr; }
private: private:
// Allocate and initialize memory for given commandID & variable param size // Allocate and initialize memory for given commandID & variable param size
......
...@@ -548,7 +548,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk, ...@@ -548,7 +548,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
&member.imageView, 0, 1)); &member.imageView, 0, 1));
// Allocate a command buffer for clearing our images to black. // Allocate a command buffer for clearing our images to black.
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(member.image.recordCommands(displayVk, &commandBuffer)); ANGLE_TRY(member.image.recordCommands(displayVk, &commandBuffer));
// Set transfer dest layout, and clear the image to black. // Set transfer dest layout, and clear the image to black.
...@@ -571,7 +571,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk, ...@@ -571,7 +571,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
VkClearDepthStencilValue depthStencilClearValue = {1.0f, 0}; VkClearDepthStencilValue depthStencilClearValue = {1.0f, 0};
// Clear the image. // Clear the image.
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mDepthStencilImage.recordCommands(displayVk, &commandBuffer)); ANGLE_TRY(mDepthStencilImage.recordCommands(displayVk, &commandBuffer));
mDepthStencilImage.clearDepthStencil(aspect, aspect, depthStencilClearValue, commandBuffer); mDepthStencilImage.clearDepthStencil(aspect, aspect, depthStencilClearValue, commandBuffer);
...@@ -706,7 +706,7 @@ angle::Result WindowSurfaceVk::present(DisplayVk *displayVk, ...@@ -706,7 +706,7 @@ angle::Result WindowSurfaceVk::present(DisplayVk *displayVk,
SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex]; SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex];
vk::CommandBuffer *swapCommands = nullptr; CommandBufferT *swapCommands = nullptr;
ANGLE_TRY(image.image.recordCommands(displayVk, &swapCommands)); ANGLE_TRY(image.image.recordCommands(displayVk, &swapCommands));
image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, swapCommands); image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, swapCommands);
......
...@@ -534,7 +534,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -534,7 +534,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
// Change source layout if necessary // Change source layout if necessary
if (srcImage->isLayoutChangeNecessary(vk::ImageLayout::TransferSrc)) if (srcImage->isLayoutChangeNecessary(vk::ImageLayout::TransferSrc))
{ {
vk::CommandBuffer *srcLayoutChange; CommandBufferT *srcLayoutChange;
ANGLE_TRY(srcImage->recordCommands(contextVk, &srcLayoutChange)); ANGLE_TRY(srcImage->recordCommands(contextVk, &srcLayoutChange));
srcImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc, srcImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc,
srcLayoutChange); srcLayoutChange);
...@@ -552,7 +552,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -552,7 +552,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
// Make sure any updates to the image are already flushed. // Make sure any updates to the image are already flushed.
ANGLE_TRY(ensureImageInitialized(contextVk)); ANGLE_TRY(ensureImageInitialized(contextVk));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
// Change the image layout before the transfer // Change the image layout before the transfer
...@@ -580,7 +580,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -580,7 +580,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
gl::Extents(sourceArea.width, sourceArea.height, 1), gl::Extents(sourceArea.width, sourceArea.height, 1),
destFormat, kTransferStagingImageFlags, layerCount)); destFormat, kTransferStagingImageFlags, layerCount));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(stagingImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(stagingImage->recordCommands(contextVk, &commandBuffer));
// Change the image layout before the transfer // Change the image layout before the transfer
...@@ -749,7 +749,7 @@ angle::Result TextureVk::setStorage(const gl::Context *context, ...@@ -749,7 +749,7 @@ angle::Result TextureVk::setStorage(const gl::Context *context,
const vk::Format &format = renderer->getFormat(internalFormat); const vk::Format &format = renderer->getFormat(internalFormat);
ANGLE_TRY(ensureImageAllocated(renderer, format)); ANGLE_TRY(ensureImageAllocated(renderer, format));
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
if (mImage->valid()) if (mImage->valid())
...@@ -782,7 +782,7 @@ angle::Result TextureVk::setEGLImageTarget(const gl::Context *context, ...@@ -782,7 +782,7 @@ angle::Result TextureVk::setEGLImageTarget(const gl::Context *context,
uint32_t rendererQueueFamilyIndex = renderer->getQueueFamilyIndex(); uint32_t rendererQueueFamilyIndex = renderer->getQueueFamilyIndex();
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex)) if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{ {
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
mImage->changeLayoutAndQueue(VK_IMAGE_ASPECT_COLOR_BIT, mImage->changeLayoutAndQueue(VK_IMAGE_ASPECT_COLOR_BIT,
vk::ImageLayout::FragmentShaderReadOnly, vk::ImageLayout::FragmentShaderReadOnly,
...@@ -938,7 +938,7 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk, ...@@ -938,7 +938,7 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk,
size_t sourceCopyAllocationSize = size_t sourceCopyAllocationSize =
sourceArea.width * sourceArea.height * imageFormat.pixelBytes * layerCount; sourceArea.width * sourceArea.height * imageFormat.pixelBytes * layerCount;
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
// Requirement of the copyImageToBuffer, the source image must be in SRC_OPTIMAL layout. // Requirement of the copyImageToBuffer, the source image must be in SRC_OPTIMAL layout.
...@@ -1004,7 +1004,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context) ...@@ -1004,7 +1004,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context)
sourceRowPitch, imageData + bufferOffset)); sourceRowPitch, imageData + bufferOffset));
} }
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
return mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), getLevelCount(), return mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), getLevelCount(),
commandBuffer); commandBuffer);
...@@ -1132,7 +1132,7 @@ angle::Result TextureVk::ensureImageInitializedImpl(ContextVk *contextVk, ...@@ -1132,7 +1132,7 @@ angle::Result TextureVk::ensureImageInitializedImpl(ContextVk *contextVk,
{ {
return angle::Result::Continue; return angle::Result::Continue;
} }
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
if (!mImage->valid()) if (!mImage->valid())
...@@ -1290,7 +1290,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk, ...@@ -1290,7 +1290,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
const vk::Format &format, const vk::Format &format,
const gl::Extents &extents, const gl::Extents &extents,
const uint32_t levelCount, const uint32_t levelCount,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
const RendererVk *renderer = contextVk->getRenderer(); const RendererVk *renderer = contextVk->getRenderer();
const angle::Format &angleFormat = format.textureFormat(); const angle::Format &angleFormat = format.textureFormat();
......
...@@ -253,7 +253,7 @@ class TextureVk : public TextureImpl ...@@ -253,7 +253,7 @@ class TextureVk : public TextureImpl
const vk::Format &format, const vk::Format &format,
const gl::Extents &extents, const gl::Extents &extents,
const uint32_t levelCount, const uint32_t levelCount,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
void releaseImage(RendererVk *renderer); void releaseImage(RendererVk *renderer);
void releaseStagingBuffer(RendererVk *renderer); void releaseStagingBuffer(RendererVk *renderer);
uint32_t getLevelCount() const; uint32_t getLevelCount() const;
......
...@@ -311,7 +311,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context, ...@@ -311,7 +311,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context,
const VkDescriptorSet descriptorSet, const VkDescriptorSet descriptorSet,
const void *pushConstants, const void *pushConstants,
size_t pushConstantsSize, size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
RendererVk *renderer = context->getRenderer(); RendererVk *renderer = context->getRenderer();
...@@ -373,7 +373,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context, ...@@ -373,7 +373,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context,
ANGLE_TRY(ensureBufferClearResourcesInitialized(context)); ANGLE_TRY(ensureBufferClearResourcesInitialized(context));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell dest it's being written to. // Tell dest it's being written to.
...@@ -429,7 +429,7 @@ angle::Result UtilsVk::copyBuffer(vk::Context *context, ...@@ -429,7 +429,7 @@ angle::Result UtilsVk::copyBuffer(vk::Context *context,
ANGLE_TRY(ensureBufferCopyResourcesInitialized(context)); ANGLE_TRY(ensureBufferCopyResourcesInitialized(context));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell src we are going to read from it. // Tell src we are going to read from it.
...@@ -498,7 +498,7 @@ angle::Result UtilsVk::convertVertexBuffer(vk::Context *context, ...@@ -498,7 +498,7 @@ angle::Result UtilsVk::convertVertexBuffer(vk::Context *context,
ANGLE_TRY(ensureConvertVertexResourcesInitialized(context)); ANGLE_TRY(ensureConvertVertexResourcesInitialized(context));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer)); ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell src we are going to read from it. // Tell src we are going to read from it.
...@@ -576,7 +576,7 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk, ...@@ -576,7 +576,7 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
const vk::ImageView *imageView, const vk::ImageView *imageView,
const vk::RenderPassDesc &renderPassDesc, const vk::RenderPassDesc &renderPassDesc,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut) CommandBufferT **commandBufferOut)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
...@@ -617,7 +617,7 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk, ...@@ -617,7 +617,7 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
ANGLE_TRY(ensureImageClearResourcesInitialized(contextVk)); ANGLE_TRY(ensureImageClearResourcesInitialized(contextVk));
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(renderer->getCurrentQueueSerial(), &commandBuffer)) if (!framebuffer->appendToStartedRenderPass(renderer->getCurrentQueueSerial(), &commandBuffer))
{ {
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, &commandBuffer)); ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, &commandBuffer));
...@@ -740,20 +740,20 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -740,20 +740,20 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
// Change source layout outside render pass // Change source layout outside render pass
if (src->isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly)) if (src->isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly))
{ {
vk::CommandBuffer *srcLayoutChange; CommandBufferT *srcLayoutChange;
ANGLE_TRY(src->recordCommands(contextVk, &srcLayoutChange)); ANGLE_TRY(src->recordCommands(contextVk, &srcLayoutChange));
src->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::FragmentShaderReadOnly, src->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::FragmentShaderReadOnly,
srcLayoutChange); srcLayoutChange);
} }
// Change destination layout outside render pass as well // Change destination layout outside render pass as well
vk::CommandBuffer *destLayoutChange; CommandBufferT *destLayoutChange;
ANGLE_TRY(dest->recordCommands(contextVk, &destLayoutChange)); ANGLE_TRY(dest->recordCommands(contextVk, &destLayoutChange));
dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment, dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
destLayoutChange); destLayoutChange);
vk::CommandBuffer *commandBuffer; CommandBufferT *commandBuffer;
ANGLE_TRY( ANGLE_TRY(
startRenderPass(contextVk, dest, destView, renderPassDesc, renderArea, &commandBuffer)); startRenderPass(contextVk, dest, destView, renderPassDesc, renderArea, &commandBuffer));
......
...@@ -192,7 +192,7 @@ class UtilsVk : angle::NonCopyable ...@@ -192,7 +192,7 @@ class UtilsVk : angle::NonCopyable
const VkDescriptorSet descriptorSet, const VkDescriptorSet descriptorSet,
const void *pushConstants, const void *pushConstants,
size_t pushConstantsSize, size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
// Initializes descriptor set layout, pipeline layout and descriptor pool corresponding to given // Initializes descriptor set layout, pipeline layout and descriptor pool corresponding to given
// function, if not already initialized. Uses setSizes to create the layout. For example, if // function, if not already initialized. Uses setSizes to create the layout. For example, if
...@@ -218,7 +218,7 @@ class UtilsVk : angle::NonCopyable ...@@ -218,7 +218,7 @@ class UtilsVk : angle::NonCopyable
const vk::ImageView *imageView, const vk::ImageView *imageView,
const vk::RenderPassDesc &renderPassDesc, const vk::RenderPassDesc &renderPassDesc,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut); CommandBufferT **commandBufferOut);
angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts; angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts;
angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts; angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts;
......
...@@ -1060,7 +1060,7 @@ void LineLoopHelper::destroy(VkDevice device) ...@@ -1060,7 +1060,7 @@ void LineLoopHelper::destroy(VkDevice device)
} }
// static // static
void LineLoopHelper::Draw(uint32_t count, CommandBuffer *commandBuffer) void LineLoopHelper::Draw(uint32_t count, CommandBufferT *commandBuffer)
{ {
// Our first index is always 0 because that's how we set it up in createIndexBuffer*. // Our first index is always 0 because that's how we set it up in createIndexBuffer*.
// Note: this could theoretically overflow and wrap to zero. // Note: this could theoretically overflow and wrap to zero.
...@@ -1128,7 +1128,7 @@ angle::Result BufferHelper::copyFromBuffer(Context *context, ...@@ -1128,7 +1128,7 @@ angle::Result BufferHelper::copyFromBuffer(Context *context,
const VkBufferCopy &copyRegion) const VkBufferCopy &copyRegion)
{ {
// 'recordCommands' will implicitly stop any reads from using the old buffer data. // 'recordCommands' will implicitly stop any reads from using the old buffer data.
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(context, &commandBuffer)); ANGLE_TRY(recordCommands(context, &commandBuffer));
if (mCurrentReadAccess != 0 || mCurrentWriteAccess != 0) if (mCurrentReadAccess != 0 || mCurrentWriteAccess != 0)
...@@ -1558,7 +1558,7 @@ bool ImageHelper::isLayoutChangeNecessary(ImageLayout newLayout) const ...@@ -1558,7 +1558,7 @@ bool ImageHelper::isLayoutChangeNecessary(ImageLayout newLayout) const
void ImageHelper::changeLayout(VkImageAspectFlags aspectMask, void ImageHelper::changeLayout(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
if (!isLayoutChangeNecessary(newLayout)) if (!isLayoutChangeNecessary(newLayout))
{ {
...@@ -1571,7 +1571,7 @@ void ImageHelper::changeLayout(VkImageAspectFlags aspectMask, ...@@ -1571,7 +1571,7 @@ void ImageHelper::changeLayout(VkImageAspectFlags aspectMask,
void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask, void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
uint32_t newQueueFamilyIndex, uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(isQueueChangeNeccesary(newQueueFamilyIndex)); ASSERT(isQueueChangeNeccesary(newQueueFamilyIndex));
forceChangeLayoutAndQueue(aspectMask, newLayout, newQueueFamilyIndex, commandBuffer); forceChangeLayoutAndQueue(aspectMask, newLayout, newQueueFamilyIndex, commandBuffer);
...@@ -1580,7 +1580,7 @@ void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask, ...@@ -1580,7 +1580,7 @@ void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask,
void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask, void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
uint32_t newQueueFamilyIndex, uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
const ImageMemoryBarrierData &transitionFrom = kImageMemoryBarrierData[mCurrentLayout]; const ImageMemoryBarrierData &transitionFrom = kImageMemoryBarrierData[mCurrentLayout];
...@@ -1613,7 +1613,7 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask, ...@@ -1613,7 +1613,7 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
void ImageHelper::clearColor(const VkClearColorValue &color, void ImageHelper::clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer); clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer);
...@@ -1624,7 +1624,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color, ...@@ -1624,7 +1624,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
uint32_t levelCount, uint32_t levelCount,
uint32_t baseArrayLayer, uint32_t baseArrayLayer,
uint32_t layerCount, uint32_t layerCount,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(valid()); ASSERT(valid());
...@@ -1643,7 +1643,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color, ...@@ -1643,7 +1643,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags, void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags, VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(valid()); ASSERT(valid());
...@@ -1678,7 +1678,7 @@ void ImageHelper::Copy(ImageHelper *srcImage, ...@@ -1678,7 +1678,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
const gl::Extents &copySize, const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresource, const VkImageSubresourceLayers &srcSubresource,
const VkImageSubresourceLayers &dstSubresource, const VkImageSubresourceLayers &dstSubresource,
CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
ASSERT(commandBuffer->valid() && srcImage->valid() && dstImage->valid()); ASSERT(commandBuffer->valid() && srcImage->valid() && dstImage->valid());
...@@ -1704,7 +1704,7 @@ void ImageHelper::Copy(ImageHelper *srcImage, ...@@ -1704,7 +1704,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel) angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel)
{ {
vk::CommandBuffer *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(recordCommands(contextVk, &commandBuffer));
changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, ImageLayout::TransferDst, commandBuffer); changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, ImageLayout::TransferDst, commandBuffer);
...@@ -2065,7 +2065,7 @@ angle::Result ImageHelper::allocateStagingMemory(ContextVk *contextVk, ...@@ -2065,7 +2065,7 @@ angle::Result ImageHelper::allocateStagingMemory(ContextVk *contextVk,
angle::Result ImageHelper::flushStagedUpdates(Context *context, angle::Result ImageHelper::flushStagedUpdates(Context *context,
uint32_t baseLevel, uint32_t baseLevel,
uint32_t levelCount, uint32_t levelCount,
vk::CommandBuffer *commandBuffer) CommandBufferT *commandBuffer)
{ {
if (mSubresourceUpdates.empty()) if (mSubresourceUpdates.empty())
{ {
......
...@@ -379,7 +379,7 @@ class LineLoopHelper final : angle::NonCopyable ...@@ -379,7 +379,7 @@ class LineLoopHelper final : angle::NonCopyable
void release(RendererVk *renderer); void release(RendererVk *renderer);
void destroy(VkDevice device); void destroy(VkDevice device);
static void Draw(uint32_t count, CommandBuffer *commandBuffer); static void Draw(uint32_t count, CommandBufferT *commandBuffer);
private: private:
DynamicBuffer mDynamicIndexBuffer; DynamicBuffer mDynamicIndexBuffer;
...@@ -613,19 +613,19 @@ class ImageHelper final : public CommandGraphResource ...@@ -613,19 +613,19 @@ class ImageHelper final : public CommandGraphResource
void clearColor(const VkClearColorValue &color, void clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
void clearColorLayer(const VkClearColorValue &color, void clearColorLayer(const VkClearColorValue &color,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
uint32_t baseArrayLayer, uint32_t baseArrayLayer,
uint32_t layerCount, uint32_t layerCount,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
void clearDepthStencil(VkImageAspectFlags imageAspectFlags, void clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags, VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
gl::Extents getSize(const gl::ImageIndex &index) const; gl::Extents getSize(const gl::ImageIndex &index) const;
static void Copy(ImageHelper *srcImage, static void Copy(ImageHelper *srcImage,
...@@ -635,7 +635,7 @@ class ImageHelper final : public CommandGraphResource ...@@ -635,7 +635,7 @@ class ImageHelper final : public CommandGraphResource
const gl::Extents &copySize, const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresources, const VkImageSubresourceLayers &srcSubresources,
const VkImageSubresourceLayers &dstSubresources, const VkImageSubresourceLayers &dstSubresources,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
angle::Result generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel); angle::Result generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel);
...@@ -683,7 +683,7 @@ class ImageHelper final : public CommandGraphResource ...@@ -683,7 +683,7 @@ class ImageHelper final : public CommandGraphResource
angle::Result flushStagedUpdates(Context *context, angle::Result flushStagedUpdates(Context *context,
uint32_t baseLevel, uint32_t baseLevel,
uint32_t levelCount, uint32_t levelCount,
vk::CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
bool hasStagedUpdates() const; bool hasStagedUpdates() const;
...@@ -694,7 +694,7 @@ class ImageHelper final : public CommandGraphResource ...@@ -694,7 +694,7 @@ class ImageHelper final : public CommandGraphResource
void changeLayout(VkImageAspectFlags aspectMask, void changeLayout(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
bool isQueueChangeNeccesary(uint32_t newQueueFamilyIndex) const bool isQueueChangeNeccesary(uint32_t newQueueFamilyIndex) const
{ {
...@@ -704,13 +704,13 @@ class ImageHelper final : public CommandGraphResource ...@@ -704,13 +704,13 @@ class ImageHelper final : public CommandGraphResource
void changeLayoutAndQueue(VkImageAspectFlags aspectMask, void changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
uint32_t newQueueFamilyIndex, uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
private: private:
void forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask, void forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout, ImageLayout newLayout,
uint32_t newQueueFamilyIndex, uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer); CommandBufferT *commandBuffer);
struct SubresourceUpdate struct SubresourceUpdate
{ {
......
...@@ -242,7 +242,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer> ...@@ -242,7 +242,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const VkBuffer *buffers, const VkBuffer *buffers,
const VkDeviceSize *offsets); const VkDeviceSize *offsets);
void bindIndexBuffer(const VkBuffer &buffer, VkDeviceSize offset, VkIndexType indexType); void bindIndexBuffer(const Buffer &buffer, VkDeviceSize offset, VkIndexType indexType);
void bindDescriptorSets(VkPipelineBindPoint bindPoint, void bindDescriptorSets(VkPipelineBindPoint bindPoint,
const PipelineLayout &layout, const PipelineLayout &layout,
uint32_t firstSet, uint32_t firstSet,
...@@ -252,7 +252,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer> ...@@ -252,7 +252,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const uint32_t *dynamicOffsets); const uint32_t *dynamicOffsets);
void executeCommands(uint32_t commandBufferCount, const CommandBuffer *commandBuffers); void executeCommands(uint32_t commandBufferCount, const CommandBuffer *commandBuffers);
void updateBuffer(const vk::Buffer &buffer, void updateBuffer(const Buffer &buffer,
VkDeviceSize dstOffset, VkDeviceSize dstOffset,
VkDeviceSize dataSize, VkDeviceSize dataSize,
const void *data); const void *data);
...@@ -534,7 +534,7 @@ ANGLE_INLINE void CommandBuffer::blitImage(const Image &srcImage, ...@@ -534,7 +534,7 @@ ANGLE_INLINE void CommandBuffer::blitImage(const Image &srcImage,
VkImageBlit *pRegions, VkImageBlit *pRegions,
VkFilter filter) VkFilter filter)
{ {
ASSERT(valid()); ASSERT(valid() && srcImage.valid() && dstImage.valid());
vkCmdBlitImage(mHandle, srcImage.getHandle(), srcImageLayout, dstImage.getHandle(), vkCmdBlitImage(mHandle, srcImage.getHandle(), srcImageLayout, dstImage.getHandle(),
dstImageLayout, regionCount, pRegions, filter); dstImageLayout, regionCount, pRegions, filter);
} }
...@@ -588,13 +588,12 @@ ANGLE_INLINE void CommandBuffer::destroy(VkDevice device, const vk::CommandPool ...@@ -588,13 +588,12 @@ ANGLE_INLINE void CommandBuffer::destroy(VkDevice device, const vk::CommandPool
} }
} }
ANGLE_INLINE void CommandBuffer::copyBuffer(const vk::Buffer &srcBuffer, ANGLE_INLINE void CommandBuffer::copyBuffer(const Buffer &srcBuffer,
const vk::Buffer &destBuffer, const Buffer &destBuffer,
uint32_t regionCount, uint32_t regionCount,
const VkBufferCopy *regions) const VkBufferCopy *regions)
{ {
ASSERT(valid()); ASSERT(valid() && srcBuffer.valid() && destBuffer.valid());
ASSERT(srcBuffer.valid() && destBuffer.valid());
vkCmdCopyBuffer(mHandle, srcBuffer.getHandle(), destBuffer.getHandle(), regionCount, regions); vkCmdCopyBuffer(mHandle, srcBuffer.getHandle(), destBuffer.getHandle(), regionCount, regions);
} }
...@@ -604,9 +603,8 @@ ANGLE_INLINE void CommandBuffer::copyBufferToImage(VkBuffer srcBuffer, ...@@ -604,9 +603,8 @@ ANGLE_INLINE void CommandBuffer::copyBufferToImage(VkBuffer srcBuffer,
uint32_t regionCount, uint32_t regionCount,
const VkBufferImageCopy *regions) const VkBufferImageCopy *regions)
{ {
ASSERT(valid()); ASSERT(valid() && dstImage.valid());
ASSERT(srcBuffer != VK_NULL_HANDLE); ASSERT(srcBuffer != VK_NULL_HANDLE);
ASSERT(dstImage.valid());
vkCmdCopyBufferToImage(mHandle, srcBuffer, dstImage.getHandle(), dstImageLayout, regionCount, vkCmdCopyBufferToImage(mHandle, srcBuffer, dstImage.getHandle(), dstImageLayout, regionCount,
regions); regions);
} }
...@@ -617,14 +615,13 @@ ANGLE_INLINE void CommandBuffer::copyImageToBuffer(const Image &srcImage, ...@@ -617,14 +615,13 @@ ANGLE_INLINE void CommandBuffer::copyImageToBuffer(const Image &srcImage,
uint32_t regionCount, uint32_t regionCount,
const VkBufferImageCopy *regions) const VkBufferImageCopy *regions)
{ {
ASSERT(valid()); ASSERT(valid() && srcImage.valid());
ASSERT(dstBuffer != VK_NULL_HANDLE); ASSERT(dstBuffer != VK_NULL_HANDLE);
ASSERT(srcImage.valid());
vkCmdCopyImageToBuffer(mHandle, srcImage.getHandle(), srcImageLayout, dstBuffer, regionCount, vkCmdCopyImageToBuffer(mHandle, srcImage.getHandle(), srcImageLayout, dstBuffer, regionCount,
regions); regions);
} }
ANGLE_INLINE void CommandBuffer::clearColorImage(const vk::Image &image, ANGLE_INLINE void CommandBuffer::clearColorImage(const Image &image,
VkImageLayout imageLayout, VkImageLayout imageLayout,
const VkClearColorValue &color, const VkClearColorValue &color,
uint32_t rangeCount, uint32_t rangeCount,
...@@ -635,7 +632,7 @@ ANGLE_INLINE void CommandBuffer::clearColorImage(const vk::Image &image, ...@@ -635,7 +632,7 @@ ANGLE_INLINE void CommandBuffer::clearColorImage(const vk::Image &image,
} }
ANGLE_INLINE void CommandBuffer::clearDepthStencilImage( ANGLE_INLINE void CommandBuffer::clearDepthStencilImage(
const vk::Image &image, const Image &image,
VkImageLayout imageLayout, VkImageLayout imageLayout,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
uint32_t rangeCount, uint32_t rangeCount,
...@@ -655,9 +652,9 @@ ANGLE_INLINE void CommandBuffer::clearAttachments(uint32_t attachmentCount, ...@@ -655,9 +652,9 @@ ANGLE_INLINE void CommandBuffer::clearAttachments(uint32_t attachmentCount,
vkCmdClearAttachments(mHandle, attachmentCount, attachments, rectCount, rects); vkCmdClearAttachments(mHandle, attachmentCount, attachments, rectCount, rects);
} }
ANGLE_INLINE void CommandBuffer::copyImage(const vk::Image &srcImage, ANGLE_INLINE void CommandBuffer::copyImage(const Image &srcImage,
VkImageLayout srcImageLayout, VkImageLayout srcImageLayout,
const vk::Image &dstImage, const Image &dstImage,
VkImageLayout dstImageLayout, VkImageLayout dstImageLayout,
uint32_t regionCount, uint32_t regionCount,
const VkImageCopy *regions) const VkImageCopy *regions)
...@@ -680,23 +677,23 @@ ANGLE_INLINE void CommandBuffer::endRenderPass() ...@@ -680,23 +677,23 @@ ANGLE_INLINE void CommandBuffer::endRenderPass()
vkCmdEndRenderPass(mHandle); vkCmdEndRenderPass(mHandle);
} }
ANGLE_INLINE void CommandBuffer::bindIndexBuffer(const VkBuffer &buffer, ANGLE_INLINE void CommandBuffer::bindIndexBuffer(const Buffer &buffer,
VkDeviceSize offset, VkDeviceSize offset,
VkIndexType indexType) VkIndexType indexType)
{ {
ASSERT(valid()); ASSERT(valid());
vkCmdBindIndexBuffer(mHandle, buffer, offset, indexType); vkCmdBindIndexBuffer(mHandle, buffer.getHandle(), offset, indexType);
} }
ANGLE_INLINE void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint, ANGLE_INLINE void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint,
const vk::PipelineLayout &layout, const PipelineLayout &layout,
uint32_t firstSet, uint32_t firstSet,
uint32_t descriptorSetCount, uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets, const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount, uint32_t dynamicOffsetCount,
const uint32_t *dynamicOffsets) const uint32_t *dynamicOffsets)
{ {
ASSERT(valid()); ASSERT(valid() && layout.valid());
vkCmdBindDescriptorSets(mHandle, bindPoint, layout.getHandle(), firstSet, descriptorSetCount, vkCmdBindDescriptorSets(mHandle, bindPoint, layout.getHandle(), firstSet, descriptorSetCount,
descriptorSets, dynamicOffsetCount, dynamicOffsets); descriptorSets, dynamicOffsetCount, dynamicOffsets);
} }
...@@ -708,7 +705,7 @@ ANGLE_INLINE void CommandBuffer::executeCommands(uint32_t commandBufferCount, ...@@ -708,7 +705,7 @@ ANGLE_INLINE void CommandBuffer::executeCommands(uint32_t commandBufferCount,
vkCmdExecuteCommands(mHandle, commandBufferCount, commandBuffers[0].ptr()); vkCmdExecuteCommands(mHandle, commandBufferCount, commandBuffers[0].ptr());
} }
ANGLE_INLINE void CommandBuffer::updateBuffer(const vk::Buffer &buffer, ANGLE_INLINE void CommandBuffer::updateBuffer(const Buffer &buffer,
VkDeviceSize dstOffset, VkDeviceSize dstOffset,
VkDeviceSize dataSize, VkDeviceSize dataSize,
const void *data) const void *data)
......
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