From: Samuel Pitoiset Date: Wed, 10 Jul 2019 22:29:50 +0000 (+0200) Subject: radv/gfx10: declare an external symbol for the ESGS ring X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8175f6269b2542a2cd8f48dc9346add8f15c55ea;p=mesa.git radv/gfx10: declare an external symbol for the ESGS ring It will be used for stream output but for now only declares it if VS and if the PrimitiveID needs to be exported. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 00c7df8574b..a5551203d29 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -4229,6 +4229,25 @@ static void prepare_gs_input_vgprs(struct radv_shader_context *ctx) ctx->gs_wave_id = ac_unpack_param(&ctx->ac, ctx->merged_wave_info, 16, 8); } +/* Ensure that the esgs ring is declared. + * + * We declare it with 64KB alignment as a hint that the + * pointer value will always be 0. + */ +static void declare_esgs_ring(struct radv_shader_context *ctx) +{ + if (ctx->esgs_ring) + return; + + assert(!LLVMGetNamedGlobal(ctx->ac.module, "esgs_ring")); + + ctx->esgs_ring = LLVMAddGlobalInAddressSpace( + ctx->ac.module, LLVMArrayType(ctx->ac.i32, 0), + "esgs_ring", + AC_ADDR_SPACE_LDS); + LLVMSetLinkage(ctx->esgs_ring, LLVMExternalLinkage); + LLVMSetAlignment(ctx->esgs_ring, 64 * 1024); +} static LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm, @@ -4368,6 +4387,12 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm, ctx.abi.emit_kill = radv_emit_kill; } + if (shaders[i]->info.stage == MESA_SHADER_VERTEX && + ctx.options->key.vs_common_out.as_ngg && + ctx.options->key.vs_common_out.export_prim_id) { + declare_esgs_ring(&ctx); + } + if (i) ac_emit_barrier(&ctx.ac, ctx.stage);