llvmpipe: added stencil ref values to jit context state
authorBrian Paul <brianp@vmware.com>
Tue, 16 Mar 2010 20:00:40 +0000 (14:00 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Mar 2010 22:29:34 +0000 (16:29 -0600)
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_state_derived.c

index 4584135d33573e988bef27ac1764ec11fc0a2393..0254272eecad73b1f6e9ffc1c1ef75b0138db3f5 100644 (file)
@@ -91,17 +91,18 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
 
    /* struct lp_jit_context */
    {
-      LLVMTypeRef elem_types[8];
+      LLVMTypeRef elem_types[9];
       LLVMTypeRef context_type;
 
       elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */
       elem_types[1] = LLVMFloatType();                     /* alpha_ref_value */
-      elem_types[2] = LLVMFloatType();                     /* scissor_xmin */
-      elem_types[3] = LLVMFloatType();                     /* scissor_ymin */
-      elem_types[4] = LLVMFloatType();                     /* scissor_xmax */
-      elem_types[5] = LLVMFloatType();                     /* scissor_ymax */
-      elem_types[6] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
-      elem_types[7] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
+      elem_types[2] = LLVMArrayType(LLVMInt8Type(), 2);    /* stencil_refs */
+      elem_types[3] = LLVMFloatType();                     /* scissor_xmin */
+      elem_types[4] = LLVMFloatType();                     /* scissor_ymin */
+      elem_types[5] = LLVMFloatType();                     /* scissor_xmax */
+      elem_types[6] = LLVMFloatType();                     /* scissor_ymax */
+      elem_types[7] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
+      elem_types[8] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
 
       context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
 
@@ -109,16 +110,18 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
                              screen->target, context_type, 0);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
                              screen->target, context_type, 1);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref,
                              screen->target, context_type, 2);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
                              screen->target, context_type, 3);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin,
                              screen->target, context_type, 4);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax,
                              screen->target, context_type, 5);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax,
                              screen->target, context_type, 6);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color,
+                             screen->target, context_type, 7);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
                              screen->target, context_type,
                              LP_JIT_CONTEXT_TEXTURES_INDEX);
index 13167ae3bf4edbc4e05a260242238a52d7c45c97..6864265ed025ef9df97a051839a4d72ac16de5d8 100644 (file)
@@ -84,6 +84,8 @@ struct lp_jit_context
 
    float alpha_ref_value;
 
+   ubyte stencil_ref[2];
+
    /** floats, not ints */
    float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
 
@@ -100,22 +102,25 @@ struct lp_jit_context
 #define lp_jit_context_alpha_ref_value(_builder, _ptr) \
    lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value")
 
+#define lp_jit_context_stencil_ref_value(_builder, _ptr) \
+   lp_build_struct_get(_builder, _ptr, 2, "stencil_ref_values")
+
 #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 2, "scissor_xmin")
+   lp_build_struct_get(_builder, _ptr, 3, "scissor_xmin")
 
 #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 3, "scissor_ymin")
+   lp_build_struct_get(_builder, _ptr, 4, "scissor_ymin")
 
 #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 4, "scissor_xmax")
+   lp_build_struct_get(_builder, _ptr, 5, "scissor_xmax")
 
 #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 5, "scissor_ymax")
+   lp_build_struct_get(_builder, _ptr, 6, "scissor_ymax")
 
 #define lp_jit_context_blend_color(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 6, "blend_color")
+   lp_build_struct_get(_builder, _ptr, 7, "blend_color")
 
-#define LP_JIT_CONTEXT_TEXTURES_INDEX 7
+#define LP_JIT_CONTEXT_TEXTURES_INDEX 8
 
 #define lp_jit_context_textures(_builder, _ptr) \
    lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures")
index cd16b6b2d38783010e3494964a87642cbb208486..bcc9d1fc1a47e3bd398e446380126633c46a121f 100644 (file)
@@ -401,6 +401,20 @@ lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
    }
 }
 
+void
+lp_setup_set_stencil_ref_values( struct lp_setup_context *setup,
+                                 const ubyte refs[2] )
+{
+   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];
+      setup->dirty |= LP_SETUP_NEW_FS;
+   }
+}
+
 void
 lp_setup_set_blend_color( struct lp_setup_context *setup,
                           const struct pipe_blend_color *blend_color )
index 414eaec98d15e56c1a165b19b00ccbadeb1bc216..dbfc1bf8d4cab1808f29486b10c5055ec47aeba0 100644 (file)
@@ -112,6 +112,10 @@ void
 lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
                               float alpha_ref_value );
 
+void
+lp_setup_set_stencil_ref_values( struct lp_setup_context *setup,
+                                 const ubyte refs[2] );
+
 void
 lp_setup_set_blend_color( struct lp_setup_context *setup,
                           const struct pipe_blend_color *blend_color );
index 9c91ce9238fcec109f397ed0e411a372da88ed52..777871638f65345fdda204fc0568a0e5500c09dd 100644 (file)
@@ -174,9 +174,12 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
    if (llvmpipe->dirty & LP_NEW_SCISSOR)
       lp_setup_set_scissor(llvmpipe->setup, &llvmpipe->scissor);
 
-   if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA)
+   if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) {
       lp_setup_set_alpha_ref_value(llvmpipe->setup, 
                                    llvmpipe->depth_stencil->alpha.ref_value);
+      lp_setup_set_stencil_ref_values(llvmpipe->setup,
+                                      llvmpipe->stencil_ref.ref_value);
+   }
 
    if (llvmpipe->dirty & LP_NEW_CONSTANTS)
       lp_setup_set_fs_constants(llvmpipe->setup,