Mesa (master): gallium/draw: cope with unused vertex_elements

Keith Whitwell keithw at kemper.freedesktop.org
Tue May 5 12:17:27 UTC 2009


Module: Mesa
Branch: master
Commit: c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Apr 30 10:59:19 2009 +0100

gallium/draw: cope with unused vertex_elements

---

 src/gallium/auxiliary/draw/draw_pt.h               |    1 +
 src/gallium/auxiliary/draw/draw_pt_fetch.c         |    8 +++++++-
 .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c  |    2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index 6f3e1e0..8ef0ea8 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -187,6 +187,7 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw );
 
 struct pt_fetch;
 void draw_pt_fetch_prepare( struct pt_fetch *fetch,
+                            unsigned vertex_input_count,
 			    unsigned vertex_size );
 
 void draw_pt_fetch_run( struct pt_fetch *fetch,
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 505d32f..65c3a34 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 #include "util/u_memory.h"
+#include "util/u_math.h"
 #include "draw/draw_context.h"
 #include "draw/draw_private.h"
 #include "draw/draw_vbuf.h"
@@ -56,9 +57,11 @@ struct pt_fetch {
  *
  */
 void draw_pt_fetch_prepare( struct pt_fetch *fetch,
+                            unsigned vs_input_count,
 			    unsigned vertex_size )
 {
    struct draw_context *draw = fetch->draw;
+   unsigned nr_inputs;
    unsigned i, nr = 0;
    unsigned dst_offset = 0;
    struct translate_key key;
@@ -89,8 +92,11 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       dst_offset += 4 * sizeof(float);
    }
       
+   assert( draw->pt.nr_vertex_elements >= vs_input_count );
 
-   for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
+   nr_inputs = MIN2( vs_input_count, draw->pt.nr_vertex_elements );
+
+   for (i = 0; i < nr_inputs; i++) {
       key.element[nr].input_format = draw->pt.vertex_element[i].src_format;
       key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index;
       key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset;
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index 11ac90f..df6c265 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -77,8 +77,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
    
 
    draw_pt_fetch_prepare( fpme->fetch, 
+                          vs->info.num_inputs,
 			  fpme->vertex_size );
-
    /* XXX: it's not really gl rasterization rules we care about here,
     * but gl vs dx9 clip spaces.
     */




More information about the mesa-commit mailing list