radv/gfx10: declare an external symbol for the ESGS ring
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Jul 2019 22:29:50 +0000 (00:29 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 15 Jul 2019 09:30:08 +0000 (11:30 +0200)
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 <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c

index 00c7df8574b7bae536bdf937fa6529fb328b4ebc..a5551203d290fd9da47abf3e123ec127da1b236c 100644 (file)
@@ -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);