[Mesa-dev] [PATCH 2/2] gallium/u_tests: use a compute-only context to test GCN compute ring

Marek Olšák maraeo at gmail.com
Tue Feb 12 18:12:51 UTC 2019


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/util/u_tests.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index 365d4fa8f17..7b87337bb98 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -783,25 +783,23 @@ test_texture_barrier(struct pipe_context *ctx, bool use_fbfetch,
    ctx->delete_fs_state(ctx, fs);
    pipe_sampler_view_reference(&view, NULL);
    pipe_resource_reference(&cb, NULL);
 
    util_report_result_helper(pass, name);
 }
 
 static void
 test_compute_clear_image(struct pipe_context *ctx)
 {
-   struct cso_context *cso;
    struct pipe_resource *cb;
    const char *text;
 
-   cso = cso_create_context(ctx, 0);
    cb = util_create_texture2d(ctx->screen, 256, 256,
                               PIPE_FORMAT_R8G8B8A8_UNORM, 1);
 
    /* Compute shader. */
    text = "COMP\n"
           "PROPERTY CS_FIXED_BLOCK_WIDTH 8\n"
           "PROPERTY CS_FIXED_BLOCK_HEIGHT 8\n"
           "PROPERTY CS_FIXED_BLOCK_DEPTH 1\n"
           "DCL SV[0], THREAD_ID\n"
           "DCL SV[1], BLOCK_ID\n"
@@ -820,21 +818,21 @@ test_compute_clear_image(struct pipe_context *ctx)
       assert(0);
       util_report_result(FAIL);
       return;
    }
 
    struct pipe_compute_state state = {0};
    state.ir_type = PIPE_SHADER_IR_TGSI;
    state.prog = tokens;
 
    void *compute_shader = ctx->create_compute_state(ctx, &state);
-   cso_set_compute_shader_handle(cso, compute_shader);
+   ctx->bind_compute_state(ctx, compute_shader);
 
    /* Bind the image. */
    struct pipe_image_view image = {0};
    image.resource = cb;
    image.shader_access = image.access = PIPE_IMAGE_ACCESS_READ_WRITE;
    image.format = cb->format;
 
    ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 1, &image);
 
    /* Dispatch compute. */
@@ -847,21 +845,20 @@ test_compute_clear_image(struct pipe_context *ctx)
    info.grid[2] = 1;
 
    ctx->launch_grid(ctx, &info);
 
    /* Check pixels. */
    static const float expected[] = {1.0, 0.0, 0.0, 0.0};
    bool pass = util_probe_rect_rgba(ctx, cb, 0, 0,
                                     cb->width0, cb->height0, expected);
 
    /* Cleanup. */
-   cso_destroy_context(cso);
    ctx->delete_compute_state(ctx, compute_shader);
    pipe_resource_reference(&cb, NULL);
 
    util_report_result(pass);
 }
 
 /**
  * Run all tests. This should be run with a clean context after
  * context_create.
  */
@@ -874,18 +871,19 @@ util_run_tests(struct pipe_screen *screen)
    tgsi_vs_window_space_position(ctx);
    null_sampler_view(ctx, TGSI_TEXTURE_2D);
    null_sampler_view(ctx, TGSI_TEXTURE_BUFFER);
    util_test_constant_buffer(ctx, NULL);
    test_sync_file_fences(ctx);
 
    for (int i = 1; i <= 8; i = i * 2)
       test_texture_barrier(ctx, false, i);
    for (int i = 1; i <= 8; i = i * 2)
       test_texture_barrier(ctx, true, i);
+   ctx->destroy(ctx);
 
+   ctx = screen->context_create(screen, NULL, PIPE_CONTEXT_COMPUTE_ONLY);
    test_compute_clear_image(ctx);
-
    ctx->destroy(ctx);
 
    puts("Done. Exiting..");
    exit(0);
 }
-- 
2.17.1



More information about the mesa-dev mailing list