From 89a41dae7702731bee298288f3acbcbd56096b30 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 28 Apr 2020 16:24:38 +0200 Subject: [PATCH] etnaviv: do not use int filter when anisotropic filtering is used The blob does not use this combination. This change moves the decision if int filter gets used to state emit time. Fixes: 7aaa0e59086 ("etnaviv: add anisotropic filter support") Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_format.c | 17 +++++++++++------ src/gallium/drivers/etnaviv/etnaviv_format.h | 4 +++- .../drivers/etnaviv/etnaviv_texture_desc.c | 7 ++++--- .../drivers/etnaviv/etnaviv_texture_state.c | 9 +++++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c b/src/gallium/drivers/etnaviv/etnaviv_format.c index c6611971d2d..97df90e065d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_format.c +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c @@ -268,9 +268,11 @@ translate_texture_format(enum pipe_format fmt) } bool -texture_use_int_filter(const struct pipe_sampler_view *so, bool tex_desc) +texture_use_int_filter(const struct pipe_sampler_view *sv, + const struct pipe_sampler_state *ss, + bool tex_desc) { - switch (so->target) { + switch (sv->target) { case PIPE_TEXTURE_1D_ARRAY: case PIPE_TEXTURE_2D_ARRAY: if (tex_desc) @@ -282,16 +284,19 @@ texture_use_int_filter(const struct pipe_sampler_view *so, bool tex_desc) } /* only unorm formats can use int filter */ - if (!util_format_is_unorm(so->format)) + if (!util_format_is_unorm(sv->format)) return false; - if (util_format_is_srgb(so->format)) + if (util_format_is_srgb(sv->format)) return false; - if (util_format_description(so->format)->layout == UTIL_FORMAT_LAYOUT_ASTC) + if (util_format_description(sv->format)->layout == UTIL_FORMAT_LAYOUT_ASTC) return false; - switch (so->format) { + if (ss->max_anisotropy > 1) + return false; + + switch (sv->format) { /* apparently D16 can't use int filter but D24 can */ case PIPE_FORMAT_Z16_UNORM: case PIPE_FORMAT_R10G10B10A2_UNORM: diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.h b/src/gallium/drivers/etnaviv/etnaviv_format.h index ecc9f8e439c..0aaa4ad6e5e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_format.h +++ b/src/gallium/drivers/etnaviv/etnaviv_format.h @@ -39,7 +39,9 @@ uint32_t translate_texture_format(enum pipe_format fmt); bool -texture_use_int_filter(const struct pipe_sampler_view *so, bool tex_desc); +texture_use_int_filter(const struct pipe_sampler_view *sv, + const struct pipe_sampler_state *ss, + bool tex_desc); bool texture_format_needs_swiz(enum pipe_format fmt); diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c index bca73d65c14..25efcd3dee3 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c @@ -161,9 +161,6 @@ etna_create_sampler_view_desc(struct pipe_context *pctx, struct pipe_resource *p if (util_format_is_srgb(so->format)) sv->SAMP_CTRL1 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL1_SRGB; - if (texture_use_int_filter(so, true)) - sv->SAMP_CTRL0 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_INT_FILTER; - /* Create texture descriptor */ sv->bo = etna_bo_new(ctx->screen->dev, 0x100, DRM_ETNA_GEM_CACHE_WC); if (!sv->bo) @@ -293,6 +290,10 @@ etna_emit_texture_desc(struct etna_context *ctx) if ((1 << x) & active_samplers) { struct etna_sampler_state_desc *ss = etna_sampler_state_desc(ctx->sampler[x]); struct etna_sampler_view_desc *sv = etna_sampler_view_desc(ctx->sampler_view[x]); + + if (texture_use_int_filter(&sv->base, &ss->base, true)) + sv->SAMP_CTRL0 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_INT_FILTER; + etna_set_state(stream, VIVS_NTE_DESCRIPTOR_TX_CTRL(x), COND(sv->ts.enable, VIVS_NTE_DESCRIPTOR_TX_CTRL_TS_ENABLE) | VIVS_NTE_DESCRIPTOR_TX_CTRL_TS_MODE(sv->ts.mode) | diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c index f64d4b39783..c66bfcee9a8 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c @@ -232,8 +232,7 @@ etna_create_sampler_view_state(struct pipe_context *pctx, struct pipe_resource * VIVS_TE_SAMPLER_LOG_SIZE_WIDTH(etna_log2_fixp55(res->base.width0)) | VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(base_height)) | COND(util_format_is_srgb(so->format) && !astc, VIVS_TE_SAMPLER_LOG_SIZE_SRGB) | - COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC) | - COND(texture_use_int_filter(so, false), VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER); + COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC); sv->TE_SAMPLER_3D_CONFIG = VIVS_TE_SAMPLER_3D_CONFIG_DEPTH(base_depth) | VIVS_TE_SAMPLER_3D_CONFIG_LOG_DEPTH(etna_log2_fixp55(base_depth)); @@ -335,6 +334,7 @@ etna_emit_texture_state(struct etna_context *ctx) } } if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) { + struct etna_sampler_state *ss; struct etna_sampler_view *sv; for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) { @@ -345,7 +345,12 @@ etna_emit_texture_state(struct etna_context *ctx) } for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) { if ((1 << x) & active_samplers) { + ss = etna_sampler_state(ctx->sampler[x]); sv = etna_sampler_view(ctx->sampler_view[x]); + + if (texture_use_int_filter(&sv->base, &ss->base, false)) + sv->TE_SAMPLER_LOG_SIZE |= VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER; + /*02080*/ EMIT_STATE(TE_SAMPLER_LOG_SIZE(x), sv->TE_SAMPLER_LOG_SIZE); } } -- 2.30.2