From bfe79babf99e6b9435195178d1ea64687c60d161 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 17 Dec 2007 16:14:29 +0000 Subject: gallium: incorporate alpha state into depth_stencil state object. --- src/mesa/pipe/softpipe/sp_context.c | 10 +++----- src/mesa/pipe/softpipe/sp_context.h | 9 +++---- src/mesa/pipe/softpipe/sp_quad.c | 8 +++--- src/mesa/pipe/softpipe/sp_quad_alpha_test.c | 4 +-- src/mesa/pipe/softpipe/sp_quad_stencil.c | 25 ++++++------------- src/mesa/pipe/softpipe/sp_state.h | 9 +------ src/mesa/pipe/softpipe/sp_state_blend.c | 38 +++++------------------------ src/mesa/pipe/softpipe/sp_state_derived.c | 8 +++--- 8 files changed, 31 insertions(+), 80 deletions(-) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index b62e691e87..b6995b8a6c 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -240,10 +240,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.get_paramf = softpipe_get_paramf; /* state setters */ - softpipe->pipe.create_alpha_test_state = softpipe_create_alpha_test_state; - softpipe->pipe.bind_alpha_test_state = softpipe_bind_alpha_test_state; - softpipe->pipe.delete_alpha_test_state = softpipe_delete_alpha_test_state; - softpipe->pipe.create_blend_state = softpipe_create_blend_state; softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; @@ -252,9 +248,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, 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.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state; + softpipe->pipe.bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state; + softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state; softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 8fd44933f2..8f14dd11d1 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -53,13 +53,13 @@ struct softpipe_tile_cache; #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_DEPTH_STENCIL_ALPHA 0x100 +#define SP_NEW_CONSTANTS 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 +#define SP_NEW_QUERY 0x4000 struct sp_vertex_shader_state { struct pipe_shader_state *state; @@ -73,10 +73,9 @@ struct softpipe_context { /* The most recent drawing state as set by the driver: */ - const struct pipe_alpha_test_state *alpha_test; const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_depth_stencil_alpha_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; const struct sp_fragment_shader_state *fs; const struct sp_vertex_shader_state *vs; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 6330465a8b..a10c9c3e02 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -43,8 +43,8 @@ static void sp_build_depth_stencil( struct softpipe_context *sp ) { - if (sp->depth_stencil->stencil.front_enabled || - sp->depth_stencil->stencil.back_enabled) { + if (sp->depth_stencil->stencil[0].enabled || + sp->depth_stencil->stencil[1].enabled) { sp_push_quad_first( sp, sp->quad.stencil_test ); } else if (sp->depth_stencil->depth.enabled && @@ -59,7 +59,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) boolean early_depth_test = sp->depth_stencil->depth.enabled && sp->framebuffer.zbuf && - !sp->alpha_test->enabled && + !sp->depth_stencil->alpha.enabled && sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION; /* build up the pipeline in reverse order... */ @@ -98,7 +98,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp_build_depth_stencil( sp ); } - if (sp->alpha_test->enabled) { + if (sp->depth_stencil->alpha.enabled) { sp_push_quad_first( sp, sp->quad.alpha_test ); } diff --git a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c index d056abe98d..4ffeac35e1 100644 --- a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c @@ -14,11 +14,11 @@ static void alpha_test_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; - const float ref = softpipe->alpha_test->ref; + const float ref = softpipe->depth_stencil->alpha.ref; unsigned passMask = 0x0, j; const float *aaaa = quad->outputs.color[3]; - switch (softpipe->alpha_test->func) { + switch (softpipe->depth_stencil->alpha.func) { case PIPE_FUNC_NEVER: quad->mask = 0x0; break; diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c index 3f3eca078b..a688a06c74 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stencil.c +++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c @@ -211,24 +211,13 @@ 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->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->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]; - } + func = softpipe->depth_stencil->stencil[quad->facing].func; + failOp = softpipe->depth_stencil->stencil[quad->facing].fail_op; + zFailOp = softpipe->depth_stencil->stencil[quad->facing].zfail_op; + zPassOp = softpipe->depth_stencil->stencil[quad->facing].zpass_op; + ref = softpipe->depth_stencil->stencil[quad->facing].ref_value; + wrtMask = softpipe->depth_stencil->stencil[quad->facing].write_mask; + valMask = softpipe->depth_stencil->stencil[quad->facing].value_mask; assert(ps); /* shouldn't get here if there's no stencil buffer */ diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index a3bd078a71..76b79b5280 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -52,13 +52,6 @@ struct sp_fragment_shader_state { #endif }; -void * -softpipe_create_alpha_test_state(struct pipe_context *, - const struct pipe_alpha_test_state *); -void -softpipe_bind_alpha_test_state(struct pipe_context *, void *); -void -softpipe_delete_alpha_test_state(struct pipe_context *, void *); void * softpipe_create_blend_state(struct pipe_context *, @@ -76,7 +69,7 @@ void softpipe_delete_sampler_state(struct pipe_context *, void *); void * softpipe_create_depth_stencil_state(struct pipe_context *, - const struct pipe_depth_stencil_state *); + const struct pipe_depth_stencil_alpha_state *); void softpipe_bind_depth_stencil_state(struct pipe_context *, void *); void softpipe_delete_depth_stencil_state(struct pipe_context *, void *); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index 5ceec2513f..160ca5cbc0 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -73,40 +73,14 @@ void softpipe_set_blend_color( struct pipe_context *pipe, * into one file. */ -void * -softpipe_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) -{ - struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) ); - memcpy(state, alpha, sizeof(struct pipe_alpha_test_state)); - return state; -} - -void -softpipe_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - softpipe->alpha_test = (const struct pipe_alpha_test_state *)alpha; - - softpipe->dirty |= SP_NEW_ALPHA_TEST; -} - -void -softpipe_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - FREE( alpha ); -} void * softpipe_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { - struct pipe_depth_stencil_state *state = - MALLOC( sizeof(struct pipe_depth_stencil_state) ); - memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state)); + struct pipe_depth_stencil_alpha_state *state = + MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) ); + memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state)); return state; } @@ -116,9 +90,9 @@ softpipe_bind_depth_stencil_state(struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil; + softpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; - softpipe->dirty |= SP_NEW_DEPTH_STENCIL; + softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA; } void diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 736ac1c33b..94072a2d30 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -201,16 +201,16 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | - SP_NEW_DEPTH_STENCIL | + SP_NEW_DEPTH_STENCIL_ALPHA | SP_NEW_FRAMEBUFFER)) compute_cliprect(softpipe); if (softpipe->dirty & (SP_NEW_BLEND | - SP_NEW_DEPTH_STENCIL | - SP_NEW_ALPHA_TEST | + SP_NEW_DEPTH_STENCIL_ALPHA | SP_NEW_FRAMEBUFFER | SP_NEW_RASTERIZER | - SP_NEW_FS)) + SP_NEW_FS | + SP_NEW_QUERY)) sp_build_quad_pipeline(softpipe); softpipe->dirty = 0; -- cgit v1.2.3