#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;
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
#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"},
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) {