radeonsi: use an explicit symbol for the LSHS LDS memory
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 4 May 2019 10:34:52 +0000 (12:34 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 13 Jun 2019 00:28:23 +0000 (20:28 -0400)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_state_draw.c

index a2fec10..3617214 100644 (file)
@@ -4925,8 +4925,21 @@ static void create_function(struct si_shader_context *ctx)
        assert(shader->info.num_input_vgprs >= num_prolog_vgprs);
        shader->info.num_input_vgprs -= num_prolog_vgprs;
 
-       if (shader->key.as_ls || ctx->type == PIPE_SHADER_TESS_CTRL)
-               ac_declare_lds_as_pointer(&ctx->ac);
+       if (shader->key.as_ls || ctx->type == PIPE_SHADER_TESS_CTRL) {
+               if (USE_LDS_SYMBOLS && HAVE_LLVM >= 0x0900) {
+                       /* The LSHS size is not known until draw time, so we append it
+                        * at the end of whatever LDS use there may be in the rest of
+                        * the shader (currently none, unless LLVM decides to do its
+                        * own LDS-based lowering).
+                        */
+                       ctx->ac.lds = LLVMAddGlobalInAddressSpace(
+                               ctx->ac.module, LLVMArrayType(ctx->i32, 0),
+                               "__lds_end", AC_ADDR_SPACE_LDS);
+                       LLVMSetAlignment(ctx->ac.lds, 256);
+               } else {
+                       ac_declare_lds_as_pointer(&ctx->ac);
+               }
+       }
 }
 
 /**
index b8a4a52..d780547 100644 (file)
@@ -252,6 +252,11 @@ static void si_emit_derived_tess_state(struct si_context *sctx,
                                  C_VS_STATE_LS_OUT_VERTEX_SIZE;
        sctx->current_vs_state |= tcs_in_layout;
 
+       /* We should be able to support in-shader LDS use with LLVM >= 9
+        * by just adding the lds_sizes together, but it has never
+        * been tested. */
+       assert(ls_current->config.lds_size == 0);
+
        if (sctx->chip_class >= GFX9) {
                unsigned hs_rsrc2 = ls_current->config.rsrc2 |
                                    S_00B42C_LDS_SIZE(lds_size);