Commit 040e4f6f by Tobin Ehlis Committed by Commit Bot

Vulkan: Minor command buffer refactor

Fix a couple minor nits with command buffer handling in ANGLE: 1. Make initialize() common CommandBufferHelper function 2. Reduce some common code when starting renderpass Bug: b/154030403 Change-Id: Ie9cfcd7c053c8605b16bc2dee7f8d69418922492 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2175106Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 10ee839c
...@@ -889,7 +889,7 @@ angle::Result ContextVk::initialize() ...@@ -889,7 +889,7 @@ angle::Result ContextVk::initialize()
// Push a scope in the pool allocator so we can easily reinitialize on flush. // Push a scope in the pool allocator so we can easily reinitialize on flush.
mPoolAllocator.push(); mPoolAllocator.push();
mOutsideRenderPassCommands.getCommandBuffer().initialize(&mPoolAllocator); mOutsideRenderPassCommands.initialize(&mPoolAllocator);
mRenderPassCommands.initialize(&mPoolAllocator); mRenderPassCommands.initialize(&mPoolAllocator);
ANGLE_TRY(startPrimaryCommandBuffer()); ANGLE_TRY(startPrimaryCommandBuffer());
...@@ -4489,6 +4489,11 @@ CommandBufferHelper::CommandBufferHelper() ...@@ -4489,6 +4489,11 @@ CommandBufferHelper::CommandBufferHelper()
CommandBufferHelper::~CommandBufferHelper() = default; CommandBufferHelper::~CommandBufferHelper() = default;
void CommandBufferHelper::initialize(angle::PoolAllocator *poolAllocator)
{
mCommandBuffer.initialize(poolAllocator);
}
void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList, void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList,
VkAccessFlags readAccessType, VkAccessFlags readAccessType,
VkPipelineStageFlags readStage, VkPipelineStageFlags readStage,
...@@ -4630,11 +4635,6 @@ RenderPassCommandBuffer::~RenderPassCommandBuffer() ...@@ -4630,11 +4635,6 @@ RenderPassCommandBuffer::~RenderPassCommandBuffer()
mFramebuffer.setHandle(VK_NULL_HANDLE); mFramebuffer.setHandle(VK_NULL_HANDLE);
} }
void RenderPassCommandBuffer::initialize(angle::PoolAllocator *poolAllocator)
{
mCommandBuffer.initialize(poolAllocator);
}
void RenderPassCommandBuffer::beginRenderPass(const vk::Framebuffer &framebuffer, void RenderPassCommandBuffer::beginRenderPass(const vk::Framebuffer &framebuffer,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const vk::RenderPassDesc &renderPassDesc, const vk::RenderPassDesc &renderPassDesc,
...@@ -4703,17 +4703,11 @@ angle::Result RenderPassCommandBuffer::flushToPrimary(ContextVk *contextVk, ...@@ -4703,17 +4703,11 @@ angle::Result RenderPassCommandBuffer::flushToPrimary(ContextVk *contextVk,
// Run commands inside the RenderPass. // Run commands inside the RenderPass.
primary->beginRenderPass(beginInfo, VK_SUBPASS_CONTENTS_INLINE); primary->beginRenderPass(beginInfo, VK_SUBPASS_CONTENTS_INLINE);
mCommandBuffer.executeCommands(primary->getHandle());
primary->endRenderPass();
if (mValidTransformFeedbackBufferCount == 0) if (mValidTransformFeedbackBufferCount != 0)
{ {
mCommandBuffer.executeCommands(primary->getHandle());
primary->endRenderPass();
}
else
{
mCommandBuffer.executeCommands(primary->getHandle());
primary->endRenderPass();
// Would be better to accumulate this barrier using the command APIs. // Would be better to accumulate this barrier using the command APIs.
// TODO: Clean thus up before we close http://anglebug.com/3206 // TODO: Clean thus up before we close http://anglebug.com/3206
VkBufferMemoryBarrier bufferBarrier = {}; VkBufferMemoryBarrier bufferBarrier = {};
......
...@@ -115,6 +115,8 @@ class CommandQueue final : angle::NonCopyable ...@@ -115,6 +115,8 @@ class CommandQueue final : angle::NonCopyable
struct CommandBufferHelper : angle::NonCopyable struct CommandBufferHelper : angle::NonCopyable
{ {
public: public:
void initialize(angle::PoolAllocator *poolAllocator);
void bufferRead(vk::ResourceUseList *resourceUseList, void bufferRead(vk::ResourceUseList *resourceUseList,
VkAccessFlags readAccessType, VkAccessFlags readAccessType,
VkPipelineStageFlags readStage, VkPipelineStageFlags readStage,
...@@ -174,8 +176,6 @@ class RenderPassCommandBuffer final : public CommandBufferHelper ...@@ -174,8 +176,6 @@ class RenderPassCommandBuffer final : public CommandBufferHelper
RenderPassCommandBuffer(); RenderPassCommandBuffer();
~RenderPassCommandBuffer(); ~RenderPassCommandBuffer();
void initialize(angle::PoolAllocator *poolAllocator);
void beginRenderPass(const vk::Framebuffer &framebuffer, void beginRenderPass(const vk::Framebuffer &framebuffer,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const vk::RenderPassDesc &renderPassDesc, const vk::RenderPassDesc &renderPassDesc,
......
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