diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 3196524a681..e51119ef530 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -989,23 +989,23 @@ agx_tex_dim(enum glsl_sampler_dim dim, bool array) switch (dim) { case GLSL_SAMPLER_DIM_1D: case GLSL_SAMPLER_DIM_BUF: - return array ? AGX_DIM_TEX_1D_ARRAY : AGX_DIM_TEX_1D; + return array ? AGX_DIM_1D_ARRAY : AGX_DIM_1D; case GLSL_SAMPLER_DIM_2D: case GLSL_SAMPLER_DIM_RECT: case GLSL_SAMPLER_DIM_EXTERNAL: - return array ? AGX_DIM_TEX_2D_ARRAY : AGX_DIM_TEX_2D; + return array ? AGX_DIM_2D_ARRAY : AGX_DIM_2D; case GLSL_SAMPLER_DIM_MS: assert(!array && "multisampled arrays unsupported"); - return AGX_DIM_TEX_2D_MS; + return AGX_DIM_2D_MS; case GLSL_SAMPLER_DIM_3D: assert(!array && "3D arrays unsupported"); - return AGX_DIM_TEX_3D; + return AGX_DIM_3D; case GLSL_SAMPLER_DIM_CUBE: - return array ? AGX_DIM_TEX_CUBE_ARRAY : AGX_DIM_TEX_CUBE; + return array ? AGX_DIM_CUBE_ARRAY : AGX_DIM_CUBE; default: unreachable("Invalid sampler dim\n"); diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index 86af91262e8..bc0bb8b6533 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -257,17 +257,6 @@ enum agx_lod_mode { AGX_LOD_MODE_LOD_GRAD_MIN = 12 }; -enum agx_dim { - AGX_DIM_TEX_1D = 0, - AGX_DIM_TEX_1D_ARRAY = 1, - AGX_DIM_TEX_2D = 2, - AGX_DIM_TEX_2D_ARRAY = 3, - AGX_DIM_TEX_2D_MS = 4, - AGX_DIM_TEX_3D = 5, - AGX_DIM_TEX_CUBE = 6, - AGX_DIM_TEX_CUBE_ARRAY = 7 -}; - /* Forward declare for branch target */ struct agx_block; diff --git a/src/asahi/compiler/agx_opcodes.h.py b/src/asahi/compiler/agx_opcodes.h.py index 55e5839445e..9b7b7b90fdb 100644 --- a/src/asahi/compiler/agx_opcodes.h.py +++ b/src/asahi/compiler/agx_opcodes.h.py @@ -26,6 +26,7 @@ template = """/* #include #include +#include "util/macros.h" /* Listing of opcodes */ @@ -38,10 +39,22 @@ enum agx_opcode { % for name in enums: enum agx_${name} { -% for k in enums[name]: - AGX_${name.upper()}_${enums[name][k].replace('.', '_').upper()} = ${k}, +% for k, v in enums[name].items(): + AGX_${name.upper()}_${v.replace('.', '_').upper()} = ${k}, % endfor }; + +static inline const char * +agx_${name}_as_str(enum agx_${name} x) +{ + switch (x) { +% for k, v in enums[name].items(): + case AGX_${name.upper()}_${v.replace('.', '_').upper()}: return "${v}"; +% endfor + default: unreachable("Nonexhaustive enum"); + } +} + % endfor /* Runtime accessible info on each defined opcode */ diff --git a/src/asahi/compiler/agx_opcodes.py b/src/asahi/compiler/agx_opcodes.py index 98eb6af6e55..52f43e2328b 100644 --- a/src/asahi/compiler/agx_opcodes.py +++ b/src/asahi/compiler/agx_opcodes.py @@ -93,7 +93,18 @@ SHIFT = immediate("shift") MASK = immediate("mask") BFI_MASK = immediate("bfi_mask") LOD_MODE = immediate("lod_mode", "enum agx_lod_mode") -DIM = immediate("dim", "enum agx_dim") + +DIM = enum("dim", { + 0: '1d', + 1: '1d_array', + 2: '2d', + 3: '2d_array', + 4: '2d_ms', + 5: '3d', + 6: 'cube', + 7: 'cube_array' +}) + OFFSET = immediate("offset", "bool") SHADOW = immediate("shadow", "bool") SCOREBOARD = immediate("scoreboard") diff --git a/src/asahi/compiler/agx_print.c b/src/asahi/compiler/agx_print.c index 852d7b7a65c..51ba9dbcdc6 100644 --- a/src/asahi/compiler/agx_print.c +++ b/src/asahi/compiler/agx_print.c @@ -173,7 +173,7 @@ agx_print_instr(agx_instr *I, FILE *fp) else print_comma = true; - fprintf(fp, "dim %u", I->dim); // TODO enumify + fputs(agx_dim_as_str(I->dim), fp); } if (info.immediates & AGX_IMMEDIATE_SCOREBOARD) {