diff options
author | Brian Paul <[email protected]> | 2010-04-20 13:50:59 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-04-20 13:51:52 -0600 |
commit | caa05ef41996f7d0ac6b77f2fe86b1771cb10e43 (patch) | |
tree | 6f3523effdbcb44148fc572bc63a7719df69c48d /src/gallium/drivers | |
parent | 48f54ecb0cc276ab7655b93419e73c8b4e5656ae (diff) |
llvmpipe: fix depth+stencil logic error
If both Z-test and stencil-test were enabled, we were mis-computing
the vector of updated Z buffer values.
Fixes Z testing bug in progs/demos/fbotexture.c
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_depth.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c index afdf4009af0..1b59a13c946 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c @@ -608,12 +608,25 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, } if (depth->writemask) { - if(z_bitmask) - z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, ""); - else - z_bitmask = mask->value; + LLVMValueRef zselectmask = mask->value; - z_dst = lp_build_select(&bld, z_bitmask, z_src, z_dst); + /* mask off bits that failed Z test */ + zselectmask = LLVMBuildAnd(builder, zselectmask, z_pass, ""); + + /* mask off bits that failed stencil test */ + if (s_pass_mask) { + zselectmask = LLVMBuildAnd(builder, zselectmask, s_pass_mask, ""); + } + + /* if combined Z/stencil format, mask off the stencil bits */ + if (z_bitmask) { + zselectmask = LLVMBuildAnd(builder, zselectmask, z_bitmask, ""); + } + + /* Mix the old and new Z buffer values. + * z_dst[i] = zselectmask[i] ? z_src[i] : z_dst[i] + */ + z_dst = lp_build_select(&bld, zselectmask, z_src, z_dst); } if (stencil[0].enabled) { |