summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/tgsi
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-09-19 18:53:36 -0600
committerBrian <[email protected]>2007-09-19 18:53:59 -0600
commit37cf13ed9a429c755f121daa1776b1b30a985ab3 (patch)
tree8ae423c054011d6826024b173e1de892c8bed78e /src/mesa/pipe/tgsi
parent83a674a7af4e58f677a56aae2111d2cbdbf1e21d (diff)
Checkpoint: replacement of TGSI_ATTRIB_x tokens with input/output semantics.
TGSI_ATTRIB_x tokens still present and used in a few places. Expanded set of TGSI_SEMANTIC_x tokens for describing the meaning of inputs/outputs. These tokens are in a crude state ATM. Lots of #if 0 / disabled code to be removed yet, etc... Softpipe and i915 drivers should be in working condition but not heavily tested.
Diffstat (limited to 'src/mesa/pipe/tgsi')
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_build.c2
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_dump.c18
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_token.h31
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c118
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h2
5 files changed, 138 insertions, 33 deletions
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_build.c b/src/mesa/pipe/tgsi/exec/tgsi_build.c
index 20e4cf17f06..1320872c64d 100755
--- a/src/mesa/pipe/tgsi/exec/tgsi_build.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_build.c
@@ -325,7 +325,7 @@ tgsi_build_declaration_semantic(
{
struct tgsi_declaration_semantic ds;
- assert( semantic_name <= TGSI_SEMANTIC_COLOR );
+ assert( semantic_name <= TGSI_SEMANTIC_COUNT );
assert( semantic_index <= 0xFFFF );
ds = tgsi_default_declaration_semantic();
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c
index e6e99d9d75c..0a47ad2a8c1 100755
--- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c
@@ -202,13 +202,27 @@ static const char *TGSI_INTERPOLATES_SHORT[] =
static const char *TGSI_SEMANTICS[] =
{
"SEMANTIC_DEPTH",
- "SEMANTIC_COLOR"
+ "SEMANTIC_COLOR0",
+ "SEMANTIC_COLOR1",
+ "SEMANTIC_COLOR0B",
+ "SEMANTIC_COLOR1B",
+ "SEMANTIC_POSITION",
+ "SEMANTIC_FOG",
+ "SEMANTIC_OTHER,"
+ "SEMANTIC_TEX0",
};
static const char *TGSI_SEMANTICS_SHORT[] =
{
"DEPTH",
- "COLOR"
+ "COLOR0",
+ "COLOR1",
+ "COLOR0B",
+ "COLOR1B",
+ "POSITION",
+ "FOG",
+ "OTHER",
+ "TEX0"
};
static const char *TGSI_IMMS[] =
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h
index ca53071a60e..a642ba131a4 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_token.h
+++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h
@@ -73,11 +73,11 @@ struct tgsi_declaration
{
unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */
unsigned Size : 8; /* UINT */
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned Declare : 4; /* TGSI_DECLARE_ */
- unsigned UsageMask : 4; /* TGSI_WRITEMASK_ */
- unsigned Interpolate : 1; /* BOOL */
- unsigned Semantic : 1; /* BOOL */
+ unsigned File : 4; /* one of TGSI_FILE_x */
+ unsigned Declare : 4; /* one of TGSI_DECLARE_x */
+ unsigned UsageMask : 4; /* bitmask of TGSI_WRITEMASK_x flags */
+ unsigned Interpolate : 1; /* BOOL, any interpolation info? */
+ unsigned Semantic : 1; /* BOOL, any semantic info? */
unsigned Padding : 5;
unsigned Extended : 1; /* BOOL */
};
@@ -103,12 +103,27 @@ struct tgsi_declaration_interpolation
unsigned Padding : 28;
};
-#define TGSI_SEMANTIC_DEPTH 0
-#define TGSI_SEMANTIC_COLOR 1
+#define TGSI_SEMANTIC_DEPTH 0
+#define TGSI_SEMANTIC_COLOR0 1
+#define TGSI_SEMANTIC_COLOR1 2
+#define TGSI_SEMANTIC_COLOR0B 3 /**< back-face primary color */
+#define TGSI_SEMANTIC_COLOR1B 4 /**< back-face secondary color */
+#define TGSI_SEMANTIC_POSITION 5
+#define TGSI_SEMANTIC_FOG 6
+#define TGSI_SEMANTIC_OTHER 7 /* XXX temp */
+#define TGSI_SEMANTIC_TEX0 8
+#define TGSI_SEMANTIC_TEX1 9
+#define TGSI_SEMANTIC_TEX2 10
+#define TGSI_SEMANTIC_TEX3 11
+#define TGSI_SEMANTIC_TEX4 12
+#define TGSI_SEMANTIC_TEX5 13
+#define TGSI_SEMANTIC_TEX6 14
+#define TGSI_SEMANTIC_TEX7 15
+#define TGSI_SEMANTIC_COUNT 16 /**< number of semantic values */
struct tgsi_declaration_semantic
{
- unsigned SemanticName : 8; /* TGSI_SEMANTIC_ */
+ unsigned SemanticName : 8; /* one of TGSI_SEMANTIC_ */
unsigned SemanticIndex : 16; /* UINT */
unsigned Padding : 8;
};
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
index 1f8d937bc6b..fb8365aab5c 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
@@ -3,9 +3,9 @@
#include "pipe/tgsi/exec/tgsi_attribs.h"
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
-#define TGSI_DEBUG 1
-
+#define TGSI_DEBUG 0
+#if 0
/**
* Convert a VERT_ATTRIB_x to a TGSI_ATTRIB_y
*/
@@ -209,9 +209,10 @@ tgsi_mesa_translate_fragment_output(GLuint attrib)
return 0;
}
}
+#endif
-#if 01
+#if 0
uint
tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)
{
@@ -225,7 +226,6 @@ tgsi_mesa_translate_vertex_input_mask(GLbitfield mask)
}
return tgsiMask;
}
-#endif
uint
tgsi_mesa_translate_vertex_output_mask(GLbitfield mask)
@@ -271,6 +271,7 @@ tgsi_mesa_translate_fragment_output_mask(GLbitfield mask)
}
+#endif
@@ -319,12 +320,16 @@ map_register_file_index(
GLuint processor,
GLuint file,
GLuint index,
+#if 0
GLbitfield usage_bitmask,
+#endif
const GLuint inputMapping[],
const GLuint outputMapping[])
{
GLuint mapped_index;
+#if 0
GLuint i;
+#endif
assert(processor == TGSI_PROCESSOR_FRAGMENT
|| processor == TGSI_PROCESSOR_VERTEX);
@@ -345,7 +350,8 @@ map_register_file_index(
inputMapping[index]);
return inputMapping[index];
}
-
+ assert(0);
+#if 0
assert( usage_bitmask & (1 << index) );
mapped_index = 0;
for( i = 0; i < index; i++ ) {
@@ -354,6 +360,7 @@ map_register_file_index(
}
}
printf("Map %d input %d to %d\n", processor, index, mapped_index);
+#endif
break;
case TGSI_FILE_OUTPUT:
@@ -375,14 +382,17 @@ map_register_file_index(
else {
/* vertex output slots are tightly packed, find mapped pos */
/* mapped_index = VERT_RESULT_x */
+#if 0
mapped_index = 0;
for( i = 0; i < index; i++ ) {
if( usage_bitmask & (1 << i) ) {
mapped_index++;
}
}
- printf("Map VP output from %d to %d\n", index, mapped_index);
assert(outputMapping[index] == mapped_index);
+#endif
+ mapped_index = outputMapping[index];
+ printf("Map VP output from %d to %d\n", index, mapped_index);
}
break;
@@ -452,8 +462,10 @@ static GLboolean
compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
+#if 0
GLuint inputs_read,
GLuint outputs_written,
+#endif
const GLuint inputMapping[],
const GLuint outputMapping[],
GLuint preamble_size,
@@ -475,8 +487,14 @@ compile_instruction(
processor,
fulldst->DstRegister.File,
inst->DstReg.Index,
+#if 0
outputs_written,
+#endif
+#if 0
NULL,
+#else
+ inputMapping,
+#endif
outputMapping
);
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
@@ -490,7 +508,9 @@ compile_instruction(
processor,
fullsrc->SrcRegister.File,
inst->SrcReg[i].Index,
+#if 0
inputs_read,
+#endif
inputMapping,
outputMapping );
@@ -766,10 +786,10 @@ compile_instruction(
static struct tgsi_full_declaration
make_frag_input_decl(
- GLuint first,
- GLuint last,
+ GLuint index,
GLuint interpolate,
- GLuint usage_mask )
+ GLuint usage_mask,
+ GLuint semantic_name )
{
struct tgsi_full_declaration decl;
@@ -777,9 +797,11 @@ make_frag_input_decl(
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Declare = TGSI_DECLARE_RANGE;
decl.Declaration.UsageMask = usage_mask;
+ decl.Declaration.Semantic = 1;
decl.Declaration.Interpolate = 1;
- decl.u.DeclarationRange.First = first;
- decl.u.DeclarationRange.Last = last;
+ decl.u.DeclarationRange.First = index;
+ decl.u.DeclarationRange.Last = index;
+ decl.Semantic.SemanticName = semantic_name;
decl.Interpolation.Interpolate = interpolate;
return decl;
@@ -809,15 +831,20 @@ make_frag_output_decl(
/**
* Convert Mesa fragment program to TGSI format.
- * \param inputMapping array to map original Mesa fragment program inputs
- * registers to TGSI generic input indexes
- * \param interpMode array[FRAG_ATTRIB_x] of TGSI_INTERPOLATE_LINEAR/PERSP.
+ * \param inputMapping maps Mesa fragment program inputs to TGSI generic
+ * input indexes
+ * \param inputSemantic the TGSI_SEMANTIC flag for each input
+ * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input
+ * \param outputMapping maps Mesa fragment program outputs to TGSI
+ * generic outputs
*
*/
GLboolean
tgsi_mesa_compile_fp_program(
const struct gl_fragment_program *program,
+ GLuint numInputs,
const GLuint inputMapping[],
+ const ubyte inputSemantic[],
const GLuint interpMode[],
const GLuint outputMapping[],
struct tgsi_token *tokens,
@@ -831,9 +858,9 @@ tgsi_mesa_compile_fp_program(
/*
struct tgsi_full_dst_register *fulldst;
struct tgsi_full_src_register *fullsrc;
- */
GLuint inputs_read;
GLboolean reads_wpos;
+ */
GLuint preamble_size = 0;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -846,6 +873,7 @@ tgsi_mesa_compile_fp_program(
ti = 3;
+#if 0
reads_wpos = program->Base.InputsRead & (1 << FRAG_ATTRIB_WPOS);
inputs_read = program->Base.InputsRead | (1 << FRAG_ATTRIB_WPOS);
@@ -857,9 +885,9 @@ tgsi_mesa_compile_fp_program(
if( reads_wpos ) {
fulldecl = make_frag_input_decl(
0,
- 0,
TGSI_INTERPOLATE_CONSTANT,
- TGSI_WRITEMASK_XY );
+ TGSI_WRITEMASK_XY,
+ TGSI_SEMANTIC_POSITION );
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
@@ -870,9 +898,9 @@ tgsi_mesa_compile_fp_program(
/* Fragment zw. */
fulldecl = make_frag_input_decl(
0,
- 0,
TGSI_INTERPOLATE_LINEAR,
- reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z );
+ reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z,
+ TGSI_SEMANTIC_POSITION );
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
@@ -884,15 +912,55 @@ tgsi_mesa_compile_fp_program(
if( inputs_read & (1 << i) ) {
count++;
fulldecl = make_frag_input_decl(count,
- count,
interpMode[i],
- TGSI_WRITEMASK_XYZW );
+ TGSI_WRITEMASK_XYZW,
+ inputSemantic[count] );
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
maxTokens - ti );
}
}
+#else
+
+ for (i = 0; i < numInputs; i++) {
+ switch (inputSemantic[i]) {
+ case TGSI_SEMANTIC_POSITION:
+ /* Fragment XY pos */
+ fulldecl = make_frag_input_decl(i,
+ TGSI_INTERPOLATE_CONSTANT,
+ TGSI_WRITEMASK_XY,
+ TGSI_SEMANTIC_POSITION );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ /* Fragment ZW pos */
+ fulldecl = make_frag_input_decl(i,
+ TGSI_INTERPOLATE_LINEAR,
+ TGSI_WRITEMASK_ZW,
+ TGSI_SEMANTIC_POSITION );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ break;
+ default:
+ fulldecl = make_frag_input_decl(i,
+ interpMode[i],
+ TGSI_WRITEMASK_XYZW,
+ inputSemantic[i] );
+ ti += tgsi_build_full_declaration(&fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ break;
+ }
+ }
+#endif
+
/*
* Declare output attributes.
@@ -914,7 +982,7 @@ tgsi_mesa_compile_fp_program(
if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) {
fulldecl = make_frag_output_decl(
1,
- TGSI_SEMANTIC_COLOR,
+ TGSI_SEMANTIC_COLOR0,
TGSI_WRITEMASK_XYZW );
ti += tgsi_build_full_declaration(
&fulldecl,
@@ -956,8 +1024,10 @@ tgsi_mesa_compile_fp_program(
if( compile_instruction(
&program->Base.Instructions[i],
&fullinst,
+#if 0
inputs_read,
~0, /*outputs_written*/
+#endif
inputMapping,
outputMapping,
preamble_size,
@@ -992,10 +1062,12 @@ tgsi_mesa_compile_vp_program(
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_instruction fullinst;
+#if 0
GLuint inputs_read = ~0;
GLuint outputs_written;
outputs_written = program->Base.OutputsWritten;
+#endif
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -1011,8 +1083,10 @@ tgsi_mesa_compile_vp_program(
if( compile_instruction(
&program->Base.Instructions[i],
&fullinst,
+#if 0
inputs_read,
outputs_written,
+#endif
inputMapping,
outputMapping,
0,
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
index 017cfce72ea..8105e9e738f 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h
@@ -10,7 +10,9 @@ struct tgsi_token;
GLboolean
tgsi_mesa_compile_fp_program(
const struct gl_fragment_program *program,
+ GLuint numInputs,
const GLuint inputMapping[],
+ const ubyte inputSemantic[],
const GLuint interpMode[],
const GLuint outputMapping[],
struct tgsi_token *tokens,