{
assert(offset < buf->size);
assert(offset + length <= buf->size);
+ assert(length);
if(screen->buffer_map_range)
return screen->buffer_map_range(screen, buf, offset, length, usage);
- else {
- uint8_t *map;
- map = screen->buffer_map(screen, buf, usage);
- return map ? map + offset : NULL;
- }
+ else
+ return screen->buffer_map(screen, buf, usage);
}
static INLINE void
{
assert(offset < buf->size);
assert(offset + length <= buf->size);
+ assert(length);
if(screen->buffer_flush_mapped_range)
screen->buffer_flush_mapped_range(screen, buf, offset, length);
}
assert(offset < buf->size);
assert(offset + size <= buf->size);
-
+ assert(size);
+
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
assert(map);
if(map) {
- memcpy(map, data, size);
+ memcpy(map + offset, data, size);
pipe_buffer_flush_mapped_range(screen, buf, offset, size);
pipe_buffer_unmap(screen, buf);
}
assert(offset < buf->size);
assert(offset + size <= buf->size);
-
+ assert(size);
+
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
assert(map);
if(map) {
- memcpy(data, map, size);
+ memcpy(data, map + offset, size);
pipe_buffer_unmap(screen, buf);
}
}
/**
* Map a subrange of the buffer data store into the client's address space.
*
- * Return pointer is always relative to offset 0, regardless of the
- * read/write ranges.
+ * The returned pointer is always relative to buffer start, regardless of
+ * the specified range. This is different from the ARB_map_buffer_range
+ * semantics because we don't forbid multiple mappings of the same buffer
+ * (yet).
*/
void *(*buffer_map_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned usage);
/**
- * written is the range that the client actually wrote.
+ * Notify a range that was actually written into.
+ *
+ * The range is relative to the buffer start, regardless of the range
+ * specified to buffer_map_range. This is different from the
+ * ARB_map_buffer_range semantics because we don't forbid multiple mappings
+ * of the same buffer (yet).
*/
void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,