summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-06-06 09:46:40 -0600
committerBrian Paul <[email protected]>2013-06-07 09:23:24 -0600
commit14541dacab218cbe82310d999d44130ebc3f6526 (patch)
tree1295e6f153bf8c3276f12ad51837bef67a4a81d4 /src/gallium
parent97d641eb229e48cacc448eefb583381a27bd8af1 (diff)
tgsi: replace tgsi_file_names tgsi_file_names[] with tgsi_file_name() function
This change came from the discovery that the STATIC_ASSERT to check that the number of register file strings didn't actually work. Similar changes could be made for the other string arrays in tgsi_string.c Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c16
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.c14
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.h6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_compiler.c4
-rw-r--r--src/gallium/drivers/ilo/shader/toy_tgsi.c4
7 files changed, 30 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
index b00aa094d38..184790b702f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
@@ -433,7 +433,7 @@ dump_info(const struct tgsi_token *tokens,
&tex_info->coord[chan];
if (chan_info->file != TGSI_FILE_NULL) {
debug_printf(" %s[%u].%c",
- tgsi_file_names[chan_info->file],
+ tgsi_file_name(chan_info->file),
chan_info->u.index,
"xyzw01"[chan_info->swizzle]);
} else {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 77b75b1e0bf..7f6a3d8ad8f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -99,11 +99,11 @@ _dump_register_src(
struct dump_ctx *ctx,
const struct tgsi_full_src_register *src )
{
- ENM(src->Register.File, tgsi_file_names);
+ TXT(tgsi_file_name(src->Register.File));
if (src->Register.Dimension) {
if (src->Dimension.Indirect) {
CHR( '[' );
- ENM( src->DimIndirect.File, tgsi_file_names );
+ TXT(tgsi_file_name(src->DimIndirect.File));
CHR( '[' );
SID( src->DimIndirect.Index );
TXT( "]." );
@@ -127,7 +127,7 @@ _dump_register_src(
}
if (src->Register.Indirect) {
CHR( '[' );
- ENM( src->Indirect.File, tgsi_file_names );
+ TXT(tgsi_file_name(src->Indirect.File));
CHR( '[' );
SID( src->Indirect.Index );
TXT( "]." );
@@ -156,11 +156,11 @@ _dump_register_dst(
struct dump_ctx *ctx,
const struct tgsi_full_dst_register *dst )
{
- ENM(dst->Register.File, tgsi_file_names);
+ TXT(tgsi_file_name(dst->Register.File));
if (dst->Register.Dimension) {
if (dst->Dimension.Indirect) {
CHR( '[' );
- ENM( dst->DimIndirect.File, tgsi_file_names );
+ TXT(tgsi_file_name(dst->DimIndirect.File));
CHR( '[' );
SID( dst->DimIndirect.Index );
TXT( "]." );
@@ -184,7 +184,7 @@ _dump_register_dst(
}
if (dst->Register.Indirect) {
CHR( '[' );
- ENM( dst->Indirect.File, tgsi_file_names );
+ TXT(tgsi_file_name(dst->Indirect.File));
CHR( '[' );
SID( dst->Indirect.Index );
TXT( "]." );
@@ -266,7 +266,7 @@ iter_declaration(
TXT( "DCL " );
- ENM(decl->Declaration.File, tgsi_file_names);
+ TXT(tgsi_file_name(decl->Declaration.File));
/* all geometry shader inputs are two dimensional */
if (decl->Declaration.File == TGSI_FILE_INPUT &&
@@ -576,7 +576,7 @@ iter_instruction(
ENM( inst->Texture.Texture, tgsi_texture_names );
for (i = 0; i < inst->Texture.NumOffsets; i++) {
TXT( ", " );
- ENM( inst->TexOffsets[i].File, tgsi_file_names);
+ TXT(tgsi_file_name(inst->TexOffsets[i].File));
CHR( '[' );
SID( inst->TexOffsets[i].Index );
CHR( ']' );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index d8caae5a606..27856767877 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -40,7 +40,7 @@ const char *tgsi_processor_type_names[4] =
"COMP"
};
-const char *tgsi_file_names[TGSI_FILE_COUNT] =
+static const char *tgsi_file_names[] =
{
"NULL",
"CONST",
@@ -176,7 +176,6 @@ const char *tgsi_immediate_type_names[3] =
static INLINE void
tgsi_strings_check(void)
{
- STATIC_ASSERT(Elements(tgsi_file_names) == TGSI_FILE_COUNT);
STATIC_ASSERT(Elements(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT);
STATIC_ASSERT(Elements(tgsi_texture_names) == TGSI_TEXTURE_COUNT);
STATIC_ASSERT(Elements(tgsi_property_names) == TGSI_PROPERTY_COUNT);
@@ -188,3 +187,14 @@ tgsi_strings_check(void)
(void) tgsi_fs_coord_origin_names;
(void) tgsi_fs_coord_pixel_center_names;
}
+
+
+const char *
+tgsi_file_name(unsigned file)
+{
+ STATIC_ASSERT(Elements(tgsi_file_names) == TGSI_FILE_COUNT);
+ if (file < Elements(tgsi_file_names))
+ return tgsi_file_names[file];
+ else
+ return "invalid file";
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.h b/src/gallium/auxiliary/tgsi/tgsi_strings.h
index 5c57e229c28..43576465790 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.h
@@ -40,8 +40,6 @@ extern "C" {
extern const char *tgsi_processor_type_names[4];
-extern const char *tgsi_file_names[TGSI_FILE_COUNT];
-
extern const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT];
extern const char *tgsi_texture_names[TGSI_TEXTURE_COUNT];
@@ -61,6 +59,10 @@ extern const char *tgsi_fs_coord_pixel_center_names[2];
extern const char *tgsi_immediate_type_names[3];
+const char *
+tgsi_file_name(unsigned file);
+
+
#if defined __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 187e23ede26..688c5bc9d8d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -322,7 +322,7 @@ parse_file( const char **pcur, uint *file )
for (i = 0; i < TGSI_FILE_COUNT; i++) {
const char *cur = *pcur;
- if (str_match_nocase_whole( &cur, tgsi_file_names[i] )) {
+ if (str_match_nocase_whole( &cur, tgsi_file_name(i) )) {
*pcur = cur;
*file = i;
return TRUE;
diff --git a/src/gallium/drivers/freedreno/freedreno_compiler.c b/src/gallium/drivers/freedreno/freedreno_compiler.c
index 1a596f50f6b..8d1e266d46a 100644
--- a/src/gallium/drivers/freedreno/freedreno_compiler.c
+++ b/src/gallium/drivers/freedreno/freedreno_compiler.c
@@ -339,7 +339,7 @@ add_dst_reg(struct fd_compile_context *ctx, struct ir2_instruction *alu,
break;
default:
DBG("unsupported dst register file: %s",
- tgsi_file_names[dst->File]);
+ tgsi_file_name(dst->File));
assert(0);
break;
}
@@ -385,7 +385,7 @@ add_src_reg(struct fd_compile_context *ctx, struct ir2_instruction *alu,
break;
default:
DBG("unsupported src register file: %s",
- tgsi_file_names[src->File]);
+ tgsi_file_name(src->File));
assert(0);
break;
}
diff --git a/src/gallium/drivers/ilo/shader/toy_tgsi.c b/src/gallium/drivers/ilo/shader/toy_tgsi.c
index 045d279ef8c..ad6161d5894 100644
--- a/src/gallium/drivers/ilo/shader/toy_tgsi.c
+++ b/src/gallium/drivers/ilo/shader/toy_tgsi.c
@@ -2565,11 +2565,11 @@ dump_reg_mapping(void *key, void *val, void *data)
if (tgsi_dim) {
ilo_printf(" v%d:\t%s[%d][%d]\n", vrf,
- tgsi_file_names[tgsi_file], tgsi_dim, tgsi_index);
+ tgsi_file_name(tgsi_file), tgsi_dim, tgsi_index);
}
else {
ilo_printf(" v%d:\t%s[%d]\n", vrf,
- tgsi_file_names[tgsi_file], tgsi_index);
+ tgsi_file_name(tgsi_file), tgsi_index);
}
return PIPE_OK;