asahi: Use pixel table in is_format_supported

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11086>
This commit is contained in:
Alyssa Rosenzweig 2021-05-31 15:34:40 -04:00 committed by Marge Bot
parent 8b1e273cb5
commit f690d1f7ab
2 changed files with 20 additions and 6 deletions

View file

@ -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

View file

@ -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) {