radv/ac: setup lds for tessellation
authorDave Airlie <airlied@redhat.com>
Thu, 30 Mar 2017 19:15:23 +0000 (20:15 +0100)
committerDave Airlie <airlied@redhat.com>
Fri, 31 Mar 2017 21:17:15 +0000 (07:17 +1000)
This seems to get lost in the rebases, should fix
the tessellation demos, crash in llvm.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index c29fb95f36483065d91561ba6fb96d3e3cb03833..520e4cf1dc56e2a75c80e361493900eef7f88dff 100644 (file)
@@ -548,6 +548,14 @@ static void set_userdata_location_indirect(struct ac_userdata_info *ud_info, uin
 }
 #endif
 
+static void declare_tess_lds(struct nir_to_llvm_context *ctx)
+{
+       unsigned lds_size = ctx->options->chip_class >= CIK ? 65536 : 32768;
+       ctx->lds = LLVMBuildIntToPtr(ctx->builder, ctx->i32zero,
+                                    LLVMPointerType(LLVMArrayType(ctx->i32, lds_size / 4), LOCAL_ADDR_SPACE),
+               "tess_lds");
+}
+
 static void create_function(struct nir_to_llvm_context *ctx)
 {
        LLVMTypeRef arg_types[23];
@@ -785,6 +793,8 @@ static void create_function(struct nir_to_llvm_context *ctx)
                        ctx->vs_prim_id = LLVMGetParam(ctx->main_function, arg_idx++);
                        ctx->instance_id = LLVMGetParam(ctx->main_function, arg_idx++);
                }
+               if (ctx->options->key.vs.as_ls)
+                       declare_tess_lds(ctx);
                break;
        case MESA_SHADER_TESS_CTRL:
                set_userdata_location_shader(ctx, AC_UD_TCS_OFFCHIP_LAYOUT, user_sgpr_idx, 4);
@@ -797,6 +807,8 @@ static void create_function(struct nir_to_llvm_context *ctx)
                ctx->tess_factor_offset = LLVMGetParam(ctx->main_function, arg_idx++);
                ctx->tcs_patch_id = LLVMGetParam(ctx->main_function, arg_idx++);
                ctx->tcs_rel_ids = LLVMGetParam(ctx->main_function, arg_idx++);
+
+               declare_tess_lds(ctx);
                break;
        case MESA_SHADER_TESS_EVAL:
                set_userdata_location_shader(ctx, AC_UD_TES_OFFCHIP_LAYOUT, user_sgpr_idx, 1);