summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorChris Wilson <[email protected]>2011-03-01 14:12:22 +0000
committerChris Wilson <[email protected]>2011-03-01 16:33:40 +0000
commit69b3f24658b74f15b622adda6464a6fcb87f4ee6 (patch)
treead6036218b0fd87c82a8e872a7a95b412cea78f3 /src/mesa
parent6ddfb322f58c7e00db73e25689ee55ffa1111bd9 (diff)
i965: Fix uploading of shortened vertex packets
... handle all cases and not just the interleaved upload. Signed-off-by: Chris Wilson <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 41565231b57..baf35a6a50a 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -242,30 +242,31 @@ static GLuint get_index_type(GLenum type)
static void
copy_array_to_vbo_array(struct brw_context *brw,
struct brw_vertex_element *element,
- int count,
+ int min, int max,
struct brw_vertex_buffer *buffer,
GLuint dst_stride)
{
+ int src_stride = element->glarray->StrideB;
+ const unsigned char *src = element->glarray->Ptr + min * src_stride;
+ int count = max - min + 1;
GLuint size = count * dst_stride;
- buffer->stride = dst_stride;
- if (dst_stride == element->glarray->StrideB) {
- intel_upload_data(&brw->intel, element->glarray->Ptr, size, dst_stride,
+ if (dst_stride == src_stride) {
+ intel_upload_data(&brw->intel, src, size, dst_stride,
&buffer->bo, &buffer->offset);
} else {
- const unsigned char *src = element->glarray->Ptr;
- char *map = intel_upload_map(&brw->intel, size, dst_stride);
+ char * const map = intel_upload_map(&brw->intel, size, dst_stride);
char *dst = map;
- int i;
- for (i = 0; i < count; i++) {
+ while (count--) {
memcpy(dst, src, dst_stride);
- src += element->glarray->StrideB;
+ src += src_stride;
dst += dst_stride;
}
intel_upload_unmap(&brw->intel, map, size, dst_stride,
&buffer->bo, &buffer->offset);
}
+ buffer->stride = dst_stride;
}
static void brw_prepare_vertices(struct brw_context *brw)
@@ -413,7 +414,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
/* All uploads are interleaved, so upload the arrays together as
* interleaved. First, upload the contents and set up upload[0].
*/
- copy_array_to_vbo_array(brw, upload[0], max_index - min_index + 1,
+ copy_array_to_vbo_array(brw, upload[0], min_index, max_index,
&brw->vb.buffers[j], interleaved);
for (i = 0; i < nr_uploads; i++) {
@@ -443,7 +444,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
offset = ALIGN(offset, get_size(upload[i]->glarray->Type));
dst = map + offset;
- src += min_index * size;
+ src += min_index * stride;
for (n = 0; n < count; n++) {
memcpy(dst, src, size);
@@ -467,7 +468,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
}
/* Upload non-interleaved arrays */
for (i = 0; i < nr_uploads; i++) {
- copy_array_to_vbo_array(brw, upload[i], max_index - min_index + 1,
+ copy_array_to_vbo_array(brw, upload[i], min_index, max_index,
&brw->vb.buffers[j], upload[i]->element_size);
upload[i]->buffer = j++;
upload[i]->offset = 0;