vulkan/render_pass: Always use separate depth/stencil layouts

There are no Vulkan drivers in Mesa that don't support this feature and
it's a hard requirement for Vulkan 1.2 so there's no reason why we
shouldn't also require it for the runtime render pass code.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40154>
This commit is contained in:
Faith Ekstrand 2025-12-08 21:38:09 -05:00 committed by Marge Bot
parent 7343aff8aa
commit 3abdee9ec7

View file

@ -356,6 +356,25 @@ vk_render_pass_attachment_init(struct vk_render_pass_attachment *att,
.has_external_format =
vk_android_rp_attachment_has_external_format(desc),
};
/* We require separate stencil layouts */
if (att->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
att->initial_layout = vk_image_layout_depth_only(att->initial_layout);
att->final_layout = vk_image_layout_depth_only(att->final_layout);
} else if (att->aspects == VK_IMAGE_ASPECT_STENCIL_BIT) {
att->initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
att->final_layout = VK_IMAGE_LAYOUT_UNDEFINED;
}
if (att->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
att->initial_stencil_layout =
vk_image_layout_stencil_only(att->initial_stencil_layout);
att->final_stencil_layout =
vk_image_layout_stencil_only(att->final_stencil_layout);
} else {
assert(att->initial_stencil_layout == VK_IMAGE_LAYOUT_UNDEFINED);
assert(att->final_stencil_layout == VK_IMAGE_LAYOUT_UNDEFINED);
}
}
static void
@ -385,6 +404,17 @@ vk_subpass_attachment_init(struct vk_subpass_attachment *att,
.stencil_layout = vk_att_ref_stencil_layout(ref, attachments),
};
/* We require separate stencil layouts */
if (att->aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
att->layout = vk_image_layout_depth_only(att->layout);
else if (att->aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
att->layout = VK_IMAGE_LAYOUT_UNDEFINED;
if (att->aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
att->stencil_layout = vk_image_layout_stencil_only(att->stencil_layout);
else
assert(att->stencil_layout == VK_IMAGE_LAYOUT_UNDEFINED);
switch (usage) {
case VK_IMAGE_USAGE_TRANSFER_DST_BIT:
break; /* No special aspect requirements */