From: Marek Olšák Date: Sun, 1 Jan 2012 16:53:55 +0000 (+0100) Subject: u_vbuf: don't map user buffers, just obtain a pointer to them X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c727cc175bcbf96f12f27c46819667948d5ebbe2;p=mesa.git u_vbuf: don't map user buffers, just obtain a pointer to them --- diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 619a5e65761..7c87bf8b210 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -243,12 +243,17 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr, for (i = 0; i < mgr->b.nr_vertex_buffers; i++) { if (vb_translated[i]) { struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i]; - - uint8_t *map = - pipe_buffer_map_range(mgr->pipe, vb->buffer, - vb->buffer_offset + vb->stride * min_index, - num_verts * vb->stride, - PIPE_TRANSFER_READ, &vb_transfer[i]); + unsigned offset = vb->buffer_offset + vb->stride * min_index; + unsigned size = vb->stride ? num_verts * vb->stride + : vb->buffer->width0 - offset; + uint8_t *map; + + if (u_vbuf_resource(vb->buffer)->user_ptr) { + map = u_vbuf_resource(vb->buffer)->user_ptr + offset; + } else { + map = pipe_buffer_map_range(mgr->pipe, vb->buffer, offset, size, + PIPE_TRANSFER_READ, &vb_transfer[i]); + } tr->set_buffer(tr, i, map, vb->stride, ~0); }