st/mesa: Allow ASTC5x5 fallbacks separately from other ASTC LDR formats.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 23 Nov 2019 05:33:19 +0000 (21:33 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 4 Jan 2020 02:06:35 +0000 (18:06 -0800)
This patch allows us to fake ASTC 5x5 specifically, while leaving the
other ASTC LDR formats with native support.  I plan to use this in iris,
at least for the time being.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_texture.h
src/mesa/state_tracker/tests/st_format.c

index df5f16efd629ecddf5890c3e4e951c12e83355ae..21f67659c0d361fe5689eb0a03ecd8cc118b5108 100644 (file)
@@ -226,6 +226,18 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
    st_texture_release_all_sampler_views(st, stObj);
 }
 
+bool
+st_astc_format_fallback(const struct st_context *st, mesa_format format)
+{
+   if (!_mesa_is_format_astc_2d(format))
+      return false;
+
+   if (format == MESA_FORMAT_RGBA_ASTC_5x5 ||
+       format == MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5)
+      return !st->has_astc_5x5_ldr;
+
+   return !st->has_astc_2d_ldr;
+}
 
 bool
 st_compressed_format_fallback(struct st_context *st, mesa_format format)
@@ -236,8 +248,8 @@ st_compressed_format_fallback(struct st_context *st, mesa_format format)
    if (_mesa_is_format_etc2(format))
       return !st->has_etc2;
 
-   if (_mesa_is_format_astc_2d(format))
-      return !st->has_astc_2d_ldr;
+   if (st_astc_format_fallback(st, format))
+      return true;
 
    return false;
 }
index c45c7f7e5fbb7d95f34060e81efce5ea0e685a6e..992f9fe00c9e52b751af7b7f9cd1edc2900e4b3f 100644 (file)
@@ -652,6 +652,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
    st->has_astc_2d_ldr =
       screen->is_format_supported(screen, PIPE_FORMAT_ASTC_4x4_SRGB,
                                   PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW);
+   st->has_astc_5x5_ldr =
+      screen->is_format_supported(screen, PIPE_FORMAT_ASTC_5x5_SRGB,
+                                  PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW);
    st->prefer_blit_based_texture_transfer = screen->get_param(screen,
                               PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER);
    st->force_persample_in_shader =
index 054a9e9317ec8cbffe461e99a54a852323e43114..9a6a1f80d33989de8bfaef591436a32a5955592b 100644 (file)
@@ -137,6 +137,7 @@ struct st_context
    boolean has_etc1;
    boolean has_etc2;
    boolean has_astc_2d_ldr;
+   boolean has_astc_5x5_ldr;
    boolean prefer_blit_based_texture_transfer;
    boolean force_persample_in_shader;
    boolean has_shareable_shaders;
index 4bbb781932d0de846e3387eaf891e7afa2f073bf..fb071beb64b67c74d341e500e7e4fdb296ba20af 100644 (file)
@@ -106,7 +106,7 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
       }
    }
 
-   if (_mesa_is_format_astc_2d(mesaFormat) && !st->has_astc_2d_ldr) {
+   if (st_astc_format_fallback(st, mesaFormat)) {
       if (_mesa_is_format_srgb(mesaFormat))
          return PIPE_FORMAT_R8G8B8A8_SRGB;
       else
index 1fc36631c2ebc4187bd084eed57bd6566034c5fd..7948daa65421417fbada908a68c0287eb354f60e 100644 (file)
@@ -322,6 +322,9 @@ st_destroy_bound_texture_handles(struct st_context *st);
 void
 st_destroy_bound_image_handles(struct st_context *st);
 
+bool
+st_astc_format_fallback(const struct st_context *st, mesa_format format);
+
 bool
 st_compressed_format_fallback(struct st_context *st, mesa_format format);
 
index 0def5ff3359fbd409e41be642bb5590eef0d43fe..64e6bb1b33ce4f2a923c00e083a4b535bf4d5d1e 100644 (file)
@@ -59,6 +59,7 @@ int main(int argc, char **argv)
       .has_etc1 = true,
       .has_etc2 = true,
       .has_astc_2d_ldr = true,
+      .has_astc_5x5_ldr = true,
    };
    struct st_context *st = &local_st;