summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2012-04-30 18:27:52 +0200
committerFrancisco Jerez <[email protected]>2012-05-11 12:39:40 +0200
commit1279923d72942ee201fcc6ad40d552143f651f03 (patch)
tree73eb59a3e623c04a0344c8b57188e96d362ec197 /src/gallium/auxiliary/tgsi
parent5f55cbc7d93c6568566893f9345e43fff311a32b (diff)
gallium/tgsi: Move interpolation info from tgsi_declaration to a separate token.
Move Interpolate, Centroid and CylindricalWrap from tgsi_declaration to a separate token -- they only make sense for FS inputs and we need room for other flags in the top-level declaration token.
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c57
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c49
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.h1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c21
9 files changed, 97 insertions, 48 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 6c3f77581f0..b4f50038bed 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -104,12 +104,10 @@ tgsi_default_declaration( void )
declaration.NrTokens = 1;
declaration.File = TGSI_FILE_NULL;
declaration.UsageMask = TGSI_WRITEMASK_XYZW;
- declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT;
+ declaration.Interpolate = 0;
declaration.Dimension = 0;
declaration.Semantic = 0;
- declaration.Centroid = 0;
declaration.Invariant = 0;
- declaration.CylindricalWrap = 0;
return declaration;
}
@@ -121,9 +119,7 @@ tgsi_build_declaration(
unsigned interpolate,
unsigned dimension,
unsigned semantic,
- unsigned centroid,
unsigned invariant,
- unsigned cylindrical_wrap,
struct tgsi_header *header )
{
struct tgsi_declaration declaration;
@@ -137,9 +133,7 @@ tgsi_build_declaration(
declaration.Interpolate = interpolate;
declaration.Dimension = dimension;
declaration.Semantic = semantic;
- declaration.Centroid = centroid;
declaration.Invariant = invariant;
- declaration.CylindricalWrap = cylindrical_wrap;
header_bodysize_grow( header );
@@ -194,6 +188,36 @@ tgsi_build_declaration_dimension(unsigned index_2d,
return dd;
}
+static struct tgsi_declaration_interp
+tgsi_default_declaration_interp( void )
+{
+ struct tgsi_declaration_interp di;
+
+ di.Interpolate = TGSI_INTERPOLATE_CONSTANT;
+ di.Centroid = 0;
+ di.CylindricalWrap = 0;
+
+ return di;
+}
+
+static struct tgsi_declaration_interp
+tgsi_build_declaration_interp(unsigned interpolate,
+ unsigned centroid,
+ unsigned cylindrical_wrap,
+ struct tgsi_declaration *declaration,
+ struct tgsi_header *header)
+{
+ struct tgsi_declaration_interp di;
+
+ di.Interpolate = interpolate;
+ di.Centroid = centroid;
+ di.CylindricalWrap = cylindrical_wrap;
+
+ declaration_grow(declaration, header);
+
+ return di;
+}
+
static struct tgsi_declaration_semantic
tgsi_default_declaration_semantic( void )
{
@@ -298,6 +322,7 @@ tgsi_default_full_declaration( void )
full_declaration.Declaration = tgsi_default_declaration();
full_declaration.Range = tgsi_default_declaration_range();
full_declaration.Semantic = tgsi_default_declaration_semantic();
+ full_declaration.Interp = tgsi_default_declaration_interp();
full_declaration.ImmediateData.u = NULL;
full_declaration.Resource = tgsi_default_declaration_resource();
full_declaration.SamplerView = tgsi_default_declaration_sampler_view();
@@ -327,9 +352,7 @@ tgsi_build_full_declaration(
full_decl->Declaration.Interpolate,
full_decl->Declaration.Dimension,
full_decl->Declaration.Semantic,
- full_decl->Declaration.Centroid,
full_decl->Declaration.Invariant,
- full_decl->Declaration.CylindricalWrap,
header );
if (maxsize <= size)
@@ -357,6 +380,22 @@ tgsi_build_full_declaration(
header);
}
+ if (full_decl->Declaration.Interpolate) {
+ struct tgsi_declaration_interp *di;
+
+ if (maxsize <= size) {
+ return 0;
+ }
+ di = (struct tgsi_declaration_interp *)&tokens[size];
+ size++;
+
+ *di = tgsi_build_declaration_interp(full_decl->Interp.Interpolate,
+ full_decl->Interp.Centroid,
+ full_decl->Interp.CylindricalWrap,
+ declaration,
+ header);
+ }
+
if( full_decl->Declaration.Semantic ) {
struct tgsi_declaration_semantic *ds;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index f20a1943b52..328dfb14f6d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -306,36 +306,39 @@ iter_declaration(
}
}
- if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
- decl->Declaration.File == TGSI_FILE_INPUT)
- {
- TXT( ", " );
- ENM( decl->Declaration.Interpolate, tgsi_interpolate_names );
- }
+ if (decl->Declaration.Interpolate) {
+ if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
+ decl->Declaration.File == TGSI_FILE_INPUT)
+ {
+ TXT( ", " );
+ ENM( decl->Interp.Interpolate, tgsi_interpolate_names );
+ }
- if (decl->Declaration.Centroid) {
- TXT( ", CENTROID" );
+ if (decl->Interp.Centroid) {
+ TXT( ", CENTROID" );
+ }
+
+ if (decl->Interp.CylindricalWrap) {
+ TXT(", CYLWRAP_");
+ if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
+ CHR('X');
+ }
+ if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {
+ CHR('Y');
+ }
+ if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {
+ CHR('Z');
+ }
+ if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {
+ CHR('W');
+ }
+ }
}
if (decl->Declaration.Invariant) {
TXT( ", INVARIANT" );
}
- if (decl->Declaration.CylindricalWrap) {
- TXT(", CYLWRAP_");
- if (decl->Declaration.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
- CHR('X');
- }
- if (decl->Declaration.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {
- CHR('Y');
- }
- if (decl->Declaration.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {
- CHR('Z');
- }
- if (decl->Declaration.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {
- CHR('W');
- }
- }
if (decl->Declaration.File == TGSI_FILE_IMMEDIATE_ARRAY) {
unsigned i;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 20bbe407caf..5e23f5da65b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -2371,7 +2371,7 @@ exec_declaration(struct tgsi_exec_machine *mach,
eval_coef_func eval;
uint i, j;
- switch (decl->Declaration.Interpolate) {
+ switch (decl->Interp.Interpolate) {
case TGSI_INTERPOLATE_CONSTANT:
eval = eval_constant_coef;
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index 67d138914e7..45c5c41ec82 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -113,6 +113,10 @@ tgsi_parse_token(
next_token(ctx, &decl->Dim);
}
+ if( decl->Declaration.Interpolate ) {
+ next_token( ctx, &decl->Interp );
+ }
+
if( decl->Declaration.Semantic ) {
next_token( ctx, &decl->Semantic );
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h
index 3dce222565b..3f8bf99e3c1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -67,6 +67,7 @@ struct tgsi_full_declaration
struct tgsi_declaration Declaration;
struct tgsi_declaration_range Range;
struct tgsi_declaration_dimension Dim;
+ struct tgsi_declaration_interp Interp;
struct tgsi_declaration_semantic Semantic;
struct tgsi_immediate_array_data ImmediateData;
struct tgsi_declaration_resource Resource;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index 1e00e2e54ed..ce728ecee06 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -1170,7 +1170,7 @@ emit_declaration(
for( i = first; i <= last; i++ ) {
for( j = 0; j < NUM_CHANNELS; j++ ) {
if( mask & (1 << j) ) {
- switch( decl->Declaration.Interpolate ) {
+ switch( decl->Interp.Interpolate ) {
case TGSI_INTERPOLATE_CONSTANT:
emit_coef_a0( func, 0, i, j );
emit_inputs( func, 0, i, j );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index e4e9c032e02..036ff314389 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -157,9 +157,9 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
if (file == TGSI_FILE_INPUT) {
info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.Name;
info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.Index;
- info->input_interpolate[reg] = (ubyte)fulldecl->Declaration.Interpolate;
- info->input_centroid[reg] = (ubyte)fulldecl->Declaration.Centroid;
- info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Declaration.CylindricalWrap;
+ info->input_interpolate[reg] = (ubyte)fulldecl->Interp.Interpolate;
+ info->input_centroid[reg] = (ubyte)fulldecl->Interp.Centroid;
+ info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Interp.CylindricalWrap;
info->num_inputs++;
if (procType == TGSI_PROCESSOR_FRAGMENT &&
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index cec9cd36a55..7269f5343ec 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1225,7 +1225,8 @@ static boolean parse_declaration( struct translate_ctx *ctx )
if (str_match_no_case( &cur, tgsi_interpolate_names[i] )) {
if (is_digit_alpha_underscore( cur ))
continue;
- decl.Declaration.Interpolate = i;
+ decl.Declaration.Interpolate = 1;
+ decl.Interp.Interpolate = i;
ctx->cur = cur;
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 496b31a5d13..a5efd2a3152 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -46,6 +46,7 @@ union tgsi_any_token {
struct tgsi_declaration decl;
struct tgsi_declaration_range decl_range;
struct tgsi_declaration_dimension decl_dim;
+ struct tgsi_declaration_interp decl_interp;
struct tgsi_declaration_semantic decl_semantic;
struct tgsi_declaration_sampler_view decl_sampler_view;
struct tgsi_immediate imm;
@@ -1229,25 +1230,28 @@ emit_decl_fs(struct ureg_program *ureg,
unsigned cylindrical_wrap,
unsigned centroid)
{
- union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
+ union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 4);
out[0].value = 0;
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
- out[0].decl.NrTokens = 3;
+ out[0].decl.NrTokens = 4;
out[0].decl.File = file;
out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */
- out[0].decl.Interpolate = interpolate;
+ out[0].decl.Interpolate = 1;
out[0].decl.Semantic = 1;
- out[0].decl.CylindricalWrap = cylindrical_wrap;
- out[0].decl.Centroid = centroid;
out[1].value = 0;
out[1].decl_range.First = index;
out[1].decl_range.Last = index;
out[2].value = 0;
- out[2].decl_semantic.Name = semantic_name;
- out[2].decl_semantic.Index = semantic_index;
+ out[2].decl_interp.Interpolate = interpolate;
+ out[2].decl_interp.CylindricalWrap = cylindrical_wrap;
+ out[2].decl_interp.Centroid = centroid;
+
+ out[3].value = 0;
+ out[3].decl_semantic.Name = semantic_name;
+ out[3].decl_semantic.Index = semantic_index;
}
@@ -1263,7 +1267,6 @@ static void emit_decl_range( struct ureg_program *ureg,
out[0].decl.NrTokens = 2;
out[0].decl.File = file;
out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
- out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT;
out[0].decl.Semantic = 0;
out[1].value = 0;
@@ -1285,7 +1288,6 @@ emit_decl_range2D(struct ureg_program *ureg,
out[0].decl.NrTokens = 3;
out[0].decl.File = file;
out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
- out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT;
out[0].decl.Dimension = 1;
out[1].value = 0;
@@ -1312,7 +1314,6 @@ emit_decl_sampler_view(struct ureg_program *ureg,
out[0].decl.NrTokens = 3;
out[0].decl.File = TGSI_FILE_SAMPLER_VIEW;
out[0].decl.UsageMask = 0xf;
- out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT;
out[1].value = 0;
out[1].decl_range.First = index;