draw: remove named clipmask flags, tidy up pt middle ends
authorKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 12:20:26 +0000 (13:20 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 12:20:26 +0000 (13:20 +0100)
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_post_vs.c

index c7ac32b..a0ac980 100644 (file)
 
 
 struct pipe_context;
-struct vertex_buffer;
-struct vertex_info;
 struct draw_context;
 struct draw_stage;
 struct draw_vertex_shader;
 
 
-/**
- * Clipmask flags
- */
-/*@{*/
-#define CLIP_RIGHT_BIT   0x01
-#define CLIP_LEFT_BIT    0x02
-#define CLIP_TOP_BIT     0x04
-#define CLIP_BOTTOM_BIT  0x08
-#define CLIP_NEAR_BIT    0x10
-#define CLIP_FAR_BIT     0x20
-/*@}*/
-
-/**
- * Bitshift for each clip flag
- */
-/*@{*/
-#define CLIP_RIGHT_SHIFT       0
-#define CLIP_LEFT_SHIFT        1
-#define CLIP_TOP_SHIFT         2
-#define CLIP_BOTTOM_SHIFT       3
-#define CLIP_NEAR_SHIFT        4
-#define CLIP_FAR_SHIFT         5
-/*@}*/
-
 
 struct draw_context *draw_create( void );
 
@@ -168,15 +142,10 @@ void draw_arrays(struct draw_context *draw, unsigned prim,
 
 void draw_flush(struct draw_context *draw);
 
-/***********************************************************************
- * draw_debug.c 
- */
-boolean draw_validate_prim( unsigned prim, unsigned length );
-unsigned draw_trim_prim( unsigned mode, unsigned count );
-
-
-
 
+/*******************************************************************************
+ * Driver backend interface 
+ */
 struct vbuf_render;
 void draw_set_render( struct draw_context *draw, 
                      struct vbuf_render *render );
index 476b118..37ffdbf 100644 (file)
@@ -44,7 +44,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "rtasm/rtasm_x86sse.h"
 #include "tgsi/exec/tgsi_exec.h"
 #include "tgsi/util/tgsi_scan.h"
 
@@ -171,7 +170,8 @@ struct draw_context
     */
    struct {
       struct {
-         struct draw_pt_middle_end *opt[PT_MAX_MIDDLE];
+         struct draw_pt_middle_end *fetch_emit;
+         struct draw_pt_middle_end *general;
       } middle;
 
       struct {
@@ -289,11 +289,6 @@ extern boolean draw_need_pipeline(const struct draw_context *draw,
  */
 boolean draw_pt_init( struct draw_context *draw );
 void draw_pt_destroy( struct draw_context *draw );
-boolean draw_pt_arrays( struct draw_context *draw,
-                        unsigned prim,
-                        unsigned start,
-                        unsigned count );
-
 void draw_pt_reset_vertex_ids( struct draw_context *draw );
 
 #define DRAW_FLUSH_STATE_CHANGE              0x8
index ecaed84..f153a3e 100644 (file)
@@ -44,7 +44,7 @@
  *     - pipeline -- the prim pipeline: clipping, wide lines, etc 
  *     - backend  -- the vbuf_render provided by the driver.
  */
-boolean
+static boolean
 draw_pt_arrays(struct draw_context *draw, 
                unsigned prim,
                unsigned start, 
@@ -70,19 +70,16 @@ draw_pt_arrays(struct draw_context *draw,
       opt |= PT_SHADE;
    }
 
+   if (opt)
+      middle = draw->pt.middle.general;
+   else
+      middle = draw->pt.middle.fetch_emit;
 
-   middle = draw->pt.middle.opt[opt];
-   if (middle == NULL) {
-      middle = draw->pt.middle.opt[PT_PIPELINE | PT_CLIPTEST | PT_SHADE];
-   }
-
-   assert(middle);
 
    /* May create a short-circuited version of this for small primitives:
     */
    frontend = draw->pt.front.vcache;
 
-
    frontend->prepare( frontend, prim, middle, opt );
 
    frontend->run( frontend,
@@ -102,11 +99,12 @@ boolean draw_pt_init( struct draw_context *draw )
    if (!draw->pt.front.vcache)
       return FALSE;
 
-   draw->pt.middle.opt[0] = draw_pt_fetch_emit( draw );
-   draw->pt.middle.opt[PT_SHADE | PT_CLIPTEST | PT_PIPELINE] = 
-      draw_pt_fetch_pipeline_or_emit( draw );
+   draw->pt.middle.fetch_emit = draw_pt_fetch_emit( draw );
+   if (!draw->pt.middle.fetch_emit)
+      return FALSE;
 
-   if (!draw->pt.middle.opt[PT_SHADE | PT_CLIPTEST | PT_PIPELINE])
+   draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
+   if (!draw->pt.middle.general)
       return FALSE;
 
    return TRUE;
@@ -115,13 +113,15 @@ boolean draw_pt_init( struct draw_context *draw )
 
 void draw_pt_destroy( struct draw_context *draw )
 {
-   int i;
+   if (draw->pt.middle.general) {
+      draw->pt.middle.general->destroy( draw->pt.middle.general );
+      draw->pt.middle.general = NULL;
+   }
 
-   for (i = 0; i < PT_MAX_MIDDLE; i++)
-      if (draw->pt.middle.opt[i]) {
-        draw->pt.middle.opt[i]->destroy( draw->pt.middle.opt[i] );
-        draw->pt.middle.opt[i] = NULL;
-      }
+   if (draw->pt.middle.fetch_emit) {
+      draw->pt.middle.fetch_emit->destroy( draw->pt.middle.fetch_emit );
+      draw->pt.middle.fetch_emit = NULL;
+   }
 
    if (draw->pt.front.vcache) {
       draw->pt.front.vcache->destroy( draw->pt.front.vcache );
index eb23ee1..1119e9c 100644 (file)
@@ -50,6 +50,12 @@ struct draw_context;
 #define DRAW_PT_FLAG_MASK     (3<<30)
 
 
+#define PT_SHADE      0x1
+#define PT_CLIPTEST   0x2
+#define PT_PIPELINE   0x4
+#define PT_MAX_MIDDLE 0x8
+
+
 /* The "front end" - prepare sets of fetch, draw elements for the
  * middle end.
  *
index 315b02f..b3ecec6 100644 (file)
@@ -52,12 +52,12 @@ compute_clipmask_gl(const float *clip, /*const*/ float plane[][4], unsigned nr)
 
    /* Do the hardwired planes first:
     */
-   if (-clip[0] + clip[3] < 0) mask |= CLIP_RIGHT_BIT;
-   if ( clip[0] + clip[3] < 0) mask |= CLIP_LEFT_BIT;
-   if (-clip[1] + clip[3] < 0) mask |= CLIP_TOP_BIT;
-   if ( clip[1] + clip[3] < 0) mask |= CLIP_BOTTOM_BIT;
-   if (-clip[2] + clip[3] < 0) mask |= CLIP_FAR_BIT;
-   if ( clip[2] + clip[3] < 0) mask |= CLIP_NEAR_BIT;
+   if (-clip[0] + clip[3] < 0) mask |= (1<<0);
+   if ( clip[0] + clip[3] < 0) mask |= (1<<1);
+   if (-clip[1] + clip[3] < 0) mask |= (1<<2);
+   if ( clip[1] + clip[3] < 0) mask |= (1<<3);
+   if ( clip[2] + clip[3] < 0) mask |= (1<<4); /* match mesa clipplane numbering - for now */
+   if (-clip[2] + clip[3] < 0) mask |= (1<<5); /* match mesa clipplane numbering - for now */
 
    /* Followed by any remaining ones:
     */