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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5401>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2020-06-09 12:23:04 +02:00
parent 2c711beb5c
commit ce7692fc19
3 changed files with 11 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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,