@@ -309,7 +309,6 @@ FramebufferVk::FramebufferVk(RendererVk *renderer,
309309 mBackbuffer (backbuffer),
310310 mFramebuffer(nullptr ),
311311 mActiveColorComponents(0 ),
312- mReadOnlyDepthStencilMode(false ),
313312 mReadOnlyDepthFeedbackLoopMode(false )
314313{
315314 mReadPixelBuffer .init (renderer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, kReadPixelsBufferAlignment ,
@@ -1749,9 +1748,6 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
17491748 return angle::Result::Continue;
17501749 }
17511750
1752- // Default to writable depth on any Framebuffer change.
1753- mReadOnlyDepthStencilMode = false ;
1754-
17551751 // The FBO's new attachment may have changed the renderable area
17561752 const gl::State &glState = context->getState ();
17571753 ANGLE_TRY (contextVk->updateScissor (glState));
@@ -1819,12 +1815,9 @@ void FramebufferVk::updateRenderPassDesc()
18191815 RenderTargetVk *depthStencilRenderTarget = getDepthStencilRenderTarget ();
18201816 if (depthStencilRenderTarget)
18211817 {
1822- vk::ResourceAccess dsAccess =
1823- mReadOnlyDepthStencilMode ? vk::ResourceAccess::ReadOnly : vk::ResourceAccess::Write;
1824-
18251818 mRenderPassDesc .packDepthStencilAttachment (
18261819 depthStencilRenderTarget->getImageForRenderPass ().getFormat ().intendedFormatID ,
1827- dsAccess );
1820+ vk::ResourceAccess::Write );
18281821
18291822 // Add the resolve attachment, if any.
18301823 if (depthStencilRenderTarget->hasResolveAttachment ())
@@ -2154,7 +2147,7 @@ angle::Result FramebufferVk::clearWithLoadOp(ContextVk *contextVk,
21542147 clearValue.depthStencil = clearDepthStencilValue;
21552148 commands.updateRenderPassDepthStencilClear (dsAspectFlags, clearValue);
21562149 // If we were in depth read only mode, we must change to write mode
2157- ANGLE_TRY ( updateRenderPassReadOnlyDepthMode (contextVk, &commands) );
2150+ updateRenderPassReadOnlyDepthMode (contextVk, &commands);
21582151 }
21592152 }
21602153 else
@@ -2237,7 +2230,7 @@ angle::Result FramebufferVk::clearWithCommand(
22372230 attachments.emplace_back (VkClearAttachment{dsAspectFlags, 0 , dsClearValue});
22382231 // Because we may have changed the depth stencil access mode, update read only depth mode
22392232 // now.
2240- ANGLE_TRY ( updateRenderPassReadOnlyDepthMode (contextVk, renderpassCommands) );
2233+ updateRenderPassReadOnlyDepthMode (contextVk, renderpassCommands);
22412234 }
22422235
22432236 VkClearRect rect = {};
@@ -2260,7 +2253,6 @@ angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
22602253}
22612254
22622255angle::Result FramebufferVk::startNewRenderPass (ContextVk *contextVk,
2263- bool readOnlyDepthMode,
22642256 const gl::Rectangle &renderArea,
22652257 vk::CommandBuffer **commandBufferOut)
22662258{
@@ -2466,22 +2458,6 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
24662458 renderPassAttachmentOps.setOps (depthStencilAttachmentIndex, depthLoadOp, depthStoreOp);
24672459 renderPassAttachmentOps.setStencilOps (depthStencilAttachmentIndex, stencilLoadOp,
24682460 stencilStoreOp);
2469-
2470- // We can only start the renderpass in read only mode if it is requested to be read only and
2471- // we are not doing clear.
2472- bool depthStencilReadOnly =
2473- readOnlyDepthMode && !depthStencilRenderTarget->hasResolveAttachment () &&
2474- renderPassAttachmentOps[depthStencilAttachmentIndex].loadOp !=
2475- VK_ATTACHMENT_LOAD_OP_CLEAR &&
2476- renderPassAttachmentOps[depthStencilAttachmentIndex].stencilLoadOp !=
2477- VK_ATTACHMENT_LOAD_OP_CLEAR;
2478- setReadOnlyDepthMode (depthStencilReadOnly);
2479-
2480- vk::ImageLayout dsLayout = mReadOnlyDepthStencilMode
2481- ? vk::ImageLayout::DepthStencilReadOnly
2482- : vk::ImageLayout::DepthStencilAttachment;
2483-
2484- renderPassAttachmentOps.setLayouts (depthStencilAttachmentIndex, dsLayout, dsLayout);
24852461 }
24862462
24872463 // If render pass description is changed, the previous render pass desc is no longer compatible.
@@ -2524,7 +2500,8 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
25242500 // tracking content valid very loosely here that as long as it is attached, it assumes will
25252501 // have valid content. The only time it has undefined content is between swap and
25262502 // startNewRenderPass
2527- depthStencilRenderTarget->onDepthStencilDraw (contextVk, mReadOnlyDepthStencilMode );
2503+ // The actual layout determination will be deferred until endRenderPass time
2504+ depthStencilRenderTarget->onDepthStencilDraw (contextVk);
25282505 }
25292506
25302507 if (unresolveColorMask.any () || unresolveDepth || unresolveStencil)
@@ -2663,50 +2640,19 @@ angle::Result FramebufferVk::flushDeferredClears(ContextVk *contextVk,
26632640 return contextVk->startRenderPass (renderArea, nullptr );
26642641}
26652642
2666- void FramebufferVk::setReadOnlyDepthMode (bool readOnlyDepthEnabled)
2667- {
2668- if (mReadOnlyDepthStencilMode != readOnlyDepthEnabled)
2669- {
2670- mReadOnlyDepthStencilMode = readOnlyDepthEnabled;
2671-
2672- ASSERT (getDepthStencilRenderTarget ());
2673- vk::ResourceAccess dsAccess =
2674- isReadOnlyDepthMode () ? vk::ResourceAccess::ReadOnly : vk::ResourceAccess::Write;
2675- ASSERT (mRenderPassDesc .hasDepthStencilAttachment ());
2676- mRenderPassDesc .updateDepthStencilAccess (dsAccess);
2677- }
2678- }
2679-
2680- angle::Result FramebufferVk::updateRenderPassReadOnlyDepthMode (ContextVk *contextVk,
2681- vk::CommandBufferHelper *renderPass)
2643+ void FramebufferVk::updateRenderPassReadOnlyDepthMode (ContextVk *contextVk,
2644+ vk::CommandBufferHelper *renderPass)
26822645{
2683- ASSERT (getDepthStencilRenderTarget ());
2684-
2685- bool readOnlyDepthStencil =
2686- !getDepthStencilRenderTarget ()->hasResolveAttachment () &&
2646+ bool readOnlyDepthStencilMode =
2647+ getDepthStencilRenderTarget () && !getDepthStencilRenderTarget ()->hasResolveAttachment () &&
26872648 (mReadOnlyDepthFeedbackLoopMode || !renderPass->hasDepthStencilWriteOrClear ());
2688- if (readOnlyDepthStencil == mReadOnlyDepthStencilMode )
2689- {
2690- return angle::Result::Continue;
2691- }
26922649
26932650 // If readOnlyDepthStencil is false, we are switching out of read only mode due to depth write.
26942651 // We must not be in the read only feedback loop mode because the logic in
26952652 // ContextVk::updateRenderPassDepthStencilAccess() should ensure we end the previous renderpass
26962653 // and a new renderpass will start with feedback loop disabled.
2697- ASSERT (readOnlyDepthStencil || !mReadOnlyDepthFeedbackLoopMode );
2698-
2699- setReadOnlyDepthMode (readOnlyDepthStencil);
2700-
2701- // When we toggle read/write mode, we must insert a layout transition.
2702- getDepthStencilRenderTarget ()->onDepthStencilDraw (contextVk, readOnlyDepthStencil);
2654+ ASSERT (readOnlyDepthStencilMode || !mReadOnlyDepthFeedbackLoopMode );
27032655
2704- vk::Framebuffer *currentFramebuffer = nullptr ;
2705- ANGLE_TRY (getFramebuffer (contextVk, ¤tFramebuffer, nullptr ));
2706-
2707- renderPass->updateStartedRenderPassWithDepthMode (*currentFramebuffer, mRenderPassDesc ,
2708- readOnlyDepthStencil);
2709-
2710- return angle::Result::Continue;
2656+ renderPass->updateStartedRenderPassWithDepthMode (readOnlyDepthStencilMode);
27112657}
27122658} // namespace rx
0 commit comments