From ec82e9fbfab7a7c1e8dc9870204545f2624ebd82 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 15 Jun 2010 12:01:47 -0400 Subject: [PATCH] graw: fix setup for multiple constant buffers --- src/gallium/tests/graw/fs-test.c | 81 ++++++++++++++----- .../regress/fragment-shader/frag-cb-2d.sh | 4 +- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c index 3389efb7ca8..dea087357d6 100644 --- a/src/gallium/tests/graw/fs-test.c +++ b/src/gallium/tests/graw/fs-test.c @@ -42,7 +42,8 @@ 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 *constbuf = 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; @@ -73,7 +74,7 @@ static struct vertex vertices[] = { -1, 0, 0, 1 } }, }; -static float constants[] = +static float constants1[] = { 0.4, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, @@ -81,7 +82,25 @@ static float constants[] = 3, 0, 0, 0, 0, .5, 0, 0, - 0, 0, 1, 0, + 1, 0, 0, 1, + 0, 0, 0, 1, + + 1, 0, 0, 0.5, + 0, 1, 0, 0.5, + 0, 0, 1, 0, + 0, 0, 0, 1, +}; + + +static float constants2[] = +{ 1, 0, 0, 1, + 0, 1, 0, 1, + 0, 0, 1, 1, + 0, 0, 0, 0, + + 1, 1, 0, 1, + 1, .5, 0, 1, + 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0.5, @@ -97,34 +116,58 @@ static void init_fs_constbuf( void ) templat.target = PIPE_BUFFER; templat.format = PIPE_FORMAT_R8_UNORM; - templat.width0 = sizeof(constants); + templat.width0 = sizeof(constants1); templat.height0 = 1; templat.depth0 = 1; templat.last_level = 0; templat.nr_samples = 1; templat.bind = PIPE_BIND_CONSTANT_BUFFER; - constbuf = screen->resource_create(screen, - &templat); - if (constbuf == NULL) + constbuf1 = screen->resource_create(screen, + &templat); + if (constbuf1 == NULL) exit(4); + constbuf2 = screen->resource_create(screen, + &templat); + if (constbuf2 == NULL) + exit(4); - u_box_2d(0,0,sizeof(constants),1, &box); - ctx->transfer_inline_write(ctx, - constbuf, - u_subresource(0,0), - PIPE_TRANSFER_WRITE, - &box, - constants, - sizeof constants, - sizeof constants); + { + u_box_2d(0,0,sizeof(constants1),1, &box); + + ctx->transfer_inline_write(ctx, + constbuf1, + u_subresource(0,0), + PIPE_TRANSFER_WRITE, + &box, + constants1, + sizeof constants1, + sizeof constants1); - ctx->set_constant_buffer(ctx, - PIPE_SHADER_FRAGMENT, 0, - constbuf); + ctx->set_constant_buffer(ctx, + PIPE_SHADER_FRAGMENT, 0, + constbuf1); + } + { + u_box_2d(0,0,sizeof(constants2),1, &box); + + ctx->transfer_inline_write(ctx, + constbuf2, + u_subresource(0,0), + PIPE_TRANSFER_WRITE, + &box, + constants2, + sizeof constants2, + sizeof constants2); + + + ctx->set_constant_buffer(ctx, + PIPE_SHADER_FRAGMENT, 1, + constbuf2); + } } diff --git a/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-2d.sh b/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-2d.sh index f70a5146f4e..bbc3a10f9b5 100644 --- a/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-2d.sh +++ b/src/gallium/tests/python/tests/regress/fragment-shader/frag-cb-2d.sh @@ -2,8 +2,8 @@ FRAG DCL IN[0], COLOR, LINEAR DCL OUT[0], COLOR -DCL CONST[1][1..2] +DCL CONST[1][6] -MAD OUT[0], IN[0], CONST[1][2], CONST[1][1] +MOV OUT[0], CONST[1][6] END -- 2.30.2