From: Samuel Pitoiset Date: Fri, 9 Feb 2018 12:54:23 +0000 (+0100) Subject: ac: add load_resource() to the ABI X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ed179fbdf37192cba5f3ff1c335d8ac09323ea81;p=mesa.git ac: add load_resource() to the ABI Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 406f55d8c40..f99c9d3d692 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2351,12 +2351,11 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, return ac_build_image_opcode(&ctx->ac, args); } -static LLVMValueRef visit_vulkan_resource_index(struct nir_to_llvm_context *ctx, - nir_intrinsic_instr *instr) +static LLVMValueRef +radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index, + unsigned desc_set, unsigned binding) { - LLVMValueRef index = get_src(ctx->nir, instr->src[0]); - unsigned desc_set = nir_intrinsic_desc_set(instr); - unsigned binding = nir_intrinsic_binding(instr); + struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi); LLVMValueRef desc_ptr = ctx->descriptor_sets[desc_set]; struct radv_pipeline_layout *pipeline_layout = ctx->options->layout; struct radv_descriptor_set_layout *layout = pipeline_layout->set[desc_set].layout; @@ -4386,9 +4385,15 @@ static void visit_intrinsic(struct ac_nir_context *ctx, case nir_intrinsic_load_push_constant: result = visit_load_push_constant(ctx->nctx, instr); break; - case nir_intrinsic_vulkan_resource_index: - result = visit_vulkan_resource_index(ctx->nctx, instr); + case nir_intrinsic_vulkan_resource_index: { + LLVMValueRef index = get_src(ctx, instr->src[0]); + unsigned desc_set = nir_intrinsic_desc_set(instr); + unsigned binding = nir_intrinsic_binding(instr); + + result = ctx->abi->load_resource(ctx->abi, index, desc_set, + binding); break; + } case nir_intrinsic_vulkan_resource_reindex: result = visit_vulkan_resource_reindex(ctx->nctx, instr); break; @@ -6781,6 +6786,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, ctx.abi.load_ubo = radv_load_ubo; ctx.abi.load_ssbo = radv_load_ssbo; ctx.abi.load_sampler_desc = radv_get_sampler_desc; + ctx.abi.load_resource = radv_load_resource; ctx.abi.clamp_shadow_reference = false; if (shader_count >= 2) diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h index c5f7fcd2f87..c89987c35f8 100644 --- a/src/amd/common/ac_shader_abi.h +++ b/src/amd/common/ac_shader_abi.h @@ -156,6 +156,18 @@ struct ac_shader_abi { enum ac_descriptor_type desc_type, bool image, bool write); + /** + * Load a Vulkan-specific resource. + * + * \param index resource index + * \param desc_set descriptor set + * \param binding descriptor set binding + */ + LLVMValueRef (*load_resource)(struct ac_shader_abi *abi, + LLVMValueRef index, + unsigned desc_set, + unsigned binding); + LLVMValueRef (*lookup_interp_param)(struct ac_shader_abi *abi, enum glsl_interp_mode interp, unsigned location);