/* state setters */
- cell->pipe.create_alpha_test_state = cell_create_alpha_test_state;
- cell->pipe.bind_alpha_test_state = cell_bind_alpha_test_state;
- cell->pipe.delete_alpha_test_state = cell_delete_alpha_test_state;
-
cell->pipe.create_blend_state = cell_create_blend_state;
cell->pipe.bind_blend_state = cell_bind_blend_state;
cell->pipe.delete_blend_state = cell_delete_blend_state;
struct cell_winsys *winsys;
- 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;
struct pipe_blend_color blend_color;
const struct pipe_framebuffer_state * );
-extern void *
-cell_create_alpha_test_state(struct pipe_context *,
- const struct pipe_alpha_test_state *);
-extern void
-cell_bind_alpha_test_state(struct pipe_context *, void *);
-extern void
-cell_delete_alpha_test_state(struct pipe_context *, void *);
extern void *
cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *);
extern void *
cell_create_depth_stencil_state(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
+ const struct pipe_depth_stencil_alpha_state *);
extern void
cell_bind_depth_stencil_state(struct pipe_context *, void *);
}
-/** XXX move someday? Or consolidate all these simple state setters
- * into one file.
- */
-
-void *
-cell_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
-cell_bind_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell->alpha_test = (const struct pipe_alpha_test_state *)alpha;
-
- cell->dirty |= CELL_NEW_ALPHA_TEST;
-}
-
-void
-cell_delete_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- FREE( alpha );
-}
void *
cell_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;
}
{
struct cell_context *cell = cell_context(pipe);
- cell->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil;
+ cell->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
cell->dirty |= CELL_NEW_DEPTH_STENCIL;
}
case CSO_SAMPLER:
hash = sc->sampler_hash;
break;
- case CSO_DEPTH_STENCIL:
+ case CSO_DEPTH_STENCIL_ALPHA:
hash = sc->depth_stencil_hash;
break;
case CSO_RASTERIZER:
case CSO_VERTEX_SHADER:
hash = sc->vs_hash;
break;
- case CSO_ALPHA_TEST:
- hash = sc->alpha_hash;
- break;
}
return hash;
return sizeof(struct pipe_blend_state);
case CSO_SAMPLER:
return sizeof(struct pipe_sampler_state);
- case CSO_DEPTH_STENCIL:
- return sizeof(struct pipe_depth_stencil_state);
+ case CSO_DEPTH_STENCIL_ALPHA:
+ return sizeof(struct pipe_depth_stencil_alpha_state);
case CSO_RASTERIZER:
return sizeof(struct pipe_rasterizer_state);
case CSO_FRAGMENT_SHADER:
return sizeof(struct pipe_shader_state);
case CSO_VERTEX_SHADER:
return sizeof(struct pipe_shader_state);
- case CSO_ALPHA_TEST:
- return sizeof(struct pipe_alpha_test_state);
}
return 0;
}
sc->rasterizer_hash = cso_hash_create();
sc->fs_hash = cso_hash_create();
sc->vs_hash = cso_hash_create();
- sc->alpha_hash = cso_hash_create();
return sc;
}
cso_hash_delete(sc->rasterizer_hash);
cso_hash_delete(sc->fs_hash);
cso_hash_delete(sc->vs_hash);
- cso_hash_delete(sc->alpha_hash);
free(sc);
}
struct cso_hash;
struct cso_cache {
- struct cso_hash *alpha_hash;
struct cso_hash *blend_hash;
struct cso_hash *depth_stencil_hash;
struct cso_hash *fs_hash;
void *data;
};
-struct cso_depth_stencil {
- struct pipe_depth_stencil_state state;
+struct cso_depth_stencil_alpha {
+ struct pipe_depth_stencil_alpha_state state;
void *data;
};
void *data;
};
-struct cso_alpha_test {
- struct pipe_alpha_test_state state;
- void *data;
-};
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
- CSO_DEPTH_STENCIL,
+ CSO_DEPTH_STENCIL_ALPHA,
CSO_RASTERIZER,
CSO_FRAGMENT_SHADER,
- CSO_VERTEX_SHADER,
- CSO_ALPHA_TEST
+ CSO_VERTEX_SHADER
};
unsigned cso_construct_key(void *item, int item_size);
/* The most recent drawing state as set by the driver:
*/
- const struct fo_state *alpha_test;
const struct fo_state *blend;
const struct fo_state *sampler[PIPE_MAX_SAMPLERS];
const struct fo_state *depth_stencil;
* lower overheads.
*/
-static void *
-failover_create_alpha_test_state(struct pipe_context *pipe,
- const struct pipe_alpha_test_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_alpha_test_state(pipe, templ);
- state->hw_state = failover->hw->create_alpha_test_state(pipe, templ);
-
- return state;
-}
-
-static void
-failover_bind_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- struct failover_context *failover = failover_context(pipe);
- struct fo_state *state = (struct fo_state *)alpha;
-
- failover->alpha_test = state;
- failover->dirty |= FO_NEW_ALPHA_TEST;
- failover->hw->bind_alpha_test_state(failover->hw,
- state->hw_state);
-}
-
-static void
-failover_delete_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- struct fo_state *state = (struct fo_state*)alpha;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_alpha_test_state(pipe, state->sw_state);
- failover->hw->delete_alpha_test_state(pipe, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
static void *
static void *
failover_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *templ)
+ const struct pipe_depth_stencil_alpha_state *templ)
{
struct fo_state *state = malloc(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
- state->sw_state = failover->sw->create_depth_stencil_state(pipe, templ);
- state->hw_state = failover->hw->create_depth_stencil_state(pipe, templ);
+ state->sw_state = failover->sw->create_depth_stencil_alpha_state(pipe, templ);
+ state->hw_state = failover->hw->create_depth_stencil_alpha_state(pipe, templ);
return state;
}
struct fo_state *state = (struct fo_state *)depth_stencil;
failover->depth_stencil = state;
failover->dirty |= FO_NEW_DEPTH_STENCIL;
- failover->hw->bind_depth_stencil_state(failover->hw, state->hw_state);
+ failover->hw->bind_depth_stencil_alpha_state(failover->hw, state->hw_state);
}
static void
struct fo_state *state = (struct fo_state*)ds;
struct failover_context *failover = failover_context(pipe);
- failover->sw->delete_depth_stencil_state(pipe, state->sw_state);
- failover->hw->delete_depth_stencil_state(pipe, state->hw_state);
+ failover->sw->delete_depth_stencil_alpha_state(pipe, state->sw_state);
+ failover->hw->delete_depth_stencil_alpha_state(pipe, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
free(state);
void
failover_init_state_functions( struct failover_context *failover )
{
- failover->pipe.create_alpha_test_state = failover_create_alpha_test_state;
- failover->pipe.bind_alpha_test_state = failover_bind_alpha_test_state;
- failover->pipe.delete_alpha_test_state = failover_delete_alpha_test_state;
failover->pipe.create_blend_state = failover_create_blend_state;
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state;
failover->pipe.create_sampler_state = failover_create_sampler_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state;
failover->pipe.delete_sampler_state = failover_delete_sampler_state;
- failover->pipe.create_depth_stencil_state = failover_create_depth_stencil_state;
- failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
- failover->pipe.delete_depth_stencil_state = failover_delete_depth_stencil_state;
+ failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
+ failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state;
+ failover->pipe.delete_depth_stencil_alpha_state = failover_delete_depth_stencil_state;
failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
{
unsigned i;
- if (failover->dirty & FO_NEW_ALPHA_TEST)
- failover->sw->bind_alpha_test_state( failover->sw,
- failover->alpha_test->sw_state );
-
if (failover->dirty & FO_NEW_BLEND)
failover->sw->bind_blend_state( failover->sw,
failover->blend->sw_state );
failover->sw->set_clip_state( failover->sw, &failover->clip );
if (failover->dirty & FO_NEW_DEPTH_STENCIL)
- failover->sw->bind_depth_stencil_state( failover->sw,
- failover->depth_stencil->sw_state );
+ failover->sw->bind_depth_stencil_alpha_state( failover->sw,
+ failover->depth_stencil->sw_state );
if (failover->dirty & FO_NEW_FRAMEBUFFER)
failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
const struct pipe_sampler_state *templ;
};
-struct i915_alpha_test_state {
- unsigned LIS6;
-};
struct i915_texture {
struct pipe_texture base;
/* The most recent drawing state as set by the driver:
*/
- 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;
static void *
i915_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 i915_depth_stencil_state *cso = CALLOC_STRUCT( i915_depth_stencil_state );
{
- int testmask = depth_stencil->stencil.value_mask[0] & 0xff;
- int writemask = depth_stencil->stencil.write_mask[0] & 0xff;
+ int testmask = depth_stencil->stencil[0].value_mask & 0xff;
+ int writemask = depth_stencil->stencil[0].write_mask & 0xff;
cso->stencil_modes4 |= (_3DSTATE_MODES_4_CMD |
ENABLE_STENCIL_TEST_MASK |
STENCIL_WRITE_MASK(writemask));
}
- if (depth_stencil->stencil.front_enabled) {
- int test = i915_translate_compare_func(depth_stencil->stencil.front_func);
- int fop = i915_translate_stencil_op(depth_stencil->stencil.front_fail_op);
- int dfop = i915_translate_stencil_op(depth_stencil->stencil.front_zfail_op);
- int dpop = i915_translate_stencil_op(depth_stencil->stencil.front_zpass_op);
- int ref = depth_stencil->stencil.ref_value[0] & 0xff;
+ if (depth_stencil->stencil[0].enabled) {
+ int test = i915_translate_compare_func(depth_stencil->stencil[0].func);
+ int fop = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op);
+ int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op);
+ int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op);
+ int ref = depth_stencil->stencil[0].ref_value & 0xff;
cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE |
(dpop << S5_STENCIL_PASS_Z_PASS_SHIFT));
}
- if (depth_stencil->stencil.back_enabled) {
- int test = i915_translate_compare_func(depth_stencil->stencil.back_func);
- int fop = i915_translate_stencil_op(depth_stencil->stencil.back_fail_op);
- int dfop = i915_translate_stencil_op(depth_stencil->stencil.back_zfail_op);
- int dpop = i915_translate_stencil_op(depth_stencil->stencil.back_zpass_op);
- int ref = depth_stencil->stencil.ref_value[1] & 0xff;
- int tmask = depth_stencil->stencil.value_mask[1] & 0xff;
- int wmask = depth_stencil->stencil.write_mask[1] & 0xff;
+ if (depth_stencil->stencil[1].enabled) {
+ int test = i915_translate_compare_func(depth_stencil->stencil[1].func);
+ int fop = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op);
+ int dfop = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op);
+ int dpop = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op);
+ int ref = depth_stencil->stencil[1].ref_value & 0xff;
+ int tmask = depth_stencil->stencil[1].value_mask & 0xff;
+ int wmask = depth_stencil->stencil[1].write_mask & 0xff;
cso->bfo[0] = (_3DSTATE_BACKFACE_STENCIL_OPS |
BFO_ENABLE_STENCIL_FUNCS |
cso->depth_LIS6 |= S6_DEPTH_WRITE_ENABLE;
}
+ if (depth_stencil->alpha.enabled) {
+ int test = i915_translate_compare_func(depth_stencil->alpha.func);
+ ubyte refByte = float_to_ubyte(depth_stencil->alpha.ref);
+
+ cso->depth_LIS6 |= (S6_ALPHA_TEST_ENABLE |
+ (test << S6_ALPHA_TEST_FUNC_SHIFT) |
+ (((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
+ }
+
return cso;
}
}
-static void *
-i915_create_alpha_test_state(struct pipe_context *pipe,
- const struct pipe_alpha_test_state *alpha_test)
-{
- struct i915_alpha_test_state *cso = CALLOC_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,
- void *alpha)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->alpha_test = (const struct i915_alpha_test_state*)alpha;
-
- i915->dirty |= I915_NEW_ALPHA_TEST;
-}
-
-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,
const struct pipe_scissor_state *scissor )
{
void
i915_init_state_functions( struct i915_context *i915 )
{
- i915->pipe.create_alpha_test_state = i915_create_alpha_test_state;
- i915->pipe.bind_alpha_test_state = i915_bind_alpha_test_state;
- i915->pipe.delete_alpha_test_state = i915_delete_alpha_test_state;
-
i915->pipe.create_blend_state = i915_create_blend_state;
i915->pipe.bind_blend_state = i915_bind_blend_state;
i915->pipe.delete_blend_state = i915_delete_blend_state;
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.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
+ i915->pipe.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state;
+ i915->pipe.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state;
i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
unsigned LIS6 = (S6_COLOR_WRITE_ENABLE |
(2 << S6_TRISTRIP_PV_SHIFT));
- /* I915_NEW_ALPHA_TEST
- */
- LIS6 |= i915->alpha_test->LIS6;
-
/* I915_NEW_BLEND
*/
LIS6 |= i915->blend->LIS6;
}
const struct i915_tracked_state i915_upload_S6 = {
- I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
+ I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
upload_S6
};
memset(&cc, 0, sizeof(cc));
/* BRW_NEW_DEPTH_STENCIL */
- if (brw->attribs.DepthStencil->stencil.front_enabled) {
- cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil.front_enabled;
- cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil.front_func);
- cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil.front_fail_op);
+ if (brw->attribs.DepthStencil->stencil[0].enabled) {
+ cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil[0].enabled;
+ cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil[0].func);
+ cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil[0].fail_op);
cc.cc0.stencil_pass_depth_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil.front_zfail_op);
+ brw->attribs.DepthStencil->stencil[0].zfail_op);
cc.cc0.stencil_pass_depth_pass_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil.front_zpass_op);
- cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[0];
- cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[0];
- cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[0];
+ brw->attribs.DepthStencil->stencil[0].zpass_op);
+ cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil[0].ref_value;
+ cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil[0].write_mask;
+ cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil[0].value_mask;
- if (brw->attribs.DepthStencil->stencil.back_enabled) {
- cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil.back_enabled;
+ if (brw->attribs.DepthStencil->stencil[1].enabled) {
+ cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil[1].enabled;
cc.cc0.bf_stencil_func = brw_translate_compare_func(
- brw->attribs.DepthStencil->stencil.back_func);
+ brw->attribs.DepthStencil->stencil[1].func);
cc.cc0.bf_stencil_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil.back_fail_op);
+ brw->attribs.DepthStencil->stencil[1].fail_op);
cc.cc0.bf_stencil_pass_depth_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil.back_zfail_op);
+ brw->attribs.DepthStencil->stencil[1].zfail_op);
cc.cc0.bf_stencil_pass_depth_pass_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil.back_zpass_op);
- cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[1];
- cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[1];
- cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[1];
+ brw->attribs.DepthStencil->stencil[1].zpass_op);
+ cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil[1].ref_value;
+ cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil[1].write_mask;
+ cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil[1].value_mask;
}
/* Not really sure about this:
*/
- if (brw->attribs.DepthStencil->stencil.write_mask[0] ||
- (brw->attribs.DepthStencil->stencil.back_enabled &&
- brw->attribs.DepthStencil->stencil.write_mask[1]))
+ if (brw->attribs.DepthStencil->stencil[0].write_mask ||
+ brw->attribs.DepthStencil->stencil[1].write_mask)
cc.cc0.stencil_write_enable = 1;
}
/* BRW_NEW_ALPHATEST
*/
- if (brw->attribs.AlphaTest->enabled) {
+ if (brw->attribs.DepthStencil->alpha.enabled) {
cc.cc3.alpha_test = 1;
- cc.cc3.alpha_test_func = brw_translate_compare_func(brw->attribs.AlphaTest->func);
+ cc.cc3.alpha_test_func =
+ brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func);
- UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], brw->attribs.AlphaTest->ref);
+ UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0],
+ brw->attribs.DepthStencil->alpha.ref);
cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
}
struct {
- const struct pipe_alpha_test_state *AlphaTest;
const struct pipe_blend_state *Blend;
- const struct pipe_depth_stencil_state *DepthStencil;
+ const struct pipe_depth_stencil_alpha_state *DepthStencil;
const struct pipe_poly_stipple *PolygonStipple;
const struct pipe_rasterizer_state *Raster;
const struct pipe_sampler_state *Samplers[PIPE_MAX_SAMPLERS];
static void *
brw_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)
{
- DUP( pipe_depth_stencil_state, depth_stencil );
+ DUP( pipe_depth_stencil_alpha_state, depth_stencil );
}
static void brw_bind_depth_stencil_state(struct pipe_context *pipe,
{
struct brw_context *brw = brw_context(pipe);
- brw->attribs.DepthStencil = (const struct pipe_depth_stencil_state *)depth_stencil;
+ brw->attribs.DepthStencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
brw->state.dirty.brw |= BRW_NEW_DEPTH_STENCIL;
}
free(depth_stencil);
}
-/************************************************************************
- * Alpha test
- */
-static void *
-brw_create_alpha_test_state(struct pipe_context *pipe,
- const struct pipe_alpha_test_state *alpha_test)
-{
- DUP(pipe_alpha_test_state, alpha_test);
-}
-
-static void brw_bind_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.AlphaTest = (const struct pipe_alpha_test_state*)alpha;
-
- brw->state.dirty.brw |= BRW_NEW_ALPHA_TEST;
-}
-
-static void brw_delete_alpha_test_state(struct pipe_context *pipe,
- void *alpha)
-{
- free(alpha);
-}
-
/************************************************************************
* Scissor
*/
void
brw_init_state_functions( struct brw_context *brw )
{
- brw->pipe.create_alpha_test_state = brw_create_alpha_test_state;
- brw->pipe.bind_alpha_test_state = brw_bind_alpha_test_state;
- brw->pipe.delete_alpha_test_state = brw_delete_alpha_test_state;
-
brw->pipe.create_blend_state = brw_create_blend_state;
brw->pipe.bind_blend_state = brw_bind_blend_state;
brw->pipe.delete_blend_state = brw_delete_blend_state;
brw->pipe.bind_sampler_state = brw_bind_sampler_state;
brw->pipe.delete_sampler_state = brw_delete_sampler_state;
- brw->pipe.create_depth_stencil_state = brw_create_depth_stencil_state;
- brw->pipe.bind_depth_stencil_state = brw_bind_depth_stencil_state;
- brw->pipe.delete_depth_stencil_state = brw_delete_depth_stencil_state;
+ brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
+ brw->pipe.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
+ brw->pipe.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
brw->pipe.create_rasterizer_state = brw_create_rasterizer_state;
brw->pipe.bind_rasterizer_state = brw_bind_rasterizer_state;
/* Build the index for table lookup
*/
- /* _NEW_COLOR */
+ /* BRW_NEW_DEPTH_STENCIL */
if (fp->UsesKill ||
- brw->attribs.AlphaTest->enabled)
+ brw->attribs.DepthStencil->alpha.enabled)
lookup |= IZ_PS_KILL_ALPHATEST_BIT;
if (fp->ComputesDepth)
lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
- /* _NEW_DEPTH */
if (brw->attribs.DepthStencil->depth.enabled)
lookup |= IZ_DEPTH_TEST_ENABLE_BIT;
brw->attribs.DepthStencil->depth.writemask) /* ?? */
lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
- /* _NEW_STENCIL */
- if (brw->attribs.DepthStencil->stencil.front_enabled) {
+ if (brw->attribs.DepthStencil->stencil[0].enabled) {
lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
- if (brw->attribs.DepthStencil->stencil.write_mask[0] ||
- (brw->attribs.DepthStencil->stencil.back_enabled &&
- brw->attribs.DepthStencil->stencil.write_mask[1]))
+ if (brw->attribs.DepthStencil->stencil[0].write_mask ||
+ brw->attribs.DepthStencil->stencil[1].write_mask)
lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
}
/* BRW_NEW_ALPHA_TEST */
if (fp->UsesKill ||
- brw->attribs.AlphaTest->enabled)
+ brw->attribs.DepthStencil->alpha.enabled)
wm.wm5.program_uses_killpixel = 1;
wm.wm5.enable_8_pix = 1;
/*
* State functions
*/
- void * (*create_alpha_test_state)(struct pipe_context *,
- const struct pipe_alpha_test_state *);
- void (*bind_alpha_test_state)(struct pipe_context *, void *);
- void (*delete_alpha_test_state)(struct pipe_context *, void *);
-
void * (*create_blend_state)(struct pipe_context *,
const struct pipe_blend_state *);
void (*bind_blend_state)(struct pipe_context *, void *);
void (*bind_rasterizer_state)(struct pipe_context *, void *);
void (*delete_rasterizer_state)(struct pipe_context *, void *);
- void * (*create_depth_stencil_state)(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
- void (*bind_depth_stencil_state)(struct pipe_context *, void *);
- void (*delete_depth_stencil_state)(struct pipe_context *, void *);
+ void * (*create_depth_stencil_alpha_state)(struct pipe_context *,
+ const struct pipe_depth_stencil_alpha_state *);
+ void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *);
+ void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *);
void * (*create_fs_state)(struct pipe_context *,
const struct pipe_shader_state *);
ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
};
-struct pipe_depth_stencil_state
+struct pipe_depth_stencil_alpha_state
{
struct {
unsigned enabled:1; /**< depth test enabled? */
unsigned occlusion_count:1; /**< XXX move this elsewhere? */
} 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];
- } stencil;
-};
+ unsigned enabled:1;
+ unsigned func:3; /**< PIPE_FUNC_x */
+ unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */
+ unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */
+ ubyte ref_value;
+ ubyte value_mask;
+ ubyte write_mask;
+ } stencil[2]; /**< [0] = front, [1] = back */
-struct pipe_alpha_test_state {
- unsigned enabled:1;
- unsigned func:3; /**< PIPE_FUNC_x */
- float ref; /**< reference value */
+ struct {
+ unsigned enabled:1;
+ unsigned func:3; /**< PIPE_FUNC_x */
+ float ref; /**< reference value */
+ } alpha;
};
+
struct pipe_blend_state {
unsigned blend_enable:1;
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;
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;
#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;
/* 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;
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 &&
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... */
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 );
}
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;
/* 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 */
#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 *,
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 *);
* 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;
}
{
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
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;
STATETRACKER_SOURCES = \
state_tracker/st_atom.c \
- state_tracker/st_atom_alphatest.c \
state_tracker/st_atom_blend.c \
state_tracker/st_atom_clip.c \
state_tracker/st_atom_constbuf.c \
static const struct st_tracked_state *atoms[] =
{
&st_update_framebuffer,
- &st_update_depth_stencil,
+ &st_update_depth_stencil_alpha,
&st_update_clip,
&st_update_shader,
&st_update_texture,
&st_update_vs_constants,
&st_update_fs_constants,
- &st_update_alpha_test,
&st_update_pixel_transfer
};
const struct st_tracked_state st_update_framebuffer;
const struct st_tracked_state st_update_clip;
-const struct st_tracked_state st_update_depth_stencil;
+const struct st_tracked_state st_update_depth_stencil_alpha;
const struct st_tracked_state st_update_shader;
const struct st_tracked_state st_update_rasterizer;
const struct st_tracked_state st_update_polygon_stipple;
const struct st_tracked_state st_update_texture;
const struct st_tracked_state st_update_fs_constants;
const struct st_tracked_state st_update_vs_constants;
-const struct st_tracked_state st_update_alpha_test;
const struct st_tracked_state st_update_pixel_transfer;
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-
-#include "st_context.h"
-#include "st_cache.h"
-#include "st_atom.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-
-
-/**
- * Convert GLenum stencil func tokens to pipe tokens.
- */
-static GLuint
-gl_alpha_func_to_sp(GLenum func)
-{
- /* Same values, just biased */
- assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
- assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
- assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
- assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
- assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
- assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
- assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
- assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
- assert(func >= GL_NEVER);
- assert(func <= GL_ALWAYS);
- return func - GL_NEVER;
-}
-
-
-static void
-update_alpha_test( struct st_context *st )
-{
- struct pipe_alpha_test_state alpha;
- const struct cso_alpha_test *cso;
-
- memset(&alpha, 0, sizeof(alpha));
-
- if (st->ctx->Color.AlphaEnabled) {
- alpha.enabled = 1;
- alpha.func = gl_alpha_func_to_sp(st->ctx->Color.AlphaFunc);
- alpha.ref = st->ctx->Color.AlphaRef;
- }
- cso = st_cached_alpha_test_state(st, &alpha);
- if (st->state.alpha_test != cso) {
- /* state has changed */
- st->state.alpha_test = cso;
- st->pipe->bind_alpha_test_state(st->pipe, cso->data); /* bind new state */
- }
-}
-
-
-const struct st_tracked_state st_update_alpha_test = {
- .name = "st_update_alpha_test",
- .dirty = {
- .mesa = (_NEW_COLOR),
- .st = 0,
- },
- .update = update_alpha_test
-};
}
static void
-update_depth_stencil(struct st_context *st)
+update_depth_stencil_alpha(struct st_context *st)
{
- struct pipe_depth_stencil_state depth_stencil;
- const struct cso_depth_stencil *cso;
+ struct pipe_depth_stencil_alpha_state depth_stencil;
+ const struct cso_depth_stencil_alpha *cso;
memset(&depth_stencil, 0, sizeof(depth_stencil));
depth_stencil.depth.occlusion_count = 1;
if (st->ctx->Stencil.Enabled) {
- depth_stencil.stencil.front_enabled = 1;
- depth_stencil.stencil.front_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
- depth_stencil.stencil.front_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
- depth_stencil.stencil.front_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
- depth_stencil.stencil.front_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
- depth_stencil.stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff;
- depth_stencil.stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff;
- depth_stencil.stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff;
+ depth_stencil.stencil[0].enabled = 1;
+ depth_stencil.stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
+ depth_stencil.stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
+ depth_stencil.stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
+ depth_stencil.stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
+ depth_stencil.stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff;
+ depth_stencil.stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff;
+ depth_stencil.stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff;
+
if (st->ctx->Stencil.TestTwoSide) {
- depth_stencil.stencil.back_enabled = 1;
- depth_stencil.stencil.back_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
- depth_stencil.stencil.back_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
- depth_stencil.stencil.back_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
- depth_stencil.stencil.back_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
- depth_stencil.stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff;
- depth_stencil.stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff;
- depth_stencil.stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff;
+ depth_stencil.stencil[1].enabled = 1;
+ depth_stencil.stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
+ depth_stencil.stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
+ depth_stencil.stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
+ depth_stencil.stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
+ depth_stencil.stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff;
+ depth_stencil.stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff;
+ depth_stencil.stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff;
}
}
- cso = st_cached_depth_stencil_state(st, &depth_stencil);
+ if (st->ctx->Color.AlphaEnabled) {
+ depth_stencil.alpha.enabled = 1;
+ depth_stencil.alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc);
+ depth_stencil.alpha.ref = st->ctx->Color.AlphaRef;
+ }
+
+ cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
if (st->state.depth_stencil != cso) {
/* state has changed */
st->state.depth_stencil = cso;
- st->pipe->bind_depth_stencil_state(st->pipe, cso->data); /* bind new state */
+ st->pipe->bind_depth_stencil_alpha_state(st->pipe, cso->data); /* bind new state */
}
}
-const struct st_tracked_state st_update_depth_stencil = {
+const struct st_tracked_state st_update_depth_stencil_alpha = {
.name = "st_update_depth_stencil",
.dirty = {
- .mesa = (_NEW_DEPTH|_NEW_STENCIL),
+ .mesa = (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR),
.st = 0,
},
- .update = update_depth_stencil
+ .update = update_depth_stencil_alpha
};
return (struct cso_sampler*)(cso_hash_iter_data(iter));
}
-const struct cso_depth_stencil *
-st_cached_depth_stencil_state(struct st_context *st,
- const struct pipe_depth_stencil_state *templ)
+const struct cso_depth_stencil_alpha *
+st_cached_depth_stencil_alpha_state(struct st_context *st,
+ const struct pipe_depth_stencil_alpha_state *templ)
{
unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_depth_stencil_state));
+ sizeof(struct pipe_depth_stencil_alpha_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_DEPTH_STENCIL,
+ hash_key,
+ CSO_DEPTH_STENCIL_ALPHA,
(void*)templ);
if (cso_hash_iter_is_null(iter)) {
- struct cso_depth_stencil *cso = malloc(sizeof(struct cso_depth_stencil));
- memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_state));
- cso->data = st->pipe->create_depth_stencil_state(st->pipe, &cso->state);
+ struct cso_depth_stencil_alpha *cso = malloc(sizeof(struct cso_depth_stencil_alpha));
+ memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_alpha_state));
+ cso->data = st->pipe->create_depth_stencil_alpha_state(st->pipe, &cso->state);
if (!cso->data)
cso->data = &cso->state;
- iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, cso);
+ iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL_ALPHA, cso);
}
- return (struct cso_depth_stencil*)(cso_hash_iter_data(iter));
+ return (struct cso_depth_stencil_alpha*)(cso_hash_iter_data(iter));
}
const struct cso_rasterizer* st_cached_rasterizer_state(
return (struct cso_vertex_shader*)(cso_hash_iter_data(iter));
}
-const struct cso_alpha_test *
-st_cached_alpha_test_state(struct st_context *st,
- const struct pipe_alpha_test_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_alpha_test_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_ALPHA_TEST,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_alpha_test *cso = malloc(sizeof(struct cso_alpha_test));
- memcpy(&cso->state, templ, sizeof(struct pipe_alpha_test_state));
- cso->data = st->pipe->create_alpha_test_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- iter = cso_insert_state(st->cache, hash_key, CSO_ALPHA_TEST, cso);
- }
- return ((struct cso_alpha_test *)cso_hash_iter_data(iter));
-}
struct pipe_sampler_state;
struct st_context;
-const struct cso_alpha_test *
-st_cached_alpha_test_state(struct st_context *st,
- const struct pipe_alpha_test_state *alpha);
const struct cso_blend *
st_cached_blend_state(struct st_context *st,
st_cached_sampler_state(struct st_context *st,
const struct pipe_sampler_state *sampler);
-const struct cso_depth_stencil *
-st_cached_depth_stencil_state(struct st_context *st,
- const struct pipe_depth_stencil_state *depth_stencil);
+const struct cso_depth_stencil_alpha *
+st_cached_depth_stencil_alpha_state(struct st_context *st,
+ const struct pipe_depth_stencil_alpha_state *depth_stencil);
const struct cso_rasterizer *
st_cached_rasterizer_state(struct st_context *st,
const GLfloat x1 = ctx->DrawBuffer->_Xmax;
const GLfloat y1 = ctx->DrawBuffer->_Ymax;
- /* alpha state: disabled */
- {
- struct pipe_alpha_test_state alpha_test;
- const struct cso_alpha_test *cso;
- memset(&alpha_test, 0, sizeof(alpha_test));
- cso = st_cached_alpha_test_state(st, &alpha_test);
- pipe->bind_alpha_test_state(pipe, cso->data);
- }
/* blend state: RGBA masking */
{
/* depth_stencil state: always pass/set to ref value */
{
- struct pipe_depth_stencil_state depth_stencil;
- const struct cso_depth_stencil *cso;
+ struct pipe_depth_stencil_alpha_state depth_stencil;
+ const struct cso_depth_stencil_alpha *cso;
memset(&depth_stencil, 0, sizeof(depth_stencil));
if (depth) {
depth_stencil.depth.enabled = 1;
}
if (stencil) {
- depth_stencil.stencil.front_enabled = 1;
- depth_stencil.stencil.front_func = PIPE_FUNC_ALWAYS;
- depth_stencil.stencil.front_fail_op = PIPE_STENCIL_OP_REPLACE;
- depth_stencil.stencil.front_zpass_op = PIPE_STENCIL_OP_REPLACE;
- depth_stencil.stencil.front_zfail_op = PIPE_STENCIL_OP_REPLACE;
- depth_stencil.stencil.ref_value[0] = ctx->Stencil.Clear;
- depth_stencil.stencil.value_mask[0] = 0xff;
- depth_stencil.stencil.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff;
+ depth_stencil.stencil[0].enabled = 1;
+ depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS;
+ depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
+ depth_stencil.stencil[0].ref_value = ctx->Stencil.Clear;
+ depth_stencil.stencil[0].value_mask = 0xff;
+ depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff;
}
- cso = st_cached_depth_stencil_state(st, &depth_stencil);
- pipe->bind_depth_stencil_state(pipe, cso->data);
+ cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
+ pipe->bind_depth_stencil_alpha_state(pipe, cso->data);
}
/* rasterizer state: nothing */
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
/* Restore pipe state */
- pipe->bind_alpha_test_state(pipe, st->state.alpha_test->data);
pipe->bind_blend_state(pipe, st->state.blend->data);
- pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil->data);
+ pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data);
pipe->bind_fs_state(pipe, st->state.fs->data);
pipe->bind_vs_state(pipe, st->state.vs->data);
pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
static GLboolean
any_fragment_ops(const struct st_context *st)
{
- if (st->state.alpha_test->state.enabled ||
+ if (st->state.depth_stencil->state.alpha.enabled ||
st->state.blend->state.blend_enable ||
st->state.blend->state.logicop_enable ||
st->state.depth_stencil->state.depth.enabled)
const struct cso_alpha_test *alpha_test;
const struct cso_blend *blend;
const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS];
- const struct cso_depth_stencil *depth_stencil;
+ const struct cso_depth_stencil_alpha *depth_stencil;
const struct cso_rasterizer *rasterizer;
const struct cso_fragment_shader *fs;
const struct cso_vertex_shader *vs;