diff options
author | Marek Olšák <maraeo@gmail.com> | 2012-04-24 22:53:05 +0200 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2012-04-30 01:18:48 +0200 |
commit | 0b7d48cbad86eaac21fce3793da41b46db8be3b4 (patch) | |
tree | 437f5cfeb3a77278d29e384b47dfaef9b96faa75 /src/gallium/drivers/softpipe/sp_state_shader.c | |
parent | 01bf5569c44389c1127bbb9e873c8a234ac92ff7 (diff) | |
download | external_mesa3d-0b7d48cbad86eaac21fce3793da41b46db8be3b4.zip external_mesa3d-0b7d48cbad86eaac21fce3793da41b46db8be3b4.tar.gz external_mesa3d-0b7d48cbad86eaac21fce3793da41b46db8be3b4.tar.bz2 |
gallium: add void *user_buffer to pipe_constant_buffer
This reduces CPU overhead when updating constants.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_state_shader.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_shader.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c index af05d0d..4056d2d 100644 --- a/src/gallium/drivers/softpipe/sp_state_shader.c +++ b/src/gallium/drivers/softpipe/sp_state_shader.c @@ -346,8 +346,17 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); struct pipe_resource *constants = cb ? cb->buffer : NULL; - unsigned size = constants ? constants->width0 : 0; - const void *data = constants ? softpipe_resource(constants)->data : NULL; + unsigned size; + const void *data; + + if (cb && cb->user_buffer) { + constants = softpipe_user_buffer_create(pipe->screen, cb->user_buffer, + cb->buffer_size, + PIPE_BIND_CONSTANT_BUFFER); + } + + size = constants ? constants->width0 : 0; + data = constants ? softpipe_resource(constants)->data : NULL; assert(shader < PIPE_SHADER_TYPES); @@ -364,6 +373,10 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, softpipe->const_buffer_size[shader][index] = size; softpipe->dirty |= SP_NEW_CONSTANTS; + + if (cb && cb->user_buffer) { + pipe_resource_reference(&constants, NULL); + } } |