From 84eba3ef71dfa822e5ff0463032cdd2e3515b888 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 13 Oct 2010 13:58:44 -0700 Subject: Track separate programs for each stage The assumption is that all stages are the same program or that varyings are passed between stages using built-in varyings. --- src/mesa/drivers/common/meta.c | 30 ++++++++++++++++++++++++------ src/mesa/drivers/dri/i965/brw_fs.cpp | 6 +++--- src/mesa/drivers/dri/i965/brw_wm_state.c | 4 ++-- 3 files changed, 29 insertions(+), 11 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 9946bf1990..1bfd76a665 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -143,7 +143,10 @@ struct save_state struct gl_vertex_program *VertexProgram; GLboolean FragmentProgramEnabled; struct gl_fragment_program *FragmentProgram; - GLuint Shader; + GLuint VertexShader; + GLuint GeometryShader; + GLuint FragmentShader; + GLuint ActiveShader; /** META_STENCIL_TEST */ struct gl_stencil_attrib Stencil; @@ -433,8 +436,15 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) } if (ctx->Extensions.ARB_shader_objects) { - save->Shader = ctx->Shader.CurrentProgram ? - ctx->Shader.CurrentProgram->Name : 0; + save->VertexShader = ctx->Shader.CurrentVertexProgram ? + ctx->Shader.CurrentVertexProgram->Name : 0; + save->GeometryShader = ctx->Shader.CurrentGeometryProgram ? + ctx->Shader.CurrentGeometryProgram->Name : 0; + save->FragmentShader = ctx->Shader.CurrentFragmentProgram ? + ctx->Shader.CurrentFragmentProgram->Name : 0; + save->ActiveShader = ctx->Shader.ActiveProgram ? + ctx->Shader.ActiveProgram->Name : 0; + _mesa_UseProgramObjectARB(0); } } @@ -664,9 +674,17 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); } - if (ctx->Extensions.ARB_shader_objects) { - _mesa_UseProgramObjectARB(save->Shader); - } + if (ctx->Extensions.ARB_vertex_shader) + _mesa_UseShaderProgramEXT(GL_VERTEX_SHADER, save->VertexShader); + + if (ctx->Extensions.ARB_geometry_shader4) + _mesa_UseShaderProgramEXT(GL_GEOMETRY_SHADER_ARB, + save->GeometryShader); + + if (ctx->Extensions.ARB_fragment_shader) + _mesa_UseShaderProgramEXT(GL_FRAGMENT_SHADER, save->FragmentShader); + + _mesa_ActiveProgramEXT(save->ActiveShader); } if (state & META_STENCIL_TEST) { diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 4919394bc8..5f6deb841c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1186,7 +1186,7 @@ fs_visitor::visit(ir_texture *ir) assert(!ir->projector); sampler = _mesa_get_sampler_uniform_value(ir->sampler, - ctx->Shader.CurrentProgram, + ctx->Shader.CurrentFragmentProgram, &brw->fragment_program->Base); sampler = c->fp->program.Base.SamplerUnits[sampler]; @@ -3093,7 +3093,7 @@ fs_visitor::generate_code() if (INTEL_DEBUG & DEBUG_WM) { printf("Native code for fragment shader %d:\n", - ctx->Shader.CurrentProgram->Name); + ctx->Shader.CurrentFragmentProgram->Name); } if_depth_in_loop[loop_stack_depth] = 0; @@ -3320,7 +3320,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c) { struct intel_context *intel = &brw->intel; struct gl_context *ctx = &intel->ctx; - struct gl_shader_program *prog = ctx->Shader.CurrentProgram; + struct gl_shader_program *prog = ctx->Shader.CurrentFragmentProgram; if (!prog) return GL_FALSE; diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index 433ccc66f0..9a27b93710 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -137,9 +137,9 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key) /* If using the fragment shader backend, the program is always * 8-wide. */ - if (ctx->Shader.CurrentProgram) { + if (ctx->Shader.CurrentFragmentProgram) { struct brw_shader *shader = (struct brw_shader *) - ctx->Shader.CurrentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]; + ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]; if (shader != NULL && shader->ir != NULL) { key->is_glsl = GL_TRUE; -- cgit v1.2.3