mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 12:30:09 +01:00
965: scan fs inputs to work out interpolation in setup program
This commit is contained in:
parent
4e62fbbfc5
commit
25c9728644
2 changed files with 87 additions and 45 deletions
|
|
@ -119,7 +119,11 @@ static boolean search_cache( struct brw_context *brw,
|
|||
*/
|
||||
static void upload_sf_prog( struct brw_context *brw )
|
||||
{
|
||||
const struct brw_fragment_program *fs = brw->attribs.FragmentProgram;
|
||||
struct brw_sf_prog_key key;
|
||||
struct tgsi_parse_context parse;
|
||||
int i, done = 0;
|
||||
|
||||
|
||||
memset(&key, 0, sizeof(key));
|
||||
|
||||
|
|
@ -149,6 +153,63 @@ static void upload_sf_prog( struct brw_context *brw )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Scan fp inputs to figure out what interpolation modes are
|
||||
* required for each incoming vp output. There is an assumption
|
||||
* that the state tracker makes sure there is a 1:1 linkage between
|
||||
* these sets of attributes (XXX: position??)
|
||||
*/
|
||||
tgsi_parse_init( &parse, fs->program.tokens );
|
||||
while( !done &&
|
||||
!tgsi_parse_end_of_tokens( &parse ) )
|
||||
{
|
||||
tgsi_parse_token( &parse );
|
||||
|
||||
switch( parse.FullToken.Token.Type ) {
|
||||
case TGSI_TOKEN_TYPE_DECLARATION:
|
||||
if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT)
|
||||
{
|
||||
int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
|
||||
int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
|
||||
int interp_mode = parse.FullToken.FullDeclaration.Interpolation.Interpolate;
|
||||
//int semantic = parse.FullToken.FullDeclaration.Semantic.SemanticName;
|
||||
//int semantic_index = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
|
||||
|
||||
_mesa_printf("fs input %d..%d interp mode %d\n", first, last, interp_mode);
|
||||
|
||||
switch (interp_mode) {
|
||||
case TGSI_INTERPOLATE_CONSTANT:
|
||||
for (i = first; i <= last; i++)
|
||||
key.const_mask |= (1 << i);
|
||||
break;
|
||||
case TGSI_INTERPOLATE_LINEAR:
|
||||
for (i = first; i <= last; i++)
|
||||
key.linear_mask |= (1 << i);
|
||||
break;
|
||||
case TGSI_INTERPOLATE_PERSPECTIVE:
|
||||
for (i = first; i <= last; i++)
|
||||
key.persp_mask |= (1 << i);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Also need stuff for flat shading, twosided color.
|
||||
*/
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_mesa_printf("key.persp_mask: %x\n", key.persp_mask);
|
||||
_mesa_printf("key.linear_mask: %x\n", key.linear_mask);
|
||||
_mesa_printf("key.const_mask: %x\n", key.const_mask);
|
||||
|
||||
|
||||
// key.do_point_sprite = brw->attribs.Point->PointSprite;
|
||||
// key.SpriteOrigin = brw->attribs.Point->SpriteOrigin;
|
||||
|
||||
|
|
@ -176,6 +237,8 @@ const struct brw_tracked_state brw_sf_prog = {
|
|||
};
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/* Build a struct like the one we'd like the state tracker to pass to
|
||||
* us.
|
||||
*/
|
||||
|
|
@ -202,43 +265,6 @@ static void update_sf_linkage( struct brw_context *brw )
|
|||
|
||||
|
||||
|
||||
/* First scan fp inputs
|
||||
*/
|
||||
tgsi_parse_init( &parse, fs->program.tokens );
|
||||
while( !done &&
|
||||
!tgsi_parse_end_of_tokens( &parse ) )
|
||||
{
|
||||
tgsi_parse_token( &parse );
|
||||
|
||||
switch( parse.FullToken.Token.Type ) {
|
||||
case TGSI_TOKEN_TYPE_DECLARATION:
|
||||
if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT)
|
||||
{
|
||||
int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
|
||||
int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
|
||||
|
||||
for (i = first; i < last; i++) {
|
||||
state.fp_input[i].vp_output = ~0;
|
||||
state.fp_input[i].bf_vp_output = ~0;
|
||||
state.fp_input[i].interp_mode =
|
||||
parse.FullToken.FullDeclaration.Interpolation.Interpolate;
|
||||
|
||||
fp_semantic[i].semantic =
|
||||
parse.FullToken.FullDeclaration.Semantic.SemanticName;
|
||||
fp_semantic[i].semantic_index =
|
||||
parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
|
||||
|
||||
}
|
||||
|
||||
assert(last > state.fp_input_count);
|
||||
state.fp_input_count = last;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
assert(state.fp_input_count == fs->program.num_inputs);
|
||||
|
|
@ -313,3 +339,5 @@ const struct brw_tracked_state brw_sf_linkage = {
|
|||
.update = update_sf_linkage
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -134,30 +134,39 @@ static boolean calculate_masks( struct brw_sf_compile *c,
|
|||
ushort *pc_linear)
|
||||
{
|
||||
boolean is_last_attr = (reg == c->nr_setup_regs - 1);
|
||||
unsigned persp_mask = c->key.persp_mask;
|
||||
unsigned linear_mask = c->key.linear_mask;
|
||||
|
||||
_mesa_printf("persp_mask: %x\n", persp_mask);
|
||||
_mesa_printf("linear_mask: %x\n", linear_mask);
|
||||
|
||||
*pc_persp = 0;
|
||||
*pc_linear = 0;
|
||||
*pc = 0xf;
|
||||
|
||||
// if (persp_mask & (1 << c->idx_to_attr[reg*2]))
|
||||
// *pc_persp = 0xf;
|
||||
if (persp_mask & (1 << (reg*2)))
|
||||
*pc_persp = 0xf;
|
||||
|
||||
// if (linear_mask & (1 << c->idx_to_attr[reg*2]))
|
||||
if (linear_mask & (1 << (reg*2)))
|
||||
*pc_linear = 0xf;
|
||||
|
||||
/* Maybe only processs one attribute on the final round:
|
||||
*/
|
||||
if (1 || reg*2+1 < c->nr_setup_attrs) {
|
||||
if (reg*2+1 < c->nr_setup_attrs) {
|
||||
*pc |= 0xf0;
|
||||
|
||||
// if (persp_mask & (1 << c->idx_to_attr[reg*2+1]))
|
||||
// *pc_persp |= 0xf0;
|
||||
if (persp_mask & (1 << (reg*2+1)))
|
||||
*pc_persp |= 0xf0;
|
||||
|
||||
// if (linear_mask & (1 << c->idx_to_attr[reg*2+1]))
|
||||
if (linear_mask & (1 << (reg*2+1)))
|
||||
*pc_linear |= 0xf0;
|
||||
}
|
||||
|
||||
_mesa_printf("pc: %x\n", *pc);
|
||||
_mesa_printf("pc_persp: %x\n", *pc_persp);
|
||||
_mesa_printf("pc_linear: %x\n", *pc_linear);
|
||||
|
||||
|
||||
return is_last_attr;
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +177,8 @@ void brw_emit_tri_setup( struct brw_sf_compile *c )
|
|||
struct brw_compile *p = &c->func;
|
||||
unsigned i;
|
||||
|
||||
_mesa_printf("%s START ==============\n", __FUNCTION__);
|
||||
|
||||
c->nr_verts = 3;
|
||||
alloc_regs(c);
|
||||
invert_det(c);
|
||||
|
|
@ -181,7 +192,7 @@ void brw_emit_tri_setup( struct brw_sf_compile *c )
|
|||
struct brw_reg a0 = offset(c->vert[0], i);
|
||||
struct brw_reg a1 = offset(c->vert[1], i);
|
||||
struct brw_reg a2 = offset(c->vert[2], i);
|
||||
ushort pc, pc_persp, pc_linear;
|
||||
ushort pc = 0, pc_persp = 0, pc_linear = 0;
|
||||
boolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
|
||||
|
||||
if (pc_persp)
|
||||
|
|
@ -238,6 +249,9 @@ void brw_emit_tri_setup( struct brw_sf_compile *c )
|
|||
BRW_URB_SWIZZLE_TRANSPOSE); /* XXX: Swizzle control "SF to windower" */
|
||||
}
|
||||
}
|
||||
|
||||
_mesa_printf("%s DONE ==============\n", __FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue