Commit a08495d9 by Courtney Goeltzenleuchter Committed by Commit Bot

Revert "Vulkan: restore mContentDefined at endRP()"

This reverts commit 53ee431e. Bug: chromium:1122621 Change-Id: Ifd63aa0694e00ed6ef74b385466b874604355e79 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2380610Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent 44df3fa9
......@@ -2489,8 +2489,8 @@ void ContextVk::optimizeRenderPassForPresent(VkFramebuffer framebufferHandle)
if (depthStencilRenderTarget)
{
// Change depthstencil attachment storeOp to DONT_CARE
mRenderPassCommands->invalidateRenderPassStencilAttachment(depthStencilRenderTarget);
mRenderPassCommands->invalidateRenderPassDepthAttachment(depthStencilRenderTarget);
mRenderPassCommands->invalidateRenderPassStencilAttachment();
mRenderPassCommands->invalidateRenderPassDepthAttachment();
// Mark content as invalid so that we will not load them in next renderpass
depthStencilRenderTarget->invalidateEntireContent();
}
......@@ -2908,6 +2908,12 @@ 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,6 +4908,12 @@ 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,14 +1456,12 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
{
if (invalidateDepthBuffer)
{
contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment(
depthStencilRenderTarget);
contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment();
}
if (invalidateStencilBuffer)
{
contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment(
depthStencilRenderTarget);
contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment();
}
}
if (invalidateColorBuffers.any())
......@@ -2364,6 +2362,18 @@ 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,6 +117,7 @@ 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,7 +565,6 @@ CommandBufferHelper::CommandBufferHelper()
mDepthInvalidatedState(NeverInvalidated),
mStencilEnabled(false),
mStencilInvalidatedState(NeverInvalidated),
mDepthStencilRenderTarget(nullptr),
mDepthStencilAttachmentIndex(kInvalidAttachmentIndex)
{}
......@@ -867,25 +866,12 @@ void CommandBufferHelper::endRenderPass(ContextVk *contextVk)
// Address invalidated depth/stencil attachments
if (mDepthInvalidatedState == Invalidated)
{
// The depth attachment is invalid, so don't store it
dsOps.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
}
if (mStencilInvalidatedState == Invalidated)
{
// The stencil attachment is invalid, so don't store it
dsOps.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
......@@ -1113,11 +1099,10 @@ void CommandBufferHelper::reset()
mRebindTransformFeedbackBuffers = false;
mDepthStartAccess = ResourceAccess::Unused;
mStencilStartAccess = ResourceAccess::Unused;
mDepthEnabled = false;
mDepthInvalidatedState = NeverInvalidated;
mStencilEnabled = false;
mDepthEnabled = false;
mStencilInvalidatedState = NeverInvalidated;
mDepthStencilRenderTarget = nullptr;
mStencilEnabled = false;
mDepthStencilAttachmentIndex = kInvalidAttachmentIndex;
mRenderPassUsedImages.clear();
}
......
......@@ -969,18 +969,29 @@ class CommandBufferHelper : angle::NonCopyable
SetBitField(mAttachmentOps[attachmentIndex].storeOp, VK_ATTACHMENT_STORE_OP_DONT_CARE);
}
void invalidateRenderPassDepthAttachment(RenderTargetVk *depthStencilRenderTarget)
void invalidateRenderPassDepthAttachment()
{
ASSERT(mIsRenderPassCommandBuffer);
mDepthInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget;
mDepthInvalidatedState = Invalidated;
}
void invalidateRenderPassStencilAttachment(RenderTargetVk *depthStencilRenderTarget)
void invalidateRenderPassStencilAttachment()
{
ASSERT(mIsRenderPassCommandBuffer);
mStencilInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget;
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;
}
void updateRenderPassAttachmentFinalLayout(size_t attachmentIndex, ImageLayout finalLayout)
......@@ -1074,8 +1085,6 @@ 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