diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-24 22:57:33 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-26 15:37:09 +0200 |
commit | 5c2eadbbe485edde3c8d845538f824aa6055a352 (patch) | |
tree | ddba8279a175e4420acc956b5499d612cff8167b | |
parent | 5915289ff2cbece9d507fbe9236977537d443148 (diff) |
ac/nir: pass ac_nir_context to emit_ddxy
Allocating the ddxy_lds is considered to be part of the API shader
translation and not part of the ABI.
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 7fc07704b5..6e72bbcc3c 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -67,6 +67,8 @@ struct ac_nir_context { int num_locals; LLVMValueRef *locals; + LLVMValueRef ddxy_lds; + struct nir_to_llvm_context *nctx; /* TODO get rid of this */ }; @@ -169,8 +171,6 @@ struct nir_to_llvm_context { uint8_t num_output_clips; uint8_t num_output_culls; - bool has_ds_bpermute; - bool is_gs_copy_shader; LLVMValueRef gs_next_vertex; unsigned gs_max_out_vertices; @@ -1468,17 +1468,18 @@ static LLVMValueRef emit_unpack_half_2x16(struct ac_llvm_context *ctx, return result; } -static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx, +static LLVMValueRef emit_ddxy(struct ac_nir_context *ctx, nir_op op, LLVMValueRef src0) { unsigned mask; int idx; LLVMValueRef result; + bool has_ds_bpermute = ctx->abi->chip_class >= VI; - if (!ctx->lds && !ctx->has_ds_bpermute) - ctx->lds = LLVMAddGlobalInAddressSpace(ctx->module, - LLVMArrayType(ctx->i32, 64), + if (!ctx->ddxy_lds && !has_ds_bpermute) + ctx->ddxy_lds = LLVMAddGlobalInAddressSpace(ctx->ac.module, + LLVMArrayType(ctx->ac.i32, 64), "ddxy_lds", LOCAL_ADDR_SPACE); if (op == nir_op_fddx_fine || op == nir_op_fddx) @@ -1496,8 +1497,8 @@ static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx, else idx = 2; - result = ac_build_ddxy(&ctx->ac, ctx->has_ds_bpermute, - mask, idx, ctx->lds, + result = ac_build_ddxy(&ctx->ac, has_ds_bpermute, + mask, idx, ctx->ddxy_lds, src0); return result; } @@ -1508,15 +1509,15 @@ static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx, * it returns DDX(I), DDX(J), DDY(I), DDY(J). */ static LLVMValueRef emit_ddxy_interp( - struct nir_to_llvm_context *ctx, + struct ac_nir_context *ctx, LLVMValueRef interp_ij) { LLVMValueRef result[4], a; unsigned i; for (i = 0; i < 2; i++) { - a = LLVMBuildExtractElement(ctx->builder, interp_ij, - LLVMConstInt(ctx->i32, i, false), ""); + a = LLVMBuildExtractElement(ctx->ac.builder, interp_ij, + LLVMConstInt(ctx->ac.i32, i, false), ""); result[i] = emit_ddxy(ctx, nir_op_fddx, a); result[2+i] = emit_ddxy(ctx, nir_op_fddy, a); } @@ -1880,7 +1881,7 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) case nir_op_fddy_fine: case nir_op_fddx_coarse: case nir_op_fddy_coarse: - result = emit_ddxy(ctx->nctx, instr->op, src[0]); + result = emit_ddxy(ctx, instr->op, src[0]); break; default: fprintf(stderr, "Unknown NIR alu instr: "); @@ -3738,7 +3739,7 @@ static LLVMValueRef visit_interp(struct nir_to_llvm_context *ctx, if (location == INTERP_SAMPLE || location == INTERP_CENTER) { LLVMValueRef ij_out[2]; - LLVMValueRef ddxy_out = emit_ddxy_interp(ctx, interp_param); + LLVMValueRef ddxy_out = emit_ddxy_interp(ctx->nir, interp_param); /* * take the I then J parameters, and the DDX/Y for it, and @@ -6048,8 +6049,6 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, ac_llvm_context_init(&ctx.ac, ctx.context); ctx.ac.module = ctx.module; - ctx.has_ds_bpermute = ctx.options->chip_class >= VI; - memset(shader_info, 0, sizeof(*shader_info)); ac_nir_shader_info_pass(nir, options, &shader_info->info); |