draw: allow drivers to query pipeline state more easily
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 22 Apr 2008 19:50:20 +0000 (20:50 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 22 Apr 2008 19:50:20 +0000 (20:50 +0100)
Also, provide a separate flag to say whether the driver can handle
clipping/rhw tasks, in addition to the API flag which indicates they
have already been done.

src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_pipe_validate.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_post_vs.c

index b4dbdccd610767ddecd51d8d94dbb0a16d4cf0e4..b916b278772712bac1ea31b53e6a281cfa0016a8 100644 (file)
@@ -122,6 +122,19 @@ void draw_set_rasterizer_state( struct draw_context *draw,
    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 
    draw->rasterizer = raster;
+   draw->bypass_clipping = (draw->rasterizer->bypass_clipping || 
+                            draw->driver.bypass_clipping);
+}
+
+
+void draw_set_driver_clipping( struct draw_context *draw,
+                               boolean bypass_clipping )
+{
+   draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
+
+   draw->driver.bypass_clipping = bypass_clipping;
+   draw->bypass_clipping = (draw->rasterizer->bypass_clipping || 
+                            draw->driver.bypass_clipping);
 }
 
 
index 274200169878cd41409d51f4c3b5141c4a599230..c5c3d3b09e04ebe91c343f2fa4473a3ac85e8c81 100644 (file)
@@ -148,4 +148,16 @@ struct vbuf_render;
 void draw_set_render( struct draw_context *draw, 
                      struct vbuf_render *render );
 
+void draw_set_driver_clipping( struct draw_context *draw,
+                               boolean bypass_clipping );
+
+/*******************************************************************************
+ * Draw pipeline 
+ */
+boolean draw_need_pipeline(const struct draw_context *draw,
+                           const struct pipe_rasterizer_state *rasterizer,
+                           unsigned prim );
+
+
+
 #endif /* DRAW_CONTEXT_H */
index a2e0812c890e8ee6ef19668cf2878f3db16ae995..6be1d369c33b759488825208b13870fd74a1f3d7 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_defines.h"
 #include "draw_private.h"
 #include "draw_pipe.h"
+#include "draw_context.h"
 
 static boolean points( unsigned prim )
 {
@@ -57,7 +58,8 @@ static boolean triangles( unsigned prim )
  * pipeline stages.
  */
 boolean
-draw_need_pipeline(const struct draw_context *draw, 
+draw_need_pipeline(const struct draw_context *draw,
+                   const struct pipe_rasterizer_state *rasterizer,
                    unsigned int prim )
 {
    /* Don't have to worry about triangles turning into lines/points
@@ -67,30 +69,30 @@ draw_need_pipeline(const struct draw_context *draw,
    if (lines(prim)) 
    {
       /* line stipple */
-      if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple)
+      if (rasterizer->line_stipple_enable && draw->pipeline.line_stipple)
          return TRUE;
 
       /* wide lines */
-      if (draw->rasterizer->line_width > draw->pipeline.wide_line_threshold)
+      if (rasterizer->line_width > draw->pipeline.wide_line_threshold)
          return TRUE;
 
       /* AA lines */
-      if (draw->rasterizer->line_smooth && draw->pipeline.aaline)
+      if (rasterizer->line_smooth && draw->pipeline.aaline)
          return TRUE;
    }
 
    if (points(prim))
    {
       /* large points */
-      if (draw->rasterizer->point_size > draw->pipeline.wide_point_threshold)
+      if (rasterizer->point_size > draw->pipeline.wide_point_threshold)
          return TRUE;
 
       /* AA points */
-      if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
+      if (rasterizer->point_smooth && draw->pipeline.aapoint)
          return TRUE;
 
       /* point sprites */
-      if (draw->rasterizer->point_sprite && draw->pipeline.point_sprite)
+      if (rasterizer->point_sprite && draw->pipeline.point_sprite)
          return TRUE;
    }
 
@@ -98,20 +100,20 @@ draw_need_pipeline(const struct draw_context *draw,
    if (triangles(prim)) 
    {
       /* polygon stipple */
-      if (draw->rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
+      if (rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
          return TRUE;
 
       /* unfilled polygons */
-      if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
-          draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
+      if (rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
+          rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
          return TRUE;
       
       /* polygon offset */
-      if (draw->rasterizer->offset_cw || draw->rasterizer->offset_ccw)
+      if (rasterizer->offset_cw || rasterizer->offset_ccw)
          return TRUE;
 
       /* two-side lighting */
-      if (draw->rasterizer->light_twoside)
+      if (rasterizer->light_twoside)
          return TRUE;
    }
 
@@ -120,7 +122,7 @@ draw_need_pipeline(const struct draw_context *draw,
     * 
     * Generally this isn't a reason to require the pipeline, though.
     *
-   if (draw->rasterizer->cull_mode)
+   if (rasterizer->cull_mode)
       return TRUE;
     */
 
@@ -239,7 +241,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
 
    /* Clip stage
     */
-   if (!draw->rasterizer->bypass_clipping)
+   if (!draw->bypass_clipping)
    {
       draw->pipeline.clip->next = next;
       next = draw->pipeline.clip;
index da973e868b8c6a7f0d6c581ec52f44b1ae7a6c19..83b81f66a0bb5054258ebb1f0812c04cae9daebc 100644 (file)
@@ -174,7 +174,12 @@ struct draw_context
 
    } pt;
 
+   struct {
+      boolean bypass_clipping;
+   } driver;
+
    boolean flushing;
+   boolean bypass_clipping;     /* set if either api or driver bypass_clipping true */
 
    /* pipe state that we need: */
    const struct pipe_rasterizer_state *rasterizer;
@@ -243,8 +248,6 @@ void draw_pipeline_run( struct draw_context *draw,
 void draw_pipeline_flush( struct draw_context *draw, 
                           unsigned flags );
 
-boolean draw_need_pipeline(const struct draw_context *draw,
-                           unsigned prim );
 
 
 /*******************************************************************************
index 9f8e8d3d62e9448578b6234b2f1fd7a89e6340f4..f5a3bf390e883fffd3c5f149d99eb07888094892 100644 (file)
@@ -58,11 +58,13 @@ draw_pt_arrays(struct draw_context *draw,
       opt |= PT_PIPELINE;
    }
 
-   if (draw_need_pipeline(draw, prim)) {
+   if (draw_need_pipeline(draw, 
+                          draw->rasterizer,
+                          prim)) {
       opt |= PT_PIPELINE;
    }
 
-   if (!draw->rasterizer->bypass_clipping) {
+   if (!draw->bypass_clipping) {
       opt |= PT_CLIPTEST;
    }
 
index 98a2cb45e4b95bd20469b5afc12ccd2f6b593377..f0763dad8d77fbc495363c5087427edde230f728 100644 (file)
@@ -81,7 +81,7 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
     * but gl vs dx9 clip spaces.
     */
    draw_pt_post_vs_prepare( fpme->post_vs,
-                           draw->rasterizer->bypass_clipping,
+                           draw->bypass_clipping,
                            draw->identity_viewport,
                            draw->rasterizer->gl_rasterization_rules );
                            
index 581f044dae10f0bef4f8e02ad449c051ee163e75..e5e38fa264fc6a837c5a304cd47e46fceafbe623 100644 (file)
@@ -94,8 +94,10 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
    struct vertex_header *out = vertices;
    const float *scale = pvs->draw->viewport.scale;
    const float *trans = pvs->draw->viewport.translate;
+   boolean clipped = FALSE;
    unsigned j;
-   unsigned clipped = 0;
+
+   if (0) debug_printf("%s\n");
 
    for (j = 0; j < count; j++) {
       out->clip[0] = out->data[0][0];
@@ -108,10 +110,11 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
       out->clipmask = compute_clipmask_gl(out->clip, 
                                          pvs->draw->plane,
                                          pvs->draw->nr_planes);
-      clipped += out->clipmask;
 
       if (out->clipmask == 0)
       {
+         clipped = TRUE;
+
         /* divide by w */
         float w = 1.0f / out->data[0][3];
 
@@ -142,7 +145,7 @@ static boolean post_vs_viewport( struct pt_post_vs *pvs,
    const float *trans = pvs->draw->viewport.translate;
    unsigned j;
 
-   debug_printf("%s\n", __FUNCTION__);
+   if (0) debug_printf("%s\n", __FUNCTION__);
    for (j = 0; j < count; j++) {
       /* Viewport mapping only, no cliptest/rhw divide
        */
@@ -165,7 +168,7 @@ static boolean post_vs_none( struct pt_post_vs *pvs,
                             unsigned count,
                             unsigned stride )
 {
-   debug_printf("%s\n", __FUNCTION__);
+   if (0) debug_printf("%s\n", __FUNCTION__);
    return FALSE;
 }