[Mesa-dev] [PATCH] gallium: make vbuf_render::set_primitive() return void

Brian Paul brianp at vmware.com
Thu Jan 5 13:24:48 PST 2012


All the implementations of this function always return TRUE.
---
 src/gallium/auxiliary/draw/draw_pt_emit.c          |   23 +++++-------------
 src/gallium/auxiliary/draw/draw_pt_fetch_emit.c    |    8 +-----
 .../auxiliary/draw/draw_pt_fetch_shade_emit.c      |    6 +----
 src/gallium/auxiliary/draw/draw_vbuf.h             |    2 +-
 src/gallium/drivers/i915/i915_prim_vbuf.c          |   24 ++++++++++----------
 src/gallium/drivers/llvmpipe/lp_setup_vbuf.c       |    3 +-
 src/gallium/drivers/r300/r300_render.c             |    6 +---
 src/gallium/drivers/softpipe/sp_prim_vbuf.c        |    3 +-
 src/gallium/drivers/svga/svga_swtnl_backend.c      |    4 +--
 9 files changed, 27 insertions(+), 52 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index c8dfc16..8f48382 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -54,7 +54,6 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
    unsigned dst_offset;
    struct translate_key hw_key;
    unsigned i;
-   boolean ok;
    
    /* XXX: need to flush to get prim_vbuf.c to release its allocation?? 
     */
@@ -66,11 +65,7 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
     */
    emit->prim = prim;
 
-   ok = draw->render->set_primitive(draw->render, emit->prim);
-   if (!ok) {
-      assert(0);
-      return;
-   }
+   draw->render->set_primitive(draw->render, emit->prim);
 
    /* Must do this after set_primitive() above:
     */
@@ -113,10 +108,10 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
 
    if (!emit->translate ||
        translate_key_compare(&emit->translate->key, &hw_key) != 0)
-   {
-      translate_key_sanitize(&hw_key);
-      emit->translate = translate_cache_find(emit->cache, &hw_key);
-   }
+      {
+         translate_key_sanitize(&hw_key);
+         emit->translate = translate_cache_find(emit->cache, &hw_key);
+      }
 
    *max_vertices = (draw->render->max_vertex_buffer_bytes / 
                     (vinfo->size * 4));
