From: Bas Nieuwenhuizen Date: Sun, 7 Jul 2019 23:19:55 +0000 (+0200) Subject: radv/gfx10: Move NGG output handling outside of giant if-statement. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d118ad44a46cf3f9c2acee20849951692bb562d;p=mesa.git radv/gfx10: Move NGG output handling outside of giant if-statement. In merged shaders we put a big if around each shader, so both stages can have a different number of threads. However, the NGG output code still needs to run if the first shader is not executed. This can happen when there are more gs threads than vs/es threads, or when there are 0 es/vs threads (why? no clue). Fixes: ee21bd7440c "radv/gfx10: implement NGG support (VS only)" Reviewed-by: Dave Airlie --- diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 51414be2304..fb6b4bef584 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -3647,10 +3647,10 @@ handle_shader_outputs_post(struct ac_shader_abi *abi, unsigned max_outputs, case MESA_SHADER_VERTEX: if (ctx->options->key.vs.out.as_ls) handle_ls_outputs_post(ctx); + else if (ctx->options->key.vs.out.as_ngg) + break; /* handled outside of the shader body */ else if (ctx->options->key.vs.out.as_es) handle_es_outputs_post(ctx, &ctx->shader_info->vs.es_info); - else if (ctx->options->key.vs.out.as_ngg) - handle_ngg_outputs_post(ctx); else handle_vs_outputs_post(ctx, ctx->options->key.vs.out.export_prim_id, ctx->options->key.vs.out.export_layer_id, @@ -4023,6 +4023,14 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm, LLVMPositionBuilderAtEnd(ctx.ac.builder, merge_block); } + /* This needs to be outside the if wrapping the shader body, as sometimes + * the HW generates waves with 0 es/vs threads. */ + if (is_pre_gs_stage(shaders[i]->info.stage) && + ctx.options->key.vs.out.as_ngg && + i == shader_count - 1) { + handle_ngg_outputs_post(&ctx); + } + if (shaders[i]->info.stage == MESA_SHADER_GEOMETRY) { shader_info->gs.gsvs_vertex_size = ctx.gsvs_vertex_size; shader_info->gs.max_gsvs_emit_size = ctx.max_gsvs_emit_size;