From: Eric Anholt Date: Thu, 21 Aug 2008 19:12:18 +0000 (-0700) Subject: i965: use dri_bo_subdata in vertex upload to get pwrite used. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=687cd467b3461691a6fd03d3bc38c01ed79c06fd;p=mesa.git 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. --- 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)