etnaviv: update INT_FILTER choice for GLES3 formats
authorJonathan Marek <jonathan@marek.ca>
Sun, 20 Oct 2019 06:10:43 +0000 (02:10 -0400)
committerJonathan Marek <jonathan@marek.ca>
Fri, 13 Dec 2019 14:09:08 +0000 (09:09 -0500)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_format.c
src/gallium/drivers/etnaviv/etnaviv_format.h
src/gallium/drivers/etnaviv/etnaviv_texture_desc.c
src/gallium/drivers/etnaviv/etnaviv_texture_state.c

index c476e4a95435f5300dcd5e64764bf865ecd397bd..ce87f57d9f3be078fe3a1bfb6b0b176432a8399a 100644 (file)
@@ -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)
 {
index db3d8b970d1e87816b333b9551e9840f857f6374..ecc9f8e439c7af978bc874e6d2473cf3a585510d 100644 (file)
@@ -28,6 +28,7 @@
 #define ETNAVIV_FORMAT_H_
 
 #include "util/format/u_format.h"
+#include "pipe/p_state.h"
 #include <stdint.h>
 
 #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);
 
index e54b98eadc53fb0810147bf7e4315aff4a973502..29ae71b785c5dcc54fd03483202d802780c3fdfd 100644 (file)
@@ -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 */
index 8bedb7ee8829d36af0270e5a6d9f44421f3aaae3..6b112206b01d82adbc6b5fb9a95e5f499250196b 100644 (file)
@@ -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));