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) ...@@ -2489,8 +2489,8 @@ void ContextVk::optimizeRenderPassForPresent(VkFramebuffer framebufferHandle)
if (depthStencilRenderTarget) if (depthStencilRenderTarget)
{ {
// Change depthstencil attachment storeOp to DONT_CARE // Change depthstencil attachment storeOp to DONT_CARE
mRenderPassCommands->invalidateRenderPassStencilAttachment(depthStencilRenderTarget); mRenderPassCommands->invalidateRenderPassStencilAttachment();
mRenderPassCommands->invalidateRenderPassDepthAttachment(depthStencilRenderTarget); mRenderPassCommands->invalidateRenderPassDepthAttachment();
// Mark content as invalid so that we will not load them in next renderpass // Mark content as invalid so that we will not load them in next renderpass
depthStencilRenderTarget->invalidateEntireContent(); depthStencilRenderTarget->invalidateEntireContent();
} }
...@@ -2908,6 +2908,12 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2908,6 +2908,12 @@ angle::Result ContextVk::syncState(const gl::Context *context,
{ {
vk::ResourceAccess access = GetStencilAccess(mState.getDepthStencilState()); vk::ResourceAccess access = GetStencilAccess(mState.getDepthStencilState());
mRenderPassCommands->onStencilAccess(access); mRenderPassCommands->onStencilAccess(access);
// Did this depth-state change undo a previous invalidation of the depth-stencil
// attachment?
if (mRenderPassCommands->shouldRestoreDepthStencilAttachment())
{
mDrawFramebuffer->restoreDepthStencilDefinedContents();
}
} }
break; break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT: case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
...@@ -4902,6 +4908,12 @@ angle::Result ContextVk::updateRenderPassDepthAccess() ...@@ -4902,6 +4908,12 @@ angle::Result ContextVk::updateRenderPassDepthAccess()
else else
{ {
mRenderPassCommands->onDepthAccess(access); 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, ...@@ -1456,14 +1456,12 @@ angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
{ {
if (invalidateDepthBuffer) if (invalidateDepthBuffer)
{ {
contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment( contextVk->getStartedRenderPassCommands().invalidateRenderPassDepthAttachment();
depthStencilRenderTarget);
} }
if (invalidateStencilBuffer) if (invalidateStencilBuffer)
{ {
contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment( contextVk->getStartedRenderPassCommands().invalidateRenderPassStencilAttachment();
depthStencilRenderTarget);
} }
} }
if (invalidateColorBuffers.any()) if (invalidateColorBuffers.any())
...@@ -2364,6 +2362,18 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -2364,6 +2362,18 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
return angle::Result::Continue; 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) void FramebufferVk::updateActiveColorMasks(size_t colorIndexGL, bool r, bool g, bool b, bool a)
{ {
mActiveColorComponentMasksForClear[0].set(colorIndexGL, r); mActiveColorComponentMasksForClear[0].set(colorIndexGL, r);
......
...@@ -117,6 +117,7 @@ class FramebufferVk : public FramebufferImpl ...@@ -117,6 +117,7 @@ class FramebufferVk : public FramebufferImpl
angle::Result startNewRenderPass(ContextVk *contextVk, angle::Result startNewRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut); vk::CommandBuffer **commandBufferOut);
void restoreDepthStencilDefinedContents();
RenderTargetVk *getFirstRenderTarget() const; RenderTargetVk *getFirstRenderTarget() const;
GLint getSamples() const; GLint getSamples() const;
......
...@@ -565,7 +565,6 @@ CommandBufferHelper::CommandBufferHelper() ...@@ -565,7 +565,6 @@ CommandBufferHelper::CommandBufferHelper()
mDepthInvalidatedState(NeverInvalidated), mDepthInvalidatedState(NeverInvalidated),
mStencilEnabled(false), mStencilEnabled(false),
mStencilInvalidatedState(NeverInvalidated), mStencilInvalidatedState(NeverInvalidated),
mDepthStencilRenderTarget(nullptr),
mDepthStencilAttachmentIndex(kInvalidAttachmentIndex) mDepthStencilAttachmentIndex(kInvalidAttachmentIndex)
{} {}
...@@ -867,25 +866,12 @@ void CommandBufferHelper::endRenderPass(ContextVk *contextVk) ...@@ -867,25 +866,12 @@ void CommandBufferHelper::endRenderPass(ContextVk *contextVk)
// Address invalidated depth/stencil attachments // Address invalidated depth/stencil attachments
if (mDepthInvalidatedState == Invalidated) if (mDepthInvalidatedState == Invalidated)
{ {
// The depth attachment is invalid, so don't store it
dsOps.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; dsOps.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
} }
if (mStencilInvalidatedState == Invalidated) if (mStencilInvalidatedState == Invalidated)
{ {
// The stencil attachment is invalid, so don't store it
dsOps.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; 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 // 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 // buffer has not been used, and the data has also not been stored back into buffer, then
...@@ -1113,11 +1099,10 @@ void CommandBufferHelper::reset() ...@@ -1113,11 +1099,10 @@ void CommandBufferHelper::reset()
mRebindTransformFeedbackBuffers = false; mRebindTransformFeedbackBuffers = false;
mDepthStartAccess = ResourceAccess::Unused; mDepthStartAccess = ResourceAccess::Unused;
mStencilStartAccess = ResourceAccess::Unused; mStencilStartAccess = ResourceAccess::Unused;
mDepthEnabled = false;
mDepthInvalidatedState = NeverInvalidated; mDepthInvalidatedState = NeverInvalidated;
mStencilEnabled = false; mDepthEnabled = false;
mStencilInvalidatedState = NeverInvalidated; mStencilInvalidatedState = NeverInvalidated;
mDepthStencilRenderTarget = nullptr; mStencilEnabled = false;
mDepthStencilAttachmentIndex = kInvalidAttachmentIndex; mDepthStencilAttachmentIndex = kInvalidAttachmentIndex;
mRenderPassUsedImages.clear(); mRenderPassUsedImages.clear();
} }
......
...@@ -969,18 +969,29 @@ class CommandBufferHelper : angle::NonCopyable ...@@ -969,18 +969,29 @@ class CommandBufferHelper : angle::NonCopyable
SetBitField(mAttachmentOps[attachmentIndex].storeOp, VK_ATTACHMENT_STORE_OP_DONT_CARE); SetBitField(mAttachmentOps[attachmentIndex].storeOp, VK_ATTACHMENT_STORE_OP_DONT_CARE);
} }
void invalidateRenderPassDepthAttachment(RenderTargetVk *depthStencilRenderTarget) void invalidateRenderPassDepthAttachment()
{ {
ASSERT(mIsRenderPassCommandBuffer); ASSERT(mIsRenderPassCommandBuffer);
mDepthInvalidatedState = Invalidated; mDepthInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget;
} }
void invalidateRenderPassStencilAttachment(RenderTargetVk *depthStencilRenderTarget) void invalidateRenderPassStencilAttachment()
{ {
ASSERT(mIsRenderPassCommandBuffer); ASSERT(mIsRenderPassCommandBuffer);
mStencilInvalidatedState = Invalidated; mStencilInvalidatedState = Invalidated;
mDepthStencilRenderTarget = depthStencilRenderTarget; }
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) void updateRenderPassAttachmentFinalLayout(size_t attachmentIndex, ImageLayout finalLayout)
...@@ -1074,8 +1085,6 @@ class CommandBufferHelper : angle::NonCopyable ...@@ -1074,8 +1085,6 @@ class CommandBufferHelper : angle::NonCopyable
InvalidatedState mDepthInvalidatedState; InvalidatedState mDepthInvalidatedState;
bool mStencilEnabled; bool mStencilEnabled;
InvalidatedState mStencilInvalidatedState; InvalidatedState mStencilInvalidatedState;
// Used the update RenderTargetVk::mContentDefined at the end of the render pass
RenderTargetVk *mDepthStencilRenderTarget;
// Keep track of the depth/stencil attachment index // Keep track of the depth/stencil attachment index
uint32_t mDepthStencilAttachmentIndex; 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