From a6a3a7a88174905877d3c5907f5722e54bdacacc Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 19 May 2023 17:46:08 -0400 Subject: [PATCH] gallium: Add pipe_image_view::single_layer_view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Acked-by: Mike Blumenkrantz Part-of: --- src/gallium/auxiliary/util/u_dump_state.c | 1 + src/gallium/include/pipe/p_state.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index b408005280b..a8fd726b152 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -742,6 +742,7 @@ util_dump_image_view(FILE *stream, const struct pipe_image_view *state) util_dump_member(stream, uint, state, u.buf.size); } else { + util_dump_member(stream, bool, state, u.tex.single_layer_view); util_dump_member(stream, uint, state, u.tex.first_layer); util_dump_member(stream, uint, state, u.tex.last_layer); util_dump_member(stream, uint, state, u.tex.level); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 531a16be108..8e35245395f 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -546,6 +546,7 @@ struct pipe_image_view unsigned first_layer:16; /**< first layer to use for array textures */ unsigned last_layer:16; /**< last layer to use for array textures */ unsigned level:8; /**< mipmap level to use */ + bool single_layer_view; /**< single layer view of array */ } tex; struct { unsigned offset; /**< offset in bytes */