Module: Mesa
Branch: main
Commit: 985fde28a2924c53a00c3725a2597367c62e578a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=985fde28a2924c53a00c3725a2597367c62e578a

Author: Erik Faye-Lund <[email protected]>
Date:   Wed Aug 10 13:06:57 2022 +0200

mesa/st: simplify st_compressed_format_fallback

By looking at the format-layout, we can do switch-cases here instead of
serial calls to _mesa_is_format_foo(). This isn't a huge deal yet, but
this function is going to learn about a lot more formats soon...

Acked-by: Marek Olšák <[email protected]>
Acked-by: Soroush Kashani <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>

---

 src/mesa/state_tracker/st_cb_texture.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 2515c54bc3c..b753db0c192 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -433,16 +433,16 @@ st_astc_format_fallback(const struct st_context *st, 
mesa_format format)
 bool
 st_compressed_format_fallback(struct st_context *st, mesa_format format)
 {
-   if (format == MESA_FORMAT_ETC1_RGB8)
+   switch (_mesa_get_format_layout(format)) {
+   case MESA_FORMAT_LAYOUT_ETC1:
       return !st->has_etc1;
-
-   if (_mesa_is_format_etc2(format))
+   case MESA_FORMAT_LAYOUT_ETC2:
       return !st->has_etc2;
-
-   if (st_astc_format_fallback(st, format))
-      return true;
-
-   return false;
+   case MESA_FORMAT_LAYOUT_ASTC:
+      return st_astc_format_fallback(st, format);
+   default:
+      return false;
+   }
 }
 
 

Reply via email to