tgsi: Fix POSITION and FACE fragment shader inputs.

This commit is contained in:
Michal Krol 2009-11-23 10:49:41 +01:00
parent b7590cde4a
commit cc35a454da
2 changed files with 42 additions and 36 deletions

View file

@ -1832,53 +1832,58 @@ typedef void (* eval_coef_func)(
unsigned chan ); unsigned chan );
static void static void
exec_declaration( exec_declaration(struct tgsi_exec_machine *mach,
struct tgsi_exec_machine *mach, const struct tgsi_full_declaration *decl)
const struct tgsi_full_declaration *decl )
{ {
if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) { if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
if( decl->Declaration.File == TGSI_FILE_INPUT ) { if (decl->Declaration.File == TGSI_FILE_INPUT) {
unsigned first, last, mask; uint first, last, mask;
eval_coef_func eval;
first = decl->DeclarationRange.First; first = decl->DeclarationRange.First;
last = decl->DeclarationRange.Last; last = decl->DeclarationRange.Last;
mask = decl->Declaration.UsageMask; mask = decl->Declaration.UsageMask;
switch( decl->Declaration.Interpolate ) { if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
case TGSI_INTERPOLATE_CONSTANT: assert(decl->Semantic.SemanticIndex == 0);
eval = eval_constant_coef; assert(first == last);
break; assert(mask = TGSI_WRITEMASK_XYZW);
case TGSI_INTERPOLATE_LINEAR: mach->Inputs[first] = mach->QuadPos;
eval = eval_linear_coef; } else if (decl->Semantic.SemanticName == TGSI_SEMANTIC_FACE) {
break; uint i;
case TGSI_INTERPOLATE_PERSPECTIVE: assert(decl->Semantic.SemanticIndex == 0);
eval = eval_perspective_coef; assert(first == last);
break;
default: for (i = 0; i < QUAD_SIZE; i++) {
assert( 0 ); mach->Inputs[first].xyzw[0].f[i] = mach->Face;
return;
}
if( mask == TGSI_WRITEMASK_XYZW ) {
unsigned i, j;
for( i = first; i <= last; i++ ) {
for( j = 0; j < NUM_CHANNELS; j++ ) {
eval( mach, i, j );
}
} }
} } else {
else { eval_coef_func eval;
unsigned i, j; uint i, j;
for( j = 0; j < NUM_CHANNELS; j++ ) { switch (decl->Declaration.Interpolate) {
if( mask & (1 << j) ) { case TGSI_INTERPOLATE_CONSTANT:
for( i = first; i <= last; i++ ) { eval = eval_constant_coef;
eval( mach, i, j ); break;
case TGSI_INTERPOLATE_LINEAR:
eval = eval_linear_coef;
break;
case TGSI_INTERPOLATE_PERSPECTIVE:
eval = eval_perspective_coef;
break;
default:
assert(0);
return;
}
for (j = 0; j < NUM_CHANNELS; j++) {
if (mask & (1 << j)) {
for (i = first; i <= last; i++) {
eval(mach, i, j);
} }
} }
} }

View file

@ -232,6 +232,7 @@ struct tgsi_exec_machine
/* FRAGMENT processor only. */ /* FRAGMENT processor only. */
const struct tgsi_interp_coef *InterpCoefs; const struct tgsi_interp_coef *InterpCoefs;
struct tgsi_exec_vector QuadPos; struct tgsi_exec_vector QuadPos;
float Face; /**< +1 if front facing, -1 if back facing */
/* Conditional execution masks */ /* Conditional execution masks */
uint CondMask; /**< For IF/ELSE/ENDIF */ uint CondMask; /**< For IF/ELSE/ENDIF */