gallium: remove TGSI_SEMANTIC_VERTICES
[mesa.git] / src / gallium / auxiliary / draw / draw_vs_sse.c
index f638208bf580bb1d562e0ff933dd12d411cfdddf..702051387acb875fe2365d02f39f0872a893e188 100644 (file)
   *   Brian Paul
   */
 
+#include "util/u_math.h"
+#include "util/u_memory.h"
 #include "pipe/p_config.h"
 
 #include "draw_vs.h"
 
 #if defined(PIPE_ARCH_X86)
 
-#include "pipe/p_util.h"
 #include "pipe/p_shader_tokens.h"
 
 #include "draw_private.h"
 
 #include "rtasm/rtasm_cpu.h"
 #include "rtasm/rtasm_x86sse.h"
-#include "tgsi/exec/tgsi_sse2.h"
-#include "tgsi/util/tgsi_parse.h"
+#include "tgsi/tgsi_sse2.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_exec.h"
 
 #define SSE_MAX_VERTICES 4
 
-typedef void (XSTDCALL *codegen_function) (
-   const struct tgsi_exec_vector *input, /* 1 */
-   struct tgsi_exec_vector *output, /* 2 */
-   float (*constant)[4],        /* 3 */
-   struct tgsi_exec_vector *temporary, /* 4 */
-   float (*immediates)[4],      /* 5 */
-   const float (*aos_input)[4], /* 6 */
-   uint num_inputs,             /* 7 */
-   uint input_stride,           /* 8 */
-   float (*aos_output)[4],      /* 9 */
-   uint num_outputs,            /* 10 */
-   uint output_stride );        /* 11 */
 
 struct draw_sse_vertex_shader {
    struct draw_vertex_shader base;
    struct x86_function sse2_program;
 
-   codegen_function func;
+   tgsi_sse2_vs_func func;
    
    struct tgsi_exec_machine *machine;
 };
@@ -77,6 +67,10 @@ static void
 vs_sse_prepare( struct draw_vertex_shader *base,
                struct draw_context *draw )
 {
+   struct draw_sse_vertex_shader *shader = (struct draw_sse_vertex_shader *)base;
+   struct tgsi_exec_machine *machine = shader->machine;
+
+   machine->Samplers = draw->vs.samplers;
 }
 
 
@@ -98,16 +92,28 @@ vs_sse_run_linear( struct draw_vertex_shader *base,
    struct tgsi_exec_machine *machine = shader->machine;
    unsigned int i;
 
+   /* By default, execute all channels.  XXX move this inside the loop
+    * below when we support shader conditionals/loops.
+    */
+   tgsi_set_exec_mask(machine, 1, 1, 1, 1);
+
    for (i = 0; i < count; i += MAX_TGSI_VERTICES) {
       unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i);
 
+      if (max_vertices < 4) {
+         /* disable the unused execution channels */
+         tgsi_set_exec_mask(machine,
+                            1,
+                            max_vertices > 1,
+                            max_vertices > 2,
+                            0);
+      }
+
       /* run compiled shader
        */
-      shader->func(machine->Inputs,
-                  machine->Outputs,
-                  (float (*)[4])constants,
-                  machine->Temps,
-                  (float (*)[4])shader->base.immediates,
+      shader->func(machine,
+                  constants,
+                  shader->base.immediates,
                    input,
                    base->info.num_inputs,
                    input_stride,
@@ -158,8 +164,10 @@ draw_create_vs_sse(struct draw_context *draw,
    tgsi_scan_shader(templ->tokens, &vs->base.info);
 
    vs->base.draw = draw;
-   vs->base.create_varient = draw_vs_varient_aos_sse;
-//   vs->base.create_varient = draw_vs_varient_generic;
+   if (1)
+      vs->base.create_varient = draw_vs_varient_aos_sse;
+   else
+      vs->base.create_varient = draw_vs_varient_generic;
    vs->base.prepare = vs_sse_prepare;
    vs->base.run_linear = vs_sse_run_linear;
    vs->base.delete = vs_sse_delete;
@@ -167,7 +175,7 @@ draw_create_vs_sse(struct draw_context *draw,
    vs->base.immediates = align_malloc(TGSI_EXEC_NUM_IMMEDIATES * 4 *
                                       sizeof(float), 16);
 
-   vs->machine = &draw->vs.machine;
+   vs->machine = draw->vs.machine;
    
    x86_init_func( &vs->sse2_program );
 
@@ -177,7 +185,7 @@ draw_create_vs_sse(struct draw_context *draw,
                         TRUE )) 
       goto fail;
       
-   vs->func = (codegen_function) x86_get_func( &vs->sse2_program );
+   vs->func = (tgsi_sse2_vs_func) x86_get_func( &vs->sse2_program );
    if (!vs->func) {
       goto fail;
    }