i965/fs: Swap if/else conditions in SEL peephole.
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_post_vs.c
index 769409cfd67d180855f33c153fa624e26dba8a5b..9279cd176134afae8b0b14aaf6ec95646a3bf0a2 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "util/u_memory.h"
 #include "util/u_math.h"
+#include "util/u_prim.h"
 #include "pipe/p_context.h"
 #include "draw/draw_context.h"
 #include "draw/draw_private.h"
 #include "draw/draw_pt.h"
-
+#include "draw/draw_vs.h"
 
 #define DO_CLIP_XY           0x1
 #define DO_CLIP_FULL_Z       0x2
@@ -39,6 +40,7 @@
 #define DO_CLIP_USER         0x8
 #define DO_VIEWPORT          0x10
 #define DO_EDGEFLAG          0x20
+#define DO_CLIP_XY_GUARD_BAND 0x40
 
 
 struct pt_post_vs {
@@ -47,7 +49,8 @@ struct pt_post_vs {
    unsigned flags;
 
    boolean (*run)( struct pt_post_vs *pvs,
-                   struct draw_vertex_info *info );
+                   struct draw_vertex_info *info,
+                   const struct draw_prim_info *prim_info );
 };
 
 static INLINE void
@@ -55,7 +58,7 @@ initialize_vertex_header(struct vertex_header *header)
 {
    header->clipmask = 0;
    header->edgeflag = 1;
-   header->pad = 0;
+   header->have_clipdist = 0;
    header->vertex_id = UNDEFINED_VERTEX_ID;
 }
 
@@ -80,6 +83,10 @@ dot4(const float *a, const float *b)
 #define TAG(x) x##_xy_halfz_viewport
 #include "draw_cliptest_tmp.h"
 
+#define FLAGS (DO_CLIP_XY_GUARD_BAND | DO_CLIP_HALF_Z | DO_VIEWPORT)
+#define TAG(x) x##_xy_gb_halfz_viewport
+#include "draw_cliptest_tmp.h"
+
 #define FLAGS (DO_CLIP_FULL_Z | DO_VIEWPORT)
 #define TAG(x) x##_fullz_viewport
 #include "draw_cliptest_tmp.h"
@@ -110,9 +117,10 @@ dot4(const float *a, const float *b)
 
 
 boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
-                            struct draw_vertex_info *info )
+                            struct draw_vertex_info *info,
+                             const struct draw_prim_info *prim_info )
 {
-   return pvs->run( pvs, info );
+   return pvs->run( pvs, info, prim_info );
 }
 
 
@@ -120,23 +128,41 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
                              boolean clip_xy,
                              boolean clip_z,
                               boolean clip_user,
+                              boolean guard_band,
                              boolean bypass_viewport,
-                             boolean opengl,
+                              boolean clip_halfz,
                              boolean need_edgeflags )
 {
    pvs->flags = 0;
 
-   if (clip_xy)
+   /* This combination not currently tested/in use:
+    */
+   if (!clip_halfz)
+      guard_band = FALSE;
+
+   if (clip_xy && !guard_band) {
       pvs->flags |= DO_CLIP_XY;
-   
-   if (clip_z && opengl) {
-      pvs->flags |= DO_CLIP_FULL_Z;
-      ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 1 );
+      ASSIGN_4V( pvs->draw->plane[0], -1,  0,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[1],  1,  0,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[2],  0, -1,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[3],  0,  1,  0, 1 );
+   }
+   else if (clip_xy && guard_band) {
+      pvs->flags |= DO_CLIP_XY_GUARD_BAND;
+      ASSIGN_4V( pvs->draw->plane[0], -0.5,  0,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[1],  0.5,  0,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[2],  0, -0.5,  0, 1 );
+      ASSIGN_4V( pvs->draw->plane[3],  0,  0.5,  0, 1 );
    }
 
-   if (clip_z && !opengl) {
-      pvs->flags |= DO_CLIP_HALF_Z;
-      ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 0 );
+   if (clip_z) {
+      if (clip_halfz) {
+         pvs->flags |= DO_CLIP_HALF_Z;
+         ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 0 );
+      } else {
+         pvs->flags |= DO_CLIP_FULL_Z;
+         ASSIGN_4V( pvs->draw->plane[4],  0,  0,  1, 1 );
+      }
    }
 
    if (clip_user)
@@ -163,6 +189,10 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
       pvs->run = do_cliptest_xy_halfz_viewport;
       break;
 
+   case DO_CLIP_XY_GUARD_BAND | DO_CLIP_HALF_Z | DO_VIEWPORT:
+      pvs->run = do_cliptest_xy_gb_halfz_viewport;
+      break;
+
    case DO_CLIP_FULL_Z | DO_VIEWPORT:
       pvs->run = do_cliptest_fullz_viewport;
       break;