gallium: Add pipe_image_view::single_layer_view
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Fri, 19 May 2023 21:46:08 +0000 (17:46 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 22 May 2023 16:41:10 +0000 (16:41 +0000)
commita6a3a7a88174905877d3c5907f5722e54bdacacc
tree331889a1827a5c220a18bebb346b19b7177bfd62
parent17fd50b817a3a77b893ea3f421009a0410c7644f
gallium: Add pipe_image_view::single_layer_view

OpenGL has a goofy feature that allows creating an image view of a single layer
of an array texture... in which case that image is treated as non-arrayed in
shader. If you have a 16x16x16 3D texture and bind the third layer, you get a
16x16 2D texture instead of a 16x16x1 3D texture. That distinction matters to
the hardware on AGX, since the texture dimension needs to match between the
shader and the pipe_image_view. If the shader is going to use image2D, we need
to know that the pipe_image_view should be treated as 2D (even though the
underlying resource is 3D).

"But, Alyssa, we already have first_layer and last_layer. Surely you can just
check if first_layer == last_layer?" you ask. The problem is that doesn't
distinguish a 16x16x1 3D texture (accessed as image3D in the shader) from a
16x16 slice (accessed as image2D in the shader) of a 16x16x16 3D texture. To
solve, we add a boolean flag indicating we want to create a view (with a lower
dimension than the underlying resource). This provides an unambiguous way to
communicate this case to drivers.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23142>
src/gallium/auxiliary/util/u_dump_state.c
src/gallium/include/pipe/p_state.h