From ce7692fc1957145c83b59080baf9ec24aae71b4d Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 9 Jun 2020 12:23:04 +0200 Subject: [PATCH] radeonsi: add return value to gfx10_ngg_calculate_subgroup_info MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gfx10_ngg_calculate_subgroup_info uses assert to detect invalid configuration, but if asserts are disabled it will continue its execution. This commits adds a boolean return value to let the caller know that something went wrong and that the results mustn't be used. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3103 Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/gfx10_shader_ngg.c | 7 ++++++- src/gallium/drivers/radeonsi/si_shader.c | 5 ++++- src/gallium/drivers/radeonsi/si_shader_internal.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index 06eba4a1f61..62aa8b4fb66 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -1884,7 +1884,7 @@ static void clamp_gsprims_to_esverts(unsigned *max_gsprims, unsigned max_esverts * This happens before the shader is uploaded, since LDS relocations during * upload depend on the subgroup size. */ -void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader) +bool gfx10_ngg_calculate_subgroup_info(struct si_shader *shader) { const struct si_shader_selector *gs_sel = shader->selector; const struct si_shader_selector *es_sel = @@ -2047,4 +2047,9 @@ void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader) shader->ngg.ngg_emit_size = max_gsprims * gsprim_lds_size; assert(shader->ngg.hw_max_esverts >= 24); /* HW limitation */ + + /* If asserts are disabled, we use the same conditions to return false */ + return max_esverts >= max_verts_per_prim && max_gsprims >= 1 && + max_out_vertices <= 256 && + shader->ngg.hw_max_esverts >= 24; } diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 011abed49f3..cec837d6eba 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2502,7 +2502,10 @@ bool si_create_shader_variant(struct si_screen *sscreen, struct ac_llvm_compiler if (shader->key.as_ngg) { assert(!shader->key.as_es && !shader->key.as_ls); - gfx10_ngg_calculate_subgroup_info(shader); + if (!gfx10_ngg_calculate_subgroup_info(shader)) { + fprintf(stderr, "Failed to compute subgroup info\n"); + return false; + } } else if (sscreen->info.chip_class >= GFX9 && sel->type == PIPE_SHADER_GEOMETRY) { gfx9_get_gs_info(shader->previous_stage_sel, sel, &shader->gs_info); } diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 2aba488b35b..f5d6d629f35 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -219,7 +219,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, LL void gfx10_ngg_gs_emit_vertex(struct si_shader_context *ctx, unsigned stream, LLVMValueRef *addrs); void gfx10_ngg_gs_emit_prologue(struct si_shader_context *ctx); void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx); -void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader); +bool gfx10_ngg_calculate_subgroup_info(struct si_shader *shader); /* si_shader_llvm.c */ bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary, -- 2.30.2