Cosmetic changes, GLuint -> unsigned.
Preserve mesa gl_fragment_program DEPTH and COLOR semantics.
static void
header_headersize_grow( struct tgsi_header *header )
{
- assert (header->HeaderSize < 0xFF);
- assert (header->BodySize == 0);
+ assert( header->HeaderSize < 0xFF );
+ assert( header->BodySize == 0 );
header->HeaderSize++;
}
static void
header_bodysize_grow( struct tgsi_header *header )
{
- assert (header->BodySize < 0xFFFFFF);
+ assert( header->BodySize < 0xFFFFFF );
header->BodySize++;
}
struct tgsi_processor
tgsi_build_processor(
- GLuint type,
+ unsigned type,
struct tgsi_header *header )
{
struct tgsi_processor processor;
declaration.File = TGSI_FILE_NULL;
declaration.Declare = TGSI_DECLARE_RANGE;
declaration.Interpolate = 0;
+ declaration.Semantic = 0;
declaration.Padding = 0;
declaration.Extended = 0;
struct tgsi_declaration
tgsi_build_declaration(
- GLuint file,
- GLuint declare,
- GLuint interpolate,
+ unsigned file,
+ unsigned declare,
+ unsigned interpolate,
+ unsigned semantic,
struct tgsi_header *header )
{
struct tgsi_declaration declaration;
- assert (file <= TGSI_FILE_IMMEDIATE);
- assert (declare <= TGSI_DECLARE_MASK);
+ assert( file <= TGSI_FILE_IMMEDIATE );
+ assert( declare <= TGSI_DECLARE_MASK );
declaration = tgsi_default_declaration();
declaration.File = file;
declaration.Declare = declare;
declaration.Interpolate = interpolate;
+ declaration.Semantic = semantic;
header_bodysize_grow( header );
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
- assert (declaration->Size < 0xFF);
+ assert( declaration->Size < 0xFF );
declaration->Size++;
full_declaration.Declaration = tgsi_default_declaration();
full_declaration.Interpolation = tgsi_default_declaration_interpolation();
+ full_declaration.Semantic = tgsi_default_declaration_semantic();
return full_declaration;
}
-GLuint
+unsigned
tgsi_build_full_declaration(
- const struct tgsi_full_declaration *full_decl,
+ const struct tgsi_full_declaration *full_decl,
struct tgsi_token *tokens,
struct tgsi_header *header,
- GLuint maxsize )
+ unsigned maxsize )
{
- GLuint size = 0;
+ unsigned size = 0;
struct tgsi_declaration *declaration;
if( maxsize <= size )
full_decl->Declaration.File,
full_decl->Declaration.Declare,
full_decl->Declaration.Interpolate,
+ full_decl->Declaration.Semantic,
header );
switch( full_decl->Declaration.Declare ) {
- case TGSI_DECLARE_RANGE:
+ case TGSI_DECLARE_RANGE:
{
struct tgsi_declaration_range *dr;
- if( maxsize <= size )
+ if( maxsize <= size )
return 0;
dr = (struct tgsi_declaration_range *) &tokens[size];
size++;
break;
}
- case TGSI_DECLARE_MASK:
+ case TGSI_DECLARE_MASK:
{
- struct tgsi_declaration_mask *dm;
+ struct tgsi_declaration_mask *dm;
- if( maxsize <= size )
+ if( maxsize <= size )
return 0;
dm = (struct tgsi_declaration_mask *) &tokens[size];
size++;
header );
}
+ if( full_decl->Declaration.Semantic ) {
+ struct tgsi_declaration_semantic *ds;
+
+ if( maxsize <= size )
+ return 0;
+ ds = (struct tgsi_declaration_semantic *) &tokens[size];
+ size++;
+
+ *ds = tgsi_build_declaration_semantic(
+ full_decl->Semantic.SemanticName,
+ full_decl->Semantic.SemanticIndex,
+ declaration,
+ header );
+ }
+
return size;
}
struct tgsi_declaration_range
tgsi_build_declaration_range(
- GLuint first,
- GLuint last,
+ unsigned first,
+ unsigned last,
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
struct tgsi_declaration_range declaration_range;
- assert (last >= first);
- assert (last <= 0xFFFF);
+ assert( last >= first );
+ assert( last <= 0xFFFF );
declaration_range.First = first;
declaration_range.Last = last;
struct tgsi_declaration_mask
tgsi_build_declaration_mask(
- GLuint mask,
+ unsigned mask,
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
struct tgsi_declaration_interpolation
tgsi_build_declaration_interpolation(
- GLuint interpolate,
+ unsigned interpolate,
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
return di;
}
+struct tgsi_declaration_semantic
+tgsi_default_declaration_semantic( void )
+{
+ struct tgsi_declaration_semantic ds;
+
+ ds.SemanticName = TGSI_SEMANTIC_DEPTH;
+ ds.SemanticIndex = 0;
+ ds.Padding = 0;
+
+ return ds;
+}
+
+struct tgsi_declaration_semantic
+tgsi_build_declaration_semantic(
+ unsigned semantic_name,
+ unsigned semantic_index,
+ struct tgsi_declaration *declaration,
+ struct tgsi_header *header )
+{
+ struct tgsi_declaration_semantic ds;
+
+ assert( semantic_name <= TGSI_SEMANTIC_COLOR );
+ assert( semantic_index <= 0xFFFF );
+
+ ds = tgsi_default_declaration_semantic();
+ ds.SemanticName = semantic_name;
+ ds.SemanticIndex = semantic_index;
+
+ declaration_grow( declaration, header );
+
+ return ds;
+}
+
/*
* immediate
*/
unsigned file,
unsigned declare,
unsigned interpolate,
+ unsigned semantic,
struct tgsi_header *header );
struct tgsi_full_declaration
struct tgsi_declaration *declaration,
struct tgsi_header *header );
+struct tgsi_declaration_semantic
+tgsi_default_declaration_semantic( void );
+
+struct tgsi_declaration_semantic
+tgsi_build_declaration_semantic(
+ unsigned semantic_name,
+ unsigned semantic_index,
+ struct tgsi_declaration *declaration,
+ struct tgsi_header *header );
+
/*
* immediate
*/
"PERSPECTIVE"
};
+static const char *TGSI_SEMANTICS[] =
+{
+ "SEMANTIC_DEPTH",
+ "SEMANTIC_COLOR"
+};
+
+static const char *TGSI_SEMANTICS_SHORT[] =
+{
+ "DEPTH",
+ "COLOR"
+};
+
static const char *TGSI_IMMS[] =
{
"IMM_FLOAT32"
TXT( ", " );
ENM( decl->Interpolation.Interpolate, TGSI_INTERPOLATES_SHORT );
}
+
+ if( decl->Declaration.Semantic ) {
+ TXT( ", " );
+ ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS_SHORT );
+ CHR( '[' );
+ UID( decl->Semantic.SemanticIndex );
+ CHR( ']' );
+ }
}
static void
TXT( "\nInterpolate: " );
UID( decl->Declaration.Interpolate );
}
+ if( deflt || fd->Declaration.Semantic != decl->Declaration.Semantic ) {
+ TXT( "\nSemantic : " );
+ UID( decl->Declaration.Semantic );
+ }
if( ignored ) {
TXT( "\nPadding : " );
UIX( decl->Declaration.Padding );
UIX( decl->Interpolation.Padding );
}
}
+
+ if( decl->Declaration.Semantic ) {
+ CHR( '\n' );
+ TXT( "\nSemanticName : " );
+ ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS );
+ TXT( "\nSemanticIndex: " );
+ UID( decl->Semantic.SemanticIndex );
+ if( ignored ) {
+ TXT( "\nPadding : " );
+ UIX( decl->Semantic.Padding );
+ }
+ }
}
static void
free( full_token->FullImmediate.u.Pointer );
}
-GLuint
+unsigned
tgsi_parse_init(
struct tgsi_parse_context *ctx,
const struct tgsi_token *tokens )
struct tgsi_parse_context *ctx )
{
struct tgsi_token token;
- GLuint i;
+ unsigned i;
tgsi_full_token_free( &ctx->FullToken );
tgsi_full_token_init( &ctx->FullToken );
next_token( ctx, &decl->Interpolation );
}
+ if( decl->Declaration.Semantic ) {
+ next_token( ctx, &decl->Semantic );
+ }
+
break;
}
case TGSI_TOKEN_TYPE_INSTRUCTION:
{
struct tgsi_full_instruction *inst = &ctx->FullToken.FullInstruction;
- GLuint extended;
+ unsigned extended;
*inst = tgsi_default_full_instruction();
inst->Instruction = *(struct tgsi_instruction *) &token;
assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- GLuint extended;
+ unsigned extended;
next_token( ctx, &inst->FullDstRegisters[i].DstRegister );
assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- GLuint extended;
+ unsigned extended;
next_token( ctx, &inst->FullSrcRegisters[i].SrcRegister );
struct tgsi_declaration_mask DeclarationMask;
} u;
struct tgsi_declaration_interpolation Interpolation;
+ struct tgsi_declaration_semantic Semantic;
};
struct tgsi_full_immediate
struct tgsi_parse_context
{
const struct tgsi_token *Tokens;
- unsigned Position;
+ unsigned Position;
struct tgsi_full_version FullVersion;
struct tgsi_full_header FullHeader;
union tgsi_full_token FullToken;
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 Interpolate : 1; /* BOOL */
- unsigned Padding : 10;
- unsigned Extended : 1; /* BOOL */
+ unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */
+ unsigned Size : 8; /* UINT */
+ unsigned File : 4; /* TGSI_FILE_ */
+ unsigned Declare : 4; /* TGSI_DECLARE_ */
+ unsigned Interpolate : 1; /* BOOL */
+ unsigned Semantic : 1; /* BOOL */
+ unsigned Padding : 9;
+ unsigned Extended : 1; /* BOOL */
};
struct tgsi_declaration_range
unsigned Padding : 28;
};
+#define TGSI_SEMANTIC_DEPTH 0
+#define TGSI_SEMANTIC_COLOR 1
+
+struct tgsi_declaration_semantic
+{
+ unsigned SemanticName : 8; /* TGSI_SEMANTIC_ */
+ unsigned SemanticIndex : 16; /* UINT */
+ unsigned Padding : 8;
+};
+
#define TGSI_IMM_FLOAT32 0
struct tgsi_immediate
struct tgsi_src_register
{
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned Negate : 1; /* BOOL */
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- int Index : 16; /* SINT */
- unsigned Extended : 1; /* BOOL */
+ unsigned File : 4; /* TGSI_FILE_ */
+ unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */
+ unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
+ unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
+ unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
+ unsigned Negate : 1; /* BOOL */
+ unsigned Indirect : 1; /* BOOL */
+ unsigned Dimension : 1; /* BOOL */
+ int Index : 16; /* SINT */
+ unsigned Extended : 1; /* BOOL */
};
/*
struct tgsi_dimension
{
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- unsigned Padding : 13;
- int Index : 16; /* SINT */
- unsigned Extended : 1; /* BOOL */
+ unsigned Indirect : 1; /* BOOL */
+ unsigned Dimension : 1; /* BOOL */
+ unsigned Padding : 13;
+ int Index : 16; /* SINT */
+ unsigned Extended : 1; /* BOOL */
};
struct tgsi_dst_register
{
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- int Index : 16; /* SINT */
- unsigned Padding : 5;
- unsigned Extended : 1; /* BOOL */
+ unsigned File : 4; /* TGSI_FILE_ */
+ unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
+ unsigned Indirect : 1; /* BOOL */
+ unsigned Dimension : 1; /* BOOL */
+ int Index : 16; /* SINT */
+ unsigned Padding : 5;
+ unsigned Extended : 1; /* BOOL */
};
/*
}\r
\r
static struct tgsi_full_declaration\r
-make_declaration(\r
- GLuint file,\r
+make_frag_input_decl(\r
GLuint first,\r
GLuint last,\r
- GLboolean do_interpolate,\r
GLuint interpolate )\r
{\r
struct tgsi_full_declaration decl;\r
\r
decl = tgsi_default_full_declaration();\r
- decl.Declaration.File = file;\r
+ decl.Declaration.File = TGSI_FILE_INPUT;\r
decl.Declaration.Declare = TGSI_DECLARE_RANGE;\r
+ decl.Declaration.Interpolate = 1;\r
decl.u.DeclarationRange.First = first;\r
decl.u.DeclarationRange.Last = last;\r
+ decl.Interpolation.Interpolate = interpolate;\r
\r
- if( do_interpolate ) {\r
- decl.Declaration.Interpolate = 1;\r
- decl.Interpolation.Interpolate = interpolate;\r
- }\r
+ return decl;\r
+}\r
+\r
+static struct tgsi_full_declaration\r
+make_frag_output_decl(\r
+ GLuint index,\r
+ GLuint semantic_name )\r
+{\r
+ struct tgsi_full_declaration decl;\r
+\r
+ decl = tgsi_default_full_declaration();\r
+ decl.Declaration.File = TGSI_FILE_OUTPUT;\r
+ decl.Declaration.Declare = TGSI_DECLARE_RANGE;\r
+ decl.Declaration.Semantic = 1;\r
+ decl.u.DeclarationRange.First = index;\r
+ decl.u.DeclarationRange.Last = index;\r
+ decl.Semantic.SemanticName = semantic_name;\r
+ decl.Semantic.SemanticIndex = 0;\r
\r
return decl;\r
}\r
/*\r
* Declare input attributes. Note that we do not interpolate fragment position.\r
*/\r
- fulldecl = make_declaration(\r
- TGSI_FILE_INPUT,\r
+ fulldecl = make_frag_input_decl(\r
0,\r
0,\r
- GL_TRUE,\r
TGSI_INTERPOLATE_CONSTANT );\r
ti += tgsi_build_full_declaration(\r
&fulldecl,\r
}\r
}\r
if( count > 0 ) {\r
- fulldecl = make_declaration(\r
- TGSI_FILE_INPUT,\r
+ fulldecl = make_frag_input_decl(\r
1,\r
- count + 1,\r
- GL_TRUE,\r
+ 1 + count - 1,\r
TGSI_INTERPOLATE_LINEAR );\r
ti += tgsi_build_full_declaration(\r
&fulldecl,\r
program->Base.OutputsWritten ==\r
(program->Base.OutputsWritten & ((1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR))) );\r
\r
- fulldecl = make_declaration(\r
- TGSI_FILE_OUTPUT,\r
- 0,\r
+ fulldecl = make_frag_output_decl(\r
0,\r
- GL_FALSE,\r
- 0 );\r
+ TGSI_SEMANTIC_DEPTH );\r
ti += tgsi_build_full_declaration(\r
&fulldecl,\r
&tokens[ti],\r
maxTokens - ti );\r
\r
if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) {\r
- fulldecl = make_declaration(\r
- TGSI_FILE_OUTPUT,\r
- 1,\r
+ fulldecl = make_frag_output_decl(\r
1,\r
- GL_FALSE,\r
- 0 );\r
+ TGSI_SEMANTIC_COLOR );\r
ti += tgsi_build_full_declaration(\r
&fulldecl,\r
&tokens[ti],\r