From: Nicolai Hähnle <[email protected]>

We didn't really use error codes anyway.
---
 src/gallium/drivers/radeonsi/si_compute.c     |  6 +++---
 src/gallium/drivers/radeonsi/si_shader.c      | 21 +++++++++----------
 src/gallium/drivers/radeonsi/si_shader.h      |  2 +-
 .../drivers/radeonsi/si_state_shaders.c       |  6 ++----
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 2acd96545aa..2899ee146d4 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -137,21 +137,21 @@ static void si_create_compute_state_async(void *job, int 
thread_index)
        mtx_lock(&sscreen->shader_cache_mutex);
 
        if (ir_binary &&
            si_shader_cache_load_shader(sscreen, ir_binary, shader)) {
                mtx_unlock(&sscreen->shader_cache_mutex);
 
                si_shader_dump_stats_for_shader_db(shader, debug);
                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);
 
                if (!si_shader_create(sscreen, compiler, &program->shader, 
debug)) {
                        program->shader.compilation_failed = true;
 
                        if (program->ir_type == PIPE_SHADER_IR_TGSI)
                                FREE(program->ir.tgsi);
                        program->shader.selector = NULL;
@@ -246,21 +246,21 @@ static void *si_create_compute_state(
                                        program->shader.binary.reloc_count);
                                FREE(program);
                                return NULL;
                        }
                } else {
                        ac_shader_binary_read_config(&program->shader.binary,
                                     &program->shader.config, 0, false);
                }
                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;
                }
        }
 
        return program;
 }
 
 static void si_bind_compute_state(struct pipe_context *ctx, void *state)
