v3d: restrict formats supported for PIPE_BIND_SHADER_IMAGE
authorAlejandro Piñeiro <apinheiro@igalia.com>
Sun, 5 Sep 2021 23:12:52 +0000 (01:12 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Dec 2021 15:32:36 +0000 (15:32 +0000)
So far we were relying on the supported formats filtering when
creating images from the user API.

But for some other (internal) uses, some of the formats that pass the
filter need to be restricted when binding them as shader images, as they
are not supported for this case.

v3 (Iago):
 - Change commit message.

Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13409>

src/gallium/drivers/v3d/v3d_screen.c

index 1c72dc4..69aa824 100644 (file)
@@ -652,6 +652,23 @@ v3d_screen_is_format_supported(struct pipe_screen *pscreen,
                 return false;
         }
 
+        if (usage & PIPE_BIND_SHADER_IMAGE) {
+                switch (format) {
+                /* FIXME: maybe we can implement a swizzle-on-writes to add
+                 * support for BGRA-alike formats.
+                 */
+                case PIPE_FORMAT_A4B4G4R4_UNORM:
+                case PIPE_FORMAT_A1B5G5R5_UNORM:
+                case PIPE_FORMAT_B5G6R5_UNORM:
+                case PIPE_FORMAT_B8G8R8A8_UNORM:
+                case PIPE_FORMAT_X8Z24_UNORM:
+                case PIPE_FORMAT_Z16_UNORM:
+                        return false;
+                default:
+                        return true;
+                }
+        }
+
         return true;
 }