etnaviv: do not use int filter when anisotropic filtering is used
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Tue, 28 Apr 2020 14:24:38 +0000 (16:24 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 May 2020 14:39:24 +0000 (14:39 +0000)
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 <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4872>

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 c6611971d2dd715a0ecbc039f577f8558b63aa65..97df90e065d8cdf06145fbdd61307ab38057ecbd 100644 (file)
@@ -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:
index ecc9f8e439c7af978bc874e6d2473cf3a585510d..0aaa4ad6e5e0e8b577d2d8dea1ffeaf3b17bb266 100644 (file)
@@ -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);
index bca73d65c142b71b0753ede229658f54927e2899..25efcd3dee3d62343e1c2ae4794a898d7b39d9a6 100644 (file)
@@ -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) |
index f64d4b39783c3d3cac412af093dace279eb9d741..c66bfcee9a8e1fb145fd573e7a91660203686aac 100644 (file)
@@ -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);
          }
       }