Mesa (master): llvmpipe: fix issue with not writing new stencil values

Roland Scheidegger sroland at kemper.freedesktop.org
Wed May 22 20:57:42 UTC 2013


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

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Wed May 22 22:42:11 2013 +0200

llvmpipe: fix issue with not writing new stencil values

We did mask checks between depth/stencil testing and depth/stencil write.
This meant that if the depth/stencil test killed off all fragments we never
actually wrote the new stencil value. This issue affected all early/late
test/write combinations.
So move the mask check after depth/stencil write (for early depth test,
could do the same for late depth test but might not be worth it at that
point so just skip it there).
This addresses https://bugs.freedesktop.org/show_bug.cgi?id=41787.
Piglit does not hit this issue because of the simple_shader optimization
in generate_fs_loop() which means we're skipping the mask checks.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/gallium/drivers/llvmpipe/lp_bld_depth.c |    4 ----
 src/gallium/drivers/llvmpipe/lp_state_fs.c  |    7 +++++++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 5ef9947..df6a6c4 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -1116,9 +1116,5 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
 
    if (depth->enabled && stencil[0].enabled)
       lp_build_mask_update(mask, z_pass);
-
-   if (do_branch)
-      lp_build_mask_check(mask);
-
 }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 1dfc75a..754288b 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -361,6 +361,13 @@ generate_fs_loop(struct gallivm_state *gallivm,
                                                depth_ptr, depth_stride,
                                                z_value, s_value);
       }
+      /*
+       * Note mask check if stencil is enabled must be after ds write not after
+       * stencil test otherwise new stencil values may not get written if all
+       * fragments got killed by depth/stencil test.
+       */
+      if (!simple_shader && key->stencil[0].enabled)
+         lp_build_mask_check(&mask);
    }
 
    lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter);




More information about the mesa-commit mailing list