diff options
author | Marek Olšák <[email protected]> | 2012-04-24 22:53:05 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-04-30 01:18:48 +0200 |
commit | 0b7d48cbad86eaac21fce3793da41b46db8be3b4 (patch) | |
tree | 437f5cfeb3a77278d29e384b47dfaef9b96faa75 /src/gallium/drivers/llvmpipe | |
parent | 01bf5569c44389c1127bbb9e873c8a234ac92ff7 (diff) |
gallium: add void *user_buffer to pipe_constant_buffer
This reduces CPU overhead when updating constants.
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_texture.c | 2 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 438fc887083..d4750705b43 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -155,6 +155,12 @@ extern unsigned llvmpipe_variant_count; struct pipe_context * llvmpipe_create_context( struct pipe_screen *screen, void *priv ); +struct pipe_resource * +llvmpipe_user_buffer_create(struct pipe_screen *screen, + void *ptr, + unsigned bytes, + unsigned bind_flags); + static INLINE struct llvmpipe_context * llvmpipe_context( struct pipe_context *pipe ) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 7a6c1ab5bc7..ec94190649c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1173,8 +1173,17 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); struct pipe_resource *constants = cb ? cb->buffer : NULL; - unsigned size = constants ? constants->width0 : 0; - const void *data = constants ? llvmpipe_resource_data(constants) : NULL; + unsigned size; + const void *data; + + if (cb && cb->user_buffer) { + constants = llvmpipe_user_buffer_create(pipe->screen, cb->user_buffer, + cb->buffer_size, + PIPE_BIND_CONSTANT_BUFFER); + } + + size = constants ? constants->width0 : 0; + data = constants ? llvmpipe_resource_data(constants) : NULL; assert(shader < PIPE_SHADER_TYPES); assert(index < PIPE_MAX_CONSTANT_BUFFERS); @@ -1194,6 +1203,10 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, } llvmpipe->dirty |= LP_NEW_CONSTANTS; + + if (cb && cb->user_buffer) { + pipe_resource_reference(&constants, NULL); + } } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index f6a1ec26bc5..958a8127b89 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -748,7 +748,7 @@ llvmpipe_is_resource_referenced( struct pipe_context *pipe, /** * Create buffer which wraps user-space data. */ -static struct pipe_resource * +struct pipe_resource * llvmpipe_user_buffer_create(struct pipe_screen *screen, void *ptr, unsigned bytes, |