From: Brian Paul Date: Fri, 14 Dec 2012 17:34:33 +0000 (-0700) Subject: softpipe: fix unreliable FS variant binding bug X-Git-Tag: accepted/2.0alpha-wayland/20130301.050525~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8830f5a4009c3784836edb441319a62c7beef36;p=profile%2Fivi%2Fmesa.git softpipe: fix unreliable FS variant binding bug In exec_prepare() we were comparing pointers to see if the fragment shader variant had changed before calling tgsi_exec_machine_bind_shader(). This didn't work reliably when there was a lot of shader token malloc/ freeing going on because the memory might get reused. Instead, bind the shader variant during regular state validation. Fixes http://bugs.freedesktop.org/show_bug.cgi?id=40404 (fixes a couple of piglit's glsl-max-varyings test) Note: This is a candidate for the stable branches. (cherry picked from commit 18ef8f83b2586de037df7e578d88cbfb6e764012) --- diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c index 16efb51..3793d9b 100644 --- a/src/gallium/drivers/softpipe/sp_fs_exec.c +++ b/src/gallium/drivers/softpipe/sp_fs_exec.c @@ -66,14 +66,11 @@ exec_prepare( const struct sp_fragment_shader_variant *var, { /* * Bind tokens/shader to the interpreter's machine state. - * Avoid redundant binding. */ - if (machine->Tokens != var->tokens) { - tgsi_exec_machine_bind_shader( machine, - var->tokens, - PIPE_MAX_SAMPLERS, - samplers ); - } + tgsi_exec_machine_bind_shader(machine, + var->tokens, + PIPE_MAX_SAMPLERS, + samplers); } diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 892d9c6..f32fe5f 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -148,13 +148,6 @@ shade_quads(struct quad_stage *qs, static void shade_begin(struct quad_stage *qs) { - struct softpipe_context *softpipe = qs->softpipe; - - softpipe->fs_variant->prepare( softpipe->fs_variant, - softpipe->fs_machine, - (struct tgsi_sampler **) - softpipe->tgsi.samplers_list[PIPE_SHADER_FRAGMENT] ); - qs->next->begin(qs->next); } diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index cb954a1..e4a5a63 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -242,6 +242,12 @@ update_fragment_shader(struct softpipe_context *softpipe, unsigned prim) if (softpipe->fs) { softpipe->fs_variant = softpipe_find_fs_variant(softpipe, softpipe->fs, &key); + + /* prepare the TGSI interpreter for FS execution */ + softpipe->fs_variant->prepare(softpipe->fs_variant, + softpipe->fs_machine, + (struct tgsi_sampler **) softpipe-> + tgsi.samplers_list[PIPE_SHADER_FRAGMENT]); } else { softpipe->fs_variant = NULL;