draw: move some pipeline-specific code & state to draw_pipe.[ch]
authorKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 14:29:27 +0000 (15:29 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 14:29:27 +0000 (15:29 +0100)
28 files changed:
src/gallium/auxiliary/draw/Makefile
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_pipe.c [new file with mode: 0644]
src/gallium/auxiliary/draw/draw_pipe.h [new file with mode: 0644]
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/draw/draw_pipe_clip.c
src/gallium/auxiliary/draw/draw_pipe_cull.c
src/gallium/auxiliary/draw/draw_pipe_flatshade.c
src/gallium/auxiliary/draw/draw_pipe_offset.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/draw/draw_pipe_stipple.c
src/gallium/auxiliary/draw/draw_pipe_twoside.c
src/gallium/auxiliary/draw/draw_pipe_unfilled.c
src/gallium/auxiliary/draw/draw_pipe_validate.c
src/gallium/auxiliary/draw/draw_pipe_vbuf.c
src/gallium/auxiliary/draw/draw_pipe_wide_line.c
src/gallium/auxiliary/draw/draw_pipe_wide_point.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt_pipeline.c
src/gallium/auxiliary/draw/draw_pt_post_vs.c
src/gallium/auxiliary/draw/draw_vertex.c
src/gallium/drivers/i915simple/i915_context.c
src/gallium/drivers/i915simple/i915_prim_emit.c
src/gallium/drivers/softpipe/sp_prim_setup.c
src/mesa/state_tracker/st_cb_feedback.c
src/mesa/state_tracker/st_cb_rasterpos.c

index 62f46c6db1e3095150c6e134a0ed92a20d4a906d..4fffd11b77044ce20a19bfa83d1ad71d1f471e74 100644 (file)
@@ -5,6 +5,7 @@ LIBNAME = draw
 
 C_SOURCES = \
        draw_context.c \
+       draw_pipe.c \
        draw_pipe_aaline.c \
        draw_pipe_aapoint.c \
        draw_pipe_clip.c \
index 6012bc155ef5d5a79b7f0aa03f1d6d926abc5283..fa6791fa0b215beefc5a6b4f878a222133442827 100644 (file)
@@ -35,6 +35,8 @@
 #include "draw_context.h"
 #include "draw_vbuf.h"
 #include "draw_vs.h"
+#include "draw_pt.h"
+#include "draw_pipe.h"
 
 
 struct draw_context *draw_create( void )
@@ -49,32 +51,6 @@ struct draw_context *draw_create( void )
    draw->use_sse = FALSE;
 #endif
 
-   /* create pipeline stages */
-   draw->pipeline.wide_line  = draw_wide_line_stage( draw );
-   draw->pipeline.wide_point = draw_wide_point_stage( draw );
-   draw->pipeline.stipple   = draw_stipple_stage( draw );
-   draw->pipeline.unfilled  = draw_unfilled_stage( draw );
-   draw->pipeline.twoside   = draw_twoside_stage( draw );
-   draw->pipeline.offset    = draw_offset_stage( draw );
-   draw->pipeline.clip      = draw_clip_stage( draw );
-   draw->pipeline.flatshade = draw_flatshade_stage( draw );
-   draw->pipeline.cull      = draw_cull_stage( draw );
-   draw->pipeline.validate  = draw_validate_stage( draw );
-   draw->pipeline.first     = draw->pipeline.validate;
-
-   if (!draw->pipeline.wide_line ||
-       !draw->pipeline.wide_point ||
-       !draw->pipeline.stipple ||
-       !draw->pipeline.unfilled ||
-       !draw->pipeline.twoside ||
-       !draw->pipeline.offset ||
-       !draw->pipeline.clip ||
-       !draw->pipeline.flatshade ||
-       !draw->pipeline.cull ||
-       !draw->pipeline.validate)
-      goto fail;
-
-
    ASSIGN_4V( draw->plane[0], -1,  0,  0, 1 );
    ASSIGN_4V( draw->plane[1],  1,  0,  0, 1 );
    ASSIGN_4V( draw->plane[2],  0, -1,  0, 1 );
@@ -83,11 +59,6 @@ struct draw_context *draw_create( void )
    ASSIGN_4V( draw->plane[5],  0,  0, -1, 1 ); /* mesa's a bit wonky */
    draw->nr_planes = 6;
 
-   /* these defaults are oriented toward the needs of softpipe */
-   draw->wide_point_threshold = 1000000.0; /* infinity */
-   draw->wide_line_threshold = 1.0;
-   draw->line_stipple = TRUE;
-   draw->point_sprite = TRUE;
 
    draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
 
@@ -100,6 +71,8 @@ struct draw_context *draw_create( void )
    draw->machine.Inputs = align_malloc(PIPE_MAX_ATTRIBS * sizeof(struct tgsi_exec_vector), 16);
    draw->machine.Outputs = align_malloc(PIPE_MAX_ATTRIBS * sizeof(struct tgsi_exec_vector), 16);
 
+   if (!draw_pipeline_init( draw ))
+      goto fail;
 
    if (!draw_pt_init( draw ))
       goto fail;
@@ -117,39 +90,13 @@ void draw_destroy( struct draw_context *draw )
    if (!draw)
       return;
 
-   if (draw->pipeline.wide_line)
-      draw->pipeline.wide_line->destroy( draw->pipeline.wide_line );
-   if (draw->pipeline.wide_point)
-      draw->pipeline.wide_point->destroy( draw->pipeline.wide_point );
-   if (draw->pipeline.stipple)
-      draw->pipeline.stipple->destroy( draw->pipeline.stipple );
-   if (draw->pipeline.unfilled)
-      draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
-   if (draw->pipeline.twoside)
-      draw->pipeline.twoside->destroy( draw->pipeline.twoside );
-   if (draw->pipeline.offset)
-      draw->pipeline.offset->destroy( draw->pipeline.offset );
-   if (draw->pipeline.clip)
-      draw->pipeline.clip->destroy( draw->pipeline.clip );
-   if (draw->pipeline.flatshade)
-      draw->pipeline.flatshade->destroy( draw->pipeline.flatshade );
-   if (draw->pipeline.cull)
-      draw->pipeline.cull->destroy( draw->pipeline.cull );
-   if (draw->pipeline.validate)
-      draw->pipeline.validate->destroy( draw->pipeline.validate );
-   if (draw->pipeline.aaline)
-      draw->pipeline.aaline->destroy( draw->pipeline.aaline );
-   if (draw->pipeline.aapoint)
-      draw->pipeline.aapoint->destroy( draw->pipeline.aapoint );
-   if (draw->pipeline.pstipple)
-      draw->pipeline.pstipple->destroy( draw->pipeline.pstipple );
-   if (draw->pipeline.rasterize)
-      draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
 
    if (draw->machine.Inputs)
       align_free(draw->machine.Inputs);
+
    if (draw->machine.Outputs)
       align_free(draw->machine.Outputs);
+
    tgsi_exec_machine_free_data(&draw->machine);
 
    /* Not so fast -- we're just borrowing this at the moment.
@@ -158,6 +105,7 @@ void draw_destroy( struct draw_context *draw )
       draw->render->destroy( draw->render );
    */
 
+   draw_pipeline_destroy( draw );
    draw_pt_destroy( draw );
 
    FREE( draw );
@@ -284,7 +232,7 @@ void
 draw_wide_point_threshold(struct draw_context *draw, float threshold)
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-   draw->wide_point_threshold = threshold;
+   draw->pipeline.wide_point_threshold = threshold;
 }
 
 
