gallium: handle TGSI immediates in SSE code for vertex shaders
[mesa.git] / src / gallium / auxiliary / draw / draw_vs_sse.c
index bc910dc2d042508a6cad1ee832d3bb68464fd5a9..13394129bc88e6d294338de1ce13b1d5f870207d 100644 (file)
@@ -50,13 +50,15 @@ typedef void (XSTDCALL *codegen_function) (
    const struct tgsi_exec_vector *input,
    struct tgsi_exec_vector *output,
    float (*constant)[4],
-   struct tgsi_exec_vector *temporary );
+   struct tgsi_exec_vector *temporary,
+   float (*immediates)[4] );
 
 
 struct draw_sse_vertex_shader {
    struct draw_vertex_shader base;
    struct x86_function sse2_program;
    codegen_function func;
+   float immediates[TGSI_EXEC_NUM_IMMEDIATES][4];
 };
 
 
@@ -126,7 +128,13 @@ vs_sse_run( struct draw_vertex_shader *base,
    /* Consts does not require 16 byte alignment. */
    machine->Consts = (float (*)[4]) draw->user.constants;
    machine->Inputs = ALIGN16_ASSIGN(inputs);
-   machine->Outputs = ALIGN16_ASSIGN(outputs);
+   if (draw->rasterizer->bypass_vs) {
+      /* outputs are just the inputs */
+      machine->Outputs = machine->Inputs;
+   }
+   else {
+      machine->Outputs = ALIGN16_ASSIGN(outputs);
+   }
 
 
    /* Fetch vertices.  This may at some point be integrated into the
@@ -137,13 +145,15 @@ vs_sse_run( struct draw_vertex_shader *base,
    draw->vertex_fetch.fetch_func( draw, machine, elts, count );
 
 
-   /* run compiled shader
-    */   
-   shader->func(
-      machine->Inputs,
-      machine->Outputs,
-      machine->Consts,
-      machine->Temps );
+   if (!draw->rasterizer->bypass_vs) {
+      /* run compiled shader
+       */   
+      shader->func(machine->Inputs,
+                   machine->Outputs,
+                   machine->Consts,
+                   machine->Temps,
+                   shader->immediates);
+   }
 
 
    /* XXX: Computing the clipmask and emitting results should be done
@@ -161,14 +171,19 @@ vs_sse_run( struct draw_vertex_shader *base,
 
       if (!draw->rasterizer->bypass_clipping) {
          vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
-         vOut[j]->edgeflag = 1;
 
          /* divide by w */
          w = 1.0f / w;
          x *= w;
          y *= w;
          z *= w;
-         
+      }
+      else {
+         vOut[j]->clipmask = 0;
+      }
+      vOut[j]->edgeflag = 1;
+
+      if (!draw->identity_viewport) {
          /* Viewport mapping */
          vOut[j]->data[0][0] = x * scale[0] + trans[0];
          vOut[j]->data[0][1] = y * scale[1] + trans[1];
@@ -176,8 +191,6 @@ vs_sse_run( struct draw_vertex_shader *base,
          vOut[j]->data[0][3] = w;
       }
       else {
-         vOut[j]->clipmask = 0;
-         vOut[j]->edgeflag = 1;
          vOut[j]->data[0][0] = x;
          vOut[j]->data[0][1] = y;
          vOut[j]->data[0][2] = z;
@@ -233,7 +246,7 @@ draw_create_vs_sse(struct draw_context *draw,
    x86_init_func( &vs->sse2_program );
 
    if (!tgsi_emit_sse2( (struct tgsi_token *) vs->base.state.tokens,
-                       &vs->sse2_program )) 
+                       &vs->sse2_program, vs->immediates )) 
       goto fail;
       
    vs->func = (codegen_function) x86_get_func( &vs->sse2_program );