diff options
author | José Fonseca <[email protected]> | 2012-10-26 15:12:31 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-10-26 16:02:59 +0100 |
commit | 8eb2b331ef74dc06f8e54042529d10dc4a10216f (patch) | |
tree | 86761418e3d10ae32f2f20d9e545a4403f56edc7 /src/gallium/tests/graw/fs-test.c | |
parent | ce10624e9e827921b503962e2eb04ce0eb06246a (diff) |
graw/fs-test: Use user constant buffers.
Much simpler. More interesting.
Diffstat (limited to 'src/gallium/tests/graw/fs-test.c')
-rw-r--r-- | src/gallium/tests/graw/fs-test.c | 70 |
1 files changed, 14 insertions, 56 deletions
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c index f31034406f6..51be87478f7 100644 --- a/src/gallium/tests/graw/fs-test.c +++ b/src/gallium/tests/graw/fs-test.c @@ -42,8 +42,6 @@ static const int HEIGHT = 250; static struct pipe_screen *screen = NULL; static struct pipe_context *ctx = NULL; static struct pipe_resource *rttex = NULL; -static struct pipe_resource *constbuf1 = NULL; -static struct pipe_resource *constbuf2 = NULL; static struct pipe_surface *surf = NULL; static struct pipe_sampler_view *sv = NULL; static void *sampler = NULL; @@ -111,64 +109,24 @@ static float constants2[] = static void init_fs_constbuf( void ) { - struct pipe_resource templat; - struct pipe_box box; - - templat.target = PIPE_BUFFER; - templat.format = PIPE_FORMAT_R8_UNORM; - templat.width0 = sizeof(constants1); - templat.height0 = 1; - templat.depth0 = 1; - templat.array_size = 1; - templat.last_level = 0; - templat.nr_samples = 1; - templat.bind = PIPE_BIND_CONSTANT_BUFFER; + struct pipe_constant_buffer cb1; + struct pipe_constant_buffer cb2; - constbuf1 = screen->resource_create(screen, - &templat); - if (constbuf1 == NULL) - exit(4); + memset(&cb1, 0, sizeof cb1); + cb1.buffer_size = sizeof constants1; + cb1.user_buffer = constants1; - constbuf2 = screen->resource_create(screen, - &templat); - if (constbuf2 == NULL) - exit(4); + ctx->set_constant_buffer(ctx, + PIPE_SHADER_FRAGMENT, 0, + &cb1); + memset(&cb2, 0, sizeof cb2); + cb2.buffer_size = sizeof constants2; + cb2.user_buffer = constants2; - { - u_box_2d(0,0,sizeof(constants1),1, &box); - - ctx->transfer_inline_write(ctx, - constbuf1, - 0, - PIPE_TRANSFER_WRITE, - &box, - constants1, - sizeof constants1, - sizeof constants1); - - - pipe_set_constant_buffer(ctx, - PIPE_SHADER_FRAGMENT, 0, - constbuf1); - } - { - u_box_2d(0,0,sizeof(constants2),1, &box); - - ctx->transfer_inline_write(ctx, - constbuf2, - 0, - PIPE_TRANSFER_WRITE, - &box, - constants2, - sizeof constants2, - sizeof constants2); - - - pipe_set_constant_buffer(ctx, - PIPE_SHADER_FRAGMENT, 1, - constbuf2); - } + ctx->set_constant_buffer(ctx, + PIPE_SHADER_FRAGMENT, 1, + &cb2); } |