diff options
author | Zack Rusin <zackr@vmware.com> | 2009-08-28 16:43:21 -0400 |
---|---|---|
committer | Zack Rusin <zackr@vmware.com> | 2009-08-31 13:26:01 -0400 |
commit | 9ccbadb22d74c649a634c515cd1123fe96781357 (patch) | |
tree | 8379999432722d933626fc494b223844e3d78d94 /src/gallium | |
parent | 3c3ad915d831a962b284da42659ad15bcadcffa1 (diff) |
st/xorg: setup constant buffers for vertex and fragment shaders
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_composite.c | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index af4ae05fb4..ad14eb75ed 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -172,27 +172,10 @@ set_viewport(struct exa_context *exa, int width, int height, static void bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture) { - const int param_bytes = 8 * sizeof(float); int width = pDstPicture->pDrawable->width; int height = pDstPicture->pDrawable->height; - float vs_consts[8] = { - 2.f/width, 2.f/height, 1, 1, - -1, -1, 0, 0 - }; - struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer; set_viewport(exa, width, height, Y0_BOTTOM); - - pipe_buffer_reference(&cbuf->buffer, NULL); - cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16, - PIPE_BUFFER_USAGE_CONSTANT, - param_bytes); - - if (cbuf->buffer) { - pipe_buffer_write(exa->ctx->screen, cbuf->buffer, - 0, param_bytes, vs_consts); - } - exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf); } static void @@ -295,6 +278,61 @@ bind_samplers(struct exa_context *exa, int op, cso_set_sampler_textures(exa->cso, 3, textures); } +static void +setup_vs_constant_buffer(struct exa_context *exa, + int width, int height) +{ + const int param_bytes = 8 * sizeof(float); + float vs_consts[8] = { + 2.f/width, 2.f/height, 1, 1, + -1, -1, 0, 0 + }; + struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer; + + pipe_buffer_reference(&cbuf->buffer, NULL); + cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16, + PIPE_BUFFER_USAGE_CONSTANT, + param_bytes); + + if (cbuf->buffer) { + pipe_buffer_write(exa->ctx->screen, cbuf->buffer, + 0, param_bytes, vs_consts); + } + exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf); +} + + +static void +setup_fs_constant_buffer(struct exa_context *exa) +{ + const int param_bytes = 4 * sizeof(float); + float fs_consts[8] = { + 0, 0, 0, 1, + }; + struct pipe_constant_buffer *cbuf = &exa->fs_const_buffer; + + pipe_buffer_reference(&cbuf->buffer, NULL); + cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16, + PIPE_BUFFER_USAGE_CONSTANT, + param_bytes); + + if (cbuf->buffer) { + pipe_buffer_write(exa->ctx->screen, cbuf->buffer, + 0, param_bytes, fs_consts); + } + exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_FRAGMENT, 0, cbuf); +} + +static void +setup_constant_buffers(struct exa_context *exa, PicturePtr pDstPicture) +{ + int width = pDstPicture->pDrawable->width; + int height = pDstPicture->pDrawable->height; + + setup_vs_constant_buffer(exa, width, height); + setup_fs_constant_buffer(exa); +} + boolean xorg_composite_bind_state(struct exa_context *exa, int op, PicturePtr pSrcPicture, @@ -312,6 +350,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa, bind_samplers(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask, pDst); + setup_constant_buffers(exa, pDstPicture); + return FALSE; } |