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") {
}
if (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) {
defines += [ "ANGLE_ENABLE_NULL" ]
......
......@@ -84,6 +84,9 @@ declare_args() {
# Disallow non-conformant configurations in official builds.
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)
# define ANGLE_NO_DISCARD
#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_
......@@ -246,7 +246,7 @@ angle::Result BufferVk::copyToBuffer(ContextVk *contextVk,
uint32_t copyCount,
const VkBufferCopy *copies)
{
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer));
commandBuffer->copyBuffer(mBuffer.getBuffer(), destBuffer->getBuffer(), copyCount, copies);
......
......@@ -25,14 +25,28 @@ namespace vk
{
namespace
{
ANGLE_MAYBE_UNUSED
angle::Result InitAndBeginCommandBuffer(vk::Context *context,
const CommandPool &commandPool,
const VkCommandBufferInheritanceInfo &inheritanceInfo,
VkCommandBufferUsageFlags flags,
CommandBuffer *commandBuffer)
angle::PoolAllocator *poolAllocator,
SecondaryCommandBuffer *commandBuffer)
{
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 = {};
createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
createInfo.commandPool = commandPool.getHandle();
......@@ -124,6 +138,26 @@ void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT
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
// CommandGraphResource implementation.
......@@ -139,7 +173,7 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
}
angle::Result CommandGraphResource::recordCommands(Context *context,
CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
......@@ -150,7 +184,7 @@ angle::Result CommandGraphResource::recordCommands(Context *context,
context, context->getRenderer()->getCommandPool(), commandBufferOut);
}
CommandBuffer *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands();
CommandBufferT *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands();
if (!outsideRenderPassCommands->valid())
{
ANGLE_TRY(mCurrentWritingNode->beginOutsideRenderPassRecording(
......@@ -175,7 +209,7 @@ angle::Result CommandGraphResource::beginRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
// If a barrier has been inserted in the meantime, stop the command buffer.
if (!hasChildlessWritingNode())
......@@ -251,9 +285,11 @@ void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial cur
}
// CommandGraphNode implementation.
CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function)
CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function,
angle::PoolAllocator *poolAllocator)
: mRenderPassClearValues{},
mFunction(function),
mPoolAllocator(poolAllocator),
mQueryPool(VK_NULL_HANDLE),
mQueryIndex(0),
mFenceSyncEvent(VK_NULL_HANDLE),
......@@ -273,15 +309,9 @@ CommandGraphNode::~CommandGraphNode()
mInsideRenderPassCommands.releaseHandle();
}
CommandBuffer *CommandGraphNode::getOutsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mOutsideRenderPassCommands;
}
angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool,
CommandBuffer **commandsOut)
CommandBufferT **commandsOut)
{
ASSERT(!mHasChildren);
......@@ -295,7 +325,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context
inheritanceInfo.queryFlags = 0;
inheritanceInfo.pipelineStatistics = 0;
ANGLE_TRY(InitAndBeginCommandBuffer(context, commandPool, inheritanceInfo, 0,
ANGLE_TRY(InitAndBeginCommandBuffer(context, commandPool, inheritanceInfo, 0, mPoolAllocator,
&mOutsideRenderPassCommands));
*commandsOut = &mOutsideRenderPassCommands;
......@@ -303,7 +333,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context
}
angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context,
CommandBuffer **commandsOut)
CommandBufferT **commandsOut)
{
ASSERT(!mHasChildren);
......@@ -323,9 +353,10 @@ angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context,
inheritanceInfo.queryFlags = 0;
inheritanceInfo.pipelineStatistics = 0;
ANGLE_TRY(InitAndBeginCommandBuffer(
context, context->getRenderer()->getCommandPool(), inheritanceInfo,
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, &mInsideRenderPassCommands));
ANGLE_TRY(InitAndBeginCommandBuffer(context, context->getRenderer()->getCommandPool(),
inheritanceInfo,
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT,
mPoolAllocator, &mInsideRenderPassCommands));
*commandsOut = &mInsideRenderPassCommands;
return angle::Result::Continue;
......@@ -462,7 +493,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
if (mOutsideRenderPassCommands.valid())
{
ANGLE_VK_TRY(context, mOutsideRenderPassCommands.end());
primaryCommandBuffer->executeCommands(1, &mOutsideRenderPassCommands);
ExecuteCommands(primaryCommandBuffer, &mOutsideRenderPassCommands);
}
if (mInsideRenderPassCommands.valid())
......@@ -488,9 +519,8 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
beginInfo.clearValueCount = mRenderPassDesc.attachmentCount();
beginInfo.pClearValues = mRenderPassClearValues.data();
primaryCommandBuffer->beginRenderPass(
beginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
primaryCommandBuffer->executeCommands(1, &mInsideRenderPassCommands);
primaryCommandBuffer->beginRenderPass(beginInfo, kRenderPassContents);
ExecuteCommands(primaryCommandBuffer, &mInsideRenderPassCommands);
primaryCommandBuffer->endRenderPass();
}
break;
......@@ -600,8 +630,10 @@ const gl::Rectangle &CommandGraphNode::getRenderPassRenderArea() const
}
// CommandGraph implementation.
CommandGraph::CommandGraph(bool enableGraphDiagnostics)
: mEnableGraphDiagnostics(enableGraphDiagnostics), mLastBarrierIndex(kInvalidNodeIndex)
CommandGraph::CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *poolAllocator)
: mEnableGraphDiagnostics(enableGraphDiagnostics),
mPoolAllocator(poolAllocator),
mLastBarrierIndex(kInvalidNodeIndex)
{}
CommandGraph::~CommandGraph()
......@@ -612,7 +644,7 @@ CommandGraph::~CommandGraph()
CommandGraphNode *CommandGraph::allocateNode(CommandGraphNodeFunction function)
{
// 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);
return newCommands;
}
......
......@@ -10,8 +10,15 @@
#ifndef 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"
#if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS
using CommandBufferT = rx::vk::SecondaryCommandBuffer;
#else
using CommandBufferT = rx::vk::CommandBuffer;
#endif
namespace rx
{
......@@ -61,20 +68,24 @@ class CommandBufferOwner
ANGLE_INLINE void onCommandBufferFinished() { mCommandBuffer = nullptr; }
protected:
vk::CommandBuffer *mCommandBuffer = nullptr;
CommandBufferT *mCommandBuffer = nullptr;
};
// Only used internally in the command graph. Kept in the header for better inlining performance.
class CommandGraphNode final : angle::NonCopyable
{
public:
CommandGraphNode(CommandGraphNodeFunction function);
CommandGraphNode(CommandGraphNodeFunction function, angle::PoolAllocator *poolAllocator);
~CommandGraphNode();
// Immutable queries for when we're walking the commands tree.
CommandBuffer *getOutsideRenderPassCommands();
CommandBufferT *getOutsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mOutsideRenderPassCommands;
}
CommandBuffer *getInsideRenderPassCommands()
CommandBufferT *getInsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mInsideRenderPassCommands;
......@@ -83,10 +94,10 @@ class CommandGraphNode final : angle::NonCopyable
// For outside the render pass (copies, transitions, etc).
angle::Result beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool,
CommandBuffer **commandsOut);
CommandBufferT **commandsOut);
// 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.
void storeRenderPassInfo(const Framebuffer &framebuffer,
......@@ -173,11 +184,11 @@ class CommandGraphNode final : angle::NonCopyable
gl::AttachmentArray<VkClearValue> mRenderPassClearValues;
CommandGraphNodeFunction mFunction;
angle::PoolAllocator *mPoolAllocator;
// Keep separate buffers for commands inside and outside a RenderPass.
// TODO(jmadill): We might not need inside and outside RenderPass commands separate.
CommandBuffer mOutsideRenderPassCommands;
CommandBuffer mInsideRenderPassCommands;
CommandBufferT mOutsideRenderPassCommands;
CommandBufferT mInsideRenderPassCommands;
// Special-function additional data:
// Queries:
......@@ -251,7 +262,7 @@ class CommandGraphResource : angle::NonCopyable
// Allocates a write node via getNewWriteNode and returns a started command buffer.
// The started command buffer will render outside of a RenderPass.
// 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.
// Called from FramebufferVk::startNewRenderPass and UtilsVk functions.
......@@ -260,12 +271,12 @@ class CommandGraphResource : angle::NonCopyable
const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut);
CommandBufferT **commandBufferOut);
// Checks if we're in a RenderPass, returning true if so. Updates serial internally.
// Returns the started command buffer in commandBufferOut.
ANGLE_INLINE bool appendToStartedRenderPass(Serial currentQueueSerial,
CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
updateQueueSerial(currentQueueSerial);
if (hasStartedRenderPass())
......@@ -340,13 +351,13 @@ class CommandGraphResource : angle::NonCopyable
// 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:
//
// 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
// 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
// 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
// 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.
//
// The Command Graph consists of an array of open Command Graph Nodes. It supports allocating new
......@@ -355,7 +366,7 @@ class CommandGraphResource : angle::NonCopyable
class CommandGraph final : angle::NonCopyable
{
public:
explicit CommandGraph(bool enableGraphDiagnostics);
explicit CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *poolAllocator);
~CommandGraph();
// 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
std::vector<CommandGraphNode *> mNodes;
bool mEnableGraphDiagnostics;
angle::PoolAllocator *mPoolAllocator;
// 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
......
......@@ -206,7 +206,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
gl::DrawElementsType indexTypeOrNone,
const void *indices,
DirtyBits dirtyBitMask,
vk::CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
// Set any dirty bits that depend on draw call parameters or other objects.
if (mode != mCurrentDrawMode)
......@@ -273,7 +273,7 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context,
GLsizei instanceCount,
gl::DrawElementsType indexType,
const void *indices,
vk::CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
if (indexType != mCurrentDrawElementsType)
{
......@@ -312,7 +312,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
vk::CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
ANGLE_TRY(mVertexArray->handleLineLoop(this, firstVertex, vertexOrIndexCount,
indexTypeOrInvalid, indices));
......@@ -325,7 +325,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(mDirtyDefaultAttribsMask.any());
......@@ -339,7 +339,7 @@ angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
if (!mCurrentPipeline)
{
......@@ -379,7 +379,7 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ANGLE_TRY(updateActiveTextures(context));
......@@ -391,7 +391,7 @@ angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
uint32_t maxAttrib = mProgram->getState().getMaxActiveAttribLocation();
const gl::AttribArray<VkBuffer> &bufferHandles = mVertexArray->getCurrentArrayBufferHandles();
......@@ -417,12 +417,12 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
vk::BufferHelper *elementArrayBuffer = mVertexArray->getCurrentElementArrayBuffer();
ASSERT(elementArrayBuffer != nullptr);
commandBuffer->bindIndexBuffer(elementArrayBuffer->getBuffer().getHandle(),
commandBuffer->bindIndexBuffer(elementArrayBuffer->getBuffer(),
mVertexArray->getCurrentElementArrayBufferOffset(),
gl_vk::kIndexTypeMap[mCurrentDrawElementsType]);
......@@ -433,7 +433,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ANGLE_TRY(mProgram->updateDescriptorSets(this, commandBuffer));
......@@ -449,7 +449,7 @@ angle::Result ContextVk::drawArrays(const gl::Context *context,
GLint first,
GLsizei count)
{
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
uint32_t clampedVertexCount = gl::GetClampedVertexCount<uint32_t>(count);
if (mode == gl::PrimitiveMode::LineLoop)
......@@ -481,7 +481,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context,
return angle::Result::Stop;
}
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum,
nullptr, mNonIndexedDirtyBitsMask, &commandBuffer));
commandBuffer->draw(gl::GetClampedVertexCount<uint32_t>(count), instances, first, 0);
......@@ -494,7 +494,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context,
gl::DrawElementsType type,
const void *indices)
{
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
if (mode == gl::PrimitiveMode::LineLoop)
{
ANGLE_TRY(setupLineLoopDraw(context, mode, 0, count, type, indices, &commandBuffer));
......@@ -523,7 +523,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context,
return angle::Result::Stop;
}
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer));
commandBuffer->drawIndexed(count, instances, 0, 0, 0);
return angle::Result::Continue;
......@@ -1157,7 +1157,7 @@ VkColorComponentFlags ContextVk::getClearColorMask() const
}
angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
// Release any previously retained buffers.
mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer);
......
......@@ -167,6 +167,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
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();
mDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
mDirtyBits.set(DIRTY_BIT_INDEX_BUFFER);
......@@ -224,7 +226,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
using DirtyBitHandler = angle::Result (ContextVk::*)(const gl::Context *,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mDirtyBitHandlers;
......@@ -236,21 +238,21 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
DirtyBits dirtyBitMask,
vk::CommandBuffer **commandBufferOut);
CommandBufferT **commandBufferOut);
angle::Result setupIndexedDraw(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei indexCount,
GLsizei instanceCount,
gl::DrawElementsType indexType,
const void *indices,
vk::CommandBuffer **commandBufferOut);
CommandBufferT **commandBufferOut);
angle::Result setupLineLoopDraw(const gl::Context *context,
gl::PrimitiveMode mode,
GLint firstVertex,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
vk::CommandBuffer **commandBufferOut);
CommandBufferT **commandBufferOut);
void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport,
......@@ -271,17 +273,16 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
void invalidateDriverUniforms();
angle::Result handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyDriverUniforms(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
angle::Result handleDirtyDescriptorSets(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
vk::PipelineHelper *mCurrentPipeline;
gl::PrimitiveMode mCurrentDrawMode;
......
......@@ -166,7 +166,7 @@ angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
ContextVk *contextVk = vk::GetImpl(context);
// This command buffer is only started once.
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
const gl::FramebufferAttachment *depthAttachment = mState.getDepthAttachment();
bool clearDepth = (depthAttachment && (mask & GL_DEPTH_BUFFER_BIT) != 0);
......@@ -424,7 +424,7 @@ angle::Result FramebufferVk::blitWithCopy(ContextVk *contextVk,
VkImageAspectFlags aspectMask =
vk::GetDepthStencilAspectFlagsForCopy(blitDepthBuffer, blitStencilBuffer);
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
......@@ -509,7 +509,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
// Reinitialize the commandBuffer after a read pixels because it calls
// renderer->finish which makes command buffers obsolete.
vk::CommandBuffer *commandBuffer;
CommandBufferT *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
......@@ -669,7 +669,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
const vk::Format &readImageFormat = readRenderTarget->getImageFormat();
......@@ -903,7 +903,7 @@ angle::Result FramebufferVk::clearWithClearAttachments(
// This command can only happen inside a render pass, so obtain one if its already happening
// or create a new one if not.
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
vk::RecordingMode mode = vk::RecordingMode::Start;
ANGLE_TRY(getCommandBufferForDraw(contextVk, &commandBuffer, &mode));
......@@ -1032,7 +1032,7 @@ angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
}
angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut,
CommandBufferT **commandBufferOut,
vk::RecordingMode *modeOut)
{
RendererVk *renderer = contextVk->getRenderer();
......@@ -1048,7 +1048,7 @@ angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
}
angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
vk::Framebuffer *framebuffer = nullptr;
ANGLE_TRY(getFramebuffer(contextVk, &framebuffer));
......@@ -1056,7 +1056,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
// TODO(jmadill): Proper clear value implementation. http://anglebug.com/2361
std::vector<VkClearValue> attachmentClearValues;
vk::CommandBuffer *writeCommands = nullptr;
CommandBufferT *writeCommands = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands));
vk::RenderPassDesc renderPassDesc;
......@@ -1112,7 +1112,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
ANGLE_TRY(renderTarget->ensureImageInitialized(contextVk));
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// Note that although we're reading from the image, we need to update the layout below.
......
......@@ -106,14 +106,14 @@ class FramebufferVk : public FramebufferImpl
RenderTargetVk *getColorReadRenderTarget() const;
// 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);
}
vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; }
angle::Result startNewRenderPass(ContextVk *context, vk::CommandBuffer **commandBufferOut);
angle::Result startNewRenderPass(ContextVk *context, CommandBufferT **commandBufferOut);
RenderTargetVk *getFirstRenderTarget() const;
GLint getSamples() const;
......@@ -127,7 +127,7 @@ class FramebufferVk : public FramebufferImpl
// Helper for appendToStarted/else startNewRenderPass.
angle::Result getCommandBufferForDraw(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut,
CommandBufferT **commandBufferOut,
vk::RecordingMode *modeOut);
// 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,
// Ensure the image is in read-only layout
if (image.isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly))
{
vk::CommandBuffer *srcLayoutChange;
CommandBufferT *srcLayoutChange;
ANGLE_TRY(image.recordCommands(contextVk, &srcLayoutChange));
image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT,
......@@ -910,8 +910,7 @@ void ProgramVk::setDefaultUniformBlocksMinSizeForTesting(size_t minSize)
}
}
angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer)
angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk, CommandBufferT *commandBuffer)
{
// Can probably use better dirty bits here.
......
......@@ -108,7 +108,7 @@ class ProgramVk : public ProgramImpl
angle::Result updateTexturesDescriptorSet(ContextVk *contextVk,
vk::FramebufferHelper *framebuffer);
angle::Result updateDescriptorSets(ContextVk *contextVk, vk::CommandBuffer *commandBuffer);
angle::Result updateDescriptorSets(ContextVk *contextVk, CommandBufferT *commandBuffer);
// For testing only.
void setDefaultUniformBlocksMinSizeForTesting(size_t minSize);
......
......@@ -53,7 +53,7 @@ void RenderTargetVk::reset()
}
void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer,
CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
......@@ -71,7 +71,7 @@ void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
}
void RenderTargetVk::onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer,
CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
......@@ -135,7 +135,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource,
vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(mImage && mImage->valid());
......@@ -145,7 +145,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi
//
// if (mImage->isLayoutChangeNecessary(layout)
// {
// vk::CommandBuffer *srcLayoutChange;
// CommandBufferT *srcLayoutChange;
// ANGLE_TRY(mImage->recordCommands(contextVk, &srcLayoutChange));
// mImage->changeLayout(mImage->getAspectFlags(), layout, srcLayoutChange);
// }
......
......@@ -53,10 +53,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
// Note: RenderTargets should be called in order, with the depth/stencil onRender last.
void onColorDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer,
CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc);
void onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer,
CommandBufferT *commandBuffer,
vk::RenderPassDesc *renderPassDesc);
vk::ImageHelper &getImage();
......@@ -65,7 +65,7 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
// getImageForRead will also transition the resource to the given layout.
vk::ImageHelper *getImageForRead(vk::CommandGraphResource *readingResource,
vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const;
vk::ImageView *getDrawImageView() const;
......
......@@ -93,7 +93,7 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context,
&mImageView, 0, 1));
// 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));
if (isDepthOrStencilFormat)
......@@ -143,7 +143,7 @@ angle::Result RenderbufferVk::setStorageEGLImageTarget(const gl::Context *contex
uint32_t rendererQueueFamilyIndex = contextVk->getRenderer()->getQueueFamilyIndex();
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
mImage->changeLayoutAndQueue(aspect, vk::ImageLayout::ColorAttachment,
rendererQueueFamilyIndex, commandBuffer);
......
......@@ -41,6 +41,7 @@ const uint32_t kMockDeviceID = 0xf005ba11;
constexpr char kMockDeviceName[] = "Vulkan Mock Device";
constexpr size_t kInFlightCommandsLimit = 100u;
constexpr VkFormatFeatureFlags kInvalidFormatFeatureFlags = static_cast<VkFormatFeatureFlags>(-1);
constexpr size_t kDefaultPoolAllocatorPageSize = 16 * 1024;
} // anonymous namespace
namespace rx
......@@ -505,7 +506,8 @@ RendererVk::RendererVk()
mCurrentQueueSerial(mQueueSerialFactory.generate()),
mDeviceLost(false),
mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod),
mCommandGraph(kEnableCommandGraphDiagnostics),
mPoolAllocator(kDefaultPoolAllocatorPageSize),
mCommandGraph(kEnableCommandGraphDiagnostics, &mPoolAllocator),
mGpuEventsEnabled(false),
mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()},
mGpuEventTimestampOrigin(0)
......
......@@ -13,6 +13,7 @@
#include <vulkan/vulkan.h>
#include <memory>
#include "common/PoolAlloc.h"
#include "common/angleutils.h"
#include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h"
......@@ -334,6 +335,9 @@ class RendererVk : angle::NonCopyable
// http://anglebug.com/2701
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.
vk::CommandGraph mCommandGraph;
......
......@@ -14,6 +14,7 @@
#include <vulkan/vulkan.h>
#include "common/PoolAlloc.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
namespace rx
{
......@@ -295,56 +296,54 @@ struct CommandHeader
class SecondaryCommandBuffer final : angle::NonCopyable
{
public:
SecondaryCommandBuffer(angle::PoolAllocator *allocator)
: mHead(nullptr), mLast(nullptr), mAllocator(allocator)
{}
SecondaryCommandBuffer() : mHead(nullptr), mLast(nullptr), mAllocator(nullptr) {}
~SecondaryCommandBuffer() {}
// Add commands
void bindDescriptorSets(VkPipelineBindPoint bindPoint,
VkPipelineLayout layout,
const PipelineLayout &layout,
uint32_t firstSet,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount,
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,
uint32_t bindingCount,
const VkBuffer *buffers,
const VkDeviceSize *offsets);
void blitImage(VkImage srcImage,
void blitImage(const Image &srcImage,
VkImageLayout srcImageLayout,
VkImage dstImage,
const Image &dstImage,
VkImageLayout dstImageLayout,
uint32_t regionCount,
const VkImageBlit *pRegions,
VkFilter filter);
void copyBuffer(const VkBuffer &srcBuffer,
const VkBuffer &destBuffer,
void copyBuffer(const Buffer &srcBuffer,
const Buffer &destBuffer,
uint32_t regionCount,
const VkBufferCopy *regions);
void copyBufferToImage(VkBuffer srcBuffer,
VkImage dstImage,
const Image &dstImage,
VkImageLayout dstImageLayout,
uint32_t regionCount,
const VkBufferImageCopy *regions);
void copyImage(VkImage srcImage,
void copyImage(const Image &srcImage,
VkImageLayout srcImageLayout,
VkImage dstImage,
const Image &dstImage,
VkImageLayout dstImageLayout,
uint32_t regionCount,
const VkImageCopy *regions);
void copyImageToBuffer(VkImage srcImage,
void copyImageToBuffer(const Image &srcImage,
VkImageLayout srcImageLayout,
VkBuffer dstBuffer,
uint32_t regionCount,
......@@ -355,24 +354,24 @@ class SecondaryCommandBuffer final : angle::NonCopyable
uint32_t rectCount,
const VkClearRect *rects);
void clearColorImage(VkImage image,
void clearColorImage(const Image &image,
VkImageLayout imageLayout,
const VkClearColorValue &color,
uint32_t rangeCount,
const VkImageSubresourceRange *ranges);
void clearDepthStencilImage(VkImage image,
void clearDepthStencilImage(const Image &image,
VkImageLayout imageLayout,
const VkClearDepthStencilValue &depthStencil,
uint32_t rangeCount,
const VkImageSubresourceRange *ranges);
void updateBuffer(VkBuffer buffer,
void updateBuffer(const Buffer &buffer,
VkDeviceSize dstOffset,
VkDeviceSize dataSize,
const void *data);
void pushConstants(VkPipelineLayout layout,
void pushConstants(const PipelineLayout &layout,
VkShaderStageFlags flag,
uint32_t offset,
uint32_t size,
......@@ -423,9 +422,17 @@ class SecondaryCommandBuffer final : angle::NonCopyable
void writeTimestamp(VkPipelineStageFlagBits pipelineStage,
VkQueryPool queryPool,
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
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:
// Allocate and initialize memory for given commandID & variable param size
......
......@@ -548,7 +548,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
&member.imageView, 0, 1));
// Allocate a command buffer for clearing our images to black.
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(member.image.recordCommands(displayVk, &commandBuffer));
// Set transfer dest layout, and clear the image to black.
......@@ -571,7 +571,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
VkClearDepthStencilValue depthStencilClearValue = {1.0f, 0};
// Clear the image.
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mDepthStencilImage.recordCommands(displayVk, &commandBuffer));
mDepthStencilImage.clearDepthStencil(aspect, aspect, depthStencilClearValue, commandBuffer);
......@@ -706,7 +706,7 @@ angle::Result WindowSurfaceVk::present(DisplayVk *displayVk,
SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex];
vk::CommandBuffer *swapCommands = nullptr;
CommandBufferT *swapCommands = nullptr;
ANGLE_TRY(image.image.recordCommands(displayVk, &swapCommands));
image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, swapCommands);
......
......@@ -534,7 +534,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
// Change source layout if necessary
if (srcImage->isLayoutChangeNecessary(vk::ImageLayout::TransferSrc))
{
vk::CommandBuffer *srcLayoutChange;
CommandBufferT *srcLayoutChange;
ANGLE_TRY(srcImage->recordCommands(contextVk, &srcLayoutChange));
srcImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc,
srcLayoutChange);
......@@ -552,7 +552,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
// Make sure any updates to the image are already flushed.
ANGLE_TRY(ensureImageInitialized(contextVk));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
// Change the image layout before the transfer
......@@ -580,7 +580,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
gl::Extents(sourceArea.width, sourceArea.height, 1),
destFormat, kTransferStagingImageFlags, layerCount));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(stagingImage->recordCommands(contextVk, &commandBuffer));
// Change the image layout before the transfer
......@@ -749,7 +749,7 @@ angle::Result TextureVk::setStorage(const gl::Context *context,
const vk::Format &format = renderer->getFormat(internalFormat);
ANGLE_TRY(ensureImageAllocated(renderer, format));
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
if (mImage->valid())
......@@ -782,7 +782,7 @@ angle::Result TextureVk::setEGLImageTarget(const gl::Context *context,
uint32_t rendererQueueFamilyIndex = renderer->getQueueFamilyIndex();
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
mImage->changeLayoutAndQueue(VK_IMAGE_ASPECT_COLOR_BIT,
vk::ImageLayout::FragmentShaderReadOnly,
......@@ -938,7 +938,7 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk,
size_t sourceCopyAllocationSize =
sourceArea.width * sourceArea.height * imageFormat.pixelBytes * layerCount;
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
// 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)
sourceRowPitch, imageData + bufferOffset));
}
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
return mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), getLevelCount(),
commandBuffer);
......@@ -1132,7 +1132,7 @@ angle::Result TextureVk::ensureImageInitializedImpl(ContextVk *contextVk,
{
return angle::Result::Continue;
}
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
if (!mImage->valid())
......@@ -1290,7 +1290,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
const vk::Format &format,
const gl::Extents &extents,
const uint32_t levelCount,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
const RendererVk *renderer = contextVk->getRenderer();
const angle::Format &angleFormat = format.textureFormat();
......
......@@ -253,7 +253,7 @@ class TextureVk : public TextureImpl
const vk::Format &format,
const gl::Extents &extents,
const uint32_t levelCount,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
void releaseImage(RendererVk *renderer);
void releaseStagingBuffer(RendererVk *renderer);
uint32_t getLevelCount() const;
......
......@@ -311,7 +311,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context,
const VkDescriptorSet descriptorSet,
const void *pushConstants,
size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
RendererVk *renderer = context->getRenderer();
......@@ -373,7 +373,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context,
ANGLE_TRY(ensureBufferClearResourcesInitialized(context));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell dest it's being written to.
......@@ -429,7 +429,7 @@ angle::Result UtilsVk::copyBuffer(vk::Context *context,
ANGLE_TRY(ensureBufferCopyResourcesInitialized(context));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell src we are going to read from it.
......@@ -498,7 +498,7 @@ angle::Result UtilsVk::convertVertexBuffer(vk::Context *context,
ANGLE_TRY(ensureConvertVertexResourcesInitialized(context));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(dest->recordCommands(context, &commandBuffer));
// Tell src we are going to read from it.
......@@ -576,7 +576,7 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
const vk::ImageView *imageView,
const vk::RenderPassDesc &renderPassDesc,
const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut)
CommandBufferT **commandBufferOut)
{
RendererVk *renderer = contextVk->getRenderer();
......@@ -617,7 +617,7 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
ANGLE_TRY(ensureImageClearResourcesInitialized(contextVk));
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(renderer->getCurrentQueueSerial(), &commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, &commandBuffer));
......@@ -740,20 +740,20 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
// Change source layout outside render pass
if (src->isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly))
{
vk::CommandBuffer *srcLayoutChange;
CommandBufferT *srcLayoutChange;
ANGLE_TRY(src->recordCommands(contextVk, &srcLayoutChange));
src->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::FragmentShaderReadOnly,
srcLayoutChange);
}
// Change destination layout outside render pass as well
vk::CommandBuffer *destLayoutChange;
CommandBufferT *destLayoutChange;
ANGLE_TRY(dest->recordCommands(contextVk, &destLayoutChange));
dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
destLayoutChange);
vk::CommandBuffer *commandBuffer;
CommandBufferT *commandBuffer;
ANGLE_TRY(
startRenderPass(contextVk, dest, destView, renderPassDesc, renderArea, &commandBuffer));
......
......@@ -192,7 +192,7 @@ class UtilsVk : angle::NonCopyable
const VkDescriptorSet descriptorSet,
const void *pushConstants,
size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
// 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
......@@ -218,7 +218,7 @@ class UtilsVk : angle::NonCopyable
const vk::ImageView *imageView,
const vk::RenderPassDesc &renderPassDesc,
const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut);
CommandBufferT **commandBufferOut);
angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts;
angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts;
......
......@@ -1060,7 +1060,7 @@ void LineLoopHelper::destroy(VkDevice device)
}
// 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*.
// Note: this could theoretically overflow and wrap to zero.
......@@ -1128,7 +1128,7 @@ angle::Result BufferHelper::copyFromBuffer(Context *context,
const VkBufferCopy &copyRegion)
{
// 'recordCommands' will implicitly stop any reads from using the old buffer data.
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(context, &commandBuffer));
if (mCurrentReadAccess != 0 || mCurrentWriteAccess != 0)
......@@ -1558,7 +1558,7 @@ bool ImageHelper::isLayoutChangeNecessary(ImageLayout newLayout) const
void ImageHelper::changeLayout(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
if (!isLayoutChangeNecessary(newLayout))
{
......@@ -1571,7 +1571,7 @@ void ImageHelper::changeLayout(VkImageAspectFlags aspectMask,
void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(isQueueChangeNeccesary(newQueueFamilyIndex));
forceChangeLayoutAndQueue(aspectMask, newLayout, newQueueFamilyIndex, commandBuffer);
......@@ -1580,7 +1580,7 @@ void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask,
void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
const ImageMemoryBarrierData &transitionFrom = kImageMemoryBarrierData[mCurrentLayout];
......@@ -1613,7 +1613,7 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
void ImageHelper::clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer);
......@@ -1624,7 +1624,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
uint32_t levelCount,
uint32_t baseArrayLayer,
uint32_t layerCount,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(valid());
......@@ -1643,7 +1643,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(valid());
......@@ -1678,7 +1678,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresource,
const VkImageSubresourceLayers &dstSubresource,
CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
ASSERT(commandBuffer->valid() && srcImage->valid() && dstImage->valid());
......@@ -1704,7 +1704,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel)
{
vk::CommandBuffer *commandBuffer = nullptr;
CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(contextVk, &commandBuffer));
changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, ImageLayout::TransferDst, commandBuffer);
......@@ -2065,7 +2065,7 @@ angle::Result ImageHelper::allocateStagingMemory(ContextVk *contextVk,
angle::Result ImageHelper::flushStagedUpdates(Context *context,
uint32_t baseLevel,
uint32_t levelCount,
vk::CommandBuffer *commandBuffer)
CommandBufferT *commandBuffer)
{
if (mSubresourceUpdates.empty())
{
......
......@@ -379,7 +379,7 @@ class LineLoopHelper final : angle::NonCopyable
void release(RendererVk *renderer);
void destroy(VkDevice device);
static void Draw(uint32_t count, CommandBuffer *commandBuffer);
static void Draw(uint32_t count, CommandBufferT *commandBuffer);
private:
DynamicBuffer mDynamicIndexBuffer;
......@@ -613,19 +613,19 @@ class ImageHelper final : public CommandGraphResource
void clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
void clearColorLayer(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
uint32_t baseArrayLayer,
uint32_t layerCount,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
void clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
gl::Extents getSize(const gl::ImageIndex &index) const;
static void Copy(ImageHelper *srcImage,
......@@ -635,7 +635,7 @@ class ImageHelper final : public CommandGraphResource
const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresources,
const VkImageSubresourceLayers &dstSubresources,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
angle::Result generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel);
......@@ -683,7 +683,7 @@ class ImageHelper final : public CommandGraphResource
angle::Result flushStagedUpdates(Context *context,
uint32_t baseLevel,
uint32_t levelCount,
vk::CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
bool hasStagedUpdates() const;
......@@ -694,7 +694,7 @@ class ImageHelper final : public CommandGraphResource
void changeLayout(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
bool isQueueChangeNeccesary(uint32_t newQueueFamilyIndex) const
{
......@@ -704,13 +704,13 @@ class ImageHelper final : public CommandGraphResource
void changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
private:
void forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBuffer *commandBuffer);
CommandBufferT *commandBuffer);
struct SubresourceUpdate
{
......
......@@ -242,7 +242,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const VkBuffer *buffers,
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,
const PipelineLayout &layout,
uint32_t firstSet,
......@@ -252,7 +252,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const uint32_t *dynamicOffsets);
void executeCommands(uint32_t commandBufferCount, const CommandBuffer *commandBuffers);
void updateBuffer(const vk::Buffer &buffer,
void updateBuffer(const Buffer &buffer,
VkDeviceSize dstOffset,
VkDeviceSize dataSize,
const void *data);
......@@ -534,7 +534,7 @@ ANGLE_INLINE void CommandBuffer::blitImage(const Image &srcImage,
VkImageBlit *pRegions,
VkFilter filter)
{
ASSERT(valid());
ASSERT(valid() && srcImage.valid() && dstImage.valid());
vkCmdBlitImage(mHandle, srcImage.getHandle(), srcImageLayout, dstImage.getHandle(),
dstImageLayout, regionCount, pRegions, filter);
}
......@@ -588,13 +588,12 @@ ANGLE_INLINE void CommandBuffer::destroy(VkDevice device, const vk::CommandPool
}
}
ANGLE_INLINE void CommandBuffer::copyBuffer(const vk::Buffer &srcBuffer,
const vk::Buffer &destBuffer,
ANGLE_INLINE void CommandBuffer::copyBuffer(const Buffer &srcBuffer,
const Buffer &destBuffer,
uint32_t regionCount,
const VkBufferCopy *regions)
{
ASSERT(valid());
ASSERT(srcBuffer.valid() && destBuffer.valid());
ASSERT(valid() && srcBuffer.valid() && destBuffer.valid());
vkCmdCopyBuffer(mHandle, srcBuffer.getHandle(), destBuffer.getHandle(), regionCount, regions);
}
......@@ -604,9 +603,8 @@ ANGLE_INLINE void CommandBuffer::copyBufferToImage(VkBuffer srcBuffer,
uint32_t regionCount,
const VkBufferImageCopy *regions)
{
ASSERT(valid());
ASSERT(valid() && dstImage.valid());
ASSERT(srcBuffer != VK_NULL_HANDLE);
ASSERT(dstImage.valid());
vkCmdCopyBufferToImage(mHandle, srcBuffer, dstImage.getHandle(), dstImageLayout, regionCount,
regions);
}
......@@ -617,14 +615,13 @@ ANGLE_INLINE void CommandBuffer::copyImageToBuffer(const Image &srcImage,
uint32_t regionCount,
const VkBufferImageCopy *regions)
{
ASSERT(valid());
ASSERT(valid() && srcImage.valid());
ASSERT(dstBuffer != VK_NULL_HANDLE);
ASSERT(srcImage.valid());
vkCmdCopyImageToBuffer(mHandle, srcImage.getHandle(), srcImageLayout, dstBuffer, regionCount,
regions);
}
ANGLE_INLINE void CommandBuffer::clearColorImage(const vk::Image &image,
ANGLE_INLINE void CommandBuffer::clearColorImage(const Image &image,
VkImageLayout imageLayout,
const VkClearColorValue &color,
uint32_t rangeCount,
......@@ -635,7 +632,7 @@ ANGLE_INLINE void CommandBuffer::clearColorImage(const vk::Image &image,
}
ANGLE_INLINE void CommandBuffer::clearDepthStencilImage(
const vk::Image &image,
const Image &image,
VkImageLayout imageLayout,
const VkClearDepthStencilValue &depthStencil,
uint32_t rangeCount,
......@@ -655,9 +652,9 @@ ANGLE_INLINE void CommandBuffer::clearAttachments(uint32_t attachmentCount,
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,
const vk::Image &dstImage,
const Image &dstImage,
VkImageLayout dstImageLayout,
uint32_t regionCount,
const VkImageCopy *regions)
......@@ -680,23 +677,23 @@ ANGLE_INLINE void CommandBuffer::endRenderPass()
vkCmdEndRenderPass(mHandle);
}
ANGLE_INLINE void CommandBuffer::bindIndexBuffer(const VkBuffer &buffer,
ANGLE_INLINE void CommandBuffer::bindIndexBuffer(const Buffer &buffer,
VkDeviceSize offset,
VkIndexType indexType)
{
ASSERT(valid());
vkCmdBindIndexBuffer(mHandle, buffer, offset, indexType);
vkCmdBindIndexBuffer(mHandle, buffer.getHandle(), offset, indexType);
}
ANGLE_INLINE void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint,
const vk::PipelineLayout &layout,
const PipelineLayout &layout,
uint32_t firstSet,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount,
const uint32_t *dynamicOffsets)
{
ASSERT(valid());
ASSERT(valid() && layout.valid());
vkCmdBindDescriptorSets(mHandle, bindPoint, layout.getHandle(), firstSet, descriptorSetCount,
descriptorSets, dynamicOffsetCount, dynamicOffsets);
}
......@@ -708,7 +705,7 @@ ANGLE_INLINE void CommandBuffer::executeCommands(uint32_t commandBufferCount,
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 dataSize,
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