Commit 2660b503 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Restore CommandBuffer to namespace vk

Moved vk::CommandBuffer and vk::SecondaryCommandBuffer to vk::priv:: and aliased vk::CommandBuffer to one or the other. This allows the rest of the classes to continue seeing vk::CommandBuffer as they used to do. Used a special alias for the primary command buffer that gets submitted (vk::PrimaryCommandBuffer). Bug: angleproject:3136 Change-Id: I61236fd182230991db7395d05e3da3be5e3f45be Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1534456Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent a8ff8814
......@@ -246,7 +246,7 @@ angle::Result BufferVk::copyToBuffer(ContextVk *contextVk,
uint32_t copyCount,
const VkBufferCopy *copies)
{
CommandBufferT *commandBuffer;
vk::CommandBuffer *commandBuffer;
ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer));
commandBuffer->copyBuffer(mBuffer.getBuffer(), destBuffer->getBuffer(), copyCount, copies);
......
......@@ -31,7 +31,7 @@ angle::Result InitAndBeginCommandBuffer(vk::Context *context,
const VkCommandBufferInheritanceInfo &inheritanceInfo,
VkCommandBufferUsageFlags flags,
angle::PoolAllocator *poolAllocator,
SecondaryCommandBuffer *commandBuffer)
priv::SecondaryCommandBuffer *commandBuffer)
{
ASSERT(!commandBuffer->valid());
commandBuffer->initialize(poolAllocator);
......@@ -44,7 +44,7 @@ angle::Result InitAndBeginCommandBuffer(vk::Context *context,
const VkCommandBufferInheritanceInfo &inheritanceInfo,
VkCommandBufferUsageFlags flags,
angle::PoolAllocator *poolAllocator,
CommandBuffer *commandBuffer)
PrimaryCommandBuffer *commandBuffer)
{
ASSERT(!commandBuffer->valid());
VkCommandBufferAllocateInfo createInfo = {};
......@@ -146,13 +146,14 @@ constexpr VkSubpassContents kRenderPassContents = VK_SUBPASS_CONTENTS_SECONDARY_
// Helpers to unify executeCommands call based on underlying cmd buffer type
ANGLE_MAYBE_UNUSED
void ExecuteCommands(CommandBuffer *primCmdBuffer, SecondaryCommandBuffer *secCmdBuffer)
void ExecuteCommands(PrimaryCommandBuffer *primCmdBuffer,
priv::SecondaryCommandBuffer *secCmdBuffer)
{
secCmdBuffer->executeCommands(primCmdBuffer->getHandle());
}
ANGLE_MAYBE_UNUSED
void ExecuteCommands(CommandBuffer *primCmdBuffer, CommandBuffer *secCmdBuffer)
void ExecuteCommands(PrimaryCommandBuffer *primCmdBuffer, priv::CommandBuffer *secCmdBuffer)
{
primCmdBuffer->executeCommands(1, secCmdBuffer);
}
......@@ -172,7 +173,7 @@ bool CommandGraphResource::isResourceInUse(RendererVk *renderer) const
}
angle::Result CommandGraphResource::recordCommands(Context *context,
CommandBufferT **commandBufferOut)
CommandBuffer **commandBufferOut)
{
updateQueueSerial(context->getRenderer()->getCurrentQueueSerial());
......@@ -183,7 +184,7 @@ angle::Result CommandGraphResource::recordCommands(Context *context,
context, context->getRenderer()->getCommandPool(), commandBufferOut);
}
CommandBufferT *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands();
CommandBuffer *outsideRenderPassCommands = mCurrentWritingNode->getOutsideRenderPassCommands();
if (!outsideRenderPassCommands->valid())
{
ANGLE_TRY(mCurrentWritingNode->beginOutsideRenderPassRecording(
......@@ -208,7 +209,7 @@ angle::Result CommandGraphResource::beginRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues,
CommandBufferT **commandBufferOut)
CommandBuffer **commandBufferOut)
{
// If a barrier has been inserted in the meantime, stop the command buffer.
if (!hasChildlessWritingNode())
......@@ -309,7 +310,7 @@ CommandGraphNode::~CommandGraphNode()
angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool,
CommandBufferT **commandsOut)
CommandBuffer **commandsOut)
{
ASSERT(!mHasChildren);
......@@ -331,7 +332,7 @@ angle::Result CommandGraphNode::beginOutsideRenderPassRecording(Context *context
}
angle::Result CommandGraphNode::beginInsideRenderPassRecording(Context *context,
CommandBufferT **commandsOut)
CommandBuffer **commandsOut)
{
ASSERT(!mHasChildren);
......@@ -466,7 +467,7 @@ void CommandGraphNode::visitParents(std::vector<CommandGraphNode *> *stack)
angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
Serial serial,
RenderPassCache *renderPassCache,
CommandBuffer *primaryCommandBuffer)
PrimaryCommandBuffer *primaryCommandBuffer)
{
switch (mFunction)
{
......@@ -683,7 +684,7 @@ angle::Result CommandGraph::submitCommands(Context *context,
Serial serial,
RenderPassCache *renderPassCache,
CommandPool *commandPool,
CommandBuffer *primaryCommandBufferOut)
PrimaryCommandBuffer *primaryCommandBufferOut)
{
// There is no point in submitting an empty command buffer, so make sure not to call this
// function if there's nothing to do.
......
......@@ -13,12 +13,6 @@
#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
{
......@@ -69,7 +63,7 @@ class CommandBufferOwner
ANGLE_INLINE void onCommandBufferFinished() { mCommandBuffer = nullptr; }
protected:
CommandBufferT *mCommandBuffer = nullptr;
CommandBuffer *mCommandBuffer = nullptr;
};
// Only used internally in the command graph. Kept in the header for better inlining performance.
......@@ -80,13 +74,13 @@ class CommandGraphNode final : angle::NonCopyable
~CommandGraphNode();
// Immutable queries for when we're walking the commands tree.
CommandBufferT *getOutsideRenderPassCommands()
CommandBuffer *getOutsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mOutsideRenderPassCommands;
}
CommandBufferT *getInsideRenderPassCommands()
CommandBuffer *getInsideRenderPassCommands()
{
ASSERT(!mHasChildren);
return &mInsideRenderPassCommands;
......@@ -95,10 +89,10 @@ class CommandGraphNode final : angle::NonCopyable
// For outside the render pass (copies, transitions, etc).
angle::Result beginOutsideRenderPassRecording(Context *context,
const CommandPool &commandPool,
CommandBufferT **commandsOut);
CommandBuffer **commandsOut);
// For rendering commands (draws).
angle::Result beginInsideRenderPassRecording(Context *context, CommandBufferT **commandsOut);
angle::Result beginInsideRenderPassRecording(Context *context, CommandBuffer **commandsOut);
// storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass.
void storeRenderPassInfo(const Framebuffer &framebuffer,
......@@ -134,7 +128,7 @@ class CommandGraphNode final : angle::NonCopyable
angle::Result visitAndExecute(Context *context,
Serial serial,
RenderPassCache *renderPassCache,
CommandBuffer *primaryCommandBuffer);
PrimaryCommandBuffer *primaryCommandBuffer);
// Only used in the command graph diagnostics.
const std::vector<CommandGraphNode *> &getParentsForDiagnostics() const;
......@@ -190,8 +184,8 @@ class CommandGraphNode final : angle::NonCopyable
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.
CommandBufferT mOutsideRenderPassCommands;
CommandBufferT mInsideRenderPassCommands;
CommandBuffer mOutsideRenderPassCommands;
CommandBuffer mInsideRenderPassCommands;
// Special-function additional data:
// Queries:
......@@ -265,7 +259,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, CommandBufferT **commandBufferOut);
angle::Result recordCommands(Context *context, CommandBuffer **commandBufferOut);
// Begins a command buffer on the current graph node for in-RenderPass rendering.
// Called from FramebufferVk::startNewRenderPass and UtilsVk functions.
......@@ -274,12 +268,12 @@ class CommandGraphResource : angle::NonCopyable
const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues,
CommandBufferT **commandBufferOut);
CommandBuffer **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,
CommandBufferT **commandBufferOut)
CommandBuffer **commandBufferOut)
{
updateQueueSerial(currentQueueSerial);
if (hasStartedRenderPass())
......@@ -382,7 +376,7 @@ class CommandGraph final : angle::NonCopyable
Serial serial,
RenderPassCache *renderPassCache,
CommandPool *commandPool,
CommandBuffer *primaryCommandBufferOut);
PrimaryCommandBuffer *primaryCommandBufferOut);
bool empty() const;
void clear();
......
......@@ -206,7 +206,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
gl::DrawElementsType indexTypeOrNone,
const void *indices,
DirtyBits dirtyBitMask,
CommandBufferT **commandBufferOut)
vk::CommandBuffer **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,
CommandBufferT **commandBufferOut)
vk::CommandBuffer **commandBufferOut)
{
if (indexType != mCurrentDrawElementsType)
{
......@@ -312,7 +312,7 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
CommandBufferT **commandBufferOut)
vk::CommandBuffer **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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ASSERT(mDirtyDefaultAttribsMask.any());
......@@ -339,7 +339,7 @@ angle::Result ContextVk::handleDirtyDefaultAttribs(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
if (!mCurrentPipeline)
{
......@@ -377,7 +377,7 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ANGLE_TRY(updateActiveTextures(context));
......@@ -389,7 +389,7 @@ angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
uint32_t maxAttrib = mProgram->getState().getMaxActiveAttribLocation();
const gl::AttribArray<VkBuffer> &bufferHandles = mVertexArray->getCurrentArrayBufferHandles();
......@@ -415,7 +415,7 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
vk::BufferHelper *elementArrayBuffer = mVertexArray->getCurrentElementArrayBuffer();
ASSERT(elementArrayBuffer != nullptr);
......@@ -431,7 +431,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
}
angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ANGLE_TRY(mProgram->updateDescriptorSets(this, commandBuffer));
......@@ -447,8 +447,8 @@ angle::Result ContextVk::drawArrays(const gl::Context *context,
GLint first,
GLsizei count)
{
CommandBufferT *commandBuffer = nullptr;
uint32_t clampedVertexCount = gl::GetClampedVertexCount<uint32_t>(count);
vk::CommandBuffer *commandBuffer = nullptr;
uint32_t clampedVertexCount = gl::GetClampedVertexCount<uint32_t>(count);
if (mode == gl::PrimitiveMode::LineLoop)
{
......@@ -479,7 +479,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context,
return angle::Result::Stop;
}
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum,
nullptr, mNonIndexedDirtyBitsMask, &commandBuffer));
commandBuffer->drawInstanced(gl::GetClampedVertexCount<uint32_t>(count), instances, first);
......@@ -492,7 +492,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context,
gl::DrawElementsType type,
const void *indices)
{
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
if (mode == gl::PrimitiveMode::LineLoop)
{
ANGLE_TRY(setupLineLoopDraw(context, mode, 0, count, type, indices, &commandBuffer));
......@@ -521,7 +521,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context,
return angle::Result::Stop;
}
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer));
commandBuffer->drawIndexedInstanced(count, instances);
return angle::Result::Continue;
......@@ -1155,7 +1155,7 @@ VkColorComponentFlags ContextVk::getClearColorMask() const
}
angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
// Release any previously retained buffers.
mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer);
......
......@@ -226,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 *,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mDirtyBitHandlers;
......@@ -238,21 +238,21 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
DirtyBits dirtyBitMask,
CommandBufferT **commandBufferOut);
vk::CommandBuffer **commandBufferOut);
angle::Result setupIndexedDraw(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei indexCount,
GLsizei instanceCount,
gl::DrawElementsType indexType,
const void *indices,
CommandBufferT **commandBufferOut);
vk::CommandBuffer **commandBufferOut);
angle::Result setupLineLoopDraw(const gl::Context *context,
gl::PrimitiveMode mode,
GLint firstVertex,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
CommandBufferT **commandBufferOut);
vk::CommandBuffer **commandBufferOut);
void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport,
......@@ -273,16 +273,17 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
void invalidateDriverUniforms();
angle::Result handleDirtyDefaultAttribs(const gl::Context *context,
CommandBufferT *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, CommandBufferT *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyVertexBuffers(const gl::Context *context,
CommandBufferT *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context, CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyDriverUniforms(const gl::Context *context,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyDescriptorSets(const gl::Context *context,
CommandBufferT *commandBuffer);
vk::CommandBuffer *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.
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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);
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
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.
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
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);
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
const vk::Format &readImageFormat = readRenderTarget->getImageFormat();
......@@ -903,8 +903,8 @@ 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.
CommandBufferT *commandBuffer = nullptr;
vk::RecordingMode mode = vk::RecordingMode::Start;
vk::CommandBuffer *commandBuffer = nullptr;
vk::RecordingMode mode = vk::RecordingMode::Start;
ANGLE_TRY(getCommandBufferForDraw(contextVk, &commandBuffer, &mode));
// The array layer is offset by the ImageView. So we shouldn't need to set a base array layer.
......@@ -1032,7 +1032,7 @@ angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
}
angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
CommandBufferT **commandBufferOut,
vk::CommandBuffer **commandBufferOut,
vk::RecordingMode *modeOut)
{
RendererVk *renderer = contextVk->getRenderer();
......@@ -1048,7 +1048,7 @@ angle::Result FramebufferVk::getCommandBufferForDraw(ContextVk *contextVk,
}
angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
CommandBufferT **commandBufferOut)
vk::CommandBuffer **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;
CommandBufferT *writeCommands = nullptr;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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, CommandBufferT **commandBufferOut)
bool appendToStartedRenderPass(Serial currentQueueSerial, vk::CommandBuffer **commandBufferOut)
{
return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, commandBufferOut);
}
vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; }
angle::Result startNewRenderPass(ContextVk *context, CommandBufferT **commandBufferOut);
angle::Result startNewRenderPass(ContextVk *context, vk::CommandBuffer **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,
CommandBufferT **commandBufferOut,
vk::CommandBuffer **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))
{
CommandBufferT *srcLayoutChange;
vk::CommandBuffer *srcLayoutChange;
ANGLE_TRY(image.recordCommands(contextVk, &srcLayoutChange));
image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT,
......@@ -910,7 +910,8 @@ void ProgramVk::setDefaultUniformBlocksMinSizeForTesting(size_t minSize)
}
}
angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk, CommandBufferT *commandBuffer)
angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk,
vk::CommandBuffer *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, CommandBufferT *commandBuffer);
angle::Result updateDescriptorSets(ContextVk *contextVk, vk::CommandBuffer *commandBuffer);
// For testing only.
void setDefaultUniformBlocksMinSizeForTesting(size_t minSize);
......
......@@ -53,7 +53,7 @@ void RenderTargetVk::reset()
}
void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
CommandBufferT *commandBuffer,
vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
......@@ -71,7 +71,7 @@ void RenderTargetVk::onColorDraw(vk::FramebufferHelper *framebufferVk,
}
void RenderTargetVk::onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
CommandBufferT *commandBuffer,
vk::CommandBuffer *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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ASSERT(mImage && mImage->valid());
......@@ -145,7 +145,7 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi
//
// if (mImage->isLayoutChangeNecessary(layout)
// {
// CommandBufferT *srcLayoutChange;
// vk::CommandBuffer *srcLayoutChange;
// ANGLE_TRY(mImage->recordCommands(contextVk, &srcLayoutChange));
// mImage->changeLayout(mImage->getAspectFlags(), layout, srcLayoutChange);
// }
......
......@@ -20,7 +20,6 @@ namespace rx
{
namespace vk
{
class CommandBuffer;
struct Format;
class FramebufferHelper;
class ImageHelper;
......@@ -53,10 +52,10 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
// Note: RenderTargets should be called in order, with the depth/stencil onRender last.
void onColorDraw(vk::FramebufferHelper *framebufferVk,
CommandBufferT *commandBuffer,
vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc);
void onDepthStencilDraw(vk::FramebufferHelper *framebufferVk,
CommandBufferT *commandBuffer,
vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc);
vk::ImageHelper &getImage();
......@@ -65,7 +64,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,
CommandBufferT *commandBuffer);
vk::CommandBuffer *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
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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))
{
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
mImage->changeLayoutAndQueue(aspect, vk::ImageLayout::ColorAttachment,
rendererQueueFamilyIndex, commandBuffer);
......
......@@ -1324,7 +1324,7 @@ angle::Result RendererVk::finish(vk::Context *context)
{
TRACE_EVENT0("gpu.angle", "RendererVk::finish");
vk::Scoped<vk::CommandBuffer> commandBatch(mDevice);
vk::Scoped<vk::PrimaryCommandBuffer> commandBatch(mDevice);
ANGLE_TRY(flushCommandGraph(context, &commandBatch.get()));
angle::FixedVector<VkSemaphore, kMaxWaitSemaphores> waitSemaphores;
......@@ -1434,7 +1434,7 @@ angle::Result RendererVk::checkCompletedCommands(vk::Context *context)
angle::Result RendererVk::submitFrame(vk::Context *context,
const VkSubmitInfo &submitInfo,
vk::CommandBuffer &&commandBuffer)
vk::PrimaryCommandBuffer &&commandBuffer)
{
TRACE_EVENT0("gpu.angle", "RendererVk::submitFrame");
......@@ -1557,7 +1557,8 @@ vk::CommandGraph *RendererVk::getCommandGraph()
return &mCommandGraph;
}
angle::Result RendererVk::flushCommandGraph(vk::Context *context, vk::CommandBuffer *commandBatch)
angle::Result RendererVk::flushCommandGraph(vk::Context *context,
vk::PrimaryCommandBuffer *commandBatch)
{
return mCommandGraph.submitCommands(context, mCurrentQueueSerial, &mRenderPassCache,
&mCommandPool, commandBatch);
......@@ -1572,7 +1573,7 @@ angle::Result RendererVk::flush(vk::Context *context)
TRACE_EVENT0("gpu.angle", "RendererVk::flush");
vk::Scoped<vk::CommandBuffer> commandBatch(mDevice);
vk::Scoped<vk::PrimaryCommandBuffer> commandBatch(mDevice);
ANGLE_TRY(flushCommandGraph(context, &commandBatch.get()));
angle::FixedVector<VkSemaphore, kMaxWaitSemaphores> waitSemaphores;
......@@ -1742,8 +1743,8 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
ANGLE_TRY(timestampQueryPool.get().allocateQuery(context, &timestampQuery));
// Record the command buffer
vk::Scoped<vk::CommandBuffer> commandBatch(mDevice);
vk::CommandBuffer &commandBuffer = commandBatch.get();
vk::Scoped<vk::PrimaryCommandBuffer> commandBatch(mDevice);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
VkCommandBufferAllocateInfo commandBufferInfo = {};
commandBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
......@@ -1948,8 +1949,8 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
ANGLE_VK_TRY(context, gpuDone.get().reset(mDevice));
// Record the command buffer
vk::Scoped<vk::CommandBuffer> commandBatch(mDevice);
vk::CommandBuffer &commandBuffer = commandBatch.get();
vk::Scoped<vk::PrimaryCommandBuffer> commandBatch(mDevice);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
VkCommandBufferAllocateInfo commandBufferInfo = {};
commandBufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
......@@ -2069,7 +2070,7 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
}
angle::Result RendererVk::traceGpuEventImpl(vk::Context *context,
vk::CommandBuffer *commandBuffer,
vk::PrimaryCommandBuffer *commandBuffer,
char phase,
const char *name)
{
......
......@@ -183,7 +183,7 @@ class RendererVk : angle::NonCopyable
// The events are queued until the query results are available. Possible values for `phase`
// are TRACE_EVENT_PHASE_*
ANGLE_INLINE angle::Result traceGpuEvent(vk::Context *context,
vk::CommandBuffer *commandBuffer,
vk::PrimaryCommandBuffer *commandBuffer,
char phase,
const char *name)
{
......@@ -227,16 +227,16 @@ class RendererVk : angle::NonCopyable
angle::FixedVector<VkPipelineStageFlags, kMaxWaitSemaphores> *waitStageMasks);
angle::Result submitFrame(vk::Context *context,
const VkSubmitInfo &submitInfo,
vk::CommandBuffer &&commandBuffer);
vk::PrimaryCommandBuffer &&commandBuffer);
void freeAllInFlightResources();
angle::Result flushCommandGraph(vk::Context *context, vk::CommandBuffer *commandBatch);
angle::Result flushCommandGraph(vk::Context *context, vk::PrimaryCommandBuffer *commandBatch);
void initFeatures(const ExtensionNameList &extensions);
void initPipelineCacheVkKey();
angle::Result initPipelineCache(DisplayVk *display);
angle::Result synchronizeCpuGpuTime(vk::Context *context);
angle::Result traceGpuEventImpl(vk::Context *context,
vk::CommandBuffer *commandBuffer,
vk::PrimaryCommandBuffer *commandBuffer,
char phase,
const char *name);
angle::Result checkCompletedGpuEvents(vk::Context *context);
......
......@@ -14,6 +14,8 @@ namespace rx
{
namespace vk
{
namespace priv
{
void SecondaryCommandBuffer::blitImage(const Image &srcImage,
VkImageLayout srcImageLayout,
const Image &dstImage,
......@@ -610,5 +612,6 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
}
}
} // namespace priv
} // namespace vk
} // namespace rx
......@@ -22,6 +22,9 @@ namespace rx
namespace vk
{
namespace priv
{
enum class CommandID : uint16_t
{
// Invalid cmd used to mark end of sequence of commands
......@@ -705,6 +708,7 @@ ANGLE_INLINE void SecondaryCommandBuffer::drawIndexedInstanced(uint32_t indexCou
paramStruct->instanceCount = instanceCount;
}
} // namespace priv
} // namespace vk
} // namespace rx
......
......@@ -548,7 +548,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
&member.imageView, 0, 1));
// Allocate a command buffer for clearing our images to black.
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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.
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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];
CommandBufferT *swapCommands = nullptr;
vk::CommandBuffer *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))
{
CommandBufferT *srcLayoutChange;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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))
{
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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;
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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));
}
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
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;
}
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *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,
CommandBufferT *commandBuffer);
vk::CommandBuffer *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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
RendererVk *renderer = context->getRenderer();
......@@ -373,7 +373,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context,
ANGLE_TRY(ensureBufferClearResourcesInitialized(context));
CommandBufferT *commandBuffer;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer;
vk::CommandBuffer *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));
CommandBufferT *commandBuffer;
vk::CommandBuffer *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,
CommandBufferT **commandBufferOut)
vk::CommandBuffer **commandBufferOut)
{
RendererVk *renderer = contextVk->getRenderer();
......@@ -617,7 +617,7 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
ANGLE_TRY(ensureImageClearResourcesInitialized(contextVk));
CommandBufferT *commandBuffer;
vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(renderer->getCurrentQueueSerial(), &commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, &commandBuffer));
......@@ -738,20 +738,20 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
// Change source layout outside render pass
if (src->isLayoutChangeNecessary(vk::ImageLayout::FragmentShaderReadOnly))
{
CommandBufferT *srcLayoutChange;
vk::CommandBuffer *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
CommandBufferT *destLayoutChange;
vk::CommandBuffer *destLayoutChange;
ANGLE_TRY(dest->recordCommands(contextVk, &destLayoutChange));
dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
destLayoutChange);
CommandBufferT *commandBuffer;
vk::CommandBuffer *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,
CommandBufferT *commandBuffer);
vk::CommandBuffer *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,
CommandBufferT **commandBufferOut);
vk::CommandBuffer **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, CommandBufferT *commandBuffer)
void LineLoopHelper::Draw(uint32_t count, vk::CommandBuffer *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.
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
if (!isLayoutChangeNecessary(newLayout))
{
......@@ -1571,7 +1571,7 @@ void ImageHelper::changeLayout(VkImageAspectFlags aspectMask,
void ImageHelper::changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBufferT *commandBuffer)
vk::CommandBuffer *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,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
const ImageMemoryBarrierData &transitionFrom = kImageMemoryBarrierData[mCurrentLayout];
......@@ -1612,7 +1612,7 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
void ImageHelper::clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer);
}
......@@ -1622,7 +1622,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
uint32_t levelCount,
uint32_t baseArrayLayer,
uint32_t layerCount,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ASSERT(valid());
......@@ -1641,7 +1641,7 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
void ImageHelper::clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ASSERT(valid());
......@@ -1676,7 +1676,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresource,
const VkImageSubresourceLayers &dstSubresource,
CommandBufferT *commandBuffer)
vk::CommandBuffer *commandBuffer)
{
ASSERT(commandBuffer->valid() && srcImage->valid() && dstImage->valid());
......@@ -1702,7 +1702,7 @@ void ImageHelper::Copy(ImageHelper *srcImage,
angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel)
{
CommandBufferT *commandBuffer = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(contextVk, &commandBuffer));
changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, ImageLayout::TransferDst, commandBuffer);
......@@ -2060,7 +2060,7 @@ angle::Result ImageHelper::allocateStagingMemory(ContextVk *contextVk,
angle::Result ImageHelper::flushStagedUpdates(Context *context,
uint32_t baseLevel,
uint32_t levelCount,
CommandBufferT *commandBuffer)
vk::CommandBuffer *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, CommandBufferT *commandBuffer);
static void Draw(uint32_t count, vk::CommandBuffer *commandBuffer);
private:
DynamicBuffer mDynamicIndexBuffer;
......@@ -613,20 +613,19 @@ class ImageHelper final : public CommandGraphResource
void clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
void clearColorLayer(const VkClearColorValue &color,
uint32_t baseMipLevel,
uint32_t levelCount,
uint32_t baseArrayLayer,
uint32_t layerCount,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
void clearDepthStencil(VkImageAspectFlags imageAspectFlags,
VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
gl::Extents getSize(const gl::ImageIndex &index) const;
static void Copy(ImageHelper *srcImage,
......@@ -636,7 +635,7 @@ class ImageHelper final : public CommandGraphResource
const gl::Extents &copySize,
const VkImageSubresourceLayers &srcSubresources,
const VkImageSubresourceLayers &dstSubresources,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
angle::Result generateMipmapsWithBlit(ContextVk *contextVk, GLuint maxLevel);
......@@ -684,7 +683,7 @@ class ImageHelper final : public CommandGraphResource
angle::Result flushStagedUpdates(Context *context,
uint32_t baseLevel,
uint32_t levelCount,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
bool hasStagedUpdates() const;
......@@ -695,7 +694,7 @@ class ImageHelper final : public CommandGraphResource
void changeLayout(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
bool isQueueChangeNeccesary(uint32_t newQueueFamilyIndex) const
{
......@@ -705,13 +704,13 @@ class ImageHelper final : public CommandGraphResource
void changeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
private:
void forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
ImageLayout newLayout,
uint32_t newQueueFamilyIndex,
CommandBufferT *commandBuffer);
vk::CommandBuffer *commandBuffer);
struct SubresourceUpdate
{
......
......@@ -18,6 +18,7 @@
#include "common/debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/Observer.h"
#include "libANGLE/renderer/vulkan/SecondaryCommandBuffer.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
#define ANGLE_GL_OBJECTS_X(PROC) \
......@@ -114,6 +115,14 @@ class Context : angle::NonCopyable
RendererVk *const mRenderer;
};
#if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS
using CommandBuffer = priv::SecondaryCommandBuffer;
#else
using CommandBuffer = priv::CommandBuffer;
#endif
using PrimaryCommandBuffer = priv::CommandBuffer;
VkImageAspectFlags GetDepthStencilAspectFlags(const angle::Format &format);
VkImageAspectFlags GetFormatAspectFlags(const angle::Format &format);
VkImageAspectFlags GetDepthStencilAspectFlagsForCopy(bool copyDepth, bool copyStencil);
......
......@@ -70,7 +70,6 @@ class WrappedObject : angle::NonCopyable
#define ANGLE_HANDLE_TYPES_X(FUNC) \
FUNC(Buffer) \
FUNC(BufferView) \
FUNC(CommandBuffer) \
FUNC(CommandPool) \
FUNC(DescriptorPool) \
FUNC(DescriptorSetLayout) \
......@@ -94,6 +93,7 @@ class WrappedObject : angle::NonCopyable
enum class HandleType
{
Invalid,
CommandBuffer,
ANGLE_HANDLE_TYPES_X(ANGLE_COMMA_SEP_FUNC)
};
......@@ -101,6 +101,10 @@ enum class HandleType
#define ANGLE_PRE_DECLARE_CLASS_FUNC(TYPE) class TYPE;
ANGLE_HANDLE_TYPES_X(ANGLE_PRE_DECLARE_CLASS_FUNC)
namespace priv
{
class CommandBuffer;
} // namespace priv
#undef ANGLE_PRE_DECLARE_CLASS_FUNC
// Returns the HandleType of a Vk Handle.
......@@ -115,6 +119,11 @@ struct HandleTypeHelper;
};
ANGLE_HANDLE_TYPES_X(ANGLE_HANDLE_TYPE_HELPER_FUNC)
template <>
struct HandleTypeHelper<priv::CommandBuffer>
{
constexpr static HandleType kHandleType = HandleType::CommandBuffer;
};
#undef ANGLE_HANDLE_TYPE_HELPER_FUNC
......@@ -142,6 +151,9 @@ class Pipeline final : public WrappedObject<Pipeline, VkPipeline>
const PipelineCache &pipelineCacheVk);
};
namespace priv
{
// Helper class that wraps a Vulkan command buffer.
class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
{
......@@ -293,6 +305,8 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
void setScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors);
};
} // namespace priv
class Image final : public WrappedObject<Image, VkImage>
{
public:
......@@ -518,6 +532,9 @@ ANGLE_INLINE VkResult CommandPool::init(VkDevice device, const VkCommandPoolCrea
return vkCreateCommandPool(device, &createInfo, nullptr, &mHandle);
}
namespace priv
{
// CommandBuffer implementation.
ANGLE_INLINE VkCommandBuffer CommandBuffer::releaseHandle()
{
......@@ -715,7 +732,7 @@ ANGLE_INLINE void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoin
}
ANGLE_INLINE void CommandBuffer::executeCommands(uint32_t commandBufferCount,
const vk::CommandBuffer *commandBuffers)
const CommandBuffer *commandBuffers)
{
ASSERT(valid());
vkCmdExecuteCommands(mHandle, commandBufferCount, commandBuffers[0].ptr());
......@@ -896,6 +913,8 @@ ANGLE_INLINE void CommandBuffer::bindVertexBuffers(uint32_t firstBinding,
vkCmdBindVertexBuffers(mHandle, firstBinding, bindingCount, buffers, offsets);
}
} // namespace priv
// Image implementation.
ANGLE_INLINE void Image::setHandle(VkImage handle)
{
......
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