[Mesa-dev] [PATCH 06/18] ac: add load_resource() to the ABI

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Feb 9 12:54:23 UTC 2018


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/common/ac_nir_to_llvm.c | 20 +++++++++++++-------
 src/amd/common/ac_shader_abi.h  | 12 ++++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index b5390ce083..5bd5171438 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2350,12 +2350,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;
@@ -4385,9 +4384,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;
@@ -6780,6 +6785,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 c5f7fcd2f8..c89987c35f 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);
-- 
2.16.1



More information about the mesa-dev mailing list