etnaviv: support 3d/array/integer formats in texture descriptors
authorJonathan Marek <jonathan@marek.ca>
Sun, 20 Oct 2019 06:11:45 +0000 (02:11 -0400)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Tue, 26 Nov 2019 18:07:04 +0000 (19:07 +0100)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_texture_desc.c

index 05b6de44f91dc32c4f9536fcee64a2fe6765e191..e54b98eadc53fb0810147bf7e4315aff4a973502 100644 (file)
@@ -90,6 +90,7 @@ static struct pipe_sampler_view *
 etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *prsc,
                          const struct pipe_sampler_view *so)
 {
+   const struct util_format_description *desc = util_format_description(so->format);
    struct etna_sampler_view_desc *sv = CALLOC_STRUCT(etna_sampler_view_desc);
    struct etna_context *ctx = etna_context(pctx);
    const uint32_t format = translate_texture_format(so->format);
@@ -141,6 +142,17 @@ etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *p
    /** GC7000 needs the size of the BASELOD level */
    uint32_t base_width = u_minify(res->base.width0, sv->base.u.tex.first_level);
    uint32_t base_height = u_minify(res->base.height0, sv->base.u.tex.first_level);
+   uint32_t base_depth = u_minify(res->base.depth0, sv->base.u.tex.first_level);
+   bool is_array = false;
+   bool sint = util_format_is_pure_sint(so->format);
+
+   if (sv->base.target == PIPE_TEXTURE_1D_ARRAY) {
+      is_array = true;
+      base_height = res->base.array_size;
+   } else if (sv->base.target == PIPE_TEXTURE_2D_ARRAY) {
+      is_array = true;
+      base_depth = res->base.array_size;
+   }
 
 #define DESC_SET(x, y) buf[(TEXDESC_##x)>>2] = (y)
    DESC_SET(CONFIG0, COND(!ext && !astc, VIVS_TE_SAMPLER_CONFIG0_FORMAT(format))
@@ -149,11 +161,15 @@ etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *p
                         VIVS_TE_SAMPLER_CONFIG0_ADDRESSING_MODE(TEXTURE_ADDRESSING_MODE_LINEAR)));
    DESC_SET(CONFIG1, COND(ext, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(format)) |
                      COND(astc, VIVS_TE_SAMPLER_CONFIG1_FORMAT_EXT(TEXTURE_FORMAT_EXT_ASTC)) |
-                            VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz);
-   DESC_SET(CONFIG2, 0x00030000);
+                     COND(is_array, VIVS_TE_SAMPLER_CONFIG1_TEXTURE_ARRAY) |
+                     VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz);
+   DESC_SET(CONFIG2, 0x00030000 |
+         COND(sint && desc->channel[0].size == 8, TE_SAMPLER_CONFIG2_SIGNED_INT8) |
+         COND(sint && desc->channel[0].size == 16, TE_SAMPLER_CONFIG2_SIGNED_INT16));
    DESC_SET(LINEAR_STRIDE, res->levels[0].stride);
+   DESC_SET(VOLUME, etna_log2_fixp88(base_depth));
    DESC_SET(SLICE, res->levels[0].layer_stride);
-   DESC_SET(3D_CONFIG, 0x00000001);
+   DESC_SET(3D_CONFIG, VIVS_TE_SAMPLER_3D_CONFIG_DEPTH(base_depth));
    DESC_SET(ASTC0, COND(astc, VIVS_NTE_SAMPLER_ASTC0_ASTC_FORMAT(format)) |
                    VIVS_NTE_SAMPLER_ASTC0_UNK8(0xc) |
                    VIVS_NTE_SAMPLER_ASTC0_UNK16(0xc) |