summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/failover/fo_context.h40
-rw-r--r--src/mesa/pipe/failover/fo_state.c25
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c7
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h22
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c44
-rw-r--r--src/mesa/pipe/i915simple/i915_state_dynamic.c24
-rw-r--r--src/mesa/pipe/i915simple/i915_state_immediate.c22
-rw-r--r--src/mesa/pipe/p_context.h14
-rw-r--r--src/mesa/pipe/p_state.h48
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h26
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c8
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_depth_test.c4
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_quad_fs.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stencil.c32
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h15
-rw-r--r--src/mesa/pipe/softpipe/sp_state_blend.c34
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c7
18 files changed, 188 insertions, 191 deletions
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
index fa336193a8..63ec7239ab 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -36,25 +36,24 @@
-#define FO_NEW_VIEWPORT 0x1
-#define FO_NEW_SETUP 0x2
-#define FO_NEW_FRAGMENT_SHADER 0x4
-#define FO_NEW_BLEND 0x8
-#define FO_NEW_CLIP 0x10
-#define FO_NEW_SCISSOR 0x20
-#define FO_NEW_STIPPLE 0x40
-#define FO_NEW_FRAMEBUFFER 0x80
-#define FO_NEW_ALPHA_TEST 0x100
-#define FO_NEW_DEPTH_TEST 0x200
-#define FO_NEW_SAMPLER 0x400
-#define FO_NEW_TEXTURE 0x800
-#define FO_NEW_STENCIL 0x1000
-#define FO_NEW_VERTEX 0x2000
-#define FO_NEW_VERTEX_SHADER 0x4000
-#define FO_NEW_BLEND_COLOR 0x8000
-#define FO_NEW_CLEAR_COLOR 0x10000
-#define FO_NEW_VERTEX_BUFFER 0x20000
-#define FO_NEW_VERTEX_ELEMENT 0x40000
+#define FO_NEW_VIEWPORT 0x1
+#define FO_NEW_SETUP 0x2
+#define FO_NEW_FRAGMENT_SHADER 0x4
+#define FO_NEW_BLEND 0x8
+#define FO_NEW_CLIP 0x10
+#define FO_NEW_SCISSOR 0x20
+#define FO_NEW_STIPPLE 0x40
+#define FO_NEW_FRAMEBUFFER 0x80
+#define FO_NEW_ALPHA_TEST 0x100
+#define FO_NEW_DEPTH_STENCIL 0x200
+#define FO_NEW_SAMPLER 0x400
+#define FO_NEW_TEXTURE 0x800
+#define FO_NEW_VERTEX 0x2000
+#define FO_NEW_VERTEX_SHADER 0x4000
+#define FO_NEW_BLEND_COLOR 0x8000
+#define FO_NEW_CLEAR_COLOR 0x10000
+#define FO_NEW_VERTEX_BUFFER 0x20000
+#define FO_NEW_VERTEX_ELEMENT 0x40000
@@ -69,19 +68,18 @@ struct failover_context {
*/
const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct pipe_depth_stencil_state *depth_stencil;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
struct pipe_clear_color_state clear_color;
struct pipe_clip_state clip;
- struct pipe_depth_state depth_test;
struct pipe_framebuffer_state framebuffer;
struct pipe_shader_state fragment_shader;
struct pipe_shader_state vertex_shader;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_setup_state setup;
- struct pipe_stencil_state stencil;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
index f3a99e4198..43b9757b31 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -103,14 +103,14 @@ failover_set_clear_color_state( struct pipe_context *pipe,
}
static void
-failover_set_depth_test_state(struct pipe_context *pipe,
- const struct pipe_depth_state *depth)
+failover_bind_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
{
struct failover_context *failover = failover_context(pipe);
- failover->depth_test = *depth;
- failover->dirty |= FO_NEW_DEPTH_TEST;
- failover->hw->set_depth_state( failover->hw, depth );
+ failover->depth_stencil = depth_stencil;
+ failover->dirty |= FO_NEW_DEPTH_STENCIL;
+ failover->hw->bind_depth_stencil_state( failover->hw, depth_stencil );
}
static void
@@ -184,18 +184,6 @@ failover_set_scissor_state( struct pipe_context *pipe,
}
static void
-failover_set_stencil_state(struct pipe_context *pipe,
- const struct pipe_stencil_state *stencil)
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->stencil = *stencil;
- failover->dirty |= FO_NEW_STENCIL;
- failover->hw->set_stencil_state( failover->hw, stencil );
-}
-
-
-static void
failover_bind_sampler_state(struct pipe_context *pipe,
unsigned unit,
const struct pipe_sampler_state *sampler)
@@ -268,19 +256,18 @@ failover_init_state_functions( struct failover_context *failover )
{
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state;
+ failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
failover->pipe.set_alpha_test_state = failover_set_alpha_test_state;
failover->pipe.set_blend_color = failover_set_blend_color;
failover->pipe.set_clip_state = failover_set_clip_state;
failover->pipe.set_clear_color_state = failover_set_clear_color_state;
- failover->pipe.set_depth_state = failover_set_depth_test_state;
failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
failover->pipe.set_fs_state = failover_set_fs_state;
failover->pipe.set_vs_state = failover_set_vs_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
failover->pipe.set_scissor_state = failover_set_scissor_state;
failover->pipe.set_setup_state = failover_set_setup_state;
- failover->pipe.set_stencil_state = failover_set_stencil_state;
failover->pipe.set_texture_state = failover_set_texture_state;
failover->pipe.set_viewport_state = failover_set_viewport_state;
failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index 9d462678c5..3a1865d766 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -70,8 +70,8 @@ failover_state_emit( struct failover_context *failover )
if (failover->dirty & FO_NEW_CLEAR_COLOR)
failover->sw->set_clear_color_state( failover->sw, &failover->clear_color );
- if (failover->dirty & FO_NEW_DEPTH_TEST)
- failover->sw->set_depth_state( failover->sw, &failover->depth_test );
+ if (failover->dirty & FO_NEW_DEPTH_STENCIL)
+ failover->sw->bind_depth_stencil_state( failover->sw, failover->depth_stencil );
if (failover->dirty & FO_NEW_FRAMEBUFFER)
failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
@@ -91,9 +91,6 @@ failover_state_emit( struct failover_context *failover )
if (failover->dirty & FO_NEW_SCISSOR)
failover->sw->set_scissor_state( failover->sw, &failover->scissor );
- if (failover->dirty & FO_NEW_STENCIL)
- failover->sw->set_stencil_state( failover->sw, &failover->stencil );
-
if (failover->dirty & FO_NEW_VIEWPORT)
failover->sw->set_viewport_state( failover->sw, &failover->viewport );
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 51baa281ec..518f780449 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -125,19 +125,18 @@ struct i915_context
*/
const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct pipe_depth_stencil_state *depth_stencil;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
struct pipe_clear_color_state clear_color;
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
- struct pipe_depth_state depth_test;
struct pipe_framebuffer_state framebuffer;
struct pipe_shader_state fs;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_setup_state setup;
- struct pipe_stencil_state stencil;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
@@ -163,16 +162,15 @@ struct i915_context
#define I915_NEW_SETUP 0x2
#define I915_NEW_FS 0x4
#define I915_NEW_BLEND 0x8
-#define I915_NEW_CLIP 0x10
-#define I915_NEW_SCISSOR 0x20
-#define I915_NEW_STIPPLE 0x40
-#define I915_NEW_FRAMEBUFFER 0x80
-#define I915_NEW_ALPHA_TEST 0x100
-#define I915_NEW_DEPTH_TEST 0x200
-#define I915_NEW_SAMPLER 0x400
-#define I915_NEW_TEXTURE 0x800
-#define I915_NEW_STENCIL 0x1000
-#define I915_NEW_CONSTANTS 0x2000
+#define I915_NEW_CLIP 0x10
+#define I915_NEW_SCISSOR 0x20
+#define I915_NEW_STIPPLE 0x40
+#define I915_NEW_FRAMEBUFFER 0x80
+#define I915_NEW_ALPHA_TEST 0x100
+#define I915_NEW_DEPTH_STENCIL 0x200
+#define I915_NEW_SAMPLER 0x400
+#define I915_NEW_TEXTURE 0x800
+#define I915_NEW_CONSTANTS 0x1000
/* Driver's internally generated state flags:
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 10060b45a4..5ac2e27d1a 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -107,38 +107,44 @@ static void i915_delete_sampler_state(struct pipe_context *pipe,
/** XXX move someday? Or consolidate all these simple state setters
* into one file.
*/
-static void i915_set_depth_test_state(struct pipe_context *pipe,
- const struct pipe_depth_state *depth)
-{
- struct i915_context *i915 = i915_context(pipe);
- i915->depth_test = *depth;
+static const struct pipe_depth_stencil_state *
+i915_create_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
+{
+ struct pipe_depth_stencil_state *new_ds =
+ malloc(sizeof(struct pipe_depth_stencil_state));
+ memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state));
- i915->dirty |= I915_NEW_DEPTH_TEST;
+ return new_ds;
}
-static void i915_set_alpha_test_state(struct pipe_context *pipe,
- const struct pipe_alpha_test_state *alpha)
+static void i915_bind_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
{
struct i915_context *i915 = i915_context(pipe);
- i915->alpha_test = *alpha;
+ i915->depth_stencil = depth_stencil;
- i915->dirty |= I915_NEW_ALPHA_TEST;
+ i915->dirty |= I915_NEW_DEPTH_STENCIL;
}
-static void i915_set_stencil_state(struct pipe_context *pipe,
- const struct pipe_stencil_state *stencil)
+static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
+{
+ free((struct pipe_depth_stencil_state *)depth_stencil);
+}
+
+static void i915_set_alpha_test_state(struct pipe_context *pipe,
+ const struct pipe_alpha_test_state *alpha)
{
struct i915_context *i915 = i915_context(pipe);
- i915->stencil = *stencil;
+ i915->alpha_test = *alpha;
- i915->dirty |= I915_NEW_STENCIL;
+ i915->dirty |= I915_NEW_ALPHA_TEST;
}
-
-
static void i915_set_scissor_state( struct pipe_context *pipe,
const struct pipe_scissor_state *scissor )
{
@@ -328,19 +334,21 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.bind_sampler_state = i915_bind_sampler_state;
i915->pipe.delete_sampler_state = i915_delete_sampler_state;
+ i915->pipe.create_depth_stencil_state = i915_create_depth_stencil_state;
+ i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state;
+ i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state;
+
i915->pipe.set_alpha_test_state = i915_set_alpha_test_state;
i915->pipe.set_blend_color = i915_set_blend_color;
i915->pipe.set_clip_state = i915_set_clip_state;
i915->pipe.set_clear_color_state = i915_set_clear_color_state;
i915->pipe.set_constant_buffer = i915_set_constant_buffer;
- i915->pipe.set_depth_state = i915_set_depth_test_state;
i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
i915->pipe.set_fs_state = i915_set_fs_state;
i915->pipe.set_vs_state = i915_set_vs_state;
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
i915->pipe.set_scissor_state = i915_set_scissor_state;
i915->pipe.set_setup_state = i915_set_setup_state;
- i915->pipe.set_stencil_state = i915_set_stencil_state;
i915->pipe.set_texture_state = i915_set_texture_state;
i915->pipe.set_viewport_state = i915_set_viewport_state;
i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c
index 49a30fac11..9140eee7c2 100644
--- a/src/mesa/pipe/i915simple/i915_state_dynamic.c
+++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c
@@ -68,8 +68,8 @@ static void upload_MODES4( struct i915_context *i915 )
/* I915_NEW_STENCIL */
{
- int testmask = i915->stencil.value_mask[0] & 0xff;
- int writemask = i915->stencil.write_mask[0] & 0xff;
+ int testmask = i915->depth_stencil->stencil.value_mask[0] & 0xff;
+ int writemask = i915->depth_stencil->stencil.write_mask[0] & 0xff;
modes4 |= (_3DSTATE_MODES_4_CMD |
ENABLE_STENCIL_TEST_MASK |
@@ -94,7 +94,7 @@ static void upload_MODES4( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_MODES4 = {
- .dirty = I915_NEW_BLEND | I915_NEW_STENCIL,
+ .dirty = I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
.update = upload_MODES4
};
@@ -112,14 +112,14 @@ static void upload_BFO( struct i915_context *i915 )
/* _NEW_STENCIL
*/
- if (i915->stencil.back_enabled) {
- int test = i915_translate_compare_func(i915->stencil.back_func);
- int fop = i915_translate_stencil_op(i915->stencil.back_fail_op);
- int dfop = i915_translate_stencil_op(i915->stencil.back_zfail_op);
- int dpop = i915_translate_stencil_op(i915->stencil.back_zpass_op);
- int ref = i915->stencil.ref_value[1] & 0xff;
- int tmask = i915->stencil.value_mask[1] & 0xff;
- int wmask = i915->stencil.write_mask[1] & 0xff;
+ if (i915->depth_stencil->stencil.back_enabled) {
+ int test = i915_translate_compare_func(i915->depth_stencil->stencil.back_func);
+ int fop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_fail_op);
+ int dfop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_zfail_op);
+ int dpop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_zpass_op);
+ int ref = i915->depth_stencil->stencil.ref_value[1] & 0xff;
+ int tmask = i915->depth_stencil->stencil.value_mask[1] & 0xff;
+ int wmask = i915->depth_stencil->stencil.write_mask[1] & 0xff;
bf[0] = (_3DSTATE_BACKFACE_STENCIL_OPS |
BFO_ENABLE_STENCIL_FUNCS |
@@ -157,7 +157,7 @@ static void upload_BFO( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_BFO = {
- .dirty = I915_NEW_STENCIL,
+ .dirty = I915_NEW_DEPTH_STENCIL,
.update = upload_BFO
};
diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c
index aaca534f5a..484913d308 100644
--- a/src/mesa/pipe/i915simple/i915_state_immediate.c
+++ b/src/mesa/pipe/i915simple/i915_state_immediate.c
@@ -128,12 +128,12 @@ static void upload_S5( struct i915_context *i915 )
unsigned LIS5 = 0;
/* I915_NEW_STENCIL */
- if (i915->stencil.front_enabled) {
- int test = i915_translate_compare_func(i915->stencil.front_func);
- int fop = i915_translate_stencil_op(i915->stencil.front_fail_op);
- int dfop = i915_translate_stencil_op(i915->stencil.front_zfail_op);
- int dpop = i915_translate_stencil_op(i915->stencil.front_zpass_op);
- int ref = i915->stencil.ref_value[0] & 0xff;
+ if (i915->depth_stencil->stencil.front_enabled) {
+ int test = i915_translate_compare_func(i915->depth_stencil->stencil.front_func);
+ int fop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_fail_op);
+ int dfop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_zfail_op);
+ int dpop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_zpass_op);
+ int ref = i915->depth_stencil->stencil.ref_value[0] & 0xff;
LIS5 |= (S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE |
@@ -179,7 +179,7 @@ static void upload_S5( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_S5 = {
- .dirty = (I915_NEW_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP),
+ .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP),
.update = upload_S5
};
@@ -219,13 +219,13 @@ static void upload_S6( struct i915_context *i915 )
/* I915_NEW_DEPTH
*/
- if (i915->depth_test.enabled) {
- int func = i915_translate_compare_func(i915->depth_test.func);
+ if (i915->depth_stencil->depth.enabled) {
+ int func = i915_translate_compare_func(i915->depth_stencil->depth.func);
LIS6 |= (S6_DEPTH_TEST_ENABLE |
(func << S6_DEPTH_TEST_FUNC_SHIFT));
- if (i915->depth_test.writemask)
+ if (i915->depth_stencil->depth.writemask)
LIS6 |= S6_DEPTH_WRITE_ENABLE;
}
@@ -236,7 +236,7 @@ static void upload_S6( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_S6 = {
- .dirty = I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_TEST,
+ .dirty = I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
.update = upload_S6
};
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 0913e49096..488f002531 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -101,6 +101,14 @@ struct pipe_context {
void (*delete_sampler_state)(struct pipe_context *,
const struct pipe_sampler_state *);
+ const struct pipe_depth_stencil_state * (*create_depth_stencil_state)(
+ struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+ void (*bind_depth_stencil_state)(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+ void (*delete_depth_stencil_state)(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+
void (*set_alpha_test_state)( struct pipe_context *,
const struct pipe_alpha_test_state * );
@@ -116,9 +124,6 @@ struct pipe_context {
void (*set_constant_buffer)( struct pipe_context *,
uint shader, uint index,
const struct pipe_constant_buffer *buf );
-
- void (*set_depth_state)( struct pipe_context *,
- const struct pipe_depth_state * );
void (*set_feedback_state)( struct pipe_context *,
const struct pipe_feedback_state *);
@@ -141,9 +146,6 @@ struct pipe_context {
void (*set_scissor_state)( struct pipe_context *,
const struct pipe_scissor_state * );
- void (*set_stencil_state)( struct pipe_context *,
- const struct pipe_stencil_state * );
-
void (*set_texture_state)( struct pipe_context *,
unsigned unit,
struct pipe_mipmap_tree * );
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index b994d17ea9..30e559b594 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -146,13 +146,31 @@ struct pipe_shader_state {
void *executable;
};
-struct pipe_depth_state
+struct pipe_depth_stencil_state
{
- unsigned enabled:1; /**< depth test enabled? */
- unsigned writemask:1; /**< allow depth buffer writes? */
- unsigned func:3; /**< depth test func (PIPE_FUNC_x) */
- unsigned occlusion_count:1; /**< XXX move this elsewhere? */
- float clear; /**< Clear value in [0,1] (XXX correct place?) */
+ struct {
+ unsigned enabled:1; /**< depth test enabled? */
+ unsigned writemask:1; /**< allow depth buffer writes? */
+ unsigned func:3; /**< depth test func (PIPE_FUNC_x) */
+ unsigned occlusion_count:1; /**< XXX move this elsewhere? */
+ float clear; /**< Clear value in [0,1] (XXX correct place?) */
+ } depth;
+ struct {
+ unsigned front_enabled:1;
+ unsigned front_func:3; /**< PIPE_FUNC_x */
+ unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned back_enabled:1;
+ unsigned back_func:3; /**< PIPE_FUNC_x */
+ unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */
+ ubyte ref_value[2]; /**< [0] = front, [1] = back */
+ ubyte value_mask[2];
+ ubyte write_mask[2];
+ ubyte clear_value;
+ } stencil;
};
struct pipe_alpha_test_state {
@@ -188,24 +206,6 @@ struct pipe_clear_color_state
float color[4];
};
-struct pipe_stencil_state {
- unsigned front_enabled:1;
- unsigned front_func:3; /**< PIPE_FUNC_x */
- unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned back_enabled:1;
- unsigned back_func:3; /**< PIPE_FUNC_x */
- unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */
- ubyte ref_value[2]; /**< [0] = front, [1] = back */
- ubyte value_mask[2];
- ubyte write_mask[2];
- ubyte clear_value;
-};
-
-
struct pipe_framebuffer_state
{
/** multiple colorbuffers for multiple render targets */
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index bab7985e8d..9a8b55bb0e 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -256,13 +256,15 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state;
softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
+ softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state;
+ softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state;
+ softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state;
softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
softpipe->pipe.set_blend_color = softpipe_set_blend_color;
softpipe->pipe.set_clip_state = softpipe_set_clip_state;
softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state;
softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
- softpipe->pipe.set_depth_state = softpipe_set_depth_test_state;
softpipe->pipe.set_feedback_state = softpipe_set_feedback_state;
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
softpipe->pipe.set_fs_state = softpipe_set_fs_state;
@@ -270,7 +272,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
softpipe->pipe.set_setup_state = softpipe_set_setup_state;
- softpipe->pipe.set_stencil_state = softpipe_set_stencil_state;
softpipe->pipe.set_texture_state = softpipe_set_texture_state;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 5cee1a3cf9..4cbb0f891e 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -50,18 +50,17 @@ struct draw_stage;
#define SP_NEW_SETUP 0x2
#define SP_NEW_FS 0x4
#define SP_NEW_BLEND 0x8
-#define SP_NEW_CLIP 0x10
-#define SP_NEW_SCISSOR 0x20
-#define SP_NEW_STIPPLE 0x40
-#define SP_NEW_FRAMEBUFFER 0x80
-#define SP_NEW_ALPHA_TEST 0x100
-#define SP_NEW_DEPTH_TEST 0x200
-#define SP_NEW_SAMPLER 0x400
-#define SP_NEW_TEXTURE 0x800
-#define SP_NEW_STENCIL 0x1000
-#define SP_NEW_VERTEX 0x2000
-#define SP_NEW_VS 0x4000
-#define SP_NEW_CONSTANTS 0x8000
+#define SP_NEW_CLIP 0x10
+#define SP_NEW_SCISSOR 0x20
+#define SP_NEW_STIPPLE 0x40
+#define SP_NEW_FRAMEBUFFER 0x80
+#define SP_NEW_ALPHA_TEST 0x100
+#define SP_NEW_DEPTH_STENCIL 0x200
+#define SP_NEW_SAMPLER 0x400
+#define SP_NEW_TEXTURE 0x800
+#define SP_NEW_VERTEX 0x1000
+#define SP_NEW_VS 0x2000
+#define SP_NEW_CONSTANTS 0x4000
struct softpipe_context {
@@ -73,13 +72,13 @@ struct softpipe_context {
*/
const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct pipe_depth_stencil_state *depth_stencil;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
struct pipe_clear_color_state clear_color;
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[2];
- struct pipe_depth_state depth_test;
struct pipe_feedback_state feedback;
struct pipe_framebuffer_state framebuffer;
struct pipe_shader_state fs;
@@ -87,7 +86,6 @@ struct softpipe_context {
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_setup_state setup;
- struct pipe_stencil_state stencil;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
index 2fcbea1f22..1f45776d47 100644
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ b/src/mesa/pipe/softpipe/sp_quad.c
@@ -31,7 +31,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.bufloop;
}
- if (sp->depth_test.occlusion_count) {
+ if (sp->depth_stencil->depth.occlusion_count) {
sp->quad.occlusion->next = sp->quad.first;
sp->quad.first = sp->quad.occlusion;
}
@@ -43,12 +43,12 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.coverage;
}
- if ( sp->stencil.front_enabled
- || sp->stencil.front_enabled) {
+ if ( sp->depth_stencil->stencil.front_enabled
+ || sp->depth_stencil->stencil.back_enabled) {
sp->quad.stencil_test->next = sp->quad.first;
sp->quad.first = sp->quad.stencil_test;
}
- else if (sp->depth_test.enabled &&
+ else if (sp->depth_stencil->depth.enabled &&
sp->framebuffer.zbuf) {
sp->quad.depth_test->next = sp->quad.first;
sp->quad.first = sp->quad.depth_test;
diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c
index 5d46e70393..ff1d84a02d 100644
--- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c
+++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c
@@ -77,7 +77,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
/* get zquad from zbuffer */
sps->read_quad_z(sps, quad->x0, quad->y0, bzzzz);
- switch (softpipe->depth_test.func) {
+ switch (softpipe->depth_stencil->depth.func) {
case PIPE_FUNC_NEVER:
/* zmask = 0 */
break;
@@ -129,7 +129,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
quad->mask &= zmask;
- if (softpipe->depth_test.writemask) {
+ if (softpipe->depth_stencil->depth.writemask) {
/* This is also efficient with sse / spe instructions:
*/
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index cb0b6d8a77..46ad08aaa1 100755
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -179,7 +179,7 @@ static void shade_begin(struct quad_stage *qs)
unsigned i, entry;
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- qss->samplers[i].state = &softpipe->sampler[i];
+ qss->samplers[i].state = softpipe->sampler[i];
qss->samplers[i].texture = softpipe->texture[i];
qss->samplers[i].get_samples = sp_get_samples;
qss->samplers[i].pipe = &softpipe->pipe;
diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c
index 47b3b4f089..56cc6907b2 100644
--- a/src/mesa/pipe/softpipe/sp_quad_stencil.c
+++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c
@@ -207,23 +207,23 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
/* choose front or back face function, operator, etc */
/* XXX we could do these initializations once per primitive */
- if (softpipe->stencil.back_enabled && quad->facing) {
- func = softpipe->stencil.back_func;
- failOp = softpipe->stencil.back_fail_op;
- zFailOp = softpipe->stencil.back_zfail_op;
- zPassOp = softpipe->stencil.back_zpass_op;
- ref = softpipe->stencil.ref_value[1];
- wrtMask = softpipe->stencil.write_mask[1];
- valMask = softpipe->stencil.value_mask[1];
+ if (softpipe->depth_stencil->stencil.back_enabled && quad->facing) {
+ func = softpipe->depth_stencil->stencil.back_func;
+ failOp = softpipe->depth_stencil->stencil.back_fail_op;
+ zFailOp = softpipe->depth_stencil->stencil.back_zfail_op;
+ zPassOp = softpipe->depth_stencil->stencil.back_zpass_op;
+ ref = softpipe->depth_stencil->stencil.ref_value[1];
+ wrtMask = softpipe->depth_stencil->stencil.write_mask[1];
+ valMask = softpipe->depth_stencil->stencil.value_mask[1];
}
else {
- func = softpipe->stencil.front_func;
- failOp = softpipe->stencil.front_fail_op;
- zFailOp = softpipe->stencil.front_zfail_op;
- zPassOp = softpipe->stencil.front_zpass_op;
- ref = softpipe->stencil.ref_value[0];
- wrtMask = softpipe->stencil.write_mask[0];
- valMask = softpipe->stencil.value_mask[0];
+ func = softpipe->depth_stencil->stencil.front_func;
+ failOp = softpipe->depth_stencil->stencil.front_fail_op;
+ zFailOp = softpipe->depth_stencil->stencil.front_zfail_op;
+ zPassOp = softpipe->depth_stencil->stencil.front_zpass_op;
+ ref = softpipe->depth_stencil->stencil.ref_value[0];
+ wrtMask = softpipe->depth_stencil->stencil.write_mask[0];
+ valMask = softpipe->depth_stencil->stencil.value_mask[0];
}
assert(s_surf); /* shouldn't get here if there's no stencil buffer */
@@ -244,7 +244,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
if (quad->mask) {
/* now the pixels that passed the stencil test are depth tested */
- if (softpipe->depth_test.enabled) {
+ if (softpipe->depth_stencil->depth.enabled) {
const unsigned origMask = quad->mask;
sp_depth_test_quad(qs, quad); /* quad->mask is updated */
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index c8c93709db..caec3b4519 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -50,6 +50,15 @@ void softpipe_bind_sampler_state(struct pipe_context *,
void softpipe_delete_sampler_state(struct pipe_context *,
const struct pipe_sampler_state *);
+
+const struct pipe_depth_stencil_state *
+softpipe_create_depth_stencil_state(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+void softpipe_bind_depth_stencil_state(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+void softpipe_delete_depth_stencil_state(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+
void softpipe_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
@@ -69,9 +78,6 @@ void softpipe_set_constant_buffer(struct pipe_context *,
uint shader, uint index,
const struct pipe_constant_buffer *buf);
-void softpipe_set_depth_test_state( struct pipe_context *,
- const struct pipe_depth_state * );
-
void softpipe_set_feedback_state( struct pipe_context *,
const struct pipe_feedback_state * );
@@ -90,9 +96,6 @@ void softpipe_set_scissor_state( struct pipe_context *,
void softpipe_set_setup_state( struct pipe_context *,
const struct pipe_setup_state * );
-void softpipe_set_stencil_state( struct pipe_context *,
- const struct pipe_stencil_state * );
-
void softpipe_set_texture_state( struct pipe_context *,
unsigned unit,
struct pipe_mipmap_tree * );
diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c
index 34da613f9d..83f456ded5 100644
--- a/src/mesa/pipe/softpipe/sp_state_blend.c
+++ b/src/mesa/pipe/softpipe/sp_state_blend.c
@@ -71,16 +71,6 @@ void softpipe_set_blend_color( struct pipe_context *pipe,
/** XXX move someday? Or consolidate all these simple state setters
* into one file.
*/
-void
-softpipe_set_depth_test_state(struct pipe_context *pipe,
- const struct pipe_depth_state *depth)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->depth_test = *depth;
-
- softpipe->dirty |= SP_NEW_DEPTH_TEST;
-}
void
softpipe_set_alpha_test_state(struct pipe_context *pipe,
@@ -93,14 +83,30 @@ softpipe_set_alpha_test_state(struct pipe_context *pipe,
softpipe->dirty |= SP_NEW_ALPHA_TEST;
}
+const struct pipe_depth_stencil_state *
+softpipe_create_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
+{
+ struct pipe_depth_stencil_state *new_ds = malloc(sizeof(struct pipe_depth_stencil_state));
+ memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state));
+
+ return new_ds;
+}
+
void
-softpipe_set_stencil_state(struct pipe_context *pipe,
- const struct pipe_stencil_state *stencil)
+softpipe_bind_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth_stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->stencil = *stencil;
+ softpipe->depth_stencil = depth_stencil;
- softpipe->dirty |= SP_NEW_STENCIL;
+ softpipe->dirty |= SP_NEW_DEPTH_STENCIL;
}
+void
+softpipe_delete_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *depth)
+{
+ free((struct pipe_depth_stencil_state*)depth);
+}
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index e08ed50a70..47743e185c 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -55,7 +55,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
/* Need Z if depth test is enabled or the fragment program uses the
* fragment position (XYZW).
*/
- if (softpipe->depth_test.enabled ||
+ if (softpipe->depth_stencil->depth.enabled ||
(inputsRead & (1 << TGSI_ATTRIB_POS)))
softpipe->need_z = TRUE;
else
@@ -186,15 +186,14 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
calculate_vertex_layout( softpipe );
if (softpipe->dirty & (SP_NEW_SCISSOR |
- SP_NEW_STENCIL |
+ SP_NEW_DEPTH_STENCIL |
SP_NEW_FRAMEBUFFER))
compute_cliprect(softpipe);
if (softpipe->dirty & (SP_NEW_BLEND |
- SP_NEW_DEPTH_TEST |
+ SP_NEW_DEPTH_STENCIL |
SP_NEW_ALPHA_TEST |
SP_NEW_FRAMEBUFFER |
- SP_NEW_STENCIL |
SP_NEW_SETUP |
SP_NEW_FS))
sp_build_quad_pipeline(softpipe);