@@ -388,21 +388,21 @@ static bool si_setup_compute_scratch_buffer(struct 
si_context *sctx,
 
                if (!sctx->compute_scratch_buffer)
                        return false;
        }
 
        if (sctx->compute_scratch_buffer != shader->scratch_bo && 
scratch_needed) {
                uint64_t scratch_va = sctx->compute_scratch_buffer->gpu_address;
 
                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,
                                        sctx->compute_scratch_buffer);
        }
 
        return true;
 }
 
 static bool si_switch_compute_shader(struct si_context *sctx,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 4d08ab88f4a..71c85eb79a5 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5005,21 +5005,21 @@ static unsigned si_get_shader_binary_size(const struct 
si_shader *shader)
                size += shader->prolog->binary.code_size;
        if (shader->previous_stage)
                size += shader->previous_stage->binary.code_size;
        if (shader->prolog2)
                size += shader->prolog2->binary.code_size;
        if (shader->epilog)
                size += shader->epilog->binary.code_size;
        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;
        const struct ac_shader_binary *previous_stage =
                shader->previous_stage ? &shader->previous_stage->binary : NULL;
        const struct ac_shader_binary *prolog2 =
                shader->prolog2 ? &shader->prolog2->binary : NULL;
        const struct ac_shader_binary *epilog =
                shader->epilog ? &shader->epilog->binary : NULL;
        const struct ac_shader_binary *mainb = &shader->binary;
@@ -5035,21 +5035,21 @@ int si_shader_binary_upload(struct si_screen *sscreen, 
struct si_shader *shader)
        assert(!epilog || !epilog->rodata_size);
 
        si_resource_reference(&shader->bo, NULL);
        shader->bo = si_aligned_buffer_create(&sscreen->b,
                                              
sscreen->cpdma_prefetch_writes_memory ?
                                                0 : SI_RESOURCE_FLAG_READ_ONLY,
                                               PIPE_USAGE_IMMUTABLE,
                                               align(bo_size, 
SI_CPDMA_ALIGNMENT),
                                               256);
        if (!shader->bo)
-               return -ENOMEM;
+               return false;
 
        /* Upload. */
        ptr = sscreen->ws->buffer_map(shader->bo->buf, NULL,
                                        PIPE_TRANSFER_READ_WRITE |
                                        PIPE_TRANSFER_UNSYNCHRONIZED |
                                        RADEON_TRANSFER_TEMPORARY);
 
        /* Don't use util_memcpy_cpu_to_le32. LLVM binaries are
         * endian-independent. */
        if (prolog) {
@@ -5075,21 +5075,21 @@ int si_shader_binary_upload(struct si_screen *sscreen, 
struct si_shader *shader)
                memcpy(ptr, mainb->rodata, mainb->rodata_size);
                ptr += mainb->rodata_size;
        }
 
        /* Add end-of-code markers for the UMR disassembler. */
        uint32_t *ptr32 = (uint32_t*)ptr;
        for (unsigned i = 0; i < DEBUGGER_NUM_MARKERS; i++)
                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,
                                       struct pipe_debug_callback *debug,
                                       const char *name, FILE *file)
 {
        char *line, *p;
        unsigned i, count;
 
        if (binary->disasm_string) {
@@ -5405,21 +5405,21 @@ struct si_shader *
 si_generate_gs_copy_shader(struct si_screen *sscreen,
                           struct ac_llvm_compiler *compiler,
                           struct si_shader_selector *gs_selector,
                           struct pipe_debug_callback *debug)
 {
        struct si_shader_context ctx;
        struct si_shader *shader;
        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);
        if (!shader)
                return NULL;
 
        /* We can leave the fence as permanently signaled because the GS copy
         * shader only becomes visible globally after it has been compiled. */
        util_queue_fence_init(&shader->ready);
 
@@ -5557,36 +5557,36 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
                LLVMBuildBr(builder, end_bb);
        }
 
        LLVMPositionBuilderAtEnd(builder, end_bb);
 
        LLVMBuildRetVoid(ctx.ac.builder);
 
        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 {
                si_fix_resource_usage(sscreen, shader);
        }
        return shader;
 }
 
 static void si_dump_shader_key_vs(const struct si_shader_key *key,
                                  const struct si_vs_prolog_bits *prolog,
@@ -7899,22 +7899,21 @@ bool si_shader_create(struct si_screen *sscreen, struct 
ac_llvm_compiler *compil
                                                        
shader->epilog->config.num_vgprs);
                }
                si_calculate_max_simd_waves(shader);
        }
 
        si_fix_resource_usage(sscreen, shader);
        si_shader_dump(sscreen, shader, debug, sel->info.processor,
                       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;
        }
 
        return true;
 }
 
 void si_shader_destroy(struct si_shader *shader)
 {
        if (shader->scratch_bo)
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index 9a007a9c62c..26cfc432899 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -668,21 +668,21 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                           struct ac_llvm_compiler *compiler,
                           struct si_shader *shader,
                           struct pipe_debug_callback *debug);
 bool si_shader_create(struct si_screen *sscreen, struct ac_llvm_compiler 
*compiler,
                     struct si_shader *shader,
                     struct pipe_debug_callback *debug);
 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);
 void si_shader_dump_stats_for_shader_db(const struct si_shader *shader,
                                        struct pipe_debug_callback *debug);
 void si_multiwave_lds_size_workaround(struct si_screen *sscreen,
                                      unsigned *lds_size);
 void si_shader_apply_scratch_relocs(struct si_shader *shader,
                                    uint64_t scratch_va);
 const char *si_get_shader_name(const struct si_shader *shader, unsigned 
processor);
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index b419a6f5bf5..b8a587b50eb 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -3071,21 +3071,20 @@ static void si_shader_unlock(struct si_shader *shader)
 
 /**
  * @returns 1 if \p sel has been updated to use a new scratch buffer
  *          0 if not
  *          < 0 if there was a failure
  */
 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;
 
        /* This shader doesn't need a scratch buffer */
        if (shader->config.scratch_bytes_per_wave == 0)
                return 0;
 
        /* Prevent race conditions when updating:
         * - si_shader::scratch_bo
@@ -3102,24 +3101,23 @@ static int si_update_scratch_buffer(struct si_context 
*sctx,
        }
 
        assert(sctx->scratch_buffer);
 
        if (shader->previous_stage)
                si_shader_apply_scratch_relocs(shader->previous_stage, 
scratch_va);
 
        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. */
        si_shader_init_pm4_state(sctx->screen, shader);
 
        si_resource_reference(&shader->scratch_bo, sctx->scratch_buffer);
 
        si_shader_unlock(shader);
        return 1;
 }
-- 
2.20.1

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to