panfrost: Advertise support for other 8-bit UNORM formats
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Jun 2019 14:01:52 +0000 (07:01 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Jun 2019 20:39:18 +0000 (13:39 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_screen.c

index 1ae01d5a4f0eba7a75b40d8ee926a38d3d5bd7ce..b7dd16a38bc6f88e1743b9153dd677f8fbe389c3 100644 (file)
@@ -459,16 +459,24 @@ panfrost_is_format_supported( struct pipe_screen *screen,
                 return FALSE;
 
         if (bind & PIPE_BIND_RENDER_TARGET) {
-                /* TODO: Support all the formats! :) */
-                bool supported = util_format_is_rgba8_variant(format_desc);
-                supported |= format == PIPE_FORMAT_B5G6R5_UNORM;
-
-                if (!supported)
-                        return FALSE;
-
                 if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
                         return FALSE;
 
+                if (format == PIPE_FORMAT_B5G6R5_UNORM)
+                        return TRUE;
+
+                /* 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
@@ -491,25 +499,6 @@ panfrost_is_format_supported( struct pipe_screen *screen,
                 return FALSE;
         }
 
-        if ((bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) &&
-                        ((bind & PIPE_BIND_DISPLAY_TARGET) == 0) &&
-                        target != PIPE_BUFFER) {
-                const struct util_format_description *desc =
-                        util_format_description(format);
-
-                if (desc->nr_channels == 3 && desc->is_array) {
-                        /* Don't support any 3-component formats for rendering/texturing
-                         * since we don't support the corresponding 8-bit 3 channel UNORM
-                         * formats.  This allows us to support GL_ARB_copy_image between
-                         * GL_RGB8 and GL_RGB8UI, for example.  Otherwise, we may be asked to
-                         * do a resource copy between PIPE_FORMAT_R8G8B8_UINT and
-                         * PIPE_FORMAT_R8G8B8X8_UNORM, for example, which will not work
-                         * (different bpp).
-                         */
-                        return FALSE;
-                }
-        }
-
         return TRUE;
 }