u_vbuf: don't map user buffers, just obtain a pointer to them
authorMarek Olšák <maraeo@gmail.com>
Sun, 1 Jan 2012 16:53:55 +0000 (17:53 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 5 Jan 2012 17:29:11 +0000 (18:29 +0100)
src/gallium/auxiliary/util/u_vbuf.c

index 619a5e65761b9bfa3d531af6fee320829d82476d..7c87bf8b210407a77541239d095b8a452717dd48 100644 (file)
@@ -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);
       }