summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-03-18 11:31:38 -0600
committerBrian Paul <brianp@vmware.com>2010-03-18 11:31:38 -0600
commit521c61ff017ab15b829abbe9a98b179136a36009 (patch)
tree9e1d207b35b732e69d67933c16e586aea0f83677
parentecf85c7d750478e433e640897bb25a18069f14de (diff)
gallivm/llvmpipe: simplify front/back stencil ref value handling
Instead of passing an array, just pass two scalar values.
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_depth.c41
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_depth.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.c10
-rw-r--r--src/gallium/drivers/llvmpipe/lp_jit.h12
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c7
6 files changed, 30 insertions, 50 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c
index 49de5c94a3..c253764e60 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c
@@ -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);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h
index eedc1e419b..5708ced983 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h
@@ -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);
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index 1eee9212e6..927e472ff2 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -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);
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h
index 63e05c5d5e..bbd0c9610d 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.h
+++ b/src/gallium/drivers/llvmpipe/lp_jit.h
@@ -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")
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index bcc9d1fc1a..fbb0d6f8a6 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -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;
}
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 921c51fbe8..0f96654a67 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -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);