summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-02-02 08:54:19 -0700
committerBrian Paul <[email protected]>2018-02-06 15:23:26 -0700
commit1852a2e1a2113b69cf4662acd7533da144837084 (patch)
tree03b5f4126125dafa7e8b5181f3753a1ae55d6c09 /src
parent8a32dd2ec9cd57bddef306fe9728ae0343d072f2 (diff)
st/mesa: refactor st_bufferobj_map_range()
Use a new helper function, st_access_flags_to_transfer_flags(), to convert the GL_MAP_x flags to PIPE_TRANSFER_x flags. We'll be able to use this function in a couple other places. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c38
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.h4
2 files changed, 31 insertions, 11 deletions
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 6b64ba132c7..044916b4dc8 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -427,17 +427,13 @@ st_bufferobj_invalidate(struct gl_context *ctx,
/**
- * Called via glMapBufferRange().
+ * Convert GLbitfield of GL_MAP_x flags to gallium pipe_transfer_usage flags.
+ * \param wholeBuffer is the whole buffer being mapped?
*/
-static void *
-st_bufferobj_map_range(struct gl_context *ctx,
- GLintptr offset, GLsizeiptr length, GLbitfield access,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index)
+enum pipe_transfer_usage
+st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer)
{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_buffer_object *st_obj = st_buffer_object(obj);
- enum pipe_transfer_usage flags = 0x0;
+ enum pipe_transfer_usage flags = 0;
if (access & GL_MAP_WRITE_BIT)
flags |= PIPE_TRANSFER_WRITE;
@@ -452,7 +448,7 @@ st_bufferobj_map_range(struct gl_context *ctx,
flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
}
else if (access & GL_MAP_INVALIDATE_RANGE_BIT) {
- if (offset == 0 && length == obj->Size)
+ if (wholeBuffer)
flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
else
flags |= PIPE_TRANSFER_DISCARD_RANGE;
@@ -473,15 +469,35 @@ st_bufferobj_map_range(struct gl_context *ctx,
if (access & MESA_MAP_NOWAIT_BIT)
flags |= PIPE_TRANSFER_DONTBLOCK;
+ return flags;
+}
+
+
+/**
+ * Called via glMapBufferRange().
+ */
+static void *
+st_bufferobj_map_range(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length, GLbitfield access,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_buffer_object *st_obj = st_buffer_object(obj);
+
assert(offset >= 0);
assert(length >= 0);
assert(offset < obj->Size);
assert(offset + length <= obj->Size);
+ const enum pipe_transfer_usage transfer_flags =
+ st_access_flags_to_transfer_flags(access,
+ offset == 0 && length == obj->Size);
+
obj->Mappings[index].Pointer = pipe_buffer_map_range(pipe,
st_obj->buffer,
offset, length,
- flags,
+ transfer_flags,
&st_obj->transfer[index]);
if (obj->Mappings[index].Pointer) {
obj->Mappings[index].Offset = offset;
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index ea77c58f5ef..534506a62b3 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -55,6 +55,10 @@ st_buffer_object(struct gl_buffer_object *obj)
}
+enum pipe_transfer_usage
+st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer);
+
+
extern void
st_init_bufferobject_functions(struct pipe_screen *screen,
struct dd_function_table *functions);