From 7aaa0e59086fa2bf9c5fa7db2774cb2aa32f95b9 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Fri, 17 Apr 2020 18:22:33 +0200 Subject: [PATCH] etnaviv: add anisotropic filter support 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 Part-of: --- src/gallium/drivers/etnaviv/etnaviv_texture_desc.c | 5 +++++ src/gallium/drivers/etnaviv/etnaviv_texture_state.c | 4 +++- src/gallium/drivers/etnaviv/etnaviv_translate.h | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c index fc5d799d973..efa0cd67147 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c @@ -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); } } } diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c index f3b2c72b340..f64d4b39783 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c @@ -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 && diff --git a/src/gallium/drivers/etnaviv/etnaviv_translate.h b/src/gallium/drivers/etnaviv/etnaviv_translate.h index e0811545e74..0638bfd5dca 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_translate.h +++ b/src/gallium/drivers/etnaviv/etnaviv_translate.h @@ -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; -- 2.30.2