[Mesa-dev] [PATCH 2/3] radeon/llvm: fix radeon_llvm_emit_prepare_cube_coords

Vadim Girlin vadimgirlin at gmail.com
Sat Dec 15 11:29:39 PST 2012


---
 src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index db25c89..e1670ce 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -519,23 +519,20 @@ void radeon_llvm_emit_prepare_cube_coords(
 		LLVMValueRef *arg,
                 unsigned target)
 {
-	boolean shadowcube = (target == TGSI_TEXTURE_SHADOWCUBE);
 	struct gallivm_state * gallivm = bld_base->base.gallivm;
 	LLVMBuilderRef builder = gallivm->builder;
 	LLVMTypeRef type = bld_base->base.elem_type;
 	LLVMValueRef coords[4];
 	LLVMValueRef mad_args[3];
-	unsigned i, cnt;
+	LLVMValueRef idx;
+	unsigned i;
 
 	LLVMValueRef v = build_intrinsic(builder, "llvm.AMDGPU.cube",
 			LLVMVectorType(type, 4),
 			arg, 1, LLVMReadNoneAttribute);
 
-	/* save src.w for shadow cube */
-	cnt = shadowcube ? 3 : 4;
-
-	for (i = 0; i < cnt; ++i) {
-		LLVMValueRef idx = lp_build_const_int32(gallivm, i);
+	for (i = 0; i < 4; ++i) {
+		idx = lp_build_const_int32(gallivm, i);
 		coords[i] = LLVMBuildExtractElement(builder, v, idx, "");
 	}
 
@@ -554,12 +551,16 @@ void radeon_llvm_emit_prepare_cube_coords(
 	coords[1] = lp_build_emit_llvm_ternary(bld_base, TGSI_OPCODE_MAD,
 			mad_args[0], mad_args[1], mad_args[2]);
 
-	/* apply yxwy swizzle to cooords */
+	/* apply xyz = yxw swizzle to cooords */
 	coords[2] = coords[3];
 	coords[3] = coords[1];
 	coords[1] = coords[0];
 	coords[0] = coords[3];
 
+	/* use original w component */
+	idx = lp_build_const_int32(gallivm, 3);
+	coords[3] = LLVMBuildExtractElement(builder, *arg, idx, "");
+
 	*arg = lp_build_gather_values(bld_base->base.gallivm, coords, 4);
 }
 
-- 
1.8.0.2



More information about the mesa-dev mailing list