@@ -147,10 +142,7 @@ void draw_pt_emit( struct pt_emit *emit,
    /* XXX: and work out some way to coordinate the render primitive
     * between vbuf.c and here...
     */
-   if (!draw->render->set_primitive(draw->render, emit->prim)) {
-      assert(0);
-      return;
-   }
+   draw->render->set_primitive(draw->render, emit->prim);
 
    render->allocate_vertices(render,
                              (ushort)translate->key.output_stride,
@@ -221,8 +213,7 @@ void draw_pt_emit_linear(struct pt_emit *emit,
    /* XXX: and work out some way to coordinate the render primitive
     * between vbuf.c and here...
     */
-   if (!draw->render->set_primitive(draw->render, emit->prim)) 
-      goto fail;
+   draw->render->set_primitive(draw->render, emit->prim);
 
    if (!render->allocate_vertices(render,
                                   (ushort)translate->key.output_stride,
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 0ab11d0..97d66e5 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -98,7 +98,6 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
    struct draw_context *draw = feme->draw;
    const struct vertex_info *vinfo;
    unsigned i, dst_offset;
-   boolean ok;
    struct translate_key key;
 
    unsigned gs_out_prim = (draw->gs.geometry_shader ? 
@@ -107,12 +106,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
 
 
 
-   ok = draw->render->set_primitive( draw->render, 
-                                     gs_out_prim );
-   if (!ok) {
-      assert(0);
-      return;
-   }
+   draw->render->set_primitive(draw->render, gs_out_prim);
    
    /* Must do this after set_primitive() above:
     */
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
index 0dbbfe2..4bed256 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -83,11 +83,7 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
     */
    assert(!draw->gs.geometry_shader);
 
-   if (!draw->render->set_primitive( draw->render,
-                                     prim )) {
-      assert(0);
-      return;
-   }
+   draw->render->set_primitive(draw->render, prim);
 
    /* Must do this after set_primitive() above:
     */
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index e32803c..1f1a7b4 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -95,7 +95,7 @@ struct vbuf_render {
     * the discretion of the driver, for the benefit of the passthrough
     * path.
     */
-   boolean (*set_primitive)( struct vbuf_render *, unsigned prim );
+   void (*set_primitive)( struct vbuf_render *, unsigned prim );
 
    /**
     * Draw indexed primitives.  Note that indices are ushort.  The driver
diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c b/src/gallium/drivers/i915/i915_prim_vbuf.c
index 3f85466..f9b2ade 100644
--- a/src/gallium/drivers/i915/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915/i915_prim_vbuf.c
@@ -322,7 +322,7 @@ i915_vbuf_ensure_index_bounds(struct vbuf_render *render,
    i915_vbuf_update_vbo_state(render);
 }
 
-static boolean
+static void
 i915_vbuf_render_set_primitive(struct vbuf_render *render, 
                                unsigned prim)
 {
@@ -333,46 +333,46 @@ i915_vbuf_render_set_primitive(struct vbuf_render *render,
    case PIPE_PRIM_POINTS:
       i915_render->hwprim = PRIM3D_POINTLIST;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_LINES:
       i915_render->hwprim = PRIM3D_LINELIST;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_LINE_LOOP:
       i915_render->hwprim = PRIM3D_LINELIST;
       i915_render->fallback = PIPE_PRIM_LINE_LOOP;
-      return TRUE;
+      break;
    case PIPE_PRIM_LINE_STRIP:
       i915_render->hwprim = PRIM3D_LINESTRIP;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_TRIANGLES:
       i915_render->hwprim = PRIM3D_TRILIST;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_TRIANGLE_STRIP:
       i915_render->hwprim = PRIM3D_TRISTRIP;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_TRIANGLE_FAN:
       i915_render->hwprim = PRIM3D_TRIFAN;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    case PIPE_PRIM_QUADS:
       i915_render->hwprim = PRIM3D_TRILIST;
       i915_render->fallback = PIPE_PRIM_QUADS;
-      return TRUE;
+      break;
    case PIPE_PRIM_QUAD_STRIP:
       i915_render->hwprim = PRIM3D_TRILIST;
       i915_render->fallback = PIPE_PRIM_QUAD_STRIP;
-      return TRUE;
+      break;
    case PIPE_PRIM_POLYGON:
       i915_render->hwprim = PRIM3D_POLY;
       i915_render->fallback = 0;
-      return TRUE;
+      break;
    default:
       /* FIXME: Actually, can handle a lot more just fine... */
-      return FALSE;
+      assert(0 && "unexpected prim in i915_vbuf_render_set_primitive()");
    }
 }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
index 384242f..b287ef4 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
@@ -113,11 +113,10 @@ lp_setup_unmap_vertices(struct vbuf_render *vbr,
 }
 
 
-static boolean
+static void
 lp_setup_set_primitive(struct vbuf_render *vbr, unsigned prim)
 {
    lp_setup_context(vbr)->prim = prim;
-   return TRUE;
 }
 
 typedef const float (*const_float4_ptr)[4];
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 90b8e53..7f04c93 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -981,15 +981,13 @@ static void r300_render_release_vertices(struct vbuf_render* render)
     r300render->vbo_max_used = 0;
 }
 
-static boolean r300_render_set_primitive(struct vbuf_render* render,
-                                               unsigned prim)
+static void r300_render_set_primitive(struct vbuf_render* render,
+                                      unsigned prim)
 {
     struct r300_render* r300render = r300_render(render);
 
     r300render->prim = prim;
     r300render->hwprim = r300_translate_primitive(prim);
-
-    return TRUE;
 }
 
 static void r300_render_draw_arrays(struct vbuf_render* render,
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index c60249d..54a6542 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -132,7 +132,7 @@ sp_vbuf_unmap_vertices(struct vbuf_render *vbr,
 }
 
 
-static boolean
+static void
 sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
 {
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
@@ -142,7 +142,6 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
 
    cvbr->softpipe->reduced_prim = u_reduced_prim(prim);
    cvbr->prim = prim;
-   return TRUE;
 }
 
 
diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c
index 521226c..33557aa 100644
--- a/src/gallium/drivers/svga/svga_swtnl_backend.c
+++ b/src/gallium/drivers/svga/svga_swtnl_backend.c
@@ -161,14 +161,12 @@ svga_vbuf_render_unmap_vertices( struct vbuf_render *render,
    svga_render->vbuf_used = MAX2(svga_render->vbuf_used, used);
 }
 
-static boolean
+static void
 svga_vbuf_render_set_primitive( struct vbuf_render *render,
                                 unsigned prim )
 {
    struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
    svga_render->prim = prim;
-
-   return TRUE;
 }
 
 static void
-- 
1.7.3.4



More information about the mesa-dev mailing list