@@ -296,7 +244,7 @@ void
 draw_wide_line_threshold(struct draw_context *draw, float threshold)
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-   draw->wide_line_threshold = threshold;
+   draw->pipeline.wide_line_threshold = threshold;
 }
 
 
@@ -307,7 +255,7 @@ void
 draw_enable_line_stipple(struct draw_context *draw, boolean enable)
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-   draw->line_stipple = enable;
+   draw->pipeline.line_stipple = enable;
 }
 
 
@@ -318,7 +266,7 @@ void
 draw_enable_point_sprites(struct draw_context *draw, boolean enable)
 {
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-   draw->point_sprite = enable;
+   draw->pipeline.point_sprite = enable;
 }
 
 
@@ -373,36 +321,6 @@ draw_num_vs_outputs(struct draw_context *draw)
 }
 
 
-/**
- * Allocate space for temporary post-transform vertices, such as for clipping.
- */
-void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
-{
-   assert(!stage->tmp);
-
-   stage->nr_tmps = nr;
-
-   if (nr) {
-      ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
-      unsigned i;
-
-      stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
-      
-      for (i = 0; i < nr; i++)
-        stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
-   }
-}
-
-
-void draw_free_temp_verts( struct draw_stage *stage )
-{
-   if (stage->tmp) {
-      FREE( stage->tmp[0] );
-      FREE( stage->tmp );
-      stage->tmp = NULL;
-   }
-}
-
 
 boolean draw_use_sse(struct draw_context *draw)
 {
@@ -410,23 +328,6 @@ boolean draw_use_sse(struct draw_context *draw)
 }
 
 
