Instead of passing an array, just pass two scalar values.
}
-/** Get front/back-face stencil ref value */
-static LLVMValueRef
-lp_build_get_stencil_ref(struct lp_build_context *bld,
- struct lp_type type, LLVMValueRef stencil_refs_ptr,
- unsigned face_index)
-{
- LLVMValueRef indexes[2], ptr, ref, ref_vec;
-
- assert(face_index < 2);
-
- /* load [face_index] element of the array */
- indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
- indexes[1] = LLVMConstInt(LLVMInt32Type(), face_index, 0);
- ptr = LLVMBuildGEP(bld->builder, stencil_refs_ptr, indexes, 2, "");
- ref = LLVMBuildLoad(bld->builder, ptr, "");
-
- /* convert int8 value to i32 */
- ref = LLVMBuildZExt(bld->builder, ref, LLVMIntType(type.width), "");
-
- /* make scalar into vector */
- ref_vec = lp_build_broadcast_scalar(bld, ref);
-
- return ref_vec;
-}
-
-
/**
* Generate code for performing depth and/or stencil tests.
* We operate on a vector of values (typically a 2x2 quad).
struct lp_type type,
const struct util_format_description *format_desc,
struct lp_build_mask_context *mask,
- LLVMValueRef stencil_refs_ptr,
+ LLVMValueRef stencil_refs[2],
LLVMValueRef z_src,
LLVMValueRef zs_dst_ptr)
{
struct lp_build_context bld;
unsigned z_swizzle, s_swizzle;
- LLVMValueRef stencil_refs[2];
LLVMValueRef zs_dst, z_dst = NULL;
LLVMValueRef stencil_vals = NULL;
LLVMValueRef z_bitmask = NULL, s_bitmask = NULL;
lp_build_name(z_dst, "zsbuf.z");
-
+ /*
printf("build depth %d stencil %d\n",
depth->enabled,
stencil[0].enabled);
-
+ */
if (stencil[0].enabled) {
- /* Incoming stencil_refs is ptr to int8[2]. Get/convert to int32[4]. */
- stencil_refs[0] = lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 0);
+ /* convert scalar stencil refs into vectors */
+ stencil_refs[0] = lp_build_broadcast_scalar(&bld, stencil_refs[0]);
+ stencil_refs[1] = lp_build_broadcast_scalar(&bld, stencil_refs[1]);
- if (stencil[1].enabled)
- stencil_refs[1] =
- lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 1);
s_pass_mask = lp_build_stencil_test(&bld, stencil,
stencil_refs, stencil_vals, face);
struct lp_type type,
const struct util_format_description *format_desc,
struct lp_build_mask_context *mask,
- LLVMValueRef stencil_refs,
+ LLVMValueRef stencil_refs[2],
LLVMValueRef zs_src,
LLVMValueRef zs_dst_ptr);
elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0);
elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType();
- elem_types[LP_JIT_CTX_STENCIL_REF] = LLVMArrayType(LLVMInt8Type(), 2);
+ elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] = LLVMInt32Type();
+ elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32Type();
elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType();
elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType();
elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType();
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
screen->target, context_type,
LP_JIT_CTX_ALPHA_REF);
- LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref,
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_front,
screen->target, context_type,
- LP_JIT_CTX_STENCIL_REF);
+ LP_JIT_CTX_STENCIL_REF_FRONT);
+ LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_back,
+ screen->target, context_type,
+ LP_JIT_CTX_STENCIL_REF_BACK);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
screen->target, context_type,
LP_JIT_CTX_SCISSOR_XMIN);
float alpha_ref_value;
- uint8_t stencil_ref[2];
+ uint32_t stencil_ref_front, stencil_ref_back;
/** floats, not ints */
float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
enum {
LP_JIT_CTX_CONSTANTS = 0,
LP_JIT_CTX_ALPHA_REF,
- LP_JIT_CTX_STENCIL_REF,
+ LP_JIT_CTX_STENCIL_REF_FRONT,
+ LP_JIT_CTX_STENCIL_REF_BACK,
LP_JIT_CTX_SCISSOR_XMIN,
LP_JIT_CTX_SCISSOR_YMIN,
LP_JIT_CTX_SCISSOR_XMAX,
#define lp_jit_context_alpha_ref_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
-#define lp_jit_context_stencil_ref_values(_builder, _ptr) \
- lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref")
+#define lp_jit_context_stencil_ref_front_value(_builder, _ptr) \
+ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front")
+
+#define lp_jit_context_stencil_ref_back_value(_builder, _ptr) \
+ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back")
#define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin")
{
LP_DBG(DEBUG_SETUP, "%s %d %d\n", __FUNCTION__, refs[0], refs[1]);
- if (setup->fs.current.jit_context.stencil_ref[0] != refs[0] ||
- setup->fs.current.jit_context.stencil_ref[1] != refs[1]) {
- setup->fs.current.jit_context.stencil_ref[0] = refs[0];
- setup->fs.current.jit_context.stencil_ref[1] = refs[1];
+ if (setup->fs.current.jit_context.stencil_ref_front != refs[0] ||
+ setup->fs.current.jit_context.stencil_ref_back != refs[1]) {
+ setup->fs.current.jit_context.stencil_ref_front = refs[0];
+ setup->fs.current.jit_context.stencil_ref_back = refs[1];
setup->dirty |= LP_SETUP_NEW_FS;
}
}
const struct lp_fragment_shader_variant_key *key,
struct lp_type src_type,
struct lp_build_mask_context *mask,
- LLVMValueRef stencil_refs,
+ LLVMValueRef stencil_refs[2],
LLVMValueRef src,
LLVMValueRef dst_ptr)
{
LLVMValueRef consts_ptr;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
LLVMValueRef z = interp->pos[2];
- LLVMValueRef stencil_refs;
+ LLVMValueRef stencil_refs[2];
struct lp_build_flow_context *flow;
struct lp_build_mask_context mask;
boolean early_depth_stencil_test;
assert(i < 4);
- stencil_refs = lp_jit_context_stencil_ref_values(builder, context_ptr);
+ stencil_refs[0] = lp_jit_context_stencil_ref_front_value(builder, context_ptr);
+ stencil_refs[1] = lp_jit_context_stencil_ref_back_value(builder, context_ptr);
elem_type = lp_build_elem_type(type);
vec_type = lp_build_vec_type(type);