summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2008-08-21 12:12:18 -0700
committerEric Anholt <[email protected]>2008-08-21 12:15:17 -0700
commit687cd467b3461691a6fd03d3bc38c01ed79c06fd (patch)
tree74924053bbf4b5af9c2a36864fc9c5f2eb4d2cde /src
parent021ce883e6146206306ebf48ccd2cd4214619ecb (diff)
i965: use dri_bo_subdata in vertex upload to get pwrite used.
Otherwise, we would ping-pong objects to GTT and back as we did pwrite on indices (flushed and mapped to GTT) and mapped for vertices (moved back to CPU domain). Fixes bug #17180.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 9427131440c..0122d18f82b 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -217,25 +217,6 @@ static GLuint get_index_type(GLenum type)
}
}
-static void copy_strided_array( GLubyte *dest,
- const GLubyte *src,
- GLuint size,
- GLuint stride,
- GLuint count )
-{
- if (size == stride)
- memcpy(dest, src, count * size);
- else {
- GLuint i;
-
- for (i = 0; i < count; i++) {
- memcpy(dest, src, size);
- src += stride;
- dest += size;
- }
- }
-}
-
static void wrap_buffers( struct brw_context *brw,
GLuint size )
{
@@ -293,13 +274,31 @@ copy_array_to_vbo_array( struct brw_context *brw,
element->stride = dst_stride;
}
- dri_bo_map(element->bo, GL_TRUE);
- copy_strided_array((unsigned char *)element->bo->virtual + element->offset,
- element->glarray->Ptr,
- dst_stride,
- element->glarray->StrideB,
- element->count);
- dri_bo_unmap(element->bo);
+ if (dst_stride == element->glarray->StrideB) {
+ dri_bo_subdata(element->bo,
+ element->offset,
+ size,
+ element->glarray->Ptr);
+ } else {
+ void *data;
+ char *dest;
+ const char *src = element->glarray->Ptr;
+ int i;
+
+ data = _mesa_malloc(dst_stride * element->count);
+ dest = data;
+ for (i = 0; i < element->count; i++) {
+ memcpy(dest, src, dst_stride);
+ src += element->glarray->StrideB;
+ dest += dst_stride;
+ }
+
+ dri_bo_subdata(element->bo,
+ element->offset,
+ size,
+ data);
+ _mesa_free(data);
+ }
}
static void brw_prepare_vertices(struct brw_context *brw)