Instead of passing an array, just pass two scalar values.tags/mesa-7.9-rc1
@@ -363,32 +363,6 @@ lp_depth_type(const struct util_format_description *format_desc, | |||
} | |||
/** 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). | |||
@@ -406,13 +380,12 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, | |||
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; | |||
@@ -502,19 +475,17 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, | |||
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); |
@@ -57,7 +57,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, | |||
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); | |||
@@ -96,7 +96,8 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) | |||
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(); | |||
@@ -113,9 +114,12 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) | |||
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); |
@@ -84,7 +84,7 @@ struct lp_jit_context | |||
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; | |||
@@ -103,7 +103,8 @@ struct lp_jit_context | |||
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, | |||
@@ -120,8 +121,11 @@ enum { | |||
#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") |
@@ -407,10 +407,10 @@ lp_setup_set_stencil_ref_values( struct lp_setup_context *setup, | |||
{ | |||
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; | |||
} | |||
} |
@@ -145,7 +145,7 @@ generate_depth_stencil(LLVMBuilderRef builder, | |||
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) | |||
{ | |||
@@ -408,7 +408,7 @@ generate_fs(struct llvmpipe_context *lp, | |||
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; | |||
@@ -418,7 +418,8 @@ generate_fs(struct llvmpipe_context *lp, | |||
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); |