summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_draw_feedback.c
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-12-29 03:17:43 +0100
committerMarek Olšák <maraeo@gmail.com>2011-01-06 16:16:29 +0100
commit58c5e782e351621bde2693fa945d0c90d140b855 (patch)
treed8a77d03790420d9e89325d74ff2e0dbb57a854c /src/mesa/state_tracker/st_draw_feedback.c
parent5adcd9c9117b125cab1155c5f3af0bb51ace74b7 (diff)
st/mesa: optimize constant buffer uploads
The overhead of resource_create, transfer_inline_write, and resource_destroy to upload constant data is very visible with some apps in sysprof, and as such should be eliminated. My approach uses a user buffer to pass a pointer to a driver. This gives the driver the freedom it needs to take the fast path, which may differ for each driver. This commit addresses the same issue as Jakob's one that suballocates out of a big constant buffer, but it also eliminates the copy to the buffer.
Diffstat (limited to 'src/mesa/state_tracker/st_draw_feedback.c')
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index da67c71371..05917992d6 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -109,9 +109,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
struct pipe_index_buffer ibuffer;
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
struct pipe_transfer *ib_transfer = NULL;
- struct pipe_transfer *cb_transfer;
GLuint attr, i;
- ubyte *mapped_constants;
const void *mapped_indices = NULL;
assert(draw);
@@ -242,14 +240,10 @@ st_feedback_draw_vbo(struct gl_context *ctx,
draw_set_mapped_index_buffer(draw, mapped_indices);
}
- /* map constant buffers */
- mapped_constants = pipe_buffer_map(pipe,
- st->state.constants[PIPE_SHADER_VERTEX],
- PIPE_TRANSFER_READ,
- &cb_transfer);
+ /* set the constant buffer */
draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0,
- mapped_constants,
- st->state.constants[PIPE_SHADER_VERTEX]->width0);
+ st->state.constants[PIPE_SHADER_VERTEX].ptr,
+ st->state.constants[PIPE_SHADER_VERTEX].size);
/* draw here */
@@ -258,9 +252,6 @@ st_feedback_draw_vbo(struct gl_context *ctx,
}
- /* unmap constant buffers */
- pipe_buffer_unmap(pipe, cb_transfer);
-
/*
* unmap vertex/index buffers
*/