[Mesa-dev] [PATCH v2 4/9] radeonsi: only touch first three coordinates in si_prepare_cube_coords

Nicolai Hähnle nhaehnle at gmail.com
Thu Jan 12 15:39:30 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Sourcing coords_arg[4] is actually never correct, since bias is handled
differently in tex_fetch_args anyway.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
index c410a8b..11bd45d 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
@@ -1020,21 +1020,21 @@ void si_prepare_cube_coords(struct lp_build_tgsi_context *bld_base,
 			    LLVMValueRef *coords_arg,
 			    LLVMValueRef *derivs_arg)
 {
 
 	unsigned target = emit_data->inst->Texture.Texture;
 	unsigned opcode = emit_data->inst->Instruction.Opcode;
 	struct gallivm_state *gallivm = bld_base->base.gallivm;
 	LLVMBuilderRef builder = gallivm->builder;
 	LLVMTypeRef type = bld_base->base.elem_type;
 	struct cube_selection_coords selcoords;
-	LLVMValueRef coords[4];
+	LLVMValueRef coords[3];
 	LLVMValueRef invma;
 
 	build_cube_intrinsic(gallivm, coords_arg, &selcoords);
 
 	invma = lp_build_intrinsic(builder, "llvm.fabs.f32",
 			type, &selcoords.ma, 1, LP_FUNC_ATTR_READNONE);
 	invma = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_RCP, invma);
 
 	for (int i = 0; i < 2; ++i)
 		coords[i] = LLVMBuildFMul(builder, selcoords.stc[i], invma, "");
@@ -1093,23 +1093,12 @@ void si_prepare_cube_coords(struct lp_build_tgsi_context *bld_base,
 		coords[i] = LLVMBuildFAdd(builder, coords[i], LLVMConstReal(type, 1.5), "");
 
 	if (target == TGSI_TEXTURE_CUBE_ARRAY ||
 	    target == TGSI_TEXTURE_SHADOWCUBE_ARRAY) {
 		/* for cube arrays coord.z = coord.w(array_index) * 8 + face */
 		/* coords_arg.w component - array_index for cube arrays */
 		coords[2] = lp_build_emit_llvm_ternary(bld_base, TGSI_OPCODE_MAD,
 						       coords_arg[3], lp_build_const_float(gallivm, 8.0), coords[2]);
 	}
 
-	/* Preserve compare/lod/bias. Put it in coords.w. */
-	if (opcode == TGSI_OPCODE_TEX2 ||
-	    opcode == TGSI_OPCODE_TXB2 ||
-	    opcode == TGSI_OPCODE_TXL2) {
-		coords[3] = coords_arg[4];
-	} else if (opcode == TGSI_OPCODE_TXB ||
-		   opcode == TGSI_OPCODE_TXL ||
-		   target == TGSI_TEXTURE_SHADOWCUBE) {
-		coords[3] = coords_arg[3];
-	}
-
 	memcpy(coords_arg, coords, sizeof(coords));
 }
-- 
2.7.4



More information about the mesa-dev mailing list