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),
"");
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
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);
}
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);
}
LLVMTypeRef reg_type;
- LLVMValueRef value;
+ LLVMValueRef var;
};
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.
*/
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:
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;
}
}
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, "");
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);
}
}
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;
-
}