diff options
author | Zack Rusin <zack@tungstengraphics.com> | 2007-09-17 11:55:18 -0400 |
---|---|---|
committer | Zack Rusin <zack@tungstengraphics.com> | 2007-09-18 06:31:22 -0400 |
commit | d6ac959833a8e40a27907940969c622692f749b1 (patch) | |
tree | ddb0c6d886142d66aabb27a3ca00c683f55dbc4c /src/mesa/pipe/softpipe | |
parent | 56edb98d975041cca2e4a3712126b151d80a045a (diff) |
Combing depth and stencil objects and making them immutable.
Converting depth and stencil objects into a single state object
(d3d10 like) and making it immutable.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 5 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.h | 26 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_depth_test.c | 4 | ||||
-rwxr-xr-x | src/mesa/pipe/softpipe/sp_quad_fs.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_stencil.c | 32 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state.h | 15 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_blend.c | 34 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 7 |
9 files changed, 70 insertions, 63 deletions
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); |