asahi: Implement linear 2D array textures
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 21 Dec 2022 02:00:10 +0000 (21:00 -0500)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 5 Jan 2023 16:49:22 +0000 (11:49 -0500)
These are useful for layered staging resources. Tested by forcing linear
textures and running dEQP-GLES3.functional.texture.format.sized.2d_array.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20446>

src/gallium/drivers/asahi/agx_pipe.c
src/gallium/drivers/asahi/agx_state.c

index d465979..52f3802 100644 (file)
@@ -300,6 +300,7 @@ agx_linear_allowed(const struct agx_resource *pres)
     * works for 2D textures. Rectangle textures are a special case of 2D.
     */
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_2D_ARRAY:
    case PIPE_TEXTURE_RECT:
       break;
 
index a78bb10..e755ac3 100644 (file)
@@ -587,9 +587,8 @@ agx_pack_texture(void *out, struct agx_resource *rsrc,
 
    util_format_compose_swizzles(format_swizzle, view_swizzle, out_swizzle);
 
-   /* Must tile array textures */
-   assert((rsrc->layout.tiling != AIL_TILING_LINEAR) ||
-          (state->u.tex.last_layer == state->u.tex.first_layer));
+   unsigned first_layer =
+      (state->target == PIPE_BUFFER) ? 0 : state->u.tex.first_layer;
 
    /* Pack the descriptor into GPU memory */
    agx_pack(out, TEXTURE, cfg) {
@@ -635,7 +634,15 @@ agx_pack_texture(void *out, struct agx_resource *rsrc,
              (state->target == PIPE_TEXTURE_CUBE_ARRAY))
             layers /= 6;
 
-         cfg.depth = layers;
+         if (rsrc->layout.tiling == AIL_TILING_LINEAR &&
+             state->target == PIPE_TEXTURE_2D_ARRAY) {
+            cfg.depth_linear = layers;
+            cfg.layer_stride_linear = (rsrc->layout.layer_stride_B - 0x80);
+            cfg.extended = true;
+         } else {
+            assert((rsrc->layout.tiling != AIL_TILING_LINEAR) || (layers == 1));
+            cfg.depth = layers;
+         }
       }
 
       if (rsrc->base.nr_samples > 1)