summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2013-01-29 10:45:01 +0000
committerJosé Fonseca <[email protected]>2013-01-29 16:41:56 +0000
commit3b683700efe81f82ba2f978d6c645385e5ccfa97 (patch)
treeb1a3d9139378782d15e277bcf1a2766d90f5a15f /src/gallium
parent0eb588a37cc0427fd5c6a1ed2b212ed5d68f4dab (diff)
llvmpipe: Fix deferred depth writes for Z16_UNORM.
This special path hadn't been exercised by my earlier testing, and mask values weren't being properly truncated to match the values. This change fixes that. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_depth.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 1c899b31cc9..24c997d4624 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -893,6 +893,7 @@ lp_build_deferred_depth_write(struct gallivm_state *gallivm,
struct lp_build_context z_bld;
LLVMValueRef z_dst;
LLVMBuilderRef builder = gallivm->builder;
+ LLVMValueRef mask_value;
/* XXX: pointlessly redo type logic:
*/
@@ -904,11 +905,15 @@ lp_build_deferred_depth_write(struct gallivm_state *gallivm,
z_dst = LLVMBuildLoad(builder, zs_dst_ptr, "zsbufval");
+ mask_value = lp_build_mask_value(mask);
+
if (z_type.width < z_src_type.width) {
+ /* Truncate incoming ZS and mask values (e.g., when writing to Z16_UNORM) */
zs_value = LLVMBuildTrunc(builder, zs_value, z_bld.vec_type, "");
+ mask_value = LLVMBuildTrunc(builder, mask_value, z_bld.int_vec_type, "");
}
- z_dst = lp_build_select(&z_bld, lp_build_mask_value(mask), zs_value, z_dst);
+ z_dst = lp_build_select(&z_bld, mask_value, zs_value, z_dst);
LLVMBuildStore(builder, z_dst, zs_dst_ptr);
}