-void draw_reset_vertex_ids(struct draw_context *draw)
-{
-   struct draw_stage *stage = draw->pipeline.first;
-   
-   while (stage) {
-      unsigned i;
-
-      for (i = 0; i < stage->nr_tmps; i++)
-        stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID;
-
-      stage = stage->next;
-   }
-
-   draw_pt_reset_vertex_ids(draw);
-}
-
-
 void draw_set_render( struct draw_context *draw, 
                      struct vbuf_render *render )
 {
@@ -467,3 +368,23 @@ draw_set_mapped_element_buffer( struct draw_context *draw,
    draw->user.elts = elements;
    draw->user.eltSize = eltSize;
 }
+
+
+/* Revamp me please:
+ */
+void draw_do_flush( struct draw_context *draw, unsigned flags )
+{
+   if (!draw->flushing) 
+   {
+      draw->flushing = TRUE;
+
+      if (flags >= DRAW_FLUSH_STATE_CHANGE) {
+        draw->pipeline.first->flush( draw->pipeline.first, flags );
+        draw->pipeline.first = draw->pipeline.validate;
+        draw->reduced_prim = ~0; /* is reduced_prim needed any more? */
+      }
+      
+      draw->flushing = FALSE;
+   }
+}
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c
new file mode 100644 (file)
index 0000000..9d62cb2
--- /dev/null
@@ -0,0 +1,161 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 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
+ * 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.
+ * 
+ **************************************************************************/
+
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#include "pipe/p_util.h"
+#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
+
+
+boolean draw_pipeline_init( struct draw_context *draw )
+{
+   /* create pipeline stages */
+   draw->pipeline.wide_line  = draw_wide_line_stage( draw );
+   draw->pipeline.wide_point = draw_wide_point_stage( draw );
+   draw->pipeline.stipple   = draw_stipple_stage( draw );
+   draw->pipeline.unfilled  = draw_unfilled_stage( draw );
+   draw->pipeline.twoside   = draw_twoside_stage( draw );
+   draw->pipeline.offset    = draw_offset_stage( draw );
+   draw->pipeline.clip      = draw_clip_stage( draw );
+   draw->pipeline.flatshade = draw_flatshade_stage( draw );
+   draw->pipeline.cull      = draw_cull_stage( draw );
+   draw->pipeline.validate  = draw_validate_stage( draw );
+   draw->pipeline.first     = draw->pipeline.validate;
+
+   if (!draw->pipeline.wide_line ||
+       !draw->pipeline.wide_point ||
+       !draw->pipeline.stipple ||
+       !draw->pipeline.unfilled ||
+       !draw->pipeline.twoside ||
+       !draw->pipeline.offset ||
+       !draw->pipeline.clip ||
+       !draw->pipeline.flatshade ||
+       !draw->pipeline.cull ||
+       !draw->pipeline.validate)
+      return FALSE;
+
+   /* these defaults are oriented toward the needs of softpipe */
+   draw->pipeline.wide_point_threshold = 1000000.0; /* infinity */
+   draw->pipeline.wide_line_threshold = 1.0;
+   draw->pipeline.line_stipple = TRUE;
+   draw->pipeline.point_sprite = TRUE;
+
+   return TRUE;
+}
+
+
+void draw_pipeline_destroy( struct draw_context *draw )
+{
+   if (draw->pipeline.wide_line)
+      draw->pipeline.wide_line->destroy( draw->pipeline.wide_line );
+   if (draw->pipeline.wide_point)
+      draw->pipeline.wide_point->destroy( draw->pipeline.wide_point );
+   if (draw->pipeline.stipple)
+      draw->pipeline.stipple->destroy( draw->pipeline.stipple );
+   if (draw->pipeline.unfilled)
+      draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
+   if (draw->pipeline.twoside)
+      draw->pipeline.twoside->destroy( draw->pipeline.twoside );
+   if (draw->pipeline.offset)
+      draw->pipeline.offset->destroy( draw->pipeline.offset );
+   if (draw->pipeline.clip)
+      draw->pipeline.clip->destroy( draw->pipeline.clip );
+   if (draw->pipeline.flatshade)
+      draw->pipeline.flatshade->destroy( draw->pipeline.flatshade );
+   if (draw->pipeline.cull)
+      draw->pipeline.cull->destroy( draw->pipeline.cull );
+   if (draw->pipeline.validate)
+      draw->pipeline.validate->destroy( draw->pipeline.validate );
+   if (draw->pipeline.aaline)
+      draw->pipeline.aaline->destroy( draw->pipeline.aaline );
+   if (draw->pipeline.aapoint)
+      draw->pipeline.aapoint->destroy( draw->pipeline.aapoint );
+   if (draw->pipeline.pstipple)
+      draw->pipeline.pstipple->destroy( draw->pipeline.pstipple );
+   if (draw->pipeline.rasterize)
+      draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
+}
+
+
+
+
+/* This is only used for temporary verts.
+ */
+#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
+
+
+/**
+ * Allocate space for temporary post-transform vertices, such as for clipping.
+ */
+void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
+{
+   assert(!stage->tmp);
+
+   stage->nr_tmps = nr;
+
+   if (nr) {
+      ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
+      unsigned i;
+
+      stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
+      
+      for (i = 0; i < nr; i++)
+        stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+   }
+}
+
+
+void draw_free_temp_verts( struct draw_stage *stage )
+{
+   if (stage->tmp) {
+      FREE( stage->tmp[0] );
+      FREE( stage->tmp );
+      stage->tmp = NULL;
+   }
+}
+
+void draw_reset_vertex_ids(struct draw_context *draw)
+{
+   struct draw_stage *stage = draw->pipeline.first;
+   
+   while (stage) {
+      unsigned i;
+
+      for (i = 0; i < stage->nr_tmps; i++)
+        stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID;
+
+      stage = stage->next;
+   }
+
+   draw_pt_reset_vertex_ids(draw);
+}
+
+
diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h
new file mode 100644 (file)
index 0000000..5b97ca5
--- /dev/null
@@ -0,0 +1,110 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 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
+ * 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.
+ * 
+ **************************************************************************/
+
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  */
+
+#ifndef DRAW_PIPE_H
+#define DRAW_PIPE_H
+
+#include "pipe/p_compiler.h"
+#include "draw_private.h"       /* for sizeof(vertex_header) */
+
+
+
+/**
+ * Base class for all primitive drawing stages.
+ */
+struct draw_stage
+{
+   struct draw_context *draw;   /**< parent context */
+
+   struct draw_stage *next;     /**< next stage in pipeline */
+
+   struct vertex_header **tmp;  /**< temp vert storage, such as for clipping */
+   unsigned nr_tmps;
+
+   void (*point)( struct draw_stage *,
+                 struct prim_header * );
+
+   void (*line)( struct draw_stage *,
+                struct prim_header * );
+
+   void (*tri)( struct draw_stage *,
+               struct prim_header * );
+
+   void (*flush)( struct draw_stage *,
+                 unsigned flags );
+
+   void (*reset_stipple_counter)( struct draw_stage * );
+
+   void (*destroy)( struct draw_stage * );
+};
+
+
+extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
+extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
+extern struct draw_stage *draw_offset_stage( struct draw_context *context );
+extern struct draw_stage *draw_clip_stage( struct draw_context *context );
+extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
+extern struct draw_stage *draw_cull_stage( struct draw_context *context );
+extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
+extern struct draw_stage *draw_validate_stage( struct draw_context *context );
+
+
+extern void draw_free_temp_verts( struct draw_stage *stage );
+
+extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
+
+
+
+
+/**
+ * Get a writeable copy of a vertex.
+ * \param stage  drawing stage info
+ * \param vert  the vertex to copy (source)
+ * \param idx  index into stage's tmp[] array to put the copy (dest)
+ * \return  pointer to the copied vertex
+ */
+static INLINE struct vertex_header *
+dup_vert( struct draw_stage *stage,
+         const struct vertex_header *vert,
+         unsigned idx )
+{   
+   struct vertex_header *tmp = stage->tmp[idx];
+   const uint vsize = sizeof(struct vertex_header)
+      + stage->draw->num_vs_outputs * 4 * sizeof(float);
+   memcpy(tmp, vert, vsize);
+   tmp->vertex_id = UNDEFINED_VERTEX_ID;
+   return tmp;
+}
+
+#endif
index e8d2a45102c85185de0fefc86efb73744b19b305..24bc87d4f8e362e5a27855402bd7ebd67e534bf3 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "draw_context.h"
 #include "draw_private.h"
+#include "draw_pipe.h"
 
 
 /**
index e84d380e500de01bbe2a2c5a9983bb244937919f..9f878f6c02f95e6f96f9d9c651a2693167acc139 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "draw_context.h"
 #include "draw_vs.h"
+#include "draw_pipe.h"
 
 
 /*
index 0ac3a240e5ed856f08adcd7d7707d37744b9e6da..6780f275d96f0388c60cb8b484e351e9a67df9bd 100644 (file)
@@ -35,8 +35,8 @@
 #include "pipe/p_util.h"
 #include "pipe/p_shader_tokens.h"
 
-#include "draw_context.h"
 #include "draw_vs.h"
+#include "draw_pipe.h"
 
 
 #ifndef IS_NEGATIVE
@@ -204,7 +204,14 @@ static void emit_poly( struct draw_stage *stage,
    }
 }
 
-
+static INLINE float
+dot4(const float *a, const float *b)
+{
+   return (a[0]*b[0] +
+           a[1]*b[1] +
+           a[2]*b[2] +
+           a[3]*b[3]);
+}
 
 
 /* Clip a triangle against the viewport and user clip planes.
index 8177b0ac86ebaaceac5d65f803e32ea4592f5145..c406f89d05648510a354e3959134585a90225acf 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "pipe/p_util.h"
 #include "pipe/p_defines.h"
-#include "draw_private.h"
+#include "draw_pipe.h"
 
 
 struct cull_stage {
index 54baa1fbc98a5060393dfd95d84721664d7197c7..bdb8b49dc4df611ada67e0d2544e789c08542aa4 100644 (file)
@@ -31,6 +31,7 @@
 #include "pipe/p_util.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw_vs.h"
+#include "draw_pipe.h"
 
 
 /** subclass of draw_stage */
index dbc676deae42de93771d8117a60973d1ec1f132d..dbdece45bb71481614a5f4fb6ddf3b9c6f67cac2 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "pipe/p_util.h"
-#include "draw_private.h"
+#include "draw_pipe.h"
 
 
 
index 4dddb72906f4cb6d378245e5468561032dc6abfe..4903ba2133620300f07c118df25db90153c5b9e0 100644 (file)
@@ -44,7 +44,7 @@
 #include "tgsi/util/tgsi_dump.h"
 
 #include "draw_context.h"
-#include "draw_private.h"
+#include "draw_pipe.h"
 
 
 
index 506f33512c8b4e436a3fd4c1c66dbc35fb1eff15..49429ee9e1698a94adce2c15c1ccce8c7df6d526 100644 (file)
@@ -39,7 +39,7 @@
 #include "pipe/p_util.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
+#include "draw_pipe.h"
 
 
 /** Subclass of draw_stage */
index 01d905c153492558fb5d919742bed574016e2544..09a9d23d57e36ab7c5a90d7a53d0a4e0e7ffb5ab 100644 (file)
@@ -32,7 +32,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw_vs.h"
-
+#include "draw_pipe.h"
 
 struct twoside_stage {
    struct draw_stage stage;
index b07860cd9ea17f55f4bd21e20d698259319e664a..31e24f6a147e86836c1256227acd076935b54677 100644 (file)
@@ -36,6 +36,7 @@
 #include "pipe/p_util.h"
 #include "pipe/p_defines.h"
 #include "draw_private.h"
+#include "draw_pipe.h"
 
 
 struct unfilled_stage {
index e163e078f0f28b0f3657e69451a2e42e23f2e6e8..ffddc2f62c2707c6cb731718f7b0e031b042706c 100644 (file)
@@ -31,6 +31,7 @@
 #include "pipe/p_util.h"
 #include "pipe/p_defines.h"
 #include "draw_private.h"
+#include "draw_pipe.h"
 
 static boolean points( unsigned prim )
 {
@@ -66,11 +67,11 @@ draw_need_pipeline(const struct draw_context *draw,
    if (lines(prim)) 
    {
       /* line stipple */
-      if (draw->rasterizer->line_stipple_enable && draw->line_stipple)
+      if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple)
          return TRUE;
 
       /* wide lines */
-      if (draw->rasterizer->line_width > draw->wide_line_threshold)
+      if (draw->rasterizer->line_width > draw->pipeline.wide_line_threshold)
          return TRUE;
 
       /* AA lines */
@@ -81,7 +82,7 @@ draw_need_pipeline(const struct draw_context *draw,
    if (points(prim))
    {
       /* large points */
-      if (draw->rasterizer->point_size > draw->wide_point_threshold)
+      if (draw->rasterizer->point_size > draw->pipeline.wide_point_threshold)
          return TRUE;
 
       /* AA points */
@@ -89,7 +90,7 @@ draw_need_pipeline(const struct draw_context *draw,
          return TRUE;
 
       /* point sprites */
-      if (draw->rasterizer->point_sprite && draw->point_sprite)
+      if (draw->rasterizer->point_sprite && draw->pipeline.point_sprite)
          return TRUE;
    }
 
@@ -145,15 +146,15 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
    stage->next = next;
 
    /* drawing wide lines? */
-   wide_lines = (draw->rasterizer->line_width > draw->wide_line_threshold
+   wide_lines = (draw->rasterizer->line_width > draw->pipeline.wide_line_threshold
                  && !draw->rasterizer->line_smooth);
 
    /* drawing large points? */
-   if (draw->rasterizer->point_sprite && draw->point_sprite)
+   if (draw->rasterizer->point_sprite && draw->pipeline.point_sprite)
       wide_points = TRUE;
    else if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
       wide_points = FALSE;
-   else if (draw->rasterizer->point_size > draw->wide_point_threshold)
+   else if (draw->rasterizer->point_size > draw->pipeline.wide_point_threshold)
       wide_points = TRUE;
    else
       wide_points = FALSE;
@@ -186,7 +187,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
       next = draw->pipeline.wide_point;
    }
 
-   if (draw->rasterizer->line_stipple_enable && draw->line_stipple) {
+   if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple) {
       draw->pipeline.stipple->next = next;
       next = draw->pipeline.stipple;
       precalc_flat = 1;                /* only needed for lines really */
index 30dceeb43defb1206d8fb9203200e681f1171fc6..c835727e323575ad7b7410ac2c5b8514bbb3fc73 100644 (file)
@@ -40,6 +40,7 @@
 #include "draw_vbuf.h"
 #include "draw_private.h"
 #include "draw_vertex.h"
+#include "draw_pipe.h"
 #include "translate/translate.h"
 
 
index 9a168ce8bdc6f66d4633733014bddc89c1af5266..329b5d0fb02bee5196b0c0b698e7c013ade5925d 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw_private.h"
+#include "draw_pipe.h"
 
 
 struct wideline_stage {
index 3d0add0c1afa1e75ff19860336814aae95153a91..7a439178a0ee2775e32b5b49e5a9d2e1e0fa7722 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw_vs.h"
+#include "draw_pipe.h"
 
 
 struct widepoint_stage {
@@ -203,8 +204,8 @@ static void widepoint_first_point( struct draw_stage *stage,
    }
 
    /* XXX we won't know the real size if it's computed by the vertex shader! */
-   if ((draw->rasterizer->point_size > draw->wide_point_threshold) ||
-       (draw->rasterizer->point_sprite && draw->point_sprite)) {
+   if ((draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) ||
+       (draw->rasterizer->point_sprite && draw->pipeline.point_sprite)) {
       stage->point = widepoint_point;
    }
    else {
index 37ffdbf90287eea26c0e6c5e25fb5bde65622e42..b2b2f82b8ffb37b1bc103726995f555d353472c5 100644 (file)
 struct pipe_context;
 struct gallivm_prog;
 struct gallivm_cpu_engine;
-
-struct draw_pt_middle_end;
-struct draw_pt_front_end;
 struct draw_vertex_shader;
+struct draw_context;
+struct draw_stage;
+struct vbuf_render;
 
-#define MAX_SHADER_VERTICES 128
 
 /**
  * Basic vertex info.
@@ -70,17 +69,14 @@ struct vertex_header {
 
    float clip[4];
 
-   float data[][4];            /* Note variable size */
+   /* This will probably become float (*data)[4] soon:
+    */
+   float data[][4];
 };
 
 /* NOTE: It should match vertex_id size above */
 #define UNDEFINED_VERTEX_ID 0xffff
 
-/* XXX This is too large */
-#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
-#define MAX_VERTEX_ALLOCATION ((MAX_VERTEX_SIZE + 0x0f) & ~0x0f)
-
-
 
 /**
  * Basic info for a point/line/triangle primitive.
@@ -95,41 +91,6 @@ struct prim_header {
 
 
 
-struct draw_context;
-
-/**
- * Base class for all primitive drawing stages.
- */
-struct draw_stage
-{
-   struct draw_context *draw;   /**< parent context */
-
-   struct draw_stage *next;     /**< next stage in pipeline */
-
-   struct vertex_header **tmp;  /**< temp vert storage, such as for clipping */
-   unsigned nr_tmps;
-
-   void (*point)( struct draw_stage *,
-                 struct prim_header * );
-
-   void (*line)( struct draw_stage *,
-                struct prim_header * );
-
-   void (*tri)( struct draw_stage *,
-               struct prim_header * );
-
-   void (*flush)( struct draw_stage *,
-                 unsigned flags );
-
-   void (*reset_stipple_counter)( struct draw_stage * );
-
-   void (*destroy)( struct draw_stage * );
-};
-
-
-
-struct vbuf_render;
-
 
 #define PT_SHADE      0x1
 #define PT_CLIPTEST   0x2
@@ -161,6 +122,12 @@ struct draw_context
       struct draw_stage *wide_line;
       struct draw_stage *wide_point;
       struct draw_stage *rasterize;
+
+      float wide_point_threshold; /**< convert pnts to tris if larger than this */
+      float wide_line_threshold;  /**< convert lines to tris if wider than this */
+      boolean line_stipple;       /**< do line stipple? */
+      boolean point_sprite;       /**< convert points to quads for sprites? */
+
    } pipeline;
 
 
@@ -225,10 +192,6 @@ struct draw_context
    float plane[12][4];
    unsigned nr_planes;
 
-   float wide_point_threshold; /**< convert pnts to tris if larger than this */
-   float wide_line_threshold;  /**< convert lines to tris if wider than this */
-   boolean line_stipple;       /**< do line stipple? */
-   boolean point_sprite;       /**< convert points to quads for sprites? */
    boolean use_sse;
 
    /* If a prim stage introduces new vertex attributes, they'll be stored here
@@ -252,44 +215,29 @@ struct draw_context
 
 
 
-extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
-extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
-extern struct draw_stage *draw_offset_stage( struct draw_context *context );
-extern struct draw_stage *draw_clip_stage( struct draw_context *context );
-extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
-extern struct draw_stage *draw_cull_stage( struct draw_context *context );
-extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
-extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
-extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
-extern struct draw_stage *draw_validate_stage( struct draw_context *context );
-
-
-extern void draw_free_temp_verts( struct draw_stage *stage );
-
-extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
 
 extern void draw_reset_vertex_ids( struct draw_context *draw );
 
 
-extern int draw_vertex_cache_check_space( struct draw_context *draw, 
-                                         unsigned nr_verts );
 
-extern void draw_vertex_cache_invalidate( struct draw_context *draw );
-extern void draw_vertex_cache_unreference( struct draw_context *draw );
-extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw );
+/*******************************************************************************
+ * Vertex processing (was passthrough) code:
+ */
+boolean draw_pt_init( struct draw_context *draw );
+void draw_pt_destroy( struct draw_context *draw );
+void draw_pt_reset_vertex_ids( struct draw_context *draw );
 
 
-extern void draw_update_vertex_fetch( struct draw_context *draw );
+/*******************************************************************************
+ * Primitive processing (pipelnie) code: 
+ */
 
-extern boolean draw_need_pipeline(const struct draw_context *draw,
-                                  unsigned prim );
+boolean draw_pipeline_init( struct draw_context *draw );
+void draw_pipeline_destroy( struct draw_context *draw );
 
+boolean draw_need_pipeline(const struct draw_context *draw,
+                           unsigned prim );
 
-/* Passthrough mode (second attempt):
- */
-boolean draw_pt_init( struct draw_context *draw );
-void draw_pt_destroy( struct draw_context *draw );
-void draw_pt_reset_vertex_ids( struct draw_context *draw );
 
 #define DRAW_FLUSH_STATE_CHANGE              0x8
 #define DRAW_FLUSH_BACKEND                   0x10
@@ -301,36 +249,6 @@ boolean draw_get_edgeflag( struct draw_context *draw,
                            unsigned idx );
 
 
-/**
- * Get a writeable copy of a vertex.
- * \param stage  drawing stage info
- * \param vert  the vertex to copy (source)
- * \param idx  index into stage's tmp[] array to put the copy (dest)
- * \return  pointer to the copied vertex
- */
-static INLINE struct vertex_header *
-dup_vert( struct draw_stage *stage,
-         const struct vertex_header *vert,
-         unsigned idx )
-{   
-   struct vertex_header *tmp = stage->tmp[idx];
-   const uint vsize = sizeof(struct vertex_header)
-      + stage->draw->num_vs_outputs * 4 * sizeof(float);
-   memcpy(tmp, vert, vsize);
-   tmp->vertex_id = UNDEFINED_VERTEX_ID;
-   return tmp;
-}
-
-static INLINE float
-dot4(const float *a, const float *b)
-{
-   float result = (a[0]*b[0] +
-                   a[1]*b[1] +
-                   a[2]*b[2] +
-                   a[3]*b[3]);
-
-   return result;
-}
 
 
 #endif /* DRAW_PRIVATE_H */
index f153a3ee2ccbd2b1f97772a8939436f959401f04..965269251f72a1b49b0316d3de7f17a5e8b0cfb2 100644 (file)
@@ -165,21 +165,3 @@ draw_arrays(struct draw_context *draw, unsigned prim,
    draw_pt_arrays(draw, prim, start, count);
 }
 
-
-/* Revamp me please:
- */
-void draw_do_flush( struct draw_context *draw, unsigned flags )
-{
-   if (!draw->flushing) 
-   {
-      draw->flushing = TRUE;
-
-      if (flags >= DRAW_FLUSH_STATE_CHANGE) {
-        draw->pipeline.first->flush( draw->pipeline.first, flags );
-        draw->pipeline.first = draw->pipeline.validate;
-        draw->reduced_prim = ~0;
-      }
-      
-      draw->flushing = FALSE;
-   }
-}
index 1a9a3adb03d9907305ccd3fb214e7bb10b5fe3ea..922344e44882e2bb9d567528c53c31867eba8ef9 100644 (file)
@@ -35,6 +35,7 @@
 #include "draw/draw_private.h"
 #include "draw/draw_vertex.h"
 #include "draw/draw_pt.h"
+#include "draw/draw_pipe.h"
 
 static void do_point( struct draw_context *draw,
                      const char *v0 )
index b3ecec6ece78ed6f399e3cc8632e27efa40851d5..581f044dae10f0bef4f8e02ad449c051ee163e75 100644 (file)
@@ -44,6 +44,17 @@ struct pt_post_vs {
 
 
 
+static INLINE float
+dot4(const float *a, const float *b)
+{
+   return (a[0]*b[0] +
+           a[1]*b[1] +
+           a[2]*b[2] +
+           a[3]*b[3]);
+}
+
+
+
 static INLINE unsigned
 compute_clipmask_gl(const float *clip, /*const*/ float plane[][4], unsigned nr)
 {
index 168036eee845ca4e75ff61f93b0a7505351ee7a6..a42adaafb1a686b081dccb2febd1f4207a7487e2 100644 (file)
@@ -72,6 +72,4 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
          assert(0);
       }
    }
-
-   assert(vinfo->size * 4 <= MAX_VERTEX_SIZE);
 }
index 58a5854f0d9c8d6121b012dc544020afde1e9336..4bef21619c23650e2340d129e3afac4a4328756a 100644 (file)
@@ -142,7 +142,7 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen,
     */
    i915->draw = draw_create();
    assert(i915->draw);
-   if (GETENV("I915_VBUF")) {
+   if (!GETENV("I915_NO_VBUF")) {
       draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915));
    }
    else {
index b6fb0a6d88f498831a85244b4c21fb881020d4ec..9ffa46013804fa0ab11b80df979a17fef1acf6fa 100644 (file)
@@ -26,7 +26,7 @@
  **************************************************************************/
 
 
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
 #include "pipe/p_util.h"
 
 #include "i915_context.h"
@@ -78,9 +78,6 @@ emit_hw_vertex( struct i915_context *i915,
       const uint j = vinfo->src_index[i];
       const float *attrib = vertex->data[j];
       switch (vinfo->emit[i]) {
-      case EMIT_OMIT:
-         /* no-op */
-         break;
       case EMIT_1F:
          OUT_BATCH( fui(attrib[0]) );
          count++;
index 0ddb06764af28032654dfe873345e7aefe6a30a5..feb35d492a346df7705c1790c04b1596fc404086 100644 (file)
@@ -39,7 +39,7 @@
 #include "sp_setup.h"
 #include "sp_state.h"
 #include "sp_prim_setup.h"
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
 #include "draw/draw_vertex.h"
 #include "pipe/p_util.h"
 
index 605bfee7434a3024c8335d4d4f6128dd58cbf86d..1b50792bd1cdb260ac4fe0a494bf5f85d8047552 100644 (file)
@@ -56,7 +56,7 @@
 #include "cso_cache/cso_cache.h"
 
 #include "draw/draw_context.h"
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
 
 
 /**
index 2ed228778e06479893e17a6bf530b18c6e0cee62..3cb7b68bea5327caf0e26203cd000c211e0bc857 100644 (file)
@@ -46,7 +46,7 @@
 #include "st_cb_rasterpos.h"
 #include "st_draw.h"
 #include "draw/draw_context.h"
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
 #include "shader/prog_instruction.h"
 #include "vbo/vbo.h"