From: Nicolai Hähnle Date: Thu, 17 May 2018 16:17:07 +0000 (+0200) Subject: radeonsi: return bool from si_shader_binary_upload X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf11c594ddc230addcf9eccdcd04c50ffb3d9692;p=mesa.git radeonsi: return bool from si_shader_binary_upload We didn't really use error codes anyway. Reviewed-by: Marek Olšák --- diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 006fb89a200..4a7ebac9ab7 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -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, diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 17323fa69ec..21b2819c857 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -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; } diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 470a73359bd..145a03bd1ae 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index db939b73b0a..77d1c014305 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -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. */