agx: Print agx_dim appropriately

Easier to read, and gets us closer to proper disasm in Mesa.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18804>
This commit is contained in:
Alyssa Rosenzweig
2022-09-23 23:15:10 -04:00
committed by Marge Bot
parent 6c95572ef0
commit f665229d77
5 changed files with 33 additions and 20 deletions

View File

@@ -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");

View File

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

View File

@@ -26,6 +26,7 @@ template = """/*
#include <stdbool.h>
#include <stdint.h>
#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 */

View File

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

View File

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