Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9a2f762

Browse files
committed
Fix attachment memory barrier
1 parent 81bd6c3 commit 9a2f762

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

impeller/renderer/backend/vulkan/render_pass_vk.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
196196
}
197197
}
198198

199-
if (auto depth = render_target_.GetDepthAttachment(); depth.has_value()) {
199+
auto depth = render_target_.GetDepthAttachment();
200+
if (depth.has_value()) {
200201
depth_stencil_ref = vk::AttachmentReference{
201202
static_cast<uint32_t>(attachments.size()),
202203
vk::ImageLayout::eDepthStencilAttachmentOptimal};
@@ -213,8 +214,14 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
213214
vk::ImageLayout::eDepthStencilAttachmentOptimal};
214215
attachments.emplace_back(CreateAttachmentDescription(
215216
stencil.value(), &Attachment::texture, supports_framebuffer_fetch));
216-
SetTextureLayout(stencil.value(), attachments.back(), command_buffer,
217-
&Attachment::texture);
217+
218+
// If the depth and stencil are stored in the same texture, then we've
219+
// already inserted a memory barrier to transition this texture as part of
220+
// the depth branch above.
221+
if (depth.has_value() && depth->texture != stencil->texture) {
222+
SetTextureLayout(stencil.value(), attachments.back(), command_buffer,
223+
&Attachment::texture);
224+
}
218225
}
219226

220227
vk::SubpassDescription subpass_desc;

0 commit comments

Comments
 (0)