llvmpipe: Obey back writemask.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 30 Oct 2012 19:45:25 +0000 (19:45 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 31 Oct 2012 16:50:40 +0000 (16:50 +0000)
Tested with a modified glean tstencil2 test.

NOTE: This is a candidate for stable branches.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_bld_depth.c

index 8efa75c01d3b88f489c1759f0ce3c514f34a626b..5c3715aa8fbe968b26d77797128498913c45095c 100644 (file)
@@ -273,11 +273,17 @@ lp_build_stencil_op(struct lp_build_context *bld,
       res = lp_build_select(bld, front_facing, res, back_res);
    }
 
-   /* XXX what about the back-face writemask? */
-   if (stencil[0].writemask != 0xff) {
+   if (stencil[0].writemask != 0xff ||
+       (stencil[1].enabled && front_facing != NULL && stencil[1].writemask != 0xff)) {
       /* mask &= stencil[0].writemask */
       LLVMValueRef writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
                                                       stencil[0].writemask);
+      if (stencil[1].enabled && stencil[1].writemask != stencil[0].writemask && front_facing != NULL) {
+         LLVMValueRef back_writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
+                                                         stencil[1].writemask);
+         writemask = lp_build_select(bld, front_facing, writemask, back_writemask);
+      }
+
       mask = LLVMBuildAnd(builder, mask, writemask, "");
       /* res = (res & mask) | (stencilVals & ~mask) */
       res = lp_build_select_bitwise(bld, mask, res, stencilVals);