panfrost: Update supported formats
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 1 Jul 2019 18:53:38 +0000 (11:53 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 13:12:09 +0000 (06:12 -0700)
Much of the format selection code was inherited from softpipe (!) of all
places, and a lot of it is accordingly cruft. Later if-elses were added
in random places to workaround missing formats at various points in
history. Clean up some of this.

Theoretically, any format we can texture from we can also render to. In
practice, there are a few corner cases that we need to disable
explicitly.

For one, we do have to restrict SCANOUT formats to workaround
buggy apps (in particular, dEQP which with --deqp-surface-type=window
under Weston will end up with RGB10_A2 and complain about low alpha
precision). Just be clearer about how/why.

Also, RGB5_A1 support is still broken; let's not worry about that quite
yet.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_screen.c

index d53a906838eb67619b8daa8e22107a7b4cba5502..b044ae993993453898a4cbbac63be264f798ce17 100644 (file)
@@ -460,48 +460,18 @@ panfrost_is_format_supported( struct pipe_screen *screen,
         if (format == PIPE_FORMAT_A1B5G5R5_UNORM || format == PIPE_FORMAT_X1B5G5R5_UNORM)
                 return FALSE;
 
-        /* Allow through special formats */
-
-        switch (format) {
-                case PIPE_FORMAT_R11G11B10_FLOAT:
-                case PIPE_FORMAT_B5G6R5_UNORM:
-                        return TRUE;
-                default:
-                        break;
-        }
-
-        if (bind & PIPE_BIND_RENDER_TARGET) {
-                if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
-                        return FALSE;
-
-                /* Check for vaguely 8UNORM formats. Looser than
-                 * util_format_is_rgba8_variant, since it permits R8 (for
-                 * instance) */
-
-                for (unsigned chan = 0; chan < 4; ++chan) {
-                        enum util_format_type t = format_desc->channel[chan].type;
-                        if (t == UTIL_FORMAT_TYPE_VOID) continue;
-                        if (t != UTIL_FORMAT_TYPE_UNSIGNED) return FALSE;
-                        if (!format_desc->channel[chan].normalized) return FALSE;
-                        if (format_desc->channel[chan].size != 8) return FALSE;
-                }
-
-                /*
-                 * Although possible, it is unnatural to render into compressed or YUV
-                 * surfaces. So disable these here to avoid going into weird paths
-                 * inside the state trackers.
-                 */
-                if (format_desc->block.width != 1 ||
-                                format_desc->block.height != 1)
-                        return FALSE;
-        }
+        /* TODO */
+        if (format == PIPE_FORMAT_B5G5R5A1_UNORM)
+                return FALSE;
 
-        if (bind & PIPE_BIND_DEPTH_STENCIL) {
-                if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
-                        return FALSE;
-        }
+        /* Don't confuse poorly written apps (workaround dEQP bug) that expect
+         * more alpha than they ask for */
+        bool scanout = bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_DISPLAY_TARGET);
+        if (scanout && !util_format_is_rgba8_variant(format_desc))
+                return FALSE;
 
-        if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
+        if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
+                        format_desc->layout != UTIL_FORMAT_LAYOUT_OTHER) {
                 /* Compressed formats not yet hooked up. */
                 return FALSE;
         }