Commit 1a4f6e1f by Tobin Ehlis Committed by Commit Bot

Vulkan:Migrate command buffers to pointers

This is an intermediate CL as we move to a worker thread. With the worker thread there will be a pool of more than 2 command buffers so the current command buffers in use on the main thread will be pointers that are assigned from that pool. This CL isolates the command buffers as pointers to make review simpler. Bug: b/154030730 Change-Id: I3fc91222b07d5f3bf60f92a4c01b0910daad7df6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2207812 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 6c4af0c3
......@@ -477,9 +477,9 @@ class ContextVk : public ContextImpl, public vk::Context
angle::Result endRenderPassAndGetCommandBuffer(vk::CommandBuffer **commandBufferOut)
{
// Only one command buffer should be active at a time
ASSERT(mOutsideRenderPassCommands.empty() || mRenderPassCommands.empty());
ASSERT(mOutsideRenderPassCommands->empty() || mRenderPassCommands->empty());
ANGLE_TRY(endRenderPass());
*commandBufferOut = &mOutsideRenderPassCommands.getCommandBuffer();
*commandBufferOut = &mOutsideRenderPassCommands->getCommandBuffer();
return angle::Result::Continue;
}
......@@ -490,12 +490,12 @@ class ContextVk : public ContextImpl, public vk::Context
const vk::ClearValuesArray &clearValues,
vk::CommandBuffer **commandBufferOut);
bool hasStartedRenderPass() const { return !mRenderPassCommands.empty(); }
bool hasStartedRenderPass() const { return !mRenderPassCommands->empty(); }
vk::CommandBufferHelper &getStartedRenderPassCommands()
{
ASSERT(hasStartedRenderPass());
return mRenderPassCommands;
return *mRenderPassCommands;
}
egl::ContextPriority getContextPriority() const override { return mContextPriority; }
......@@ -909,8 +909,14 @@ class ContextVk : public ContextImpl, public vk::Context
// When the command graph is disabled we record commands completely linearly. We have plans to
// reorder independent draws so that we can create fewer RenderPasses in some scenarios.
vk::CommandBufferHelper mOutsideRenderPassCommands;
vk::CommandBufferHelper mRenderPassCommands;
// Currently we just point the inside/outside RenderPass command buffers to respective fixed
// command buffers in the mCommandBuffers array. In the near future when we move to a worker
// thread there will a larger pool of command buffers and command buffer pointers will be
// assigned from a queue based on availability.
constexpr static size_t kNumCommandBuffers = 2;
std::array<vk::CommandBufferHelper, kNumCommandBuffers> mCommandBuffers;
vk::CommandBufferHelper *mOutsideRenderPassCommands;
vk::CommandBufferHelper *mRenderPassCommands;
vk::PrimaryCommandBuffer mPrimaryCommands;
bool mHasPrimaryCommands;
......
......@@ -511,7 +511,7 @@ VkImageLayout ConvertImageLayoutToVkImageLayout(ImageLayout imageLayout)
}
// CommandBufferHelper implementation.
CommandBufferHelper::CommandBufferHelper(bool hasRenderPass, bool mergeBarriers)
CommandBufferHelper::CommandBufferHelper()
: mPipelineBarriers(),
mPipelineBarrierMask(),
mCounter(0),
......@@ -520,8 +520,8 @@ CommandBufferHelper::CommandBufferHelper(bool hasRenderPass, bool mergeBarriers)
mTransformFeedbackCounterBuffers{},
mValidTransformFeedbackBufferCount(0),
mRebindTransformFeedbackBuffers(false),
mIsRenderPassCommandBuffer(hasRenderPass),
mMergeBarriers(mergeBarriers)
mIsRenderPassCommandBuffer(false),
mMergeBarriers(false)
{}
CommandBufferHelper::~CommandBufferHelper()
......@@ -529,9 +529,13 @@ CommandBufferHelper::~CommandBufferHelper()
mFramebuffer.setHandle(VK_NULL_HANDLE);
}
void CommandBufferHelper::initialize(angle::PoolAllocator *poolAllocator)
void CommandBufferHelper::initialize(angle::PoolAllocator *poolAllocator,
bool isRenderPassCommandBuffer,
bool mergeBarriers)
{
mCommandBuffer.initialize(poolAllocator);
mIsRenderPassCommandBuffer = isRenderPassCommandBuffer;
mMergeBarriers = mergeBarriers;
}
void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList,
......
......@@ -824,11 +824,13 @@ class BufferHelper final : public Resource
struct CommandBufferHelper : angle::NonCopyable
{
public:
CommandBufferHelper(bool canHaveRenderPass, bool mergeBarriers);
CommandBufferHelper();
~CommandBufferHelper();
// General Functions (non-renderPass specific)
void initialize(angle::PoolAllocator *poolAllocator);
void initialize(angle::PoolAllocator *poolAllocator,
bool canHaveRenderPass,
bool mergeBarriers);
void bufferRead(vk::ResourceUseList *resourceUseList,
VkAccessFlags readAccessType,
......@@ -950,8 +952,8 @@ struct CommandBufferHelper : angle::NonCopyable
uint32_t mValidTransformFeedbackBufferCount;
bool mRebindTransformFeedbackBuffers;
const bool mIsRenderPassCommandBuffer;
const bool mMergeBarriers;
bool mIsRenderPassCommandBuffer;
bool mMergeBarriers;
};
// Imagine an image going through a few layout transitions:
......
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