summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-01-05 08:30:00 -0700
committerBrian Paul <[email protected]>2012-01-05 09:01:43 -0700
commit85b5dac705fcf3fafb734696e1f863cfc21e2d6e (patch)
treefe4596433fca3a13756e90a94aa57ac0a8bc8235 /src/gallium/auxiliary/tgsi
parent188aca34923d109323e0e1a882c69f2b422b5cae (diff)
tgsi: consolidate TGSI string arrays in new tgsi_strings.h
There was some duplication between the tgsi_dump.c and tgsi_text.c files. Also use some static assertions to help catch errors when adding new TGSI values. v2: put strings in tgsi_strings.c file instead of the .h file. Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c139
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.h21
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.c172
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.h69
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c84
5 files changed, 253 insertions, 232 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index e830aa53f20..99634457ecd 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -32,6 +32,7 @@
#include "tgsi_dump.h"
#include "tgsi_info.h"
#include "tgsi_iterate.h"
+#include "tgsi_strings.h"
/** Number of spaces to indent for IF/LOOP/etc */
@@ -83,62 +84,6 @@ dump_enum(
#define FLT(F) ctx->printf( ctx, "%10.4f", F )
#define ENM(E,ENUMS) dump_enum( ctx, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
-static const char *processor_type_names[] =
-{
- "FRAG",
- "VERT",
- "GEOM"
-};
-
-const char *
-tgsi_file_names[TGSI_FILE_COUNT] =
-{
- "NULL",
- "CONST",
- "IN",
- "OUT",
- "TEMP",
- "SAMP",
- "ADDR",
- "IMM",
- "PRED",
- "SV",
- "IMMX",
- "TEMPX",
- "RES"
-};
-
-static const char *interpolate_names[] =
-{
- "CONSTANT",
- "LINEAR",
- "PERSPECTIVE"
-};
-
-static const char *semantic_names[] =
-{
- "POSITION",
- "COLOR",
- "BCOLOR",
- "FOG",
- "PSIZE",
- "GENERIC",
- "NORMAL",
- "FACE",
- "EDGEFLAG",
- "PRIM_ID",
- "INSTANCEID",
- "VERTEXID",
- "STENCIL"
-};
-
-static const char *immediate_type_names[] =
-{
- "FLT32",
- "UINT32",
- "INT32"
-};
-
const char *
tgsi_swizzle_names[4] =
{
@@ -148,75 +93,6 @@ tgsi_swizzle_names[4] =
"w"
};
-const char *
-tgsi_texture_names[TGSI_TEXTURE_COUNT] =
-{
- "UNKNOWN",
- "1D",
- "2D",
- "3D",
- "CUBE",
- "RECT",
- "SHADOW1D",
- "SHADOW2D",
- "SHADOWRECT",
- "1DARRAY",
- "2DARRAY",
- "SHADOW1DARRAY",
- "SHADOW2DARRAY",
-};
-
-const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
-{
- "GS_INPUT_PRIMITIVE",
- "GS_OUTPUT_PRIMITIVE",
- "GS_MAX_OUTPUT_VERTICES",
- "FS_COORD_ORIGIN",
- "FS_COORD_PIXEL_CENTER",
- "FS_COLOR0_WRITES_ALL_CBUFS",
- "FS_DEPTH_LAYOUT"
-};
-
-static const char *tgsi_type_names[] =
-{
- "UNORM",
- "SNORM",
- "SINT",
- "UINT",
- "FLOAT"
-};
-
-const char *tgsi_primitive_names[PIPE_PRIM_MAX] =
-{
- "POINTS",
- "LINES",
- "LINE_LOOP",
- "LINE_STRIP",
- "TRIANGLES",
- "TRIANGLE_STRIP",
- "TRIANGLE_FAN",
- "QUADS",
- "QUAD_STRIP",
- "POLYGON",
- "LINES_ADJACENCY",
- "LINE_STRIP_ADJACENCY",
- "TRIANGLES_ADJACENCY",
- "TRIANGLE_STRIP_ADJACENCY"
-};
-
-const char *tgsi_fs_coord_origin_names[2] =
-{
- "UPPER_LEFT",
- "LOWER_LEFT"
-};
-
-const char *tgsi_fs_coord_pixel_center_names[2] =
-{
- "HALF_INTEGER",
- "INTEGER"
-};
-
-
static void
_dump_register_src(
struct dump_ctx *ctx,
@@ -367,9 +243,6 @@ iter_declaration(
{
struct dump_ctx *ctx = (struct dump_ctx *)iter;
- assert(Elements(semantic_names) == TGSI_SEMANTIC_COUNT);
- assert(Elements(interpolate_names) == TGSI_INTERPOLATE_COUNT);
-
TXT( "DCL " );
ENM(decl->Declaration.File, tgsi_file_names);
@@ -400,7 +273,7 @@ iter_declaration(
if (decl->Declaration.Semantic) {
TXT( ", " );
- ENM( decl->Semantic.Name, semantic_names );
+ ENM( decl->Semantic.Name, tgsi_semantic_names );
if (decl->Semantic.Index != 0 ||
decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
CHR( '[' );
@@ -433,7 +306,7 @@ iter_declaration(
decl->Declaration.File == TGSI_FILE_INPUT)
{
TXT( ", " );
- ENM( decl->Declaration.Interpolate, interpolate_names );
+ ENM( decl->Declaration.Interpolate, tgsi_interpolate_names );
}
if (decl->Declaration.Centroid) {
@@ -521,8 +394,6 @@ iter_property(
int i;
struct dump_ctx *ctx = (struct dump_ctx *)iter;
- assert(Elements(tgsi_property_names) == TGSI_PROPERTY_COUNT);
-
TXT( "PROPERTY " );
ENM(prop->Property.PropertyName, tgsi_property_names);
@@ -571,7 +442,7 @@ iter_immediate(
struct dump_ctx *ctx = (struct dump_ctx *) iter;
TXT( "IMM " );
- ENM( imm->Immediate.DataType, immediate_type_names );
+ ENM( imm->Immediate.DataType, tgsi_immediate_type_names );
dump_imm_data(iter, imm->u, imm->Immediate.NrTokens - 1,
imm->Immediate.DataType);
@@ -753,7 +624,7 @@ prolog(
struct tgsi_iterate_context *iter )
{
struct dump_ctx *ctx = (struct dump_ctx *) iter;
- ENM( iter->processor.Processor, processor_type_names );
+ ENM( iter->processor.Processor, tgsi_processor_type_names );
EOL();
return TRUE;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.h b/src/gallium/auxiliary/tgsi/tgsi_dump.h
index 2491e9198a2..adaef9d89fe 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h
@@ -36,27 +36,6 @@
extern "C" {
#endif
-extern const char *
-tgsi_file_names[TGSI_FILE_COUNT];
-
-extern const char *
-tgsi_swizzle_names[4];
-
-extern const char *
-tgsi_texture_names[TGSI_TEXTURE_COUNT];
-
-extern const char *
-tgsi_property_names[TGSI_PROPERTY_COUNT];
-
-extern const char *
-tgsi_primitive_names[PIPE_PRIM_MAX];
-
-extern const char *
-tgsi_fs_coord_origin_names[2];
-
-extern const char *
-tgsi_fs_coord_pixel_center_names[2];
-
void
tgsi_dump_str(
const struct tgsi_token *tokens,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
new file mode 100644
index 00000000000..ee4ce080cbe
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -0,0 +1,172 @@
+/**************************************************************************
+ *
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "tgsi_strings.h"
+
+
+const char *tgsi_processor_type_names[3] =
+{
+ "FRAG",
+ "VERT",
+ "GEOM"
+};
+
+const char *tgsi_file_names[TGSI_FILE_COUNT] =
+{
+ "NULL",
+ "CONST",
+ "IN",
+ "OUT",
+ "TEMP",
+ "SAMP",
+ "ADDR",
+ "IMM",
+ "PRED",
+ "SV",
+ "IMMX",
+ "TEMPX",
+ "RES"
+};
+
+const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
+{
+ "POSITION",
+ "COLOR",
+ "BCOLOR",
+ "FOG",
+ "PSIZE",
+ "GENERIC",
+ "NORMAL",
+ "FACE",
+ "EDGEFLAG",
+ "PRIM_ID",
+ "INSTANCEID",
+ "VERTEXID",
+ "STENCIL"
+};
+
+const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =
+{
+ "UNKNOWN",
+ "1D",
+ "2D",
+ "3D",
+ "CUBE",
+ "RECT",
+ "SHADOW1D",
+ "SHADOW2D",
+ "SHADOWRECT",
+ "1DARRAY",
+ "2DARRAY",
+ "SHADOW1DARRAY",
+ "SHADOW2DARRAY",
+};
+
+const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
+{
+ "GS_INPUT_PRIMITIVE",
+ "GS_OUTPUT_PRIMITIVE",
+ "GS_MAX_OUTPUT_VERTICES",
+ "FS_COORD_ORIGIN",
+ "FS_COORD_PIXEL_CENTER",
+ "FS_COLOR0_WRITES_ALL_CBUFS",
+ "FS_DEPTH_LAYOUT"
+};
+
+const char *tgsi_type_names[5] =
+{
+ "UNORM",
+ "SNORM",
+ "SINT",
+ "UINT",
+ "FLOAT"
+};
+
+const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT] =
+{
+ "CONSTANT",
+ "LINEAR",
+ "PERSPECTIVE"
+};
+
+const char *tgsi_primitive_names[PIPE_PRIM_MAX] =
+{
+ "POINTS",
+ "LINES",
+ "LINE_LOOP",
+ "LINE_STRIP",
+ "TRIANGLES",
+ "TRIANGLE_STRIP",
+ "TRIANGLE_FAN",
+ "QUADS",
+ "QUAD_STRIP",
+ "POLYGON",
+ "LINES_ADJACENCY",
+ "LINE_STRIP_ADJACENCY",
+ "TRIANGLES_ADJACENCY",
+ "TRIANGLE_STRIP_ADJACENCY"
+};
+
+const char *tgsi_fs_coord_origin_names[2] =
+{
+ "UPPER_LEFT",
+ "LOWER_LEFT"
+};
+
+const char *tgsi_fs_coord_pixel_center_names[2] =
+{
+ "HALF_INTEGER",
+ "INTEGER"
+};
+
+const char *tgsi_immediate_type_names[3] =
+{
+ "FLT32",
+ "UINT32",
+ "INT32"
+};
+
+
+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);
+ STATIC_ASSERT(Elements(tgsi_primitive_names) == PIPE_PRIM_MAX);
+ STATIC_ASSERT(Elements(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT);
+ (void) tgsi_processor_type_names;
+ (void) tgsi_type_names;
+ (void) tgsi_immediate_type_names;
+ (void) tgsi_fs_coord_origin_names;
+ (void) tgsi_fs_coord_pixel_center_names;
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.h b/src/gallium/auxiliary/tgsi/tgsi_strings.h
new file mode 100644
index 00000000000..0946a58f135
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.h
@@ -0,0 +1,69 @@
+/**************************************************************************
+ *
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef TGSI_STRINGS_H
+#define TGSI_STRINGS_H
+
+#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
+
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+
+extern const char *tgsi_processor_type_names[3];
+
+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];
+
+extern const char *tgsi_property_names[TGSI_PROPERTY_COUNT];
+
+extern const char *tgsi_type_names[5];
+
+extern const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT];
+
+extern const char *tgsi_primitive_names[PIPE_PRIM_MAX];
+
+extern const char *tgsi_fs_coord_origin_names[2];
+
+extern const char *tgsi_fs_coord_pixel_center_names[2];
+
+extern const char *tgsi_immediate_type_names[3];
+
+
+#if defined __cplusplus
+}
+#endif
+
+
+#endif /* TGSI_STRINGS_H */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index eb9190ccb57..4b3d22c3072 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -35,6 +35,7 @@
#include "tgsi_info.h"
#include "tgsi_parse.h"
#include "tgsi_sanity.h"
+#include "tgsi_strings.h"
#include "tgsi_util.h"
#include "tgsi_dump.h"
@@ -270,23 +271,6 @@ static boolean parse_label( struct translate_ctx *ctx, uint *val )
return FALSE;
}
-static const char *file_names[TGSI_FILE_COUNT] =
-{
- "NULL",
- "CONST",
- "IN",
- "OUT",
- "TEMP",
- "SAMP",
- "ADDR",
- "IMM",
- "PRED",
- "SV",
- "IMMX",
- "TEMPX",
- "RES"
-};
-
static boolean
parse_file( const char **pcur, uint *file )
{
@@ -295,7 +279,7 @@ parse_file( const char **pcur, uint *file )
for (i = 0; i < TGSI_FILE_COUNT; i++) {
const char *cur = *pcur;
- if (str_match_no_case( &cur, file_names[i] )) {
+ if (str_match_no_case( &cur, tgsi_file_names[i] )) {
if (!is_digit_alpha_underscore( cur )) {
*pcur = cur;
*file = i;
@@ -816,32 +800,6 @@ parse_src_operand(
return TRUE;
}
-static const char *texture_names[TGSI_TEXTURE_COUNT] =
-{
- "UNKNOWN",
- "1D",
- "2D",
- "3D",
- "CUBE",
- "RECT",
- "SHADOW1D",
- "SHADOW2D",
- "SHADOWRECT",
- "1DARRAY",
- "2DARRAY",
- "SHADOW1DARRAY",
- "SHADOW2DARRAY"
-};
-
-static const char *type_names[] =
-{
- "UNORM",
- "SNORM",
- "SINT",
- "UINT",
- "FLOAT"
-};
-
static boolean
match_inst_mnemonic(const char **pcur,
const struct tgsi_opcode_info *info)
@@ -965,7 +923,7 @@ parse_instruction(
uint j;
for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
- if (str_match_no_case( &ctx->cur, texture_names[j] )) {
+ if (str_match_no_case( &ctx->cur, tgsi_texture_names[j] )) {
if (!is_digit_alpha_underscore( ctx->cur )) {
inst.Instruction.Texture = 1;
inst.Texture.Texture = j;
@@ -1010,31 +968,6 @@ parse_instruction(
return TRUE;
}
-static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
-{
- "POSITION",
- "COLOR",
- "BCOLOR",
- "FOG",
- "PSIZE",
- "GENERIC",
- "NORMAL",
- "FACE",
- "EDGEFLAG",
- "PRIM_ID",
- "INSTANCEID",
- "VERTEXID",
- "STENCIL"
-};
-
-static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
-{
- "CONSTANT",
- "LINEAR",
- "PERSPECTIVE"
-};
-
-
/* parses a 4-touple of the form {x, y, z, w}
* where x, y, z, w are numbers */
static boolean parse_immediate_data(struct translate_ctx *ctx,
@@ -1085,9 +1018,6 @@ static boolean parse_declaration( struct translate_ctx *ctx )
boolean is_vs_input;
boolean is_imm_array;
- assert(Elements(semantic_names) == TGSI_SEMANTIC_COUNT);
- assert(Elements(interpolate_names) == TGSI_INTERPOLATE_COUNT);
-
if (!eat_white( &ctx->cur )) {
report_error( ctx, "Syntax error" );
return FALSE;
@@ -1125,7 +1055,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
eat_opt_white( &cur );
if (file == TGSI_FILE_RESOURCE) {
for (i = 0; i < TGSI_TEXTURE_COUNT; i++) {
- if (str_match_no_case(&cur, texture_names[i])) {
+ if (str_match_no_case(&cur, tgsi_texture_names[i])) {
if (!is_digit_alpha_underscore(cur)) {
decl.Resource.Resource = i;
break;
@@ -1145,7 +1075,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
eat_opt_white( &cur );
for (j = 0; j < 4; ++j) {
for (i = 0; i < PIPE_TYPE_COUNT; ++i) {
- if (str_match_no_case(&cur, type_names[i])) {
+ if (str_match_no_case(&cur, tgsi_type_names[i])) {
if (!is_digit_alpha_underscore(cur)) {
switch (j) {
case 0:
@@ -1194,7 +1124,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
ctx->cur = cur;
} else {
for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) {
- if (str_match_no_case( &cur, semantic_names[i] )) {
+ if (str_match_no_case( &cur, tgsi_semantic_names[i] )) {
const char *cur2 = cur;
uint index;
@@ -1276,7 +1206,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
cur++;
eat_opt_white( &cur );
for (i = 0; i < TGSI_INTERPOLATE_COUNT; i++) {
- if (str_match_no_case( &cur, interpolate_names[i] )) {
+ if (str_match_no_case( &cur, tgsi_interpolate_names[i] )) {
if (is_digit_alpha_underscore( cur ))
continue;
decl.Declaration.Interpolate = i;