radv: tidy up ac_setup_rings() for the GSVS rings
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 13 Sep 2018 13:58:02 +0000 (15:58 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 14 Sep 2018 08:59:52 +0000 (10:59 +0200)
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 a6dbcd2a8b14e16082f8603a0e84fb161fa1f30e..838e026c8e9984fe314e2575271fa49f3a463234 100644 (file)
@@ -3135,21 +3135,42 @@ ac_setup_rings(struct radv_shader_context *ctx)
        }
 
        if (ctx->is_gs_copy_shader) {
-               ctx->gsvs_ring = ac_build_load_to_sgpr(&ctx->ac, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_GSVS_VS, false));
+               ctx->gsvs_ring =
+                       ac_build_load_to_sgpr(&ctx->ac, ctx->ring_offsets,
+                                             LLVMConstInt(ctx->ac.i32,
+                                                          RING_GSVS_VS, false));
        }
+
        if (ctx->stage == MESA_SHADER_GEOMETRY) {
-               LLVMValueRef tmp;
-               uint32_t num_entries = 64;
-               LLVMValueRef gsvs_ring_desc = LLVMConstInt(ctx->ac.i32, ctx->max_gsvs_emit_size << 16, false);
-               ctx->gsvs_ring = ac_build_load_to_sgpr(&ctx->ac, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_GSVS_GS, false));
-
-               ctx->gsvs_ring = LLVMBuildBitCast(ctx->ac.builder, ctx->gsvs_ring, ctx->ac.v4i32, "");
-
-               tmp = LLVMConstInt(ctx->ac.i32, num_entries, false);
-               ctx->gsvs_ring = LLVMBuildInsertElement(ctx->ac.builder, ctx->gsvs_ring, tmp, LLVMConstInt(ctx->ac.i32, 2, false), "");
-               tmp = LLVMBuildExtractElement(ctx->ac.builder, ctx->gsvs_ring, ctx->ac.i32_1, "");
-               tmp = LLVMBuildOr(ctx->ac.builder, tmp, gsvs_ring_desc, "");
-               ctx->gsvs_ring = LLVMBuildInsertElement(ctx->ac.builder, ctx->gsvs_ring, tmp, ctx->ac.i32_1, "");
+               unsigned num_records = 64;
+               LLVMValueRef base_ring;
+               LLVMValueRef ring, tmp;
+               unsigned stride;
+
+               base_ring =
+                       ac_build_load_to_sgpr(&ctx->ac, ctx->ring_offsets,
+                                             LLVMConstInt(ctx->ac.i32,
+                                                          RING_GSVS_GS, false));
+
+               stride = ctx->max_gsvs_emit_size;
+
+               ring = LLVMBuildBitCast(ctx->ac.builder, base_ring,
+                                       ctx->ac.v4i32, "");
+
+               tmp = LLVMBuildExtractElement(ctx->ac.builder, ring,
+                                             ctx->ac.i32_1, "");
+               tmp = LLVMBuildOr(ctx->ac.builder, tmp,
+                                 LLVMConstInt(ctx->ac.i32,
+                                              S_008F04_STRIDE(stride), false), "");
+               ring = LLVMBuildInsertElement(ctx->ac.builder, ring, tmp,
+                                             ctx->ac.i32_1, "");
+
+               ring = LLVMBuildInsertElement(ctx->ac.builder, ring,
+                                             LLVMConstInt(ctx->ac.i32,
+                                                          num_records, false),
+                                             LLVMConstInt(ctx->ac.i32, 2, false), "");
+
+               ctx->gsvs_ring = ring;
        }
 
        if (ctx->stage == MESA_SHADER_TESS_CTRL ||