diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2011-08-20 13:51:36 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2011-10-07 16:39:50 -0700 |
commit | 010cc547ca8c1fb2107106b0ad0de560780ce9aa (patch) | |
tree | c653715e4bac2040927dcdbf2f353c6070984855 | |
parent | 2fae55666e298525fe3b5550aa2a2ebeea437710 (diff) |
mesa: Use gl_shader_program::_LinkedShaders instead of VertexProgram
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs.c | 8 | ||||
-rw-r--r-- | src/mesa/main/context.c | 2 | ||||
-rw-r--r-- | src/mesa/main/ff_fragment_shader.cpp | 10 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 9 | ||||
-rw-r--r-- | src/mesa/main/shaderobj.c | 1 | ||||
-rw-r--r-- | src/mesa/main/state.c | 6 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 8 | ||||
-rw-r--r-- | src/mesa/main/uniforms.c | 12 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 4 |
13 files changed, 39 insertions, 34 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index b26700f7494..e0e4781fecd 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -2347,7 +2347,8 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c, this->current_annotation = NULL; this->c = c; - this->vp = prog->VertexProgram; + this->vp = (struct gl_vertex_program *) + prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program; this->prog_data = &c->prog_data; this->variable_ht = hash_table_ctor(0, diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index f671223b8c2..310a022d652 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -354,15 +354,17 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog) { struct brw_context *brw = brw_context(ctx); struct brw_vs_prog_key key; - struct gl_vertex_program *vp = prog->VertexProgram; - struct brw_vertex_program *bvp = brw_vertex_program(vp); uint32_t old_prog_offset = brw->vs.prog_offset; struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data; bool success; - if (!vp) + if (!prog->_LinkedShaders[MESA_SHADER_VERTEX]) return true; + struct gl_vertex_program *vp = (struct gl_vertex_program *) + prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program; + struct brw_vertex_program *bvp = brw_vertex_program(vp); + memset(&key, 0, sizeof(key)); key.program_string_id = bvp->id; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2532c47de15..b825a63feef 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1852,7 +1852,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) sh = shProg[i]->_LinkedShaders[i]; switch (sh->Type) { case GL_VERTEX_SHADER: - _mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base); + _mesa_append_uniforms_to_file(sh, sh->Program); break; case GL_GEOMETRY_SHADER_ARB: diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 7cc17216884..e6451c98b21 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -315,7 +315,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) const GLboolean vertexShader = (ctx->Shader.CurrentVertexProgram && ctx->Shader.CurrentVertexProgram->LinkStatus && - ctx->Shader.CurrentVertexProgram->VertexProgram); + ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]); const GLboolean vertexProgram = ctx->VertexProgram._Enabled; GLbitfield fp_inputs = 0x0; @@ -371,7 +371,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) } else { /* calculate from vp->outputs */ - struct gl_vertex_program *vprog; + struct gl_program *vprog; GLbitfield64 vp_outputs; /* Choose GLSL vertex shader over ARB vertex program. Need this @@ -379,11 +379,11 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) * validation (see additional comments in state.c). */ if (vertexShader) - vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program; else - vprog = ctx->VertexProgram.Current; + vprog = &ctx->VertexProgram.Current->Base; - vp_outputs = vprog->Base.OutputsWritten; + vp_outputs = vprog->OutputsWritten; /* These get generated in the setup routine regardless of the * vertex program: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d329bee8006..71236f9d67c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2171,7 +2171,6 @@ struct gl_shader_program } Vert; /* post-link info: */ - struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ struct gl_uniform_list *Uniforms; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 9e0ed9c6977..d9559baeff7 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -808,8 +808,9 @@ print_shader_info(const struct gl_shader_program *shProg) shProg->Shaders[i]->Name, shProg->Shaders[i]->SourceChecksum); } - if (shProg->VertexProgram) - printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); + if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) + printf(" vert prog %u\n", + shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id); if (shProg->FragmentProgram) printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); if (shProg->GeometryProgram) @@ -963,7 +964,7 @@ static GLboolean validate_shader_program(const struct gl_shader_program *shProg, char *errMsg) { - const struct gl_vertex_program *vp = shProg->VertexProgram; + const struct gl_shader *vs = shProg->_LinkedShaders[MESA_SHADER_VERTEX]; const struct gl_geometry_program *gp = shProg->GeometryProgram; const struct gl_fragment_program *fp = shProg->FragmentProgram; @@ -991,7 +992,7 @@ validate_shader_program(const struct gl_shader_program *shProg, * Check: any two active samplers in the current program object are of * different types, but refer to the same texture image unit, */ - if (vp && !validate_samplers(&vp->Base, errMsg)) { + if (vs && !validate_samplers(vs->Program, errMsg)) { return GL_FALSE; } if (gp && !validate_samplers(&gp->Base, errMsg)) { diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 1eba75697f7..f5f5e701a41 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -275,7 +275,6 @@ void _mesa_clear_shader_program_data(struct gl_context *ctx, struct gl_shader_program *shProg) { - _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL); _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL); _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index fc25515a00c..ab7250f3fc1 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -281,10 +281,12 @@ update_program(struct gl_context *ctx) * _mesa_get_fixed_func_vertex_program() needs to know active * fragprog inputs. */ - if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) { + if (vsProg && vsProg->LinkStatus + && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) { /* Use GLSL vertex shader */ _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - vsProg->VertexProgram); + (struct gl_vertex_program *) + vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program); } else if (ctx->VertexProgram._Enabled) { /* Use user-defined vertex program */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index e02f16240fd..ee99e507c97 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -490,16 +490,16 @@ update_texture_state( struct gl_context *ctx ) { GLuint unit; struct gl_fragment_program *fprog = NULL; - struct gl_vertex_program *vprog = NULL; + struct gl_program *vprog = NULL; GLbitfield enabledFragUnits = 0x0; if (ctx->Shader.CurrentVertexProgram && ctx->Shader.CurrentVertexProgram->LinkStatus) { - vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program; } else if (ctx->VertexProgram._Enabled) { /* XXX enable this if/when non-shader vertex programs get * texture fetches: - vprog = ctx->VertexProgram.Current; + vprog = &ctx->VertexProgram.Current->Base; */ } @@ -540,7 +540,7 @@ update_texture_state( struct gl_context *ctx ) * settle on the one with highest priority (see below). */ if (vprog) { - enabledVertTargets |= vprog->Base.TexturesUsed[unit]; + enabledVertTargets |= vprog->TexturesUsed[unit]; } if (fprog) { diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 2323819aa43..28a3beef596 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -180,7 +180,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index, pos = shProg->Uniforms->Uniforms[index].VertPos; if (pos >= 0) { - prog = &shProg->VertexProgram->Base; + prog = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program; } else { pos = shProg->Uniforms->Uniforms[index].FragPos; @@ -911,11 +911,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, /* A uniform var may be used by both a vertex shader and a fragment * shader. We may need to update one or both shader's uniform here: */ - if (shProg->VertexProgram) { + if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) { /* convert uniform location to program parameter index */ GLint index = uniform->VertPos; if (index >= 0) { - set_program_uniform(ctx, &shProg->VertexProgram->Base, + set_program_uniform(ctx, + shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program, index, offset, type, count, elems, values); } } @@ -1056,11 +1057,12 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, uniform = &shProg->Uniforms->Uniforms[location]; - if (shProg->VertexProgram) { + if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) { /* convert uniform location to program parameter index */ GLint index = uniform->VertPos; if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base, + set_program_uniform_matrix(ctx, + shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program, index, offset, count, rows, cols, transpose, values); } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2e1b8fba306..652e7067d57 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -3294,8 +3294,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) case GL_VERTEX_SHADER: ((struct gl_vertex_program *)linked_prog)->UsesClipDistance = prog->Vert.UsesClipDistance; - _mesa_reference_vertprog(ctx, &prog->VertexProgram, - (struct gl_vertex_program *)linked_prog); + _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, + linked_prog); ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, linked_prog); break; @@ -3427,7 +3427,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) } } - _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL); _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL); _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index d8ef8a3ce19..01e4d88baf7 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5184,8 +5184,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) switch (prog->_LinkedShaders[i]->Type) { case GL_VERTEX_SHADER: - _mesa_reference_vertprog(ctx, &prog->VertexProgram, - (struct gl_vertex_program *)linked_prog); + _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, + linked_prog); ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, linked_prog); if (!ok) { diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index a4f47edfcd3..5211043de04 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1153,8 +1153,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - destroy_program_variants(st, (struct gl_program *) - shProg->VertexProgram); + destroy_program_variants(st, + shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program); destroy_program_variants(st, (struct gl_program *) shProg->FragmentProgram); destroy_program_variants(st, (struct gl_program *) |