agx: Add helper to map pipe formats to agx_formats

Or a restricted subset thereof anyway.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19871>
This commit is contained in:
Alyssa Rosenzweig
2022-11-19 11:22:43 -05:00
committed by Marge Bot
parent db0461a8d0
commit 0e106681e0

View File

@@ -31,6 +31,7 @@
#include "agx_compile.h"
#include "agx_compiler.h"
#include "agx_builder.h"
#include "agx_internal_formats.h"
/* Alignment for shader programs. I'm not sure what the optimal value is. */
#define AGX_CODE_ALIGN 0x100
@@ -333,6 +334,30 @@ agx_udiv_const(agx_builder *b, agx_index P, uint32_t Q)
return n;
}
static enum agx_format
agx_format_for_pipe(enum pipe_format format)
{
#define CASE(x) \
if (format == (enum pipe_format) AGX_INTERNAL_FORMAT_##x) \
return AGX_FORMAT_##x;
CASE(I8);
CASE(I16);
CASE(I32);
CASE(F16);
CASE(U8NORM);
CASE(S8NORM);
CASE(U16NORM);
CASE(S16NORM);
CASE(RGB10A2);
CASE(SRGBA8);
CASE(RG11B10F);
CASE(RGB9E5);
#undef CASE
unreachable("Invalid format");
}
/* AGX appears to lack support for vertex attributes. Lower to global loads. */
static void
agx_emit_load_attr(agx_builder *b, agx_index dest, nir_intrinsic_instr *instr)