Commit 38e7f7a6 by Charlie Lao Committed by Commit Bot

Vulkan: Make CommandBufferHelper::empty() logic less obtuse

CommandBufferHelper::empty() logic is simplified and commented to make it easier to read. Basically empty() means there is no work in the CommandBufferHelper object. For RenderpassCommands, that is equivalent to !started(). Bug: b/162521656 Change-Id: Ic9683b392835a677501cb81e5e8a025e031ebf93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2330379Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
parent aca14d47
...@@ -2671,7 +2671,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState) ...@@ -2671,7 +2671,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState)
// a render pass, the scissor is disabled and a draw call is issued to affect the whole // a render pass, the scissor is disabled and a draw call is issued to affect the whole
// framebuffer. // framebuffer.
gl::Rectangle scissoredRenderArea = framebufferVk->getRotatedScissoredRenderArea(this); gl::Rectangle scissoredRenderArea = framebufferVk->getRotatedScissoredRenderArea(this);
if (!mRenderPassCommands->empty()) if (mRenderPassCommands->started())
{ {
if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea)) if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea))
{ {
...@@ -3934,7 +3934,7 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context, ...@@ -3934,7 +3934,7 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context,
bool ContextVk::hasRecordedCommands() bool ContextVk::hasRecordedCommands()
{ {
ASSERT(mOutsideRenderPassCommands && mRenderPassCommands); ASSERT(mOutsideRenderPassCommands && mRenderPassCommands);
return !mOutsideRenderPassCommands->empty() || !mRenderPassCommands->empty() || return !mOutsideRenderPassCommands->empty() || mRenderPassCommands->started() ||
mHasPrimaryCommands; mHasPrimaryCommands;
} }
...@@ -4395,7 +4395,7 @@ angle::Result ContextVk::startRenderPass(gl::Rectangle renderArea, ...@@ -4395,7 +4395,7 @@ angle::Result ContextVk::startRenderPass(gl::Rectangle renderArea,
angle::Result ContextVk::endRenderPass() angle::Result ContextVk::endRenderPass()
{ {
if (mRenderPassCommands->empty()) if (!mRenderPassCommands->started())
{ {
onRenderPassFinished(); onRenderPassFinished();
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -528,7 +528,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -528,7 +528,7 @@ class ContextVk : public ContextImpl, public vk::Context
const vk::ClearValuesArray &clearValues, const vk::ClearValuesArray &clearValues,
vk::CommandBuffer **commandBufferOut); vk::CommandBuffer **commandBufferOut);
bool hasStartedRenderPass() const { return !mRenderPassCommands->empty(); } bool hasStartedRenderPass() const { return mRenderPassCommands->started(); }
vk::CommandBufferHelper &getStartedRenderPassCommands() vk::CommandBufferHelper &getStartedRenderPassCommands()
{ {
......
...@@ -877,12 +877,19 @@ struct CommandBufferHelper : angle::NonCopyable ...@@ -877,12 +877,19 @@ struct CommandBufferHelper : angle::NonCopyable
void executeBarriers(vk::PrimaryCommandBuffer *primary); void executeBarriers(vk::PrimaryCommandBuffer *primary);
bool empty() const { return (!mCommandBuffer.empty() || mRenderPassStarted) ? false : true; }
void setHasRenderPass(bool hasRenderPass) { mIsRenderPassCommandBuffer = hasRenderPass; } void setHasRenderPass(bool hasRenderPass) { mIsRenderPassCommandBuffer = hasRenderPass; }
void reset(); void reset();
void releaseToContextQueue(ContextVk *contextVk); void releaseToContextQueue(ContextVk *contextVk);
// RenderPass related functions // Returns true if we have no work to execute. For renderpass command buffer, even if the
// underlying command buffer is empty, we may still have a renderpass with an empty command
// buffer just to do the clear.
bool empty() const
{
return mIsRenderPassCommandBuffer ? !mRenderPassStarted : mCommandBuffer.empty();
}
// RenderPass related functions. This is equivalent to !empty(), but only when you know this is
// a RenderPass command buffer
bool started() const bool started() const
{ {
ASSERT(mIsRenderPassCommandBuffer); ASSERT(mIsRenderPassCommandBuffer);
......
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