draw: hook up viewport / rhw emit to varient key state
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 27 May 2008 11:26:23 +0000 (12:26 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 27 May 2008 11:26:23 +0000 (12:26 +0100)
src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
src/gallium/auxiliary/draw/draw_vs_aos.c
src/gallium/auxiliary/draw/draw_vs_varient.c

index 7fefd391a6aec9e6200cd2648464f9d000f09456..2f2e7195b3fd309279ba953e0a5d3a501194b585 100644 (file)
@@ -94,8 +94,8 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
    fse->key.nr_elements = MAX2(num_vs_outputs,     /* outputs - translate to hw format */
                                num_vs_inputs);     /* inputs - fetch from api format */
 
-   fse->key.viewport = 1;
-   fse->key.clip = 0;
+   fse->key.viewport = !draw->identity_viewport;
+   fse->key.clip = !draw->bypass_clipping;
    fse->key.pad = 0;
 
    memset(fse->key.element, 0, 
index d3989fe1075ac731e7480fe84c58d44fd6643bb8..c63553216cbfda01489052102685fc1a64c94165 100644 (file)
@@ -2021,11 +2021,14 @@ static boolean build_vertex_program( struct draw_vs_varient_aos_sse *varient,
       if (cp.error)
          goto fail;
 
-      if (cp.vaos->base.key.viewport) {
-         if (0)
-            emit_viewport(&cp);
-         else
-            emit_rhw_viewport(&cp);
+      if (cp.vaos->base.key.clip) {
+         /* not really handling clipping, just do the rhw so we can
+          * see the results...
+          */
+         emit_rhw_viewport(&cp); 
+      }
+      else if (cp.vaos->base.key.viewport) {
+         emit_viewport(&cp);
       }
 
       /* Emit output...  TODO: do this eagerly after the last write to a
@@ -2188,9 +2191,6 @@ static struct draw_vs_varient *varient_aos_sse( struct draw_vertex_shader *vs,
 {
    struct draw_vs_varient_aos_sse *vaos = CALLOC_STRUCT(draw_vs_varient_aos_sse);
 
-   if (key->clip)
-      return NULL;
-
    if (!vaos)
       goto fail;
    
index c15c648527bcab4a01748872aac9779c79bf577f..d4deabfff3561afa6d6aa1b61d91a2b5ffc471ce 100644 (file)
@@ -89,9 +89,9 @@ static void vsvg_set_input( struct draw_vs_varient *varient,
 
 /* Mainly for debug at this stage:
  */
-static void do_viewport( struct draw_vs_varient_generic *vsvg,
-                         unsigned count,
-                         void *output_buffer )
+static void do_rhw_viewport( struct draw_vs_varient_generic *vsvg,
+                             unsigned count,
+                             void *output_buffer )
 {
    char *ptr = (char *)output_buffer;
    const float *scale = vsvg->viewport.scale;
@@ -109,6 +109,25 @@ static void do_viewport( struct draw_vs_varient_generic *vsvg,
       data[3] = w;
    }
 }
+
+static void do_viewport( struct draw_vs_varient_generic *vsvg,
+                             unsigned count,
+                             void *output_buffer )
+{
+   char *ptr = (char *)output_buffer;
+   const float *scale = vsvg->viewport.scale;
+   const float *trans = vsvg->viewport.translate;
+   unsigned stride = vsvg->base.key.output_stride;
+   unsigned j;
+
+   for (j = 0; j < count; j++, ptr += stride) {
+      float *data = (float *)ptr;
+
+      data[0] = data[0] * scale[0] + trans[0];
+      data[1] = data[1] * scale[1] + trans[1];
+      data[2] = data[2] * scale[2] + trans[2];
+   }
+}
                          
 
 static void vsvg_run_elts( struct draw_vs_varient *varient,
@@ -136,10 +155,20 @@ static void vsvg_run_elts( struct draw_vs_varient *varient,
                                  vsvg->base.key.output_stride, 
                                  vsvg->base.key.output_stride);
 
-      if (vsvg->base.key.viewport)
+
+      if (vsvg->base.key.clip) {
+         /* not really handling clipping, just do the rhw so we can
+          * see the results...
+          */
+         do_rhw_viewport( vsvg,
+                          count,
+                          output_buffer );
+      }
+      else if (vsvg->base.key.viewport) {
          do_viewport( vsvg,
                       count,
                       output_buffer );
+      }
 
 
       //if (!vsvg->already_in_emit_format)
@@ -182,11 +211,19 @@ static void vsvg_run_linear( struct draw_vs_varient *varient,
                                  vsvg->base.key.output_stride, 
                                  vsvg->base.key.output_stride);
 
-      if (vsvg->base.key.viewport)
+      if (vsvg->base.key.clip) {
+         /* not really handling clipping, just do the rhw so we can
+          * see the results...
+          */
+         do_rhw_viewport( vsvg,
+                          count,
+                          output_buffer );
+      }
+      else if (vsvg->base.key.viewport) {
          do_viewport( vsvg,
                       count,
                       output_buffer );
-
+      }
 
       //if (!vsvg->already_in_emit_format)
       vsvg->emit->set_buffer( vsvg->emit,
@@ -224,9 +261,6 @@ struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
    unsigned i;
    struct translate_key fetch, emit;
 
-   if (key->clip)
-      return NULL;
-
    struct draw_vs_varient_generic *vsvg = CALLOC_STRUCT( draw_vs_varient_generic );
    if (vsvg == NULL)
       return NULL;