Convert i915 to use cso semantics of alpha_test.
authorZack Rusin <zack@tungstengraphics.com>
Fri, 21 Sep 2007 11:06:19 +0000 (07:06 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Fri, 21 Sep 2007 11:06:19 +0000 (07:06 -0400)
src/mesa/pipe/i915simple/i915_context.h
src/mesa/pipe/i915simple/i915_state.c
src/mesa/pipe/i915simple/i915_state_immediate.c

index 9958a8592dcf4b3b8daec7f8c46827acc8d53ac2..dc19b6efeb9e627a9ee54a6fa0541571575cd645 100644 (file)
@@ -146,15 +146,19 @@ struct i915_sampler_state {
    const struct pipe_sampler_state *templ;
 };
 
+struct i915_alpha_test_state {
+   unsigned LIS6;
+};
+
 struct i915_context
 {
-   struct pipe_context pipe; 
+   struct pipe_context pipe;
    struct i915_winsys *winsys;
    struct draw_context *draw;
 
    /* The most recent drawing state as set by the driver:
     */
-   const struct pipe_alpha_test_state      *alpha_test;
+   const struct i915_alpha_test_state      *alpha_test;
    const struct i915_blend_state           *blend;
    const struct i915_sampler_state         *sampler[PIPE_MAX_SAMPLERS];
    const struct i915_depth_stencil_state   *depth_stencil;
index 8bfd2da3b5c91803edde12231c800a7ec4951d94..5c6d37a4661562aa25a75d2e963476e65901a5eb 100644 (file)
@@ -397,9 +397,19 @@ static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
 
 static void *
 i915_create_alpha_test_state(struct pipe_context *pipe,
-                             const struct pipe_alpha_test_state *alpha)
+                             const struct pipe_alpha_test_state *alpha_test)
 {
-   return 0;
+   struct i915_alpha_test_state *cso = calloc(1, sizeof(struct i915_alpha_test_state));
+
+   if (alpha_test->enabled) {
+      int test = i915_translate_compare_func(alpha_test->func);
+      ubyte refByte = float_to_ubyte(alpha_test->ref);
+
+      cso->LIS6 |= (S6_ALPHA_TEST_ENABLE |
+                    (test << S6_ALPHA_TEST_FUNC_SHIFT) |
+                    (((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
+   }
+   return cso;
 }
 
 static void i915_bind_alpha_test_state(struct pipe_context *pipe,
@@ -407,7 +417,7 @@ static void i915_bind_alpha_test_state(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
 
-   i915->alpha_test = (const struct pipe_alpha_test_state*)alpha;
+   i915->alpha_test = (const struct i915_alpha_test_state*)alpha;
 
    i915->dirty |= I915_NEW_ALPHA_TEST;
 }
@@ -415,6 +425,7 @@ static void i915_bind_alpha_test_state(struct pipe_context *pipe,
 static void i915_delete_alpha_test_state(struct pipe_context *pipe,
                                          void *alpha)
 {
+   free(alpha);
 }
 
 static void i915_set_scissor_state( struct pipe_context *pipe,
@@ -650,7 +661,7 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe,
 static void i915_delete_rasterizer_state(struct pipe_context *pipe,
                                          void *setup)
 {
-   /* do nothing */
+   free(setup);
 }
 
 static void i915_set_vertex_buffer( struct pipe_context *pipe,
index 014fddfdda519b77692bb57ae7aa3ab2d2d6dd90..479d72a87fdf2dfc25a63dddc7aa54a18a82966d 100644 (file)
@@ -121,15 +121,7 @@ static void upload_S6( struct i915_context *i915 )
 
    /* I915_NEW_ALPHA_TEST
     */
-   if (i915->alpha_test->enabled) {
-      int test = i915_translate_compare_func(i915->alpha_test->func);
-      ubyte refByte = float_to_ubyte(i915->alpha_test->ref);
-      
-
-      LIS6 |= (S6_ALPHA_TEST_ENABLE |
-              (test << S6_ALPHA_TEST_FUNC_SHIFT) |
-              (((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
-   }
+   LIS6 |= i915->alpha_test->LIS6;
 
    /* I915_NEW_BLEND
     */