i965: align the address of the first element within
authorXiang, Haihao <haihao.xiang@intel.com>
Fri, 14 Sep 2007 03:10:23 +0000 (11:10 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 14 Sep 2007 03:10:23 +0000 (11:10 +0800)
the index buffer. (fix#11910)

src/mesa/drivers/dri/i965/brw_draw_upload.c

index 6150cac4aa3b4d64e340f87e1627c9250e88798e..dc289ca9ae784581a8d43dd0228106a0bc17784c 100644 (file)
@@ -593,6 +593,28 @@ void brw_upload_indices( struct brw_context *brw,
                                 ib_size,
                                 index_buffer->ptr,
                                 bufferobj);
+   } else {
+       if (((1 << get_index_type(index_buffer->type)) - 1) & offset) {
+           struct gl_buffer_object *vbo;
+           GLuint voffset;
+           GLubyte *map = ctx->Driver.MapBuffer(ctx,
+                                                GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                                GL_DYNAMIC_DRAW_ARB,
+                                                bufferobj);
+           map += offset;
+           get_space(brw, ib_size, &vbo, &voffset);
+           
+           ctx->Driver.BufferSubData(ctx,
+                                     GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                     voffset,
+                                     ib_size,
+                                     map,
+                                     vbo);
+           ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, bufferobj);
+
+           bufferobj = vbo;
+           offset = voffset;
+       }
    }
 
    /* Emit the indexbuffer packet: