radeonsi: return bool from si_shader_binary_upload
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 17 May 2018 16:17:07 +0000 (18:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 13 Jun 2019 00:28:23 +0000 (20:28 -0400)
We didn't really use error codes anyway.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 006fb89a200c11b630549a4dc6ec7fe1bf93e4f4..4a7ebac9ab7844e83a569d744c96ab9db3ec815a 100644 (file)
@@ -145,7 +145,7 @@ static void si_create_compute_state_async(void *job, int thread_index)
                si_shader_dump(sscreen, shader, debug, PIPE_SHADER_COMPUTE,
                               stderr, true);
 
-               if (si_shader_binary_upload(sscreen, shader))
+               if (!si_shader_binary_upload(sscreen, shader))
                        program->shader.compilation_failed = true;
        } else {
                mtx_unlock(&sscreen->shader_cache_mutex);
@@ -254,7 +254,7 @@ static void *si_create_compute_state(
                }
                si_shader_dump(sctx->screen, &program->shader, &sctx->debug,
                               PIPE_SHADER_COMPUTE, stderr, true);
-               if (si_shader_binary_upload(sctx->screen, &program->shader) < 0) {
+               if (!si_shader_binary_upload(sctx->screen, &program->shader)) {
                        fprintf(stderr, "LLVM failed to upload shader\n");
                        FREE(program);
                        return NULL;
@@ -392,7 +392,7 @@ static bool si_setup_compute_scratch_buffer(struct si_context *sctx,
 
                si_shader_apply_scratch_relocs(shader, scratch_va);
 
-               if (si_shader_binary_upload(sctx->screen, shader))
+               if (!si_shader_binary_upload(sctx->screen, shader))
                        return false;
 
                si_resource_reference(&shader->scratch_bo,
index 17323fa69ecdc8a0844cd1f1349d1b10b5b910d1..21b2819c8570d3555dc5af916877a16b7bc66779 100644 (file)
@@ -5088,7 +5088,7 @@ static unsigned si_get_shader_binary_size(const struct si_shader *shader)
        return size + DEBUGGER_NUM_MARKERS * 4;
 }
 
-int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
+bool si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
 {
        const struct ac_shader_binary *prolog =
                shader->prolog ? &shader->prolog->binary : NULL;
@@ -5118,7 +5118,7 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
                                               align(bo_size, SI_CPDMA_ALIGNMENT),
                                               256);
        if (!shader->bo)
-               return -ENOMEM;
+               return false;
 
        /* Upload. */
        ptr = sscreen->ws->buffer_map(shader->bo->buf, NULL,
@@ -5158,7 +5158,7 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
                ptr32[i] = DEBUGGER_END_OF_CODE_MARKER;
 
        sscreen->ws->buffer_unmap(shader->bo->buf);
-       return 0;
+       return true;
 }
 
 static void si_shader_dump_disassembly(const struct ac_shader_binary *binary,
@@ -5490,7 +5490,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
        LLVMBuilderRef builder;
        struct si_shader_output_values outputs[SI_MAX_VS_OUTPUTS];
        struct tgsi_shader_info *gsinfo = &gs_selector->info;
-       int i, r;
+       int i;
 
 
        shader = CALLOC_STRUCT(si_shader);
@@ -5599,22 +5599,22 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
        ctx.type = PIPE_SHADER_GEOMETRY; /* override for shader dumping */
        si_llvm_optimize_module(&ctx);
 
-       r = si_compile_llvm(sscreen, &ctx.shader->binary,
+       bool ok = false;
+       if (si_compile_llvm(sscreen, &ctx.shader->binary,
                            &ctx.shader->config, ctx.compiler,
                            ctx.ac.module,
                            debug, PIPE_SHADER_GEOMETRY,
-                           "GS Copy Shader", false);
-       if (!r) {
+                           "GS Copy Shader", false) == 0) {
                if (si_can_dump_shader(sscreen, PIPE_SHADER_GEOMETRY))
                        fprintf(stderr, "GS Copy Shader:\n");
                si_shader_dump(sscreen, ctx.shader, debug,
                               PIPE_SHADER_GEOMETRY, stderr, true);
-               r = si_shader_binary_upload(sscreen, ctx.shader);
+               ok = si_shader_binary_upload(sscreen, ctx.shader);
        }
 
        si_llvm_dispose(&ctx);
 
-       if (r != 0) {
+       if (!ok) {
                FREE(shader);
                shader = NULL;
        } else {
@@ -8011,8 +8011,7 @@ bool si_shader_create(struct si_screen *sscreen, struct ac_llvm_compiler *compil
                       stderr, true);
 
        /* Upload. */
-       r = si_shader_binary_upload(sscreen, shader);
-       if (r) {
+       if (!si_shader_binary_upload(sscreen, shader)) {
                fprintf(stderr, "LLVM failed to upload shader\n");
                return false;
        }
index 470a73359bdb7c3159bb89b28e7b222a68cf7a9d..145a03bd1ae23b10b65534531732045a5c7720de 100644 (file)
@@ -690,7 +690,7 @@ void si_shader_destroy(struct si_shader *shader);
 unsigned si_shader_io_get_unique_index_patch(unsigned semantic_name, unsigned index);
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index,
                                       unsigned is_varying);
-int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
+bool si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
 void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader,
                    struct pipe_debug_callback *debug, unsigned processor,
                    FILE *f, bool check_debug_option);
index db939b73b0a0ef119fe0c86f1731a14e3e20360a..77d1c014305ff20dc871a7bff2c81c140e9e9819 100644 (file)
@@ -3108,7 +3108,6 @@ static int si_update_scratch_buffer(struct si_context *sctx,
                                    struct si_shader *shader)
 {
        uint64_t scratch_va = sctx->scratch_buffer->gpu_address;
-       int r;
 
        if (!shader)
                return 0;
@@ -3139,10 +3138,9 @@ static int si_update_scratch_buffer(struct si_context *sctx,
        si_shader_apply_scratch_relocs(shader, scratch_va);
 
        /* Replace the shader bo with a new bo that has the relocs applied. */
-       r = si_shader_binary_upload(sctx->screen, shader);
-       if (r) {
+       if (!si_shader_binary_upload(sctx->screen, shader)) {
                si_shader_unlock(shader);
-               return r;
+               return -1;
        }
 
        /* Update the shader state to use the new shader bo. */