broadcom/vc5: Ignore unused usage flags in is_format_supported.
authorEric Anholt <eric@anholt.net>
Fri, 23 Feb 2018 17:10:36 +0000 (09:10 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 23 Feb 2018 23:07:18 +0000 (15:07 -0800)
Like for vc4, the new DISPLAY_TARGET flag ended up causing no formats to
match.  Just drop the whole retval == usage thing and return early when we
hit a known unsupported case.

Fixes: f7604d8af521 ("st/dri: only expose config formats that are display targets")
src/gallium/drivers/vc5/vc5_screen.c

index 47727d0adad438b1f32c400441440b71480f1ad2..5d63fb6ec0b299bd02dee76b0bc20bc35a7501f2 100644 (file)
@@ -426,7 +426,6 @@ vc5_screen_is_format_supported(struct pipe_screen *pscreen,
                                unsigned usage)
 {
         struct vc5_screen *screen = vc5_screen(pscreen);
-        unsigned retval = 0;
 
         if (sample_count > 1 && sample_count != VC5_MAX_SAMPLES)
                 return FALSE;
@@ -482,49 +481,39 @@ vc5_screen_is_format_supported(struct pipe_screen *pscreen,
                 case PIPE_FORMAT_R8G8B8_SSCALED:
                 case PIPE_FORMAT_R8G8_SSCALED:
                 case PIPE_FORMAT_R8_SSCALED:
-                        retval |= PIPE_BIND_VERTEX_BUFFER;
                         break;
                 default:
-                        break;
+                        return FALSE;
                 }
         }
 
         if ((usage & PIPE_BIND_RENDER_TARGET) &&
-            vc5_rt_format_supported(&screen->devinfo, format)) {
-                retval |= PIPE_BIND_RENDER_TARGET;
+            !vc5_rt_format_supported(&screen->devinfo, format)) {
+                return FALSE;
         }
 
         if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
-            vc5_tex_format_supported(&screen->devinfo, format)) {
-                retval |= PIPE_BIND_SAMPLER_VIEW;
+            !vc5_tex_format_supported(&screen->devinfo, format)) {
+                return FALSE;
         }
 
         if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
-            (format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
-             format == PIPE_FORMAT_X8Z24_UNORM ||
-             format == PIPE_FORMAT_Z16_UNORM ||
-             format == PIPE_FORMAT_Z32_FLOAT ||
-             format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
-                retval |= PIPE_BIND_DEPTH_STENCIL;
+            !(format == PIPE_FORMAT_S8_UINT_Z24_UNORM ||
+              format == PIPE_FORMAT_X8Z24_UNORM ||
+              format == PIPE_FORMAT_Z16_UNORM ||
+              format == PIPE_FORMAT_Z32_FLOAT ||
+              format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
+                return FALSE;
         }
 
         if ((usage & PIPE_BIND_INDEX_BUFFER) &&
-            (format == PIPE_FORMAT_I8_UINT ||
-             format == PIPE_FORMAT_I16_UINT ||
-             format == PIPE_FORMAT_I32_UINT)) {
-                retval |= PIPE_BIND_INDEX_BUFFER;
-        }
-
-#if 0
-        if (retval != usage) {
-                fprintf(stderr,
-                        "not supported: format=%s, target=%d, sample_count=%d, "
-                        "usage=0x%x, retval=0x%x\n", util_format_name(format),
-                        target, sample_count, usage, retval);
+            !(format == PIPE_FORMAT_I8_UINT ||
+              format == PIPE_FORMAT_I16_UINT ||
+              format == PIPE_FORMAT_I32_UINT)) {
+                return FALSE;
         }
-#endif
 
-        return retval == usage;
+        return TRUE;
 }
 
 #define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))