[Mesa-dev] [RFC PATCH 64/65] radeonsi: add support for loading bindless images

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri May 19 16:53:09 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 31 ++++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index c9397c2fb8..1447a552b9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -184,7 +184,10 @@ image_fetch_rsrc(
 	LLVMValueRef index;
 	bool dcc_off = is_store;
 
-	assert(image->Register.File == TGSI_FILE_IMAGE);
+	assert(image->Register.File == TGSI_FILE_IMAGE ||
+	       image->Register.File == TGSI_FILE_CONSTANT ||
+	       image->Register.File == TGSI_FILE_TEMPORARY ||
+	       image->Register.File == TGSI_FILE_INPUT);
 
 	if (!image->Register.Indirect) {
 		const struct tgsi_shader_info *info = bld_base->info;
@@ -214,6 +217,18 @@ image_fetch_rsrc(
 				     index, "");
 	}
 
+	if (image->Register.File != TGSI_FILE_IMAGE) {
+		struct gallivm_state *gallivm = &ctx->gallivm;
+		LLVMBuilderRef builder = gallivm->builder;
+
+		LLVMValueRef ptr =
+			lp_build_emit_fetch_src(bld_base, image,
+						TGSI_TYPE_UNSIGNED64, 0);
+		rsrc_ptr = LLVMBuildIntToPtr(builder, ptr,
+					     si_const_array(ctx->v8i32, 0), "");
+		index = LLVMConstInt(ctx->i32, 0, 0);
+	}
+
 	*rsrc = load_image_desc(ctx, rsrc_ptr, index, target);
 	if (dcc_off && target != TGSI_TEXTURE_BUFFER)
 		*rsrc = force_dcc_off(ctx, *rsrc);
@@ -373,7 +388,8 @@ static void load_fetch_args(
 
 		buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
 				   offset, false, false);
-	} else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+	} else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+		   inst->Memory.Bindless) {
 		LLVMValueRef coords;
 
 		image_fetch_rsrc(bld_base, &inst->Src[0], false, target, &rsrc);
@@ -538,8 +554,9 @@ static bool is_oneway_access_only(const struct tgsi_full_instruction *inst,
 	 * images.
 	 */
 	if (inst->Src[0].Register.File == TGSI_FILE_BUFFER ||
-	    (inst->Src[0].Register.File == TGSI_FILE_IMAGE &&
-	     inst->Memory.Texture == TGSI_TEXTURE_BUFFER)) {
+	    (inst->Memory.Texture == TGSI_TEXTURE_BUFFER &&
+	     (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+	      inst->Memory.Bindless))) {
 		if (!shader_buffers_reverse_access_mask &&
 		    !(info->images_buffers & images_reverse_access_mask))
 			return true;
@@ -640,7 +657,8 @@ static void store_fetch_args(
 
 		buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
 				   offset, false, false);
-	} else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE) {
+	} else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE ||
+		   inst->Memory.Bindless) {
 		unsigned target = inst->Memory.Texture;
 		LLVMValueRef coords;
 
@@ -859,7 +877,8 @@ static void atomic_fetch_args(
 
 		buffer_append_args(ctx, emit_data, rsrc, ctx->i32_0,
 				   offset, true, false);
-	} else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
+	} else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE ||
+		   inst->Memory.Bindless) {
 		unsigned target = inst->Memory.Texture;
 		LLVMValueRef coords;
 
-- 
2.13.0



More information about the mesa-dev mailing list