[Mesa-dev] [PATCH mesa] gallium: simplify util_format_is_supported()

Eric Engestrom eric.engestrom at intel.com
Mon Jun 18 10:15:10 UTC 2018


As of 66673bef941af344314f ("mesa: Unconditionally enable floating-point
textures"), the `bind` argument is no longer used, and the format check
is now a simple enum range check, so inline it and remove the
unnecessary argument from callers.

Cc: Timothy Arceri <tarceri at itsqueeze.com>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
---
 src/gallium/auxiliary/util/u_format.c           | 12 ------------
 src/gallium/auxiliary/util/u_format.h           |  7 +++++--
 src/gallium/drivers/freedreno/a2xx/fd2_screen.c |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_screen.c |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_screen.c |  2 +-
 src/gallium/drivers/freedreno/a5xx/fd5_screen.c |  2 +-
 src/gallium/drivers/i915/i915_screen.c          |  2 +-
 src/gallium/drivers/nouveau/nv30/nv30_screen.c  |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_screen.c  |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c  |  2 +-
 src/gallium/drivers/r300/r300_screen.c          |  2 +-
 src/gallium/drivers/r600/evergreen_state.c      |  2 +-
 src/gallium/drivers/r600/r600_state.c           |  2 +-
 src/gallium/drivers/radeonsi/si_state.c         |  2 +-
 src/gallium/drivers/v3d/v3d_screen.c            |  2 +-
 src/gallium/drivers/vc4/vc4_screen.c            |  2 +-
 16 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index e0325e9c534974b15c65..d82d00a9d06fde2daeef 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -235,18 +235,6 @@ util_format_is_subsampled_422(enum pipe_format format)
       desc->block.bits == 32;
 }
 
-boolean
-util_format_is_supported(enum pipe_format format, unsigned bind)
-{
-   if (format >= PIPE_FORMAT_COUNT) {
-      return FALSE;
-   }
-
-   (void)bind;
-
-   return TRUE;
-}
-
 
 /**
  * Calculates the MRD for the depth format. MRD is used in depth bias
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index e497b4b3375a57771009..9c5df967b6c01288d0b3 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -721,8 +721,11 @@ util_is_format_compatible(const struct util_format_description *src_desc,
  * Whether the format is supported by Gallium for the given bindings.
  * This covers S3TC textures and floating-point render targets.
  */
-boolean
-util_format_is_supported(enum pipe_format format, unsigned bind);
+static boolean
+util_format_is_supported(enum pipe_format format)
+{
+   return format < PIPE_FORMAT_COUNT;
+}
 
 /**
  * Whether this format is a rgab8 variant.
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
index c2a60c683f86f4f34b02..2b952c0391c34d59fb61 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
@@ -44,7 +44,7 @@ fd2_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
 			(sample_count > 1) || /* TODO add MSAA */
-			!util_format_is_supported(format, usage)) {
+			!util_format_is_supported(format)) {
 		DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
 				util_format_name(format), target, sample_count, usage);
 		return FALSE;
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
index 998ec7a0bdbaa076b73a..f4bbaeb63ddee4b830a8 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
@@ -45,7 +45,7 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
 			(sample_count > 1) || /* TODO add MSAA */
-			!util_format_is_supported(format, usage)) {
+			!util_format_is_supported(format)) {
 		DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
 				util_format_name(format), target, sample_count, usage);
 		return FALSE;
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_screen.c b/src/gallium/drivers/freedreno/a4xx/fd4_screen.c
index 1b81f8db2f354154ed59..70f13f809173ed551d8c 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_screen.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_screen.c
@@ -45,7 +45,7 @@ fd4_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
 			(sample_count > 1) || /* TODO add MSAA */
-			!util_format_is_supported(format, usage)) {
+			!util_format_is_supported(format)) {
 		DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
 				util_format_name(format), target, sample_count, usage);
 		return FALSE;
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
index 7d7e76e869c9bbeae722..c361dc1039bc68072d52 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
@@ -46,7 +46,7 @@ fd5_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
 			(sample_count > 1) || /* TODO add MSAA */
