diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2020-06-09 12:23:04 +0200 |
---|---|---|
committer | Pierre-Eric Pelloux-Prayer <[email protected]> | 2020-06-10 09:33:48 +0200 |
commit | ce7692fc1957145c83b59080baf9ec24aae71b4d (patch) | |
tree | 60a7c4bc6204e89817b1009a172a4847a68999e9 /src | |
parent | 2c711beb5ce9fe013d557be71eb986444415b758 (diff) |
radeonsi: add return value to gfx10_ngg_calculate_subgroup_info
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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5401>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/gfx10_shader_ngg.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 5 | ||||
-rw-r--r-- | 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, |