From f430f794ace50022b1b81408a3721b8e0b2519bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 1 Jan 2012 17:38:22 +0100 Subject: [PATCH] u_vbuf: only map a subrange of buffers to translate --- src/gallium/auxiliary/util/u_vbuf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index b6681978391..619a5e65761 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -194,7 +194,7 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr, uint8_t *out_map; struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0}; struct pipe_resource *out_buffer = NULL; - unsigned i, num_verts, out_offset; + unsigned i, out_offset, num_verts = max_index + 1 - min_index; boolean upload_flushed = FALSE; memset(&key, 0, sizeof(key)); @@ -244,18 +244,17 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr, if (vb_translated[i]) { struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i]; - uint8_t *map = pipe_buffer_map(mgr->pipe, vb->buffer, - PIPE_TRANSFER_READ, &vb_transfer[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]); - tr->set_buffer(tr, i, - map + vb->buffer_offset + vb->stride * min_index, - vb->stride, ~0); + tr->set_buffer(tr, i, map, vb->stride, ~0); } } /* Create and map the output buffer. */ - num_verts = max_index + 1 - min_index; - u_upload_alloc(mgr->b.uploader, key.output_stride * min_index, key.output_stride * num_verts, @@ -269,7 +268,7 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr, /* Unmap all buffers. */ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) { - if (vb_translated[i]) { + if (vb_transfer[i]) { pipe_buffer_unmap(mgr->pipe, vb_transfer[i]); } } -- 2.30.2