etnaviv: add anisotropic filter support
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Fri, 17 Apr 2020 16:22:33 +0000 (18:22 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 24 Apr 2020 06:46:00 +0000 (06:46 +0000)
I have not seen any usage of TEXTURE_FILTER_ANISOTROPIC in the cmd streams
from the binary blob. Maybe it gets used on some model/rev combinations.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2888>

src/gallium/drivers/etnaviv/etnaviv_texture_desc.c
src/gallium/drivers/etnaviv/etnaviv_texture_state.c
src/gallium/drivers/etnaviv/etnaviv_translate.h

index fc5d799d973f0e5a8e76d191e928e00d75bbf913..efa0cd67147f6160a7d1fa55973371851fc3e567 100644 (file)
@@ -47,6 +47,7 @@ struct etna_sampler_state_desc {
    uint32_t SAMP_CTRL1;
    uint32_t SAMP_LOD_MINMAX;
    uint32_t SAMP_LOD_BIAS;
+   uint32_t SAMP_ANISOTROPY;
 };
 
 static inline struct etna_sampler_state_desc *
@@ -77,6 +78,7 @@ etna_create_sampler_state_desc(struct pipe_context *pipe,
                           const struct pipe_sampler_state *ss)
 {
    struct etna_sampler_state_desc *cs = CALLOC_STRUCT(etna_sampler_state_desc);
+   const bool ansio = ss->max_anisotropy > 1;
 
    if (!cs)
       return NULL;
@@ -107,6 +109,8 @@ etna_create_sampler_state_desc(struct pipe_context *pipe,
    cs->SAMP_LOD_BIAS =
       VIVS_NTE_DESCRIPTOR_SAMP_LOD_BIAS_BIAS(etna_float_to_fixp88(ss->lod_bias)) |
       COND(ss->lod_bias != 0.0, VIVS_NTE_DESCRIPTOR_SAMP_LOD_BIAS_ENABLE);
+   cs->SAMP_ANISOTROPY =
+      VIVS_NTE_DESCRIPTOR_SAMP_ANISOTROPY(COND(ansio, etna_log2_fixp88(ss->max_anisotropy)));
 
    return cs;
 }
@@ -298,6 +302,7 @@ etna_emit_texture_desc(struct etna_context *ctx)
             etna_set_state(stream, VIVS_NTE_DESCRIPTOR_SAMP_CTRL1(x), ss->SAMP_CTRL1 | sv->SAMP_CTRL1);
             etna_set_state(stream, VIVS_NTE_DESCRIPTOR_SAMP_LOD_MINMAX(x), ss->SAMP_LOD_MINMAX);
             etna_set_state(stream, VIVS_NTE_DESCRIPTOR_SAMP_LOD_BIAS(x), ss->SAMP_LOD_BIAS);
+            etna_set_state(stream, VIVS_NTE_DESCRIPTOR_SAMP_ANISOTROPY(x), ss->SAMP_ANISOTROPY);
          }
       }
    }
index f3b2c72b340e3a12eead38d9ae8eb9c0a62ce7f7..f64d4b39783c3d3cac412af093dace279eb9d741 100644 (file)
@@ -86,6 +86,7 @@ etna_create_sampler_state_state(struct pipe_context *pipe,
                           const struct pipe_sampler_state *ss)
 {
    struct etna_sampler_state *cs = CALLOC_STRUCT(etna_sampler_state);
+   const bool ansio = ss->max_anisotropy > 1;
 
    if (!cs)
       return NULL;
@@ -95,7 +96,8 @@ etna_create_sampler_state_state(struct pipe_context *pipe,
       VIVS_TE_SAMPLER_CONFIG0_VWRAP(translate_texture_wrapmode(ss->wrap_t)) |
       VIVS_TE_SAMPLER_CONFIG0_MIN(translate_texture_filter(ss->min_img_filter)) |
       VIVS_TE_SAMPLER_CONFIG0_MIP(translate_texture_mipfilter(ss->min_mip_filter)) |
-      VIVS_TE_SAMPLER_CONFIG0_MAG(translate_texture_filter(ss->mag_img_filter));
+      VIVS_TE_SAMPLER_CONFIG0_MAG(translate_texture_filter(ss->mag_img_filter)) |
+      VIVS_TE_SAMPLER_CONFIG0_ANISOTROPY(COND(ansio, etna_log2_fixp55(ss->max_anisotropy)));
 
    /* ROUND_UV improves precision - but not compatible with NEAREST filter */
    if (ss->min_img_filter != PIPE_TEX_FILTER_NEAREST &&
index e0811545e7455b1b554bc57d3b41fb0543302ea9..0638bfd5dcaff5ad66885a8acbf0794ccb3db49c 100644 (file)
@@ -227,7 +227,6 @@ translate_texture_filter(unsigned filter)
       return TEXTURE_FILTER_NEAREST;
    case PIPE_TEX_FILTER_LINEAR:
       return TEXTURE_FILTER_LINEAR;
-   /* What about anisotropic? */
    default:
       DBG("Unhandled texture filter: %i", filter);
       return ETNA_NO_MATCH;