#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
#define PIPE_BUFFER_USAGE_DISCARD (1 << 8)
#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9)
+#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 10) /**< See pipe_screen::buffer_flush_mapped_range */
/** Pipe driver custom usage flags should be greater or equal to this value */
#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
assert(offset + size <= buf->size);
assert(size);
- map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pipe_buffer_map_range(screen, buf, offset, size,
+ PIPE_BUFFER_USAGE_CPU_WRITE |
+ PIPE_BUFFER_USAGE_FLUSH_EXPLICIT);
assert(map);
if(map) {
memcpy(map + offset, data, size);
/**
* Notify a range that was actually written into.
*
+ * Can only be used if the buffer was mapped with the
+ * PIPE_BUFFER_USAGE_CPU_WRITE and PIPE_BUFFER_USAGE_FLUSH_EXPLICIT flags
+ * set.
+ *
* 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).
*
- * If the buffer was mapped for writing and no buffer_flush_mapped_range
- * call was done until the buffer_unmap is called then the pipe driver will
- * assumed that the whole buffer was written. This is for backward
- * compatibility purposes and may affect performance -- the state tracker
- * should always specify exactly what got written while the buffer was
- * mapped.
*/
void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned offset,
unsigned length);
+ /**
+ * Unmap buffer.
+ *
+ * If the buffer was mapped with PIPE_BUFFER_USAGE_CPU_WRITE flag but not
+ * PIPE_BUFFER_USAGE_FLUSH_EXPLICIT then the pipe driver will
+ * assume that the whole buffer was written. This is mostly for backward
+ * compatibility purposes and may affect performance -- the state tracker
+ * should always specify exactly what got written while the buffer was
+ * mapped.
+ */
void (*buffer_unmap)( struct pipe_screen *screen,
struct pipe_buffer *buf );