From d34705c89139d5a6917dbfbafd537809e39fdf8c Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Sun, 20 Oct 2019 02:10:43 -0400 Subject: [PATCH] etnaviv: update INT_FILTER choice for GLES3 formats Signed-off-by: Jonathan Marek Reviewed-by: Christian Gmeiner --- src/gallium/drivers/etnaviv/etnaviv_format.c | 34 +++++++++++++++++++ src/gallium/drivers/etnaviv/etnaviv_format.h | 4 +++ .../drivers/etnaviv/etnaviv_texture_desc.c | 2 +- .../drivers/etnaviv/etnaviv_texture_state.c | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c b/src/gallium/drivers/etnaviv/etnaviv_format.c index c476e4a9543..ce87f57d9f3 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_format.c +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c @@ -271,6 +271,40 @@ translate_texture_format(enum pipe_format fmt) return formats[fmt].tex; } +bool +texture_use_int_filter(const struct pipe_sampler_view *so, bool tex_desc) +{ + switch (so->target) { + case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + if (tex_desc) + break; + case PIPE_TEXTURE_3D: + return false; + default: + break; + } + + /* only unorm formats can use int filter */ + if (!util_format_is_unorm(so->format)) + return false; + + if (util_format_is_srgb(so->format)) + return false; + + switch (so->format) { + /* apparently D16 can't use int filter but D24 can */ + case PIPE_FORMAT_Z16_UNORM: + case PIPE_FORMAT_R10G10B10A2_UNORM: + case PIPE_FORMAT_R10G10B10X2_UNORM: + case PIPE_FORMAT_ETC2_R11_UNORM: + case PIPE_FORMAT_ETC2_RG11_UNORM: + return false; + default: + return true; + } +} + bool texture_format_needs_swiz(enum pipe_format fmt) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.h b/src/gallium/drivers/etnaviv/etnaviv_format.h index db3d8b970d1..ecc9f8e439c 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_format.h +++ b/src/gallium/drivers/etnaviv/etnaviv_format.h @@ -28,6 +28,7 @@ #define ETNAVIV_FORMAT_H_ #include "util/format/u_format.h" +#include "pipe/p_state.h" #include #define ETNA_NO_MATCH (~0) @@ -37,6 +38,9 @@ uint32_t translate_texture_format(enum pipe_format fmt); +bool +texture_use_int_filter(const struct pipe_sampler_view *so, 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 e54b98eadc5..29ae71b785c 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c @@ -127,7 +127,7 @@ 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 (!util_format_is_float(so->format) && so->target != PIPE_TEXTURE_3D) + if (texture_use_int_filter(so, true)) sv->SAMP_CTRL0 |= VIVS_NTE_DESCRIPTOR_SAMP_CTRL0_INT_FILTER; /* Create texture descriptor */ diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c index 8bedb7ee882..6b112206b01 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c @@ -188,7 +188,7 @@ etna_create_sampler_view_state(struct pipe_context *pctx, struct pipe_resource * 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(!util_format_is_float(so->format) && so->target != PIPE_TEXTURE_3D, VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER); + COND(texture_use_int_filter(so, false), VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER); 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)); -- 2.30.2