On Fri, Mar 28, 2014 at 5:40 AM, Ian Romanick <i...@freedesktop.org> wrote: > From: Ian Romanick <ian.d.roman...@intel.com> > > This code was broken in some odd ways before. To much state was being > saved, it was being restored in the wrong order, and in the wrong way. > The biggest problem was that the pipeline object was restored before > restoring the programs attached to the default pipeline. > > Fixes a regression in the glean texgen test. > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > --- > src/mesa/drivers/common/meta.c | 34 ++++++++++++++++++++-------------- > src/mesa/drivers/common/meta.h | 1 - > 2 files changed, 20 insertions(+), 15 deletions(-) > > diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c > index acf927b..18d8a57 100644 > --- a/src/mesa/drivers/common/meta.c > +++ b/src/mesa/drivers/common/meta.c > @@ -537,11 +537,15 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield > state) > } > > if (ctx->Extensions.ARB_separate_shader_objects) { > - /* Warning it must be done before _mesa_UseProgram call */ > - _mesa_reference_pipeline_object(ctx, &save->_Shader, ctx->_Shader); > - _mesa_reference_pipeline_object(ctx, &save->Pipeline, > - ctx->Pipeline.Current); > - _mesa_BindProgramPipeline(0); > + /* Warning: This must be done before saving the current programs. > + * Otherwise the programs attached to the pipeline will be saved > + * instead of the programs attached to the default pipeline. > + */ > + if (ctx->Pipeline.Current != ctx->Pipeline.Default) { > + _mesa_reference_pipeline_object(ctx, &save->Pipeline, > + ctx->Pipeline.Current); > + _mesa_BindProgramPipeline(0); > + } > } > > for (i = 0; i < MESA_SHADER_STAGES; i++) { > @@ -889,14 +893,6 @@ _mesa_meta_end(struct gl_context *ctx) > save->ATIFragmentShaderEnabled); > } > > - /* Warning it must be done before _mesa_use_shader_program call */ > - if (ctx->Extensions.ARB_separate_shader_objects) { > - _mesa_reference_pipeline_object(ctx, &ctx->_Shader, save->_Shader); > - _mesa_reference_pipeline_object(ctx, &ctx->Pipeline.Current, > - save->Pipeline); > - _mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL); > - } > - > if (ctx->Extensions.ARB_vertex_shader) { > _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, > save->Shader[MESA_SHADER_VERTEX], > @@ -916,10 +912,20 @@ _mesa_meta_end(struct gl_context *ctx) > _mesa_reference_shader_program(ctx, &ctx->_Shader->ActiveProgram, > save->ActiveShader); > > + /* Warning: This must be done after _mesa_use_shader_program call. > + * Otherwise the programs will be restored to the pipeline object > + * instead of to the default pipeline. > + */ > + if (save->Pipeline) { > + assert(ctx->Extensions.ARB_separate_shader_objects); > + _mesa_bind_pipeline(ctx, save->Pipeline); If the meta op called _mesa_UseProgram(), it would point ctx->_Shader to ctx->Shader. _mesa_bind_pipeline would refuse to point ctx->_Shader to save->Pipeline.
> + > + _mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL); > + } > + > for (i = 0; i < MESA_SHADER_STAGES; i++) > _mesa_reference_shader_program(ctx, &save->Shader[i], NULL); > _mesa_reference_shader_program(ctx, &save->ActiveShader, NULL); > - _mesa_reference_pipeline_object(ctx, &save->_Shader, NULL); > } > > if (state & MESA_META_STENCIL_TEST) { > diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h > index 4faae0b..c03507e 100644 > --- a/src/mesa/drivers/common/meta.h > +++ b/src/mesa/drivers/common/meta.h > @@ -121,7 +121,6 @@ struct save_state > GLboolean ATIFragmentShaderEnabled; > struct gl_shader_program *Shader[MESA_SHADER_STAGES]; > struct gl_shader_program *ActiveShader; > - struct gl_pipeline_object *_Shader; > struct gl_pipeline_object *Pipeline; > > /** MESA_META_STENCIL_TEST */ > -- > 1.8.1.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev -- o...@lunarg.com _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev