Mesa (master): ir_to_mesa: Handle shadow compare w/ projection and LOD bias correctly

Ian Romanick idr at kemper.freedesktop.org
Tue Apr 5 18:22:47 UTC 2011


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Mon Apr  4 13:35:26 2011 -0700

ir_to_mesa: Handle shadow compare w/projection and LOD bias correctly

The code would previously handle the projection, then swizzle the
shadow comparitor into place.  However, when the projection is done
"by hand," as in the TXB case, the unprojected shadow comparitor would
over-write the projected shadow comparitor.

Shadow comparison with projection and LOD is an extremely rare case in
real application code, so it shouldn't matter that we don't handle
that case with the greatest efficiency.

NOTE: This is a candidate for the stable branches.

Reviewed-by: Brian Paul <brianp at vmware.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=32395

---

 src/mesa/program/ir_to_mesa.cpp |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index bf2513d..7c1ae46 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2084,15 +2084,39 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
 	 coord_dst.writemask = WRITEMASK_W;
 	 ir_to_mesa_emit_op1(ir, OPCODE_RCP, coord_dst, projector);
 
+	 /* In the case where we have to project the coordinates "by hand,"
+	  * the shadow comparitor value must also be projected.
+	  */
+	 ir_to_mesa_src_reg tmp_src = coord;
+	 if (ir->shadow_comparitor) {
+	    /* Slot the shadow value in as the second to last component of the
+	     * coord.
+	     */
+	    ir->shadow_comparitor->accept(this);
+
+	    tmp_src = get_temp(glsl_type::vec4_type);
+	    ir_to_mesa_dst_reg tmp_dst = ir_to_mesa_dst_reg_from_src(tmp_src);
+
+	    tmp_dst.writemask = WRITEMASK_Z;
+	    ir_to_mesa_emit_op1(ir, OPCODE_MOV, tmp_dst, this->result);
+
+	    tmp_dst.writemask = WRITEMASK_XY;
+	    ir_to_mesa_emit_op1(ir, OPCODE_MOV, tmp_dst, coord);
+	 }
+
 	 coord_dst.writemask = WRITEMASK_XYZ;
-	 ir_to_mesa_emit_op2(ir, OPCODE_MUL, coord_dst, coord, coord_w);
+	 ir_to_mesa_emit_op2(ir, OPCODE_MUL, coord_dst, tmp_src, coord_w);
 
 	 coord_dst.writemask = WRITEMASK_XYZW;
 	 coord.swizzle = SWIZZLE_XYZW;
       }
    }
 
-   if (ir->shadow_comparitor) {
+   /* If projection is done and the opcode is not OPCODE_TXP, then the shadow
+    * comparitor was put in the correct place (and projected) by the code,
+    * above, that handles by-hand projection.
+    */
+   if (ir->shadow_comparitor && (!ir->projector || opcode == OPCODE_TXP)) {
       /* Slot the shadow value in as the second to last component of the
        * coord.
        */




More information about the mesa-commit mailing list