tgsi: use enum for tgsi-file type

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24002>
This commit is contained in:
Erik Faye-Lund
2023-06-26 11:21:08 +02:00
committed by Marge Bot
parent 32f40b2e81
commit 5ccf63dc9d
6 changed files with 43 additions and 28 deletions
+7 -5
View File
@@ -119,7 +119,7 @@ tgsi_default_declaration( void )
static struct tgsi_declaration
tgsi_build_declaration(
unsigned file,
enum tgsi_file_type file,
unsigned usage_mask,
unsigned interpolate,
unsigned dimension,
@@ -809,7 +809,9 @@ tgsi_default_texture_offset( void )
static struct tgsi_texture_offset
tgsi_build_texture_offset(
int index, int file, int swizzle_x, int swizzle_y, int swizzle_z,
int index,
enum tgsi_file_type file,
int swizzle_x, int swizzle_y, int swizzle_z,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
{
@@ -848,7 +850,7 @@ tgsi_default_src_register( void )
static struct tgsi_src_register
tgsi_build_src_register(
unsigned file,
enum tgsi_file_type file,
unsigned swizzle_x,
unsigned swizzle_y,
unsigned swizzle_z,
@@ -902,7 +904,7 @@ tgsi_default_ind_register( void )
static struct tgsi_ind_register
tgsi_build_ind_register(
unsigned file,
enum tgsi_file_type file,
unsigned swizzle,
int index,
unsigned arrayid,
@@ -987,7 +989,7 @@ tgsi_default_dst_register( void )
static struct tgsi_dst_register
tgsi_build_dst_register(
unsigned file,
enum tgsi_file_type file,
unsigned mask,
unsigned indirect,
unsigned dimension,
@@ -114,7 +114,8 @@ remove_dynamic_indexes(struct tgsi_transform_context *ctx,
int imm_index = dc->orig_num_imm;
struct tgsi_full_instruction inst;
unsigned INVALID_INDEX = 99999;
unsigned file = TGSI_FILE_NULL, index = INVALID_INDEX;
enum tgsi_file_type file = TGSI_FILE_NULL;
unsigned index = INVALID_INDEX;
unsigned imm_swz_index = INVALID_INDEX;
/* calculate dynamic array index store it in tmp_arrayIdx.x */
+5 -5
View File
@@ -75,7 +75,7 @@ scan_register_key(const scan_register *reg)
static void
fill_scan_register1d(scan_register *reg,
uint file, uint index)
enum tgsi_file_type file, uint index)
{
reg->file = file;
reg->dimensions = 1;
@@ -85,7 +85,7 @@ fill_scan_register1d(scan_register *reg,
static void
fill_scan_register2d(scan_register *reg,
uint file, uint index1, uint index2)
enum tgsi_file_type file, uint index1, uint index2)
{
reg->file = file;
reg->dimensions = 2;
@@ -188,7 +188,7 @@ report_warning(
static bool
check_file_name(
struct sanity_check_ctx *ctx,
uint file )
enum tgsi_file_type file )
{
if (file <= TGSI_FILE_NULL || file >= TGSI_FILE_COUNT) {
report_error( ctx, "(%u): Invalid register file name", file );
@@ -211,7 +211,7 @@ is_register_declared(
static bool
is_any_register_declared(
struct sanity_check_ctx *ctx,
uint file )
enum tgsi_file_type file )
{
struct cso_hash_iter iter =
cso_hash_first_node(&ctx->regs_decl);
@@ -393,7 +393,7 @@ iter_declaration(
struct tgsi_full_declaration *decl )
{
struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
uint file;
enum tgsi_file_type file;
uint i;
/* No declarations allowed after the first instruction.
+15 -3
View File
@@ -45,7 +45,7 @@
static bool
is_memory_file(unsigned file)
is_memory_file(enum tgsi_file_type file)
{
return file == TGSI_FILE_SAMPLER ||
file == TGSI_FILE_SAMPLER_VIEW ||
@@ -604,7 +604,7 @@ static void
scan_declaration(struct tgsi_shader_info *info,
const struct tgsi_full_declaration *fulldecl)
{
const uint file = fulldecl->Declaration.File;
enum tgsi_file_type file = fulldecl->Declaration.File;
const unsigned procType = info->processor;
uint reg;
@@ -620,6 +620,12 @@ scan_declaration(struct tgsi_shader_info *info,
assert(array_id < ARRAY_SIZE(info->output_array_first));
info->output_array_first[array_id] = fulldecl->Range.First;
break;
case TGSI_FILE_NULL:
unreachable("unexpected file");
default:
break;
}
info->array_max[file] = MAX2(info->array_max[file], array_id);
}
@@ -811,6 +817,12 @@ scan_declaration(struct tgsi_shader_info *info,
assert(info->sampler_type[reg] == type);
}
break;
case TGSI_FILE_NULL:
unreachable("unexpected file");
default:
break;
}
}
}
@@ -820,7 +832,7 @@ static void
scan_immediate(struct tgsi_shader_info *info)
{
uint reg = info->immediate_count++;
uint file = TGSI_FILE_IMMEDIATE;
enum tgsi_file_type file = TGSI_FILE_IMMEDIATE;
info->file_mask[file] |= (1 << reg);
info->file_count[file]++;
+1 -1
View File
@@ -190,7 +190,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
struct tgsi_shader_info *info);
static inline bool
tgsi_is_bindless_image_file(unsigned file)
tgsi_is_bindless_image_file(enum tgsi_file_type file)
{
return file != TGSI_FILE_IMAGE &&
file != TGSI_FILE_MEMORY &&
+13 -13
View File
@@ -379,9 +379,9 @@ static bool parse_label( struct translate_ctx *ctx, uint *val )
}
static bool
parse_file( const char **pcur, uint *file )
parse_file( const char **pcur, enum tgsi_file_type *file )
{
uint i;
enum tgsi_file_type i;
for (i = 0; i < TGSI_FILE_COUNT; i++) {
const char *cur = *pcur;
@@ -444,7 +444,7 @@ parse_opt_writemask(
static bool
parse_register_file_bracket(
struct translate_ctx *ctx,
uint *file )
enum tgsi_file_type *file )
{
if (!parse_file( &ctx->cur, file )) {
report_error( ctx, "Unknown register file" );
@@ -464,7 +464,7 @@ parse_register_file_bracket(
static bool
parse_register_file_bracket_index(
struct translate_ctx *ctx,
uint *file,
enum tgsi_file_type *file,
int *index )
{
uint uindex;
@@ -485,7 +485,7 @@ parse_register_file_bracket_index(
*/
static bool
parse_register_1d(struct translate_ctx *ctx,
uint *file,
enum tgsi_file_type *file,
int *index )
{
if (!parse_register_file_bracket_index( ctx, file, index ))
@@ -502,7 +502,7 @@ parse_register_1d(struct translate_ctx *ctx,
struct parsed_bracket {
int index;
uint ind_file;
enum tgsi_file_type ind_file;
int ind_index;
uint ind_comp;
uint ind_array;
@@ -624,7 +624,7 @@ parse_opt_register_src_bracket(
static bool
parse_register_src(
struct translate_ctx *ctx,
uint *file,
enum tgsi_file_type *file,
struct parsed_bracket *brackets)
{
brackets->ind_comp = TGSI_SWIZZLE_X;
@@ -698,7 +698,7 @@ cleanup:
static bool
parse_register_dcl(
struct translate_ctx *ctx,
uint *file,
enum tgsi_file_type *file,
struct parsed_dcl_bracket *brackets,
int *num_brackets)
{
@@ -749,7 +749,7 @@ parse_register_dcl(
static bool
parse_register_dst(
struct translate_ctx *ctx,
uint *file,
enum tgsi_file_type *file,
struct parsed_bracket *brackets)
{
brackets->ind_comp = TGSI_SWIZZLE_X;
@@ -766,7 +766,7 @@ parse_dst_operand(
struct translate_ctx *ctx,
struct tgsi_full_dst_register *dst )
{
uint file;
enum tgsi_file_type file;
uint writemask;
const char *cur;
struct parsed_bracket bracket[2];
@@ -854,7 +854,7 @@ parse_src_operand(
struct translate_ctx *ctx,
struct tgsi_full_src_register *src )
{
uint file;
enum tgsi_file_type file;
uint swizzle[4];
bool parsed_swizzle;
struct parsed_bracket bracket[2];
@@ -930,7 +930,7 @@ parse_texoffset_operand(
struct translate_ctx *ctx,
struct tgsi_texture_offset *src )
{
uint file;
enum tgsi_file_type file;
uint swizzle[3];
bool parsed_swizzle;
struct parsed_bracket bracket;
@@ -1241,7 +1241,7 @@ static bool parse_immediate_data(struct translate_ctx *ctx, unsigned type,
static bool parse_declaration( struct translate_ctx *ctx )
{
struct tgsi_full_declaration decl;
uint file;
enum tgsi_file_type file;
struct parsed_dcl_bracket brackets[2];
int num_brackets;
uint writemask;