Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 040e4f6

Browse files
tobineCommit Bot
authored andcommitted
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/+/2175106 Reviewed-by: Jamie Madill <[email protected]> Reviewed-by: Charlie Lao <[email protected]> Commit-Queue: Tobin Ehlis <[email protected]>
1 parent 10ee839 commit 040e4f6

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

src/libANGLE/renderer/vulkan/ContextVk.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ angle::Result ContextVk::initialize()
889889

890890
// Push a scope in the pool allocator so we can easily reinitialize on flush.
891891
mPoolAllocator.push();
892-
mOutsideRenderPassCommands.getCommandBuffer().initialize(&mPoolAllocator);
892+
mOutsideRenderPassCommands.initialize(&mPoolAllocator);
893893
mRenderPassCommands.initialize(&mPoolAllocator);
894894
ANGLE_TRY(startPrimaryCommandBuffer());
895895

@@ -4489,6 +4489,11 @@ CommandBufferHelper::CommandBufferHelper()
44894489

44904490
CommandBufferHelper::~CommandBufferHelper() = default;
44914491

4492+
void CommandBufferHelper::initialize(angle::PoolAllocator *poolAllocator)
4493+
{
4494+
mCommandBuffer.initialize(poolAllocator);
4495+
}
4496+
44924497
void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList,
44934498
VkAccessFlags readAccessType,
44944499
VkPipelineStageFlags readStage,
@@ -4630,11 +4635,6 @@ RenderPassCommandBuffer::~RenderPassCommandBuffer()
46304635
mFramebuffer.setHandle(VK_NULL_HANDLE);
46314636
}
46324637

4633-
void RenderPassCommandBuffer::initialize(angle::PoolAllocator *poolAllocator)
4634-
{
4635-
mCommandBuffer.initialize(poolAllocator);
4636-
}
4637-
46384638
void RenderPassCommandBuffer::beginRenderPass(const vk::Framebuffer &framebuffer,
46394639
const gl::Rectangle &renderArea,
46404640
const vk::RenderPassDesc &renderPassDesc,
@@ -4703,17 +4703,11 @@ angle::Result RenderPassCommandBuffer::flushToPrimary(ContextVk *contextVk,
47034703

47044704
// Run commands inside the RenderPass.
47054705
primary->beginRenderPass(beginInfo, VK_SUBPASS_CONTENTS_INLINE);
4706+
mCommandBuffer.executeCommands(primary->getHandle());
4707+
primary->endRenderPass();
47064708

4707-
if (mValidTransformFeedbackBufferCount == 0)
4709+
if (mValidTransformFeedbackBufferCount != 0)
47084710
{
4709-
mCommandBuffer.executeCommands(primary->getHandle());
4710-
primary->endRenderPass();
4711-
}
4712-
else
4713-
{
4714-
mCommandBuffer.executeCommands(primary->getHandle());
4715-
primary->endRenderPass();
4716-
47174711
// Would be better to accumulate this barrier using the command APIs.
47184712
// TODO: Clean thus up before we close http://anglebug.com/3206
47194713
VkBufferMemoryBarrier bufferBarrier = {};

src/libANGLE/renderer/vulkan/ContextVk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class CommandQueue final : angle::NonCopyable
115115
struct CommandBufferHelper : angle::NonCopyable
116116
{
117117
public:
118+
void initialize(angle::PoolAllocator *poolAllocator);
119+
118120
void bufferRead(vk::ResourceUseList *resourceUseList,
119121
VkAccessFlags readAccessType,
120122
VkPipelineStageFlags readStage,
@@ -174,8 +176,6 @@ class RenderPassCommandBuffer final : public CommandBufferHelper
174176
RenderPassCommandBuffer();
175177
~RenderPassCommandBuffer();
176178

177-
void initialize(angle::PoolAllocator *poolAllocator);
178-
179179
void beginRenderPass(const vk::Framebuffer &framebuffer,
180180
const gl::Rectangle &renderArea,
181181
const vk::RenderPassDesc &renderPassDesc,

0 commit comments

Comments
 (0)