Commit 53ee431e by Ian Elliott Committed by Commit Bot

Vulkan: restore mContentDefined at endRP()

CommandBufferHelper will keep a pointer to the depth-stencil RenderTargetVk, and use this to set RenderTargetVk::mContentDefined to true at the end of a render pass. Test: angle_white_box_tests --gtest_filter=VulkanPerformanceCounterTest.InvalidatingAndUsingDepthDoesNotBreakRenderPass/* Test: angle_deqp_gles3_tests --gtest_filter=dEQP.GLES3/functional_fbo_invalidate_* --use-angle=vulkan Bug: b/163854287 Change-Id: I891381825ee01e141dfa4f9099d07d9ffc943f77 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2368194Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent 295d2ccd
......@@ -2485,8 +2485,8 @@ void ContextVk::optimizeRenderPassForPresent(VkFramebuffer framebufferHandle)
if (depthStencilRenderTarget)
{
// Change depthstencil attachment storeOp to DONT_CARE
mRenderPassCommands->invalidateRenderPassStencilAttachment();
mRenderPassCommands->invalidateRenderPassDepthAttachment();
mRenderPassCommands->invalidateRenderPassStencilAttachment(depthStencilRenderTarget);
mRenderPassCommands->invalidateRenderPassDepthAttachment(depthStencilRenderTarget);
// Mark content as invalid so that we will not load them in next renderpass
depthStencilRenderTarget->invalidateEntireContent();
}
......@@ -2904,12 +2904,6 @@ angle::Result ContextVk::syncState(const gl::Context *context,
{
vk::ResourceAccess access = GetStencilAccess(mState.getDepthStencilState());
mRenderPassCommands->onStencilAccess(access);
// Did this depth-state change undo a previous invalidation of the depth-stencil
// attachment?
if (mRenderPassCommands->shouldRestoreDepthStencilAttachment())
{
mDrawFramebuffer->restoreDepthStencilDefinedContents();
}
}
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
......@@ -4902,12 +4896,6 @@ angle::Result ContextVk::updateRenderPassDepthAccess()
else
{
mRenderPassCommands->onDepthAccess(access);
// Did this depth-state change undo a previous invalidation of the depth-stencil
// attachment?
if (mRenderPassCommands->shouldRestoreDepthStencilAttachment())
{
mDrawFramebuffer->restoreDepthStencilDefinedContents();
}
}
}
......
......@@ -1456,12 +1456,14 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
{
if (invalidateDepthBuffer)
{
contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment();
contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment(
depthStencilRenderTarget);
}
if (invalidateStencilBuffer)
{
contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment();
contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment(
depthStencilRenderTarget);
}
}
if (invalidateColorBuffers.any())
......@@ -2362,18 +2364,6 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
return angle::Result::Continue;
}
void FramebufferVk::restoreDepthStencilDefinedContents()
{
// If the depthStencilRenderTarget does not have "defined content" (i.e. meaning that a future
// render pass should use a loadOp of DONT_CARE), we should restore it (i.e. so that a future
// render pass uses a loadOp of LOAD).
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
if (depthStencilRenderTarget)
{
depthStencilRenderTarget->restoreEntireContent();
}
}
void FramebufferVk::updateActiveColorMasks(size_t colorIndexGL, bool r, bool g, bool b, bool a)
{
mActiveColorComponentMasksForClear[0].set(colorIndexGL, r);
......
......@@ -117,7 +117,6 @@ class FramebufferVk : public FramebufferImpl
angle::Result startNewRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut);
void restoreDepthStencilDefinedContents();
RenderTargetVk *getFirstRenderTarget() const;
GLint getSamples() const;
......
......@@ -565,6 +565,7 @@ CommandBufferHelper::CommandBufferHelper()
mDepthInvalidatedState(NeverInvalidated),
mStencilEnabled(false),
mStencilInvalidatedState(NeverInvalidated),
mDepthStencilRenderTarget(nullptr),
mDepthStencilAttachmentIndex(kInvalidAttachmentIndex)
{}
......@@ -879,13 +880,26 @@ void CommandBufferHelper::endRenderPass()
// Address invalidated depth/stencil attachments
if (mDepthInvalidatedState == Invalidated && !mDepthEnabled)
{
// The depth attachment is invalid, so don't store it
mAttachmentOps[mDepthStencilAttachmentIndex].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
}
if (mStencilInvalidatedState == Invalidated && !mStencilEnabled)
{
// The stencil attachment is invalid, so don't store it
mAttachmentOps[mDepthStencilAttachmentIndex].stencilStoreOp =
VK_ATTACHMENT_STORE_OP_DONT_CARE;
}
if (mDepthInvalidatedState == NoLongerInvalidated ||
mStencilInvalidatedState == NoLongerInvalidated)
{
// The depth and stencil attachment were both invalidated, but at least one of them is now
// valid. When they were invalidated, RenderTargetVk::mContentDefined was set to false,
// which tells a future render pass to use DONT_CARE for the loadOp and stencilLoadOp.
// Since at least one of the attachments is now valid, tell RenderTargetVk that LOAD should
// be used.
ASSERT(mDepthStencilRenderTarget);
mDepthStencilRenderTarget->restoreEntireContent();
}
// Depth/Stencil buffer optimization: if we are loading or clearing the buffer, but the
// buffer has not been used, and the data has also not been stored back into buffer, then
......@@ -1105,10 +1119,11 @@ void CommandBufferHelper::reset()
mRebindTransformFeedbackBuffers = false;
mDepthStartAccess = ResourceAccess::Unused;
mStencilStartAccess = ResourceAccess::Unused;
mDepthInvalidatedState = NeverInvalidated;
mDepthEnabled = false;
mStencilInvalidatedState = NeverInvalidated;
mDepthInvalidatedState = NeverInvalidated;
mStencilEnabled = false;
mStencilInvalidatedState = NeverInvalidated;
mDepthStencilRenderTarget = nullptr;
mDepthStencilAttachmentIndex = kInvalidAttachmentIndex;
mRenderPassUsedImages.clear();
}
......
......@@ -969,29 +969,18 @@ class CommandBufferHelper : angle::NonCopyable
SetBitField(mAttachmentOps[attachmentIndex].storeOp, VK_ATTACHMENT_STORE_OP_DONT_CARE);
}
void invalidateRenderPassDepthAttachment()
void invalidateRenderPassDepthAttachment(RenderTargetVk *depthStencilRenderTarget)
{
ASSERT(mIsRenderPassCommandBuffer);
mDepthInvalidatedState = Invalidated;
mDepthInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget;
}
void invalidateRenderPassStencilAttachment()
void invalidateRenderPassStencilAttachment(RenderTargetVk *depthStencilRenderTarget)
{
ASSERT(mIsRenderPassCommandBuffer);
mStencilInvalidatedState = Invalidated;
}
bool shouldRestoreDepthStencilAttachment()
{
ASSERT(mIsRenderPassCommandBuffer);
// Return true when both depth and stencil attachments were previously-invalidated, and at
// least one of those attachments are no longer invalidated. When invalidated,
// RenderTargetVk::mContentDefined is set to false, which will result in the loadOp and
// stencilLoadOp of a future render pass being set to DONT_CARE. ContextVk::syncState()
// will call this method to determine if RenderTargetVk::mContentDefined should be set back
// to true (i.e. use LOAD).
return mDepthInvalidatedState == NoLongerInvalidated ||
mStencilInvalidatedState == NoLongerInvalidated;
mStencilInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget;
}
void updateRenderPassAttachmentFinalLayout(size_t attachmentIndex, ImageLayout finalLayout)
......@@ -1079,6 +1068,8 @@ class CommandBufferHelper : angle::NonCopyable
InvalidatedState mDepthInvalidatedState;
bool mStencilEnabled;
InvalidatedState mStencilInvalidatedState;
// Used the update RenderTargetVk::mContentDefined at the end of the render pass
RenderTargetVk *mDepthStencilRenderTarget;
// Keep track of the depth/stencil attachment index
uint32_t mDepthStencilAttachmentIndex;
......
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