[Mesa-dev] [PATCH 1/2] ac/radeonsi: pass type to load_tess_varyings()

Timothy Arceri tarceri at itsqueeze.com
Tue Feb 20 23:42:36 UTC 2018


We need this to be able to load 64bit varyings.
---
 src/amd/common/ac_nir_to_llvm.c                   | 15 +++++++++++++--
 src/amd/common/ac_shader_abi.h                    |  1 +
 src/gallium/drivers/radeonsi/si_shader.c          |  2 ++
 src/gallium/drivers/radeonsi/si_shader_internal.h |  1 +
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 9f55be0d45..50f3a4f69e 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2888,6 +2888,7 @@ get_dw_address(struct radv_shader_context *ctx,
 
 static LLVMValueRef
 load_tcs_varyings(struct ac_shader_abi *abi,
+		  LLVMTypeRef type,
 		  LLVMValueRef vertex_index,
 		  LLVMValueRef indir_index,
 		  unsigned const_index,
@@ -3011,6 +3012,7 @@ store_tcs_output(struct ac_shader_abi *abi,
 
 static LLVMValueRef
 load_tes_input(struct ac_shader_abi *abi,
+	       LLVMTypeRef type,
 	       LLVMValueRef vertex_index,
 	       LLVMValueRef param_index,
 	       unsigned const_index,
@@ -3149,12 +3151,21 @@ static LLVMValueRef load_tess_varyings(struct ac_nir_context *ctx,
 			 false, NULL, is_patch ? NULL : &vertex_index,
 			 &const_index, &indir_index);
 
-	result = ctx->abi->load_tess_varyings(ctx->abi, vertex_index, indir_index,
+	LLVMTypeRef dest_type = get_def_type(ctx, &instr->dest.ssa);
+
+	LLVMTypeRef src_component_type;
+	if (LLVMGetTypeKind(dest_type) == LLVMVectorTypeKind)
+		src_component_type = LLVMGetElementType(dest_type);
+	else
+		src_component_type = dest_type;
+
+	result = ctx->abi->load_tess_varyings(ctx->abi, src_component_type,
+					      vertex_index, indir_index,
 					      const_index, location, driver_location,
 					      instr->variables[0]->var->data.location_frac,
 					      instr->num_components,
 					      is_patch, is_compact, load_inputs);
-	return LLVMBuildBitCast(ctx->ac.builder, result, get_def_type(ctx, &instr->dest.ssa), "");
+	return LLVMBuildBitCast(ctx->ac.builder, result, dest_type, "");
 }
 
 static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index de3034e32f..75fd8ed554 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -96,6 +96,7 @@ struct ac_shader_abi {
 				    LLVMTypeRef type);
 
 	LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi,
+					   LLVMTypeRef type,
 					   LLVMValueRef vertex_index,
 					   LLVMValueRef param_index,
 					   unsigned const_index,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index ec03f537d0..33319b249c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1215,6 +1215,7 @@ static LLVMValueRef fetch_input_tcs(
 }
 
 static LLVMValueRef si_nir_load_tcs_varyings(struct ac_shader_abi *abi,
+					     LLVMTypeRef type,
 					     LLVMValueRef vertex_index,
 					     LLVMValueRef param_index,
 					     unsigned const_index,
@@ -1316,6 +1317,7 @@ static LLVMValueRef fetch_input_tes(
 }
 
 LLVMValueRef si_nir_load_input_tes(struct ac_shader_abi *abi,
+				   LLVMTypeRef type,
 				   LLVMValueRef vertex_index,
 				   LLVMValueRef param_index,
 				   unsigned const_index,
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 571df55977..42a1b9f107 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -268,6 +268,7 @@ LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
 				unsigned swizzle);
 
 LLVMValueRef si_nir_load_input_tes(struct ac_shader_abi *abi,
+				   LLVMTypeRef type,
 				   LLVMValueRef vertex_index,
 				   LLVMValueRef param_index,
 				   unsigned const_index,
-- 
2.14.3



More information about the mesa-dev mailing list