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

Commit c1d8935

Browse files
committed
Fix attachment memory barrier
1 parent 5d72b38 commit c1d8935

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

impeller/renderer/backend/vulkan/render_pass_vk.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
145145
}
146146
}
147147

148-
if (auto depth = render_target_.GetDepthAttachment(); depth.has_value()) {
148+
auto depth = render_target_.GetDepthAttachment();
149+
if (depth.has_value()) {
149150
depth_stencil_ref = vk::AttachmentReference{
150151
static_cast<uint32_t>(attachments.size()),
151152
vk::ImageLayout::eDepthStencilAttachmentOptimal};
@@ -162,8 +163,13 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
162163
vk::ImageLayout::eDepthStencilAttachmentOptimal};
163164
attachments.emplace_back(CreateAttachmentDescription(
164165
stencil.value(), &Attachment::texture, supports_framebuffer_fetch));
165-
SetTextureLayout(stencil.value(), attachments.back(), command_buffer,
166-
&Attachment::texture);
166+
167+
// If the depth and stencil are stored in the same texture, we need to make
168+
// sure we don't transition the layout twice.
169+
if (depth.has_value() && depth->texture != stencil->texture) {
170+
SetTextureLayout(stencil.value(), attachments.back(), command_buffer,
171+
&Attachment::texture);
172+
}
167173
}
168174

169175
vk::SubpassDescription subpass_desc;

0 commit comments

Comments
 (0)