Mesa (master): radeon/llvm: fix shadow cube texturing for GL3.0

Marek Olšák mareko at kemper.freedesktop.org
Wed Sep 25 18:50:34 UTC 2013


Module: Mesa
Branch: master
Commit: 028b26e2efa7485fb7a5dd9be681074a36f9e442
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=028b26e2efa7485fb7a5dd9be681074a36f9e442

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Sep 24 19:28:27 2013 +0200

radeon/llvm: fix shadow cube texturing for GL3.0

The fix is at the end (TGSI_TEXTURE_SHADOWCUBE handling), but I also
restructured the code for it to be more readable.

Fixes spec/!OpenGL 3.0/sampler-cube-shadow.

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>

---

 .../drivers/radeon/radeon_setup_tgsi_llvm.c        |   38 ++++++++------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 8ff9abd..dfc7a3f 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -633,31 +633,23 @@ void radeon_llvm_emit_prepare_cube_coords(
 	coords[1] = coords[0];
 	coords[0] = coords[3];
 
-	/* all cases except simple cube map sampling require special handling
-	 * for coord vector */
-	if (target != TGSI_TEXTURE_CUBE ||
-		opcode != TGSI_OPCODE_TEX) {
-
+	if (target == TGSI_TEXTURE_CUBE_ARRAY ||
+	    target == TGSI_TEXTURE_SHADOWCUBE_ARRAY) {
 		/* for cube arrays coord.z = coord.w(array_index) * 8 + face */
-		if (target == TGSI_TEXTURE_CUBE_ARRAY ||
-			target == TGSI_TEXTURE_SHADOWCUBE_ARRAY) {
-
-			/* coords_arg.w component - array_index for cube arrays or
-			 * compare value for SHADOWCUBE */
-			coords[2] = lp_build_emit_llvm_ternary(bld_base, TGSI_OPCODE_MAD,
-					coords_arg[3], lp_build_const_float(gallivm, 8.0), coords[2]);
-		}
+		/* 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]);
+	}
 
-		/* for instructions that need additional src (compare/lod/bias),
-		 * put it in coord.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) {
-			coords[3] = coords_arg[3];
-		}
+	/* 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));




More information about the mesa-commit mailing list