Mesa (master): i965: Make sure to upload the data for a collection of Stride == 0 arrays.

Eric Anholt anholt at kemper.freedesktop.org
Sat Oct 1 23:31:46 PDT 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Sep 26 16:14:40 2011 -0700

i965: Make sure to upload the data for a collection of Stride == 0 arrays.

Commit d631c19db47181129811080bfa772b210d762d4d avoided this problem
by forcing the driver to get the min/max index, but that commit was
broken, so just fix the driver problem (confusion between "do I need
to upload any data?" and "do I need the index bounds in order to
upload any data?").

---

 src/mesa/drivers/dri/i965/brw_draw_upload.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 7bc69c6..20325eb 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -31,6 +31,7 @@
 #include "main/bufferobj.h"
 #include "main/context.h"
 #include "main/enums.h"
+#include "main/macros.h"
 
 #include "brw_draw.h"
 #include "brw_defines.h"
@@ -251,6 +252,22 @@ copy_array_to_vbo_array(struct brw_context *brw,
 			struct brw_vertex_buffer *buffer,
 			GLuint dst_stride)
 {
+   if (min == -1) {
+      /* If we don't have computed min/max bounds, then this must be a use of
+       * the current attribute, which has a 0 stride.  Otherwise, we wouldn't
+       * know what data to upload.
+       */
+      assert(element->glarray->StrideB == 0);
+
+      intel_upload_data(&brw->intel, element->glarray->Ptr,
+                        element->element_size,
+                        element->element_size,
+			&buffer->bo, &buffer->offset);
+
+      buffer->stride = 0;
+      return;
+   }
+
    int src_stride = element->glarray->StrideB;
    const unsigned char *src = element->glarray->Ptr + min * src_stride;
    int count = max - min + 1;
@@ -442,7 +459,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
       else if (total_size < 2048) {
 	 /* Upload non-interleaved arrays into a single interleaved array */
 	 struct brw_vertex_buffer *buffer;
-	 int count = max_index - min_index + 1;
+	 int count = MAX2(max_index - min_index + 1, 1);
 	 int offset;
 	 char *map;
 



More information about the mesa-commit mailing list