tgsi/tgsi_ppc.c \
tgsi/tgsi_sanity.c \
tgsi/tgsi_scan.c \
+ tgsi/tgsi_strings.c \
tgsi/tgsi_text.c \
tgsi/tgsi_transform.c \
tgsi/tgsi_ureg.c \
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_strings.h"
#include "lp_bld_debug.h"
#include "lp_bld_tgsi.h"
#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 */
#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] =
{
"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,
{
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);
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( '[' );
decl->Declaration.File == TGSI_FILE_INPUT)
{
TXT( ", " );
- ENM( decl->Declaration.Interpolate, interpolate_names );
+ ENM( decl->Declaration.Interpolate, tgsi_interpolate_names );
}
if (decl->Declaration.Centroid) {
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);
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);
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;
}
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,
--- /dev/null
+/**************************************************************************
+ *
+ * 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;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * 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 */
#include "tgsi_info.h"
#include "tgsi_parse.h"
#include "tgsi_sanity.h"
+#include "tgsi_strings.h"
#include "tgsi_util.h"
#include "tgsi_dump.h"
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 )
{
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;
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)
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;
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,
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;
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;
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:
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;
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;