From 1680ef869625dc1fe9cf481b180382a34e0738e7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 17:30:59 +0100 Subject: 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. --- src/mesa/vbo/vbo_exec_draw.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_draw.c') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index f497e9a5a5..ad60c9b05f 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -150,6 +150,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) GLubyte *data = exec->vtx.buffer_map; const GLuint *map; GLuint attr; + GLuint varying_inputs = 0; /* Install the default (ie Current) attributes first, then overlay * all active ones. @@ -211,8 +212,11 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) arrays[attr]._MaxElement = count; /* ??? */ data += exec->vtx.attrsz[src] * sizeof(GLfloat); + varying_inputs |= 1<NewState) + _mesa_update_state( ctx ); + + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; -- cgit v1.2.3 From 239617fbe22d4dd7b2794510a6665f09602b5adf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Oct 2008 11:22:47 -0600 Subject: mesa: replace GLuint with GLbitfield to be clearer about usage Also, fix up some comments to be doxygen style. --- src/mesa/main/mtypes.h | 2 +- src/mesa/main/state.c | 2 +- src/mesa/main/state.h | 2 +- src/mesa/main/texenvprogram.c | 30 ++++++++++++++++-------------- src/mesa/vbo/vbo_exec_array.c | 2 +- src/mesa/vbo/vbo_exec_draw.c | 2 +- src/mesa/vbo/vbo_save_draw.c | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_draw.c') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ca1e369a35..dff474d6d0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3073,7 +3073,7 @@ struct __GLcontextRec GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - GLuint varying_vp_inputs; + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ /** \name Derived state */ /*@{*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index e0eb5f81e2..b124d48269 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -532,7 +532,7 @@ _mesa_update_state( GLcontext *ctx ) */ void _mesa_set_varying_vp_inputs( GLcontext *ctx, - unsigned varying_inputs ) + GLbitfield varying_inputs ) { if (ctx->varying_vp_inputs != varying_inputs) { ctx->varying_vp_inputs = varying_inputs; diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index dc08043a76..79f2f6beb0 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -39,6 +39,6 @@ _mesa_update_state_locked( GLcontext *ctx ); void _mesa_set_varying_vp_inputs( GLcontext *ctx, - unsigned varying_inputs ); + GLbitfield varying_inputs ); #endif diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 7049467c22..638d6be5ad 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -192,7 +192,8 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) #define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) #define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) -/* Identify all possible varying inputs. The fragment program will +/** + * Identify all possible varying inputs. The fragment program will * never reference non-varying inputs, but will track them via state * constants instead. * @@ -200,15 +201,15 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) * has access to. The bitmask is later reduced to just those which * are actually referenced. */ -static GLuint get_fp_input_mask( GLcontext *ctx ) +static GLbitfield get_fp_input_mask( GLcontext *ctx ) { - GLuint fp_inputs = 0; + GLbitfield fp_inputs = 0x0; if (!ctx->VertexProgram._Enabled || !ctx->VertexProgram._Current) { /* Fixed function logic */ - GLuint varying_inputs = ctx->varying_vp_inputs; + GLbitfield varying_inputs = ctx->varying_vp_inputs; /* First look at what values may be computed by the generated * vertex program: @@ -235,7 +236,7 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) } else { /* calculate from vp->outputs */ - GLuint vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; + GLbitfield vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0; if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1; @@ -255,8 +256,8 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) static void make_state_key( GLcontext *ctx, struct state_key *key ) { GLuint i, j; - GLuint inputs_referenced = FRAG_BIT_COL0; - GLuint inputs_available = get_fp_input_mask( ctx ); + GLbitfield inputs_referenced = FRAG_BIT_COL0; + GLbitfield inputs_available = get_fp_input_mask( ctx ); memset(key, 0, sizeof(*key)); @@ -311,7 +312,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) key->inputs_available = (inputs_available & inputs_referenced); } -/* Use uregs to represent registers internally, translate to Mesa's +/** + * Use uregs to represent registers internally, translate to Mesa's * expected formats on emit. * * NOTE: These are passed by value extensively in this file rather @@ -344,16 +346,16 @@ static const struct ureg undef = { }; -/* State used to build the fragment program: +/** State used to build the fragment program: */ struct texenv_fragment_program { struct gl_fragment_program *program; GLcontext *ctx; struct state_key *state; - GLbitfield alu_temps; /* Track texture indirections, see spec. */ - GLbitfield temps_output; /* Track texture indirections, see spec. */ - GLbitfield temp_in_use; /* Tracks temporary regs which are in use. */ + GLbitfield alu_temps; /**< Track texture indirections, see spec. */ + GLbitfield temps_output; /**< Track texture indirections, see spec. */ + GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ GLboolean error; struct ureg src_texture[MAX_TEXTURE_UNITS]; @@ -361,11 +363,11 @@ struct texenv_fragment_program { * else undef. */ - struct ureg src_previous; /* Reg containing color from previous + struct ureg src_previous; /**< Reg containing color from previous * stage. May need to be decl'd. */ - GLuint last_tex_stage; /* Number of last enabled texture unit */ + GLuint last_tex_stage; /**< Number of last enabled texture unit */ struct ureg half; struct ureg one; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 3d74f9f431..8871e10cf6 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -127,7 +127,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; const struct gl_client_array **inputs = &exec->array.inputs[0]; - GLuint const_inputs = 0; + GLbitfield const_inputs = 0x0; GLuint i; exec->array.program_mode = get_program_mode(ctx); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index ad60c9b05f..ae43857c8a 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -150,7 +150,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) GLubyte *data = exec->vtx.buffer_map; const GLuint *map; GLuint attr; - GLuint varying_inputs = 0; + GLbitfield varying_inputs = 0x0; /* Install the default (ie Current) attributes first, then overlay * all active ones. diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 68f3a965a5..0488c5d718 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -118,7 +118,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint data = node->buffer_offset; const GLuint *map; GLuint attr; - GLuint varying_inputs = 0; + GLbitfield varying_inputs = 0x0; /* Install the default (ie Current) attributes first, then overlay * all active ones. -- cgit v1.2.3