summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Krol <michal@tungstengraphics.com>2008-07-13 13:13:39 +0200
committerMichal Krol <michal@tungstengraphics.com>2008-07-13 13:17:41 +0200
commit3d5dcc2203f5018863ad51958871542696e1ed1b (patch)
treeeb03197600e31c6663456df5e91900ecf365f193 /src
parent46a7843099f02b6dcff56a52c9247c11d5c4aa8b (diff)
tgsi: Parse texture instructions correctly.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_text.c272
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h1
2 files changed, 152 insertions, 121 deletions
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_text.c b/src/gallium/auxiliary/tgsi/util/tgsi_text.c
index 3c7a4688c9..7485002862 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_text.c
@@ -400,130 +400,144 @@ struct opcode_info
{
uint num_dst;
uint num_src;
+ uint is_tex;
const char *mnemonic;
};
static const struct opcode_info opcode_info[TGSI_OPCODE_LAST] =
{
- { 1, 1, "ARL" },
- { 1, 1, "MOV" },
- { 1, 1, "LIT" },
- { 1, 1, "RCP" },
- { 1, 1, "RSQ" },
- { 1, 1, "EXP" },
- { 1, 1, "LOG" },
- { 1, 2, "MUL" },
- { 1, 2, "ADD" },
- { 1, 2, "DP3" },
- { 1, 2, "DP4" },
- { 1, 2, "DST" },
- { 1, 2, "MIN" },
- { 1, 2, "MAX" },
- { 1, 2, "SLT" },
- { 1, 2, "SGE" },
- { 1, 3, "MAD" },
- { 1, 2, "SUB" },
- { 1, 3, "LERP" },
- { 1, 3, "CND" },
- { 1, 3, "CND0" },
- { 1, 3, "DOT2ADD" },
- { 1, 2, "INDEX" },
- { 1, 1, "NEGATE" },
- { 1, 1, "FRAC" },
- { 1, 3, "CLAMP" },
- { 1, 1, "FLOOR" },
- { 1, 1, "ROUND" },
- { 1, 1, "EXPBASE2" },
- { 1, 1, "LOGBASE2" },
- { 1, 2, "POWER" },
- { 1, 2, "CROSSPRODUCT" },
- { 1, 2, "MULTIPLYMATRIX" },
- { 1, 1, "ABS" },
- { 1, 1, "RCC" },
- { 1, 2, "DPH" },
- { 1, 1, "COS" },
- { 1, 1, "DDX" },
- { 1, 1, "DDY" },
- { 0, 1, "KILP" },
- { 1, 1, "PK2H" },
- { 1, 1, "PK2US" },
- { 1, 1, "PK4B" },
- { 1, 1, "PK4UB" },
- { 1, 2, "RFL" },
- { 1, 2, "SEQ" },
- { 1, 2, "SFL" },
- { 1, 2, "SGT" },
- { 1, 1, "SIN" },
- { 1, 2, "SLE" },
- { 1, 2, "SNE" },
- { 1, 2, "STR" },
- { 1, 1, "TEX" },
- { 1, 3, "TXD" },
- { 1, 1, "TXP" },
- { 1, 1, "UP2H" },
- { 1, 1, "UP2US" },
- { 1, 1, "UP4B" },
- { 1, 1, "UP4UB" },
- { 1, 3, "X2D" },
- { 1, 1, "ARA" },
- { 1, 1, "ARR" },
- { 0, 1, "BRA" },
- { 0, 0, "CAL" },
- { 0, 0, "RET" },
- { 1, 1, "SSG" },
- { 1, 3, "CMP" },
- { 1, 1, "SCS" },
- { 1, 1, "TXB" },
- { 1, 1, "NRM" },
- { 1, 2, "DIV" },
- { 1, 2, "DP2" },
- { 1, 1, "TXL" },
- { 0, 0, "BRK" },
- { 0, 1, "IF" },
- { 0, 0, "LOOP" },
- { 0, 1, "REP" },
- { 0, 0, "ELSE" },
- { 0, 0, "ENDIF" },
- { 0, 0, "ENDLOOP" },
- { 0, 0, "ENDREP" },
- { 0, 1, "PUSHA" },
- { 1, 0, "POPA" },
- { 1, 1, "CEIL" },
- { 1, 1, "I2F" },
- { 1, 1, "NOT" },
- { 1, 1, "TRUNC" },
- { 1, 2, "SHL" },
- { 1, 2, "SHR" },
- { 1, 2, "AND" },
- { 1, 2, "OR" },
- { 1, 2, "MOD" },
- { 1, 2, "XOR" },
- { 1, 3, "SAD" },
- { 1, 1, "TXF" },
- { 1, 1, "TXQ" },
- { 0, 0, "CONT" },
- { 0, 0, "EMIT" },
- { 0, 0, "ENDPRIM" },
- { 0, 0, "BGNLOOP2" },
- { 0, 0, "BGNSUB" },
- { 0, 0, "ENDLOOP2" },
- { 0, 0, "ENDSUB" },
- { 1, 1, "NOISE1" },
- { 1, 1, "NOISE2" },
- { 1, 1, "NOISE3" },
- { 1, 1, "NOISE4" },
- { 0, 0, "NOP" },
- { 1, 2, "M4X3" },
- { 1, 2, "M3X4" },
- { 1, 2, "M3X3" },
- { 1, 2, "M3X2" },
- { 1, 1, "NRM4" },
- { 0, 1, "CALLNZ" },
- { 0, 1, "IFC" },
- { 0, 1, "BREAKC" },
- { 0, 0, "KIL" },
- { 0, 0, "END" },
- { 1, 1, "SWZ" }
+ { 1, 1, 0, "ARL" },
+ { 1, 1, 0, "MOV" },
+ { 1, 1, 0, "LIT" },
+ { 1, 1, 0, "RCP" },
+ { 1, 1, 0, "RSQ" },
+ { 1, 1, 0, "EXP" },
+ { 1, 1, 0, "LOG" },
+ { 1, 2, 0, "MUL" },
+ { 1, 2, 0, "ADD" },
+ { 1, 2, 0, "DP3" },
+ { 1, 2, 0, "DP4" },
+ { 1, 2, 0, "DST" },
+ { 1, 2, 0, "MIN" },
+ { 1, 2, 0, "MAX" },
+ { 1, 2, 0, "SLT" },
+ { 1, 2, 0, "SGE" },
+ { 1, 3, 0, "MAD" },
+ { 1, 2, 0, "SUB" },
+ { 1, 3, 0, "LERP" },
+ { 1, 3, 0, "CND" },
+ { 1, 3, 0, "CND0" },
+ { 1, 3, 0, "DOT2ADD" },
+ { 1, 2, 0, "INDEX" },
+ { 1, 1, 0, "NEGATE" },
+ { 1, 1, 0, "FRAC" },
+ { 1, 3, 0, "CLAMP" },
+ { 1, 1, 0, "FLOOR" },
+ { 1, 1, 0, "ROUND" },
+ { 1, 1, 0, "EXPBASE2" },
+ { 1, 1, 0, "LOGBASE2" },
+ { 1, 2, 0, "POWER" },
+ { 1, 2, 0, "CROSSPRODUCT" },
+ { 1, 2, 0, "MULTIPLYMATRIX" },
+ { 1, 1, 0, "ABS" },
+ { 1, 1, 0, "RCC" },
+ { 1, 2, 0, "DPH" },
+ { 1, 1, 0, "COS" },
+ { 1, 1, 0, "DDX" },
+ { 1, 1, 0, "DDY" },
+ { 0, 1, 0, "KILP" },
+ { 1, 1, 0, "PK2H" },
+ { 1, 1, 0, "PK2US" },
+ { 1, 1, 0, "PK4B" },
+ { 1, 1, 0, "PK4UB" },
+ { 1, 2, 0, "RFL" },
+ { 1, 2, 0, "SEQ" },
+ { 1, 2, 0, "SFL" },
+ { 1, 2, 0, "SGT" },
+ { 1, 1, 0, "SIN" },
+ { 1, 2, 0, "SLE" },
+ { 1, 2, 0, "SNE" },
+ { 1, 2, 0, "STR" },
+ { 1, 2, 1, "TEX" },
+ { 1, 4, 1, "TXD" },
+ { 1, 2, 1, "TXP" },
+ { 1, 1, 0, "UP2H" },
+ { 1, 1, 0, "UP2US" },
+ { 1, 1, 0, "UP4B" },
+ { 1, 1, 0, "UP4UB" },
+ { 1, 3, 0, "X2D" },
+ { 1, 1, 0, "ARA" },
+ { 1, 1, 0, "ARR" },
+ { 0, 1, 0, "BRA" },
+ { 0, 0, 0, "CAL" },
+ { 0, 0, 0, "RET" },
+ { 1, 1, 0, "SSG" },
+ { 1, 3, 0, "CMP" },
+ { 1, 1, 0, "SCS" },
+ { 1, 2, 1, "TXB" },
+ { 1, 1, 0, "NRM" },
+ { 1, 2, 0, "DIV" },
+ { 1, 2, 0, "DP2" },
+ { 1, 2, 1, "TXL" },
+ { 0, 0, 0, "BRK" },
+ { 0, 1, 0, "IF" },
+ { 0, 0, 0, "LOOP" },
+ { 0, 1, 0, "REP" },
+ { 0, 0, 0, "ELSE" },
+ { 0, 0, 0, "ENDIF" },
+ { 0, 0, 0, "ENDLOOP" },
+ { 0, 0, 0, "ENDREP" },
+ { 0, 1, 0, "PUSHA" },
+ { 1, 0, 0, "POPA" },
+ { 1, 1, 0, "CEIL" },
+ { 1, 1, 0, "I2F" },
+ { 1, 1, 0, "NOT" },
+ { 1, 1, 0, "TRUNC" },
+ { 1, 2, 0, "SHL" },
+ { 1, 2, 0, "SHR" },
+ { 1, 2, 0, "AND" },
+ { 1, 2, 0, "OR" },
+ { 1, 2, 0, "MOD" },
+ { 1, 2, 0, "XOR" },
+ { 1, 3, 0, "SAD" },
+ { 1, 2, 1, "TXF" },
+ { 1, 2, 1, "TXQ" },
+ { 0, 0, 0, "CONT" },
+ { 0, 0, 0, "EMIT" },
+ { 0, 0, 0, "ENDPRIM" },
+ { 0, 0, 0, "BGNLOOP2" },
+ { 0, 0, 0, "BGNSUB" },
+ { 0, 0, 0, "ENDLOOP2" },
+ { 0, 0, 0, "ENDSUB" },
+ { 1, 1, 0, "NOISE1" },
+ { 1, 1, 0, "NOISE2" },
+ { 1, 1, 0, "NOISE3" },
+ { 1, 1, 0, "NOISE4" },
+ { 0, 0, 0, "NOP" },
+ { 1, 2, 0, "M4X3" },
+ { 1, 2, 0, "M3X4" },
+ { 1, 2, 0, "M3X3" },
+ { 1, 2, 0, "M3X2" },
+ { 1, 1, 0, "NRM4" },
+ { 0, 1, 0, "CALLNZ" },
+ { 0, 1, 0, "IFC" },
+ { 0, 1, 0, "BREAKC" },
+ { 0, 0, 0, "KIL" },
+ { 0, 0, 0, "END" },
+ { 1, 1, 0, "SWZ" }
+};
+
+static const char *texture_names[TGSI_TEXTURE_COUNT] =
+{
+ "UNKNOWN",
+ "1D",
+ "2D",
+ "3D",
+ "CUBE",
+ "RECT",
+ "SHADOW1D",
+ "SHADOW2D",
+ "SHADOWRECT"
};
static boolean parse_instruction( struct translate_ctx *ctx )
@@ -560,7 +574,7 @@ static boolean parse_instruction( struct translate_ctx *ctx )
/* Parse instruction operands.
*/
- for (i = 0; i < info->num_dst + info->num_src; i++) {
+ for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) {
if (i > 0) {
eat_opt_white( &ctx->cur );
if (*ctx->cur != ',') {
@@ -575,10 +589,26 @@ static boolean parse_instruction( struct translate_ctx *ctx )
if (!parse_dst_operand( ctx, &inst.FullDstRegisters[i] ))
return FALSE;
}
- else {
+ else if (i < info->num_dst + info->num_src) {
if (!parse_src_operand( ctx, &inst.FullSrcRegisters[i - info->num_dst] ))
return FALSE;
}
+ else {
+ uint j;
+
+ for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
+ if (str_match_no_case( &ctx->cur, texture_names[j] )) {
+ if (!is_digit_alpha_underscore( ctx->cur )) {
+ inst.InstructionExtTexture.Texture = j;
+ break;
+ }
+ }
+ }
+ if (j == TGSI_TEXTURE_COUNT) {
+ report_error( ctx, "Expected texture target" );
+ return FALSE;
+ }
+ }
}
advance = tgsi_build_full_instruction(
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 33268553ff..c8e2830516 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -529,6 +529,7 @@ struct tgsi_instruction_ext_label
#define TGSI_TEXTURE_SHADOW1D 6
#define TGSI_TEXTURE_SHADOW2D 7
#define TGSI_TEXTURE_SHADOWRECT 8
+#define TGSI_TEXTURE_COUNT 9
struct tgsi_instruction_ext_texture
{