From: Alyssa Rosenzweig Date: Mon, 31 May 2021 19:34:40 +0000 (-0400) Subject: asahi: Use pixel table in is_format_supported X-Git-Tag: upstream/21.2.3~2682 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f690d1f7ab5103f825393ab57a3c8e1401579042;p=platform%2Fupstream%2Fmesa.git asahi: Use pixel table in is_format_supported Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/asahi/lib/agx_formats.h b/src/asahi/lib/agx_formats.h index 052e30d..2ed84a1 100644 --- a/src/asahi/lib/agx_formats.h +++ b/src/asahi/lib/agx_formats.h @@ -28,9 +28,6 @@ #include "util/format/u_format.h" #include "asahi/compiler/agx_compile.h" -/* N.b. hardware=0 corresponds to R8 UNORM, which is renderable. So a zero - * entry indicates an invalid format. */ - struct agx_pixel_format_entry { uint16_t hw; bool renderable : 1; @@ -39,4 +36,14 @@ struct agx_pixel_format_entry { extern const struct agx_pixel_format_entry agx_pixel_format[PIPE_FORMAT_COUNT]; extern const enum agx_format agx_vertex_format[PIPE_FORMAT_COUNT]; +/* N.b. hardware=0 corresponds to R8 UNORM, which is renderable. So a zero + * entry indicates an invalid format. */ + +static inline bool +agx_is_valid_pixel_format(enum pipe_format format) +{ + struct agx_pixel_format_entry entry = agx_pixel_format[format]; + return (entry.hw != 0) || entry.renderable; +} + #endif diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index e306375..17dd911 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -43,6 +43,7 @@ #include "asahi/compiler/agx_compile.h" #include "asahi/lib/decode.h" #include "asahi/lib/tiling.h" +#include "asahi/lib/agx_formats.h" static const struct debug_named_value agx_debug_options[] = { {"trace", AGX_DBG_TRACE, "Trace the command stream"}, @@ -904,9 +905,15 @@ agx_is_format_supported(struct pipe_screen* pscreen, if (MAX2(sample_count, 1) != MAX2(storage_sample_count, 1)) return false; - /* TODO: formats */ - if (usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) - return (format == PIPE_FORMAT_B8G8R8A8_UNORM); + if (usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) { + struct agx_pixel_format_entry ent = agx_pixel_format[format]; + + if (!agx_is_valid_pixel_format(format)) + return false; + + if ((usage & PIPE_BIND_RENDER_TARGET) && !ent.renderable) + return false; + } /* TODO: formats */ if (usage & PIPE_BIND_VERTEX_BUFFER) {