-			!util_format_is_supported(format, usage)) {
+			!util_format_is_supported(format)) {
 		DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
 				util_format_name(format), target, sample_count, usage);
 		return FALSE;
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index d917048e2b9b74b7f59b..3fe84501eae3d2dab32b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -513,7 +513,7 @@ i915_is_format_supported(struct pipe_screen *screen,
    const enum pipe_format *list;
    uint i;
 
-   if (!util_format_is_supported(format, tex_usage))
+   if (!util_format_is_supported(format))
       return FALSE;
 
    if (sample_count > 1)
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 470625ba54239e125f94..fe82ce2f354143339a33 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -420,7 +420,7 @@ nv30_screen_is_format_supported(struct pipe_screen *pscreen,
    if (!(0x00000017 & (1 << sample_count)))
       return false;
 
-   if (!util_format_is_supported(format, bindings)) {
+   if (!util_format_is_supported(format)) {
       return false;
    }
 
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index bdb2a8e31c7d96361f4c..6b28c6eb42726b5e4ef9 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -55,7 +55,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
    if (sample_count == 8 && util_format_get_blocksizebits(format) >= 128)
       return false;
 
-   if (!util_format_is_supported(format, bindings))
+   if (!util_format_is_supported(format))
       return false;
 
    switch (format) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 0efa5840207fc78d918a..59a55678a4ebf63ba1e8 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -57,7 +57,7 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen,
    if (format == PIPE_FORMAT_NONE && bindings & PIPE_BIND_RENDER_TARGET)
       return true;
 
-   if (!util_format_is_supported(format, bindings))
+   if (!util_format_is_supported(format))
       return false;
 
    if ((bindings & PIPE_BIND_SAMPLER_VIEW) && (target != PIPE_BUFFER))
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 793b0ba8d89105ef5fe6..029bd9c75c3a8262d6f3 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -615,7 +615,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
                             format == PIPE_FORMAT_R16G16B16X16_FLOAT;
     const struct util_format_description *desc;
 
-    if (!util_format_is_supported(format, usage))
+    if (!util_format_is_supported(format))
        return FALSE;
 
     /* Check multisampling support. */
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 05f4a65059bf2b1dbbf1..c82a353cef99e538bd85 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -253,7 +253,7 @@ boolean evergreen_is_format_supported(struct pipe_screen *screen,
 		return FALSE;
 	}
 
-	if (!util_format_is_supported(format, usage))
+	if (!util_format_is_supported(format))
 		return FALSE;
 
 	if (sample_count > 1) {
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index a37a70183717af3871fe..3e86ba8eac11f39494b2 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -172,7 +172,7 @@ boolean r600_is_format_supported(struct pipe_screen *screen,
 		return FALSE;
 	}
 
-	if (!util_format_is_supported(format, usage))
+	if (!util_format_is_supported(format))
 		return FALSE;
 
 	if (sample_count > 1) {
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index fb4649771fc0d17bb40a..4914e4e2bcf4b730ce44 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2134,7 +2134,7 @@ static boolean si_is_format_supported(struct pipe_screen *screen,
 		return false;
 	}
 
-	if (!util_format_is_supported(format, usage))
+	if (!util_format_is_supported(format))
 		return false;
 
 	if (sample_count > 1) {
diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c
index cd84e61f2770c097eae9..ec657d5e9d2b5086b470 100644
--- a/src/gallium/drivers/v3d/v3d_screen.c
+++ b/src/gallium/drivers/v3d/v3d_screen.c
@@ -445,7 +445,7 @@ v3d_screen_is_format_supported(struct pipe_screen *pscreen,
                 return FALSE;
 
         if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
-            !util_format_is_supported(format, usage)) {
+            !util_format_is_supported(format)) {
                 return FALSE;
         }
 
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index 286263bf001f6d0abd12..138a5db021bca7bd0ae5 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -485,7 +485,7 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
                 return FALSE;
 
         if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
-            !util_format_is_supported(format, usage)) {
+            !util_format_is_supported(format)) {
                 return FALSE;
         }
 
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list