Mesa (master): draw: validate stream output buffers

Zack Rusin zack at kemper.freedesktop.org
Thu Jun 17 07:48:57 PDT 2010


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

Author: Zack Rusin <zackr at vmware.com>
Date:   Thu Jun 17 10:47:10 2010 -0400

draw: validate stream output buffers

fixes a crash.

---

 src/gallium/auxiliary/draw/draw_pt_so_emit.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index 84555a7..5d82934 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -57,6 +57,20 @@ void draw_pt_so_emit_prepare(struct pt_so_emit *emit)
 
    emit->has_so = (draw->so.state.num_outputs > 0);
 
+   /* if we have a state with outputs make sure we have
+    * buffers to output to */
+   if (emit->has_so) {
+      boolean has_valid_buffer = FALSE;
+      unsigned i;
+      for (i = 0; i < draw->so.num_buffers; ++i) {
+         if (draw->so.buffers[i]) {
+            has_valid_buffer = TRUE;
+            break;
+         }
+      }
+      emit->has_so = has_valid_buffer;
+   }
+
    if (!emit->has_so)
       return;
 
@@ -240,8 +254,9 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
    emit->emitted_primitives = 0;
    emit->input_vertex_stride = input_verts->stride;
    emit->inputs = (const float (*)[4])input_verts->verts->data;
-   for (i = 0; i < draw->so.num_buffers; ++i)
+   for (i = 0; i < draw->so.num_buffers; ++i) {
       emit->buffers[i] = draw->so.buffers[i];
+   }
    emit->single_buffer = TRUE;
    for (i = 0; i < draw->so.state.num_outputs; ++i) {
       if (draw->so.state.output_buffer[i] != 0)



More information about the mesa-commit mailing list