anv/image: Rework YCbCr image aspects
The Vulkan 1.2.184 spec says:
"When creating a VkImageView, if sampler Y′CBCR conversion is
enabled in the sampler, the aspectMask of a subresourceRange used by
the VkImageView must be VK_IMAGE_ASPECT_COLOR_BIT.
When creating a VkImageView, if sampler Y′CBCR conversion is not
enabled in the sampler and the image format is multi-planar, the
image must have been created with
VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, and the aspectMask of the
VkImageView’s subresourceRange must be VK_IMAGE_ASPECT_PLANE_0_BIT,
VK_IMAGE_ASPECT_PLANE_1_BIT or VK_IMAGE_ASPECT_PLANE_2_BIT."
Previously, for YCbCr images, we were flipping this around. For single-
plane views where VK_IMAGE_ASPECT_PLANE_N_BIT would be passed in by the
app, we would store VK_IMAGE_ASPECT_COLOR_BIT. For multi-plane views
where the client says VK_IMAGE_ASPECT_COLOR_BIT, we would store a all of
the planes. (There was also an extra bit of remapping that would
compact the planes in the non-existent case of a format with a non-
contiguous set of planes.) The idea behind this was that for things
like rendering or single-plane sampling, storage, or compute, we want it
to look as much like a single-plane image as possible but we wanted the
multi-plane case to be the awkward one.
This commit changes it around so that iview->aspects is always exactly
the subset of image->vk.aspects represented by the view. This is
identical to how aspects work for depth/stencil so it gains us some
consistency.
This commit also changes anv_image_view::aspect_mask to aspects to force
a full audit of the field. As can be seen, there are only a few uses of
this field and they're all mostly fine:
- A bunch of them are used to check for depth/stencil. That hasn't
changed.
- Most of the checks for color already used ANY_COLOR_BIT, only one
needed fixing.
- There's a check that both src/depth are color for MSAA resolves.
However, we don't support MSAA on YCbCr so there's no point in
checking for ANY_COLOR_BIT.
There is a hidden usage of planes in anv_descriptor_set_write_image_view
that's not as obvious. However, this function simply looks at
anv_image_view::n_planes and blindly fills out the descriptor
accordingly. As long as image views with a single plane continue to
claim n_planes == 1, this will be fine.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12141>
This commit is contained in:
committed by
Marge Bot
parent
32157f9059
commit
0a93c0364c
@@ -2723,7 +2723,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
assert(shader->stage == MESA_SHADER_FRAGMENT);
|
||||
assert(desc->image_view != NULL);
|
||||
if ((desc->image_view->aspect_mask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0) {
|
||||
if ((desc->image_view->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0) {
|
||||
/* For depth and stencil input attachments, we treat it like any
|
||||
* old texture that a user may have bound.
|
||||
*/
|
||||
@@ -6342,7 +6342,7 @@ cmd_buffer_end_subpass(struct anv_cmd_buffer *cmd_buffer)
|
||||
* with depth.
|
||||
*/
|
||||
const struct isl_view *ds_view = &iview->planes[0].isl;
|
||||
if (iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
if (iview->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
genX(cmd_buffer_mark_image_written)(cmd_buffer, iview->image,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT,
|
||||
att_state->aux_usage,
|
||||
@@ -6350,7 +6350,7 @@ cmd_buffer_end_subpass(struct anv_cmd_buffer *cmd_buffer)
|
||||
ds_view->base_array_layer,
|
||||
fb->layers);
|
||||
}
|
||||
if (iview->aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
if (iview->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
/* Even though stencil may be plane 1, it always shares a
|
||||
* base_level with depth.
|
||||
*/
|
||||
@@ -6405,8 +6405,8 @@ cmd_buffer_end_subpass(struct anv_cmd_buffer *cmd_buffer)
|
||||
enum isl_aux_usage dst_aux_usage =
|
||||
cmd_buffer->state.attachments[dst_att].aux_usage;
|
||||
|
||||
assert(src_iview->aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT &&
|
||||
dst_iview->aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
assert(src_iview->aspects == VK_IMAGE_ASPECT_COLOR_BIT &&
|
||||
dst_iview->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
||||
anv_image_msaa_resolve(cmd_buffer,
|
||||
src_iview->image, src_aux_usage,
|
||||
|
||||
Reference in New Issue
Block a user