Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / drivers / softpipe / sp_fs_exec.c
index 0b199a2193e9fa579b07556c45b4b64d0ed644ce..f472dd0ed2ad2d9d7e7d675f8464a807600bc611 100644 (file)
 
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
 #include "pipe/p_inlines.h"
-#include "tgsi/exec/tgsi_exec.h"
-#include "tgsi/util/tgsi_parse.h"
+#include "tgsi/tgsi_exec.h"
+#include "tgsi/tgsi_parse.h"
 
-struct sp_exec_fragment_shader {
+struct sp_exec_fragment_shader
+{
    struct sp_fragment_shader base;
 };
 
 
+/** cast wrapper */
+static INLINE struct sp_exec_fragment_shader *
+sp_exec_fragment_shader(const struct sp_fragment_shader *base)
+{
+   return (struct sp_exec_fragment_shader *) base;
+}
+
 
 /**
  * Compute quad X,Y,Z,W for the four fragments in a quad.
@@ -86,10 +94,16 @@ exec_prepare( const struct sp_fragment_shader *base,
              struct tgsi_exec_machine *machine,
              struct tgsi_sampler *samplers )
 {
-   tgsi_exec_machine_bind_shader( machine,
-                                 base->shader.tokens,
-                                 PIPE_MAX_SAMPLERS,
-                                 samplers );
+   /*
+    * Bind tokens/shader to the interpreter's machine state.
+    * Avoid redundant binding.
+    */
+   if (machine->Tokens != base->shader.tokens) {
+      tgsi_exec_machine_bind_shader( machine,
+                                     base->shader.tokens,
+                                     PIPE_MAX_SAMPLERS,
+                                     samplers );
+   }
 }
 
 
@@ -106,7 +120,7 @@ exec_run( const struct sp_fragment_shader *base,
 
    /* Compute X, Y, Z, W vals for this quad */
    sp_setup_pos_vector(quad->posCoef, 
-                      (float)quad->x0, (float)quad->y0, 
+                      (float)quad->input.x0, (float)quad->input.y0, 
                       &machine->QuadPos);
    
    return tgsi_exec_machine_run( machine );