r300g: fix misaligned generated offset for ubyte vertex indices
authorMarek Olšák <maraeo@gmail.com>
Sun, 21 Mar 2010 03:39:33 +0000 (04:39 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sun, 21 Mar 2010 04:42:49 +0000 (05:42 +0100)
src/gallium/drivers/r300/r300_render.c

index ff93a16a1074596b05ffaa47e10b14de69260e2a..afd871ae302ef17e45287385799cc0418c141d59 100644 (file)
@@ -353,6 +353,7 @@ static void r300_emit_draw_elements(struct r300_context *r300,
 
 static void r300_shorten_ubyte_elts(struct r300_context* r300,
                                     struct pipe_buffer** elts,
+                                    unsigned start,
                                     unsigned count)
 {
     struct pipe_screen* screen = r300->context.screen;
@@ -370,6 +371,8 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300,
     in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ);
     out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE);
 
+    in_map += start;
+
     for (i = 0; i < count; i++) {
         *out_map = (unsigned short)*in_map;
         in_map++;
@@ -407,8 +410,9 @@ void r300_draw_range_elements(struct pipe_context* pipe,
     }
 
     if (indexSize == 1) {
-        r300_shorten_ubyte_elts(r300, &indexBuffer, count);
+        r300_shorten_ubyte_elts(r300, &indexBuffer, start, count);
         indexSize = 2;
+        start = 0;
     }
 
     r300_update_derived_state(r300);