anv: Support render to aspect other than IMAGE_ASPECT_COLOR_BIT
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

On ANV the vkCmdBeginRendering function was hard coded to use
VK_IMAGE_ASPECT_COLOR_BIT for all color attachments, instead of using
the aspect bit specified when the vkImageView was initialized, which
made it impossible for applications to render to views of multi-planar
formats like VK_FORMAT_G8_B8R8_2PLANE_420_UNORM correctly.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13221
Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35340>
This commit is contained in:
Calder Young 2025-05-31 20:30:53 -07:00 committed by Marge Bot
parent 297fdc6636
commit 57c5419bbd

View file

@ -5434,7 +5434,7 @@ void genX(CmdBeginRendering)(
enum isl_aux_usage aux_usage =
anv_layout_to_aux_usage(cmd_buffer->device->info,
iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
att->imageLayout,
cmd_buffer->queue_family->queueFlags);
@ -5476,7 +5476,7 @@ void genX(CmdBeginRendering)(
if (is_multiview) {
u_foreach_bit(view, gfx->view_mask) {
transition_color_buffer(cmd_buffer, iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
iview->vk.base_mip_level, 1,
iview->vk.base_array_layer + view,
1, /* layer_count */
@ -5488,7 +5488,7 @@ void genX(CmdBeginRendering)(
}
} else {
transition_color_buffer(cmd_buffer, iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
iview->vk.base_mip_level, 1,
iview->vk.base_array_layer,
gfx->layer_count,
@ -5511,7 +5511,7 @@ void genX(CmdBeginRendering)(
anv_image_ccs_op(cmd_buffer, iview->image,
iview->planes[0].isl.format,
iview->planes[0].isl.swizzle,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
0, 0, 1, ISL_AUX_OP_FAST_CLEAR,
&fast_clear_color,
false);
@ -5519,7 +5519,7 @@ void genX(CmdBeginRendering)(
anv_image_mcs_op(cmd_buffer, iview->image,
iview->planes[0].isl.format,
iview->planes[0].isl.swizzle,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
0, 1, ISL_AUX_OP_FAST_CLEAR,
&fast_clear_color,
false);
@ -5538,7 +5538,7 @@ void genX(CmdBeginRendering)(
if (is_multiview) {
u_foreach_bit(view, clear_view_mask) {
anv_image_clear_color(cmd_buffer, iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
aux_usage,
iview->planes[0].isl.format,
iview->planes[0].isl.swizzle,
@ -5548,7 +5548,7 @@ void genX(CmdBeginRendering)(
}
} else if (clear_rect.layerCount > 0) {
anv_image_clear_color(cmd_buffer, iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
aux_usage,
iview->planes[0].isl.format,
iview->planes[0].isl.swizzle,
@ -5573,7 +5573,7 @@ void genX(CmdBeginRendering)(
anv_image_fill_surface_state(cmd_buffer->device,
iview->image,
VK_IMAGE_ASPECT_COLOR_BIT,
iview->vk.aspects,
&isl_view,
ISL_SURF_USAGE_RENDER_TARGET_BIT,
aux_usage, &fast_clear_color,
@ -5876,6 +5876,9 @@ cmd_buffer_mark_attachment_written(struct anv_cmd_buffer *cmd_buffer,
if (iview == NULL)
return;
if (aspect == 0)
aspect = iview->vk.aspects;
if (gfx->view_mask == 0) {
genX(cmd_buffer_mark_image_written)(cmd_buffer, iview->image,
aspect, att->aux_usage,
@ -5912,8 +5915,7 @@ void genX(CmdEndRendering)(
is_multiview ? util_last_bit(gfx->view_mask) : gfx->layer_count;
for (uint32_t i = 0; i < gfx->color_att_count; i++) {
cmd_buffer_mark_attachment_written(cmd_buffer, &gfx->color_att[i],
VK_IMAGE_ASPECT_COLOR_BIT);
cmd_buffer_mark_attachment_written(cmd_buffer, &gfx->color_att[i], 0);
}
cmd_buffer_mark_attachment_written(cmd_buffer, &gfx->depth_att,