summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_bld_depth.c
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2010-10-09 11:28:00 +0100
committerKeith Whitwell <[email protected]>2010-10-09 11:44:45 +0100
commit5b7eb868fde98388d80601d8dea39e679828f42f (patch)
treec97e8a511ec7cf3bb6df50098b8cb22d2b3e5277 /src/gallium/drivers/llvmpipe/lp_bld_depth.c
parentaa4cb5e2d8d48c7dcc9653c61a9e25494e3e7b2a (diff)
llvmpipe: clean up shader pre/postamble, try to catch more early-z
Specifically, can do early-depth-test even when alpahtest or kill-pixel are active, providing we defer the actual z write until the final mask is avaialable. Improves demos/fire.c especially in the case where you get close to the trees.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_depth.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_depth.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 6b8ffb6ca26..8d9be2ebbbf 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -410,7 +410,7 @@ get_s_shift_and_mask(const struct util_format_description *format_desc,
* \param maskvalue is the depth test mask.
* \param counter is a pointer of the uint32 counter.
*/
-static void
+void
lp_build_occlusion_count(LLVMBuilderRef builder,
struct lp_type type,
LLVMValueRef maskvalue,
@@ -462,7 +462,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
LLVMValueRef z_src,
LLVMValueRef zs_dst_ptr,
LLVMValueRef face,
- LLVMValueRef counter,
+ LLVMValueRef *zs_value,
boolean do_branch)
{
struct lp_type type;
@@ -524,17 +524,14 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
* storage.
*/
if (depth->writemask) {
- type.sign = 0;
+ type.sign = 1;
lp_build_context_init(&bld, builder, type);
z_dst = lp_build_select(&bld, mask->value, z_src, z_dst);
z_dst = LLVMBuildShl(builder, z_dst, const_8_int, "z_dst");
- LLVMBuildStore(builder, z_dst, zs_dst_ptr);
+ *zs_value = z_dst;
}
- if (counter)
- lp_build_occlusion_count(builder, type, mask->value, counter);
-
return;
}
@@ -779,7 +776,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
else
zs_dst = stencil_vals;
- LLVMBuildStore(builder, zs_dst, zs_dst_ptr);
+ *zs_value = zs_dst;
}
if (s_pass_mask)
@@ -791,6 +788,29 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
if (do_branch)
lp_build_mask_check(mask);
- if (counter)
- lp_build_occlusion_count(builder, type, mask->value, counter);
+}
+
+
+
+void
+lp_build_deferred_depth_write(LLVMBuilderRef builder,
+ struct lp_type z_src_type,
+ const struct util_format_description *format_desc,
+ struct lp_build_mask_context *mask,
+ LLVMValueRef zs_dst_ptr,
+ LLVMValueRef zs_value)
+{
+ struct lp_type type;
+ struct lp_build_context bld;
+ LLVMValueRef z_dst;
+
+ /* XXX: pointlessly redo type logic:
+ */
+ type = lp_depth_type(format_desc, z_src_type.width*z_src_type.length);
+ lp_build_context_init(&bld, builder, type);
+
+ z_dst = LLVMBuildLoad(builder, zs_dst_ptr, "zsbufval");
+ z_dst = lp_build_select(&bld, mask->value, zs_value, z_dst);
+
+ LLVMBuildStore(builder, z_dst, zs_dst_ptr);
}