From: José Fonseca Date: Sat, 9 Oct 2010 11:55:31 +0000 (+0100) Subject: gallivm: Don't generate Phis for execution mask. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cc40abad519cc0f765c6d8f6fad4154bed8dd9c2;p=mesa.git gallivm: Don't generate Phis for execution mask. --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c index 1ec33c742e2..a5d65e9b396 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c @@ -454,12 +454,15 @@ void lp_build_mask_check(struct lp_build_mask_context *mask) { LLVMBuilderRef builder = mask->flow->builder; + LLVMValueRef value; LLVMValueRef cond; + value = lp_build_mask_value(mask); + /* cond = (mask == 0) */ cond = LLVMBuildICmp(builder, LLVMIntEQ, - LLVMBuildBitCast(builder, mask->value, mask->reg_type, ""), + LLVMBuildBitCast(builder, value, mask->reg_type, ""), LLVMConstNull(mask->reg_type), ""); @@ -485,14 +488,23 @@ lp_build_mask_begin(struct lp_build_mask_context *mask, mask->flow = flow; mask->reg_type = LLVMIntType(type.width * type.length); - mask->value = value; + mask->var = lp_build_alloca(flow->builder, + lp_build_int_vec_type(type), + "execution_mask"); + + LLVMBuildStore(flow->builder, value, mask->var); - lp_build_flow_scope_begin(flow); - lp_build_flow_scope_declare(flow, &mask->value); lp_build_flow_skip_begin(flow); } +LLVMValueRef +lp_build_mask_value(struct lp_build_mask_context *mask) +{ + return LLVMBuildLoad(mask->flow->builder, mask->var, ""); +} + + /** * Update boolean mask with given value (bitwise AND). * Typically used to update the quad's pixel alive/killed mask @@ -502,7 +514,10 @@ void lp_build_mask_update(struct lp_build_mask_context *mask, LLVMValueRef value) { - mask->value = LLVMBuildAnd( mask->flow->builder, mask->value, value, ""); + value = LLVMBuildAnd(mask->flow->builder, + lp_build_mask_value(mask), + value, ""); + LLVMBuildStore(mask->flow->builder, value, mask->var); } @@ -513,8 +528,7 @@ LLVMValueRef lp_build_mask_end(struct lp_build_mask_context *mask) { lp_build_flow_skip_end(mask->flow); - lp_build_flow_scope_end(mask->flow); - return mask->value; + return lp_build_mask_value(mask); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h index 095c781ec54..0fc6317b339 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h @@ -77,7 +77,7 @@ struct lp_build_mask_context LLVMTypeRef reg_type; - LLVMValueRef value; + LLVMValueRef var; }; @@ -87,6 +87,9 @@ lp_build_mask_begin(struct lp_build_mask_context *mask, struct lp_type type, LLVMValueRef value); +LLVMValueRef +lp_build_mask_value(struct lp_build_mask_context *mask); + /** * Bitwise AND the mask with the given value, if a previous mask was set. */ diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c index 8d9be2ebbbf..e768493103e 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c @@ -473,7 +473,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, LLVMValueRef stencil_vals = NULL; LLVMValueRef z_bitmask = NULL, stencil_shift = NULL; LLVMValueRef z_pass = NULL, s_pass_mask = NULL; - LLVMValueRef orig_mask = mask->value; + LLVMValueRef orig_mask = lp_build_mask_value(mask); LLVMValueRef front_facing = NULL; /* Prototype a simpler path: @@ -527,7 +527,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, type.sign = 1; lp_build_context_init(&bld, builder, type); - z_dst = lp_build_select(&bld, mask->value, z_src, z_dst); + z_dst = lp_build_select(&bld, lp_build_mask_value(mask), z_src, z_dst); z_dst = LLVMBuildShl(builder, z_dst, const_8_int, "z_dst"); *zs_value = z_dst; } @@ -710,7 +710,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, } if (depth->writemask) { - LLVMValueRef zselectmask = mask->value; + LLVMValueRef zselectmask = lp_build_mask_value(mask); /* mask off bits that failed Z test */ zselectmask = LLVMBuildAnd(builder, zselectmask, z_pass, ""); @@ -810,7 +810,7 @@ lp_build_deferred_depth_write(LLVMBuilderRef builder, 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); + z_dst = lp_build_select(&bld, lp_build_mask_value(mask), zs_value, z_dst); LLVMBuildStore(builder, z_dst, zs_dst_ptr); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index f45f36f6332..cf07cb49764 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -422,16 +422,14 @@ generate_fs(struct llvmpipe_context *lp, } if (counter) - lp_build_occlusion_count(builder, type, mask.value, counter); + lp_build_occlusion_count(builder, type, + lp_build_mask_value(&mask), counter); - lp_build_mask_end(&mask); + *pmask = lp_build_mask_end(&mask); lp_build_flow_scope_end(flow); lp_build_flow_destroy(flow); - - *pmask = mask.value; - }