gallivm/llmvpipe: pass stencil refs state into z/stencil build code
authorBrian Paul <brianp@vmware.com>
Tue, 16 Mar 2010 20:32:18 +0000 (14:32 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Mar 2010 22:29:34 +0000 (16:29 -0600)
src/gallium/auxiliary/gallivm/lp_bld_depth.c
src/gallium/auxiliary/gallivm/lp_bld_depth.h
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_fs.c

index cbc48f986519656cdad6ab7e13a8d629d7f1d1aa..3a5da4edce7f0ec4317a9b6d1d301d2f38972aff 100644 (file)
@@ -217,6 +217,7 @@ lp_build_depth_test(LLVMBuilderRef builder,
                     struct lp_type type,
                     const struct util_format_description *format_desc,
                     struct lp_build_mask_context *mask,
+                    LLVMValueRef stencil_refs,
                     LLVMValueRef src,
                     LLVMValueRef dst_ptr)
 {
index 8375824cbf4a7233ed008f3c1fa7b3f37e90029a..a7f67d210050e845607253648b707e92c6854587 100644 (file)
@@ -56,6 +56,7 @@ lp_build_depth_test(LLVMBuilderRef builder,
                     struct lp_type type,
                     const struct util_format_description *format_desc,
                     struct lp_build_mask_context *mask,
+                    LLVMValueRef stencil_refs,
                     LLVMValueRef src,
                     LLVMValueRef dst_ptr);
 
index 8f796f76d5ab4bf3091c645144e81d07633500bd..843345c62d067cf89b183898ebc6a5cbcaa1391e 100644 (file)
@@ -120,7 +120,7 @@ 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_value(_builder, _ptr) \
+#define lp_jit_context_stencil_ref_values(_builder, _ptr) \
    lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref")
 
 #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
index be02e97648e7d10be355207cbceb5bfa871ec99f..74ebf90d5803d928d676087a6aa8ac7850553126 100644 (file)
@@ -67,6 +67,7 @@ struct lp_fragment_shader;
 struct lp_fragment_shader_variant_key
 {
    struct pipe_depth_state depth;
+   struct pipe_stencil_state stencil[2];
    struct pipe_alpha_state alpha;
    struct pipe_blend_state blend;
    enum pipe_format zsbuf_format;
index a2ec8c3943593d4b327e48e4c7ae3f7b20539c1c..5b00792eec44582bddde6dc52796417060a0b169 100644 (file)
@@ -145,6 +145,7 @@ generate_depth(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 src,
                LLVMValueRef dst_ptr)
 {
@@ -189,6 +190,7 @@ generate_depth(LLVMBuilderRef builder,
                        dst_type,
                        format_desc,
                        mask,
+                       stencil_refs,
                        src,
                        dst_ptr);
 }
@@ -405,6 +407,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;
    struct lp_build_flow_context *flow;
    struct lp_build_mask_context mask;
    boolean early_depth_test;
@@ -414,6 +417,8 @@ generate_fs(struct llvmpipe_context *lp,
 
    assert(i < 4);
 
+   stencil_refs = lp_jit_context_stencil_ref_values(builder, context_ptr);
+
    elem_type = lp_build_elem_type(type);
    vec_type = lp_build_vec_type(type);
    int_vec_type = lp_build_int_vec_type(type);
@@ -462,7 +467,7 @@ generate_fs(struct llvmpipe_context *lp,
    if(early_depth_test)
       generate_depth(builder, key,
                      type, &mask,
-                     z, depth_ptr);
+                     stencil_refs, z, depth_ptr);
 
    lp_build_tgsi_soa(builder, tokens, type, &mask,
                      consts_ptr, interp->pos, interp->inputs,
@@ -509,7 +514,7 @@ generate_fs(struct llvmpipe_context *lp,
    if(!early_depth_test)
       generate_depth(builder, key,
                      type, &mask,
-                     z, depth_ptr);
+                     stencil_refs, z, depth_ptr);
 
    lp_build_mask_end(&mask);
 
@@ -1054,10 +1059,15 @@ make_variant_key(struct llvmpipe_context *lp,
 
    memset(key, 0, sizeof *key);
 
-   if(lp->framebuffer.zsbuf &&
-      lp->depth_stencil->depth.enabled) {
-      key->zsbuf_format = lp->framebuffer.zsbuf->format;
-      memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth);
+   if (lp->framebuffer.zsbuf) {
+      if (lp->depth_stencil->depth.enabled) {
+         key->zsbuf_format = lp->framebuffer.zsbuf->format;
+         memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth);
+      }
+      if (lp->depth_stencil->stencil[0].enabled) {
+         key->zsbuf_format = lp->framebuffer.zsbuf->format;
+         memcpy(&key->stencil, &lp->depth_stencil->stencil, sizeof key->stencil);
+      }
    }
 
    key->alpha.enabled = lp->depth_stencil->alpha.enabled;