Mesa (master): softpipe: fix up FS variant unbinding / deletion

Brian Paul brianp at kemper.freedesktop.org
Wed Dec 19 18:21:46 UTC 2012


Module: Mesa
Branch: master
Commit: fddcc67f5cb41f70d1d11827eb9190a5caec13c5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fddcc67f5cb41f70d1d11827eb9190a5caec13c5

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Dec 14 10:47:46 2012 -0700

softpipe: fix up FS variant unbinding / deletion

The old call to tgsi_exec_machine_bind_shader() in
softpipe_delete_fs_state() was never called since the shader's original
tokens are never passed to the tgsi interpreter (only shader _variant_
tokens are).  Now, unbind the variant's tokens from the tgsi interpreter
when we free the variant.

This doesn't fix any known bugs but it's the right thing to do.

Note: This is a candidate for the stable branches.

---

 src/gallium/drivers/softpipe/sp_fs_exec.c      |    7 ++++++-
 src/gallium/drivers/softpipe/sp_state.h        |    3 ++-
 src/gallium/drivers/softpipe/sp_state_shader.c |   10 +---------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index f534492..3793d9b 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -177,8 +177,13 @@ exec_run( const struct sp_fragment_shader_variant *var,
 
 
 static void 
-exec_delete( struct sp_fragment_shader_variant *var )
+exec_delete(struct sp_fragment_shader_variant *var,
+            struct tgsi_exec_machine *machine)
 {
+   if (machine->Tokens == var->tokens) {
+      tgsi_exec_machine_bind_shader(machine, NULL, 0, NULL);
+   }
+
    FREE( (void *) var->tokens );
    FREE(var);
 }
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index eb85b06..fa8654f 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -88,7 +88,8 @@ struct sp_fragment_shader_variant
 		   struct quad_header *quad);
 
    /* Deletes this instance of the object */
-   void (*delete)(struct sp_fragment_shader_variant *shader);
+   void (*delete)(struct sp_fragment_shader_variant *shader,
+                  struct tgsi_exec_machine *machine);
 
    struct sp_fragment_shader_variant *next;
 };
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 1e64431..40d32a4 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -38,7 +38,6 @@
 #include "draw/draw_vs.h"
 #include "draw/draw_gs.h"
 #include "tgsi/tgsi_dump.h"
-#include "tgsi/tgsi_exec.h"
 #include "tgsi/tgsi_scan.h"
 #include "tgsi/tgsi_parse.h"
 
@@ -182,13 +181,6 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
 
    assert(fs != softpipe->fs);
 
-   if (softpipe->fs_machine->Tokens == state->shader.tokens) {
-      /* unbind the shader from the tgsi executor if we're
-       * deleting it.
-       */
-      tgsi_exec_machine_bind_shader(softpipe->fs_machine, NULL, 0, NULL);
-   }
-
    /* delete variants */
    for (var = state->variants; var; var = next_var) {
       next_var = var->next;
@@ -200,7 +192,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
       draw_delete_fragment_shader(softpipe->draw, var->draw_shader);
 #endif
 
-      var->delete(var);
+      var->delete(var, softpipe->fs_machine);
    }
 
    draw_delete_fragment_shader(softpipe->draw, state->draw_shader);




More information about the mesa-commit mailing list