mesa: avoid generating constant vertex attributes in fixedfunc programs
Keep track of enabled/active vertex attributes. Keep track of potential vertex program outputs. When generating fragment program, replace references to fragment attributes which are effectively non-varying and non-computed passthrough attributes with references to the new CURRENT_ATTRIB tracked state value. Only downside is slight ugliness in VBO code where we need to validate state twice in succession.
This commit is contained in:
@@ -465,7 +465,8 @@ _mesa_update_state_locked( GLcontext *ctx )
|
||||
_mesa_update_tnl_spaces( ctx, new_state );
|
||||
|
||||
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
|
||||
prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
|
||||
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT |
|
||||
_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
|
||||
}
|
||||
if (ctx->VertexProgram._MaintainTnlProgram) {
|
||||
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
|
||||
@@ -504,3 +505,38 @@ _mesa_update_state( GLcontext *ctx )
|
||||
_mesa_update_state_locked(ctx);
|
||||
_mesa_unlock_context_textures(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Want to figure out which fragment program inputs are actually
|
||||
* constant/current values from ctx->Current. These should be
|
||||
* referenced as a tracked state variable rather than a fragment
|
||||
* program input, to save the overhead of putting a constant value in
|
||||
* every submitted vertex, transferring it to hardware, interpolating
|
||||
* it across the triangle, etc...
|
||||
*
|
||||
* When there is a VP bound, just use vp->outputs. But when we're
|
||||
* generating vp from fixed function state, basically want to
|
||||
* calculate:
|
||||
*
|
||||
* vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) |
|
||||
* potential_vp_outputs )
|
||||
*
|
||||
* Where potential_vp_outputs is calculated by looking at enabled
|
||||
* texgen, etc.
|
||||
*
|
||||
* The generated fragment program should then only declare inputs that
|
||||
* may vary or otherwise differ from the ctx->Current values.
|
||||
* Otherwise, the fp should track them as state values instead.
|
||||
*/
|
||||
void
|
||||
_mesa_set_varying_vp_inputs( GLcontext *ctx,
|
||||
unsigned varying_inputs )
|
||||
{
|
||||
if (ctx->varying_vp_inputs != varying_inputs) {
|
||||
ctx->varying_vp_inputs = varying_inputs;
|
||||
ctx->NewState |= _NEW_ARRAY;
|
||||
//_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user