Browse Source

gallium: incorporate alpha state into depth_stencil state object.

tags/mesa_20090313
Keith Whitwell 17 years ago
parent
commit
bfe79babf9
37 changed files with 206 additions and 553 deletions
  1. 0
    4
      src/mesa/pipe/cell/ppu/cell_context.c
  2. 1
    2
      src/mesa/pipe/cell/ppu/cell_context.h
  3. 1
    8
      src/mesa/pipe/cell/ppu/cell_state.h
  4. 5
    35
      src/mesa/pipe/cell/ppu/cell_state_blend.c
  5. 3
    10
      src/mesa/pipe/cso_cache/cso_cache.c
  6. 4
    10
      src/mesa/pipe/cso_cache/cso_cache.h
  7. 0
    1
      src/mesa/pipe/failover/fo_context.h
  8. 9
    51
      src/mesa/pipe/failover/fo_state.c
  9. 2
    6
      src/mesa/pipe/failover/fo_state_emit.c
  10. 0
    4
      src/mesa/pipe/i915simple/i915_context.h
  11. 29
    57
      src/mesa/pipe/i915simple/i915_state.c
  12. 1
    5
      src/mesa/pipe/i915simple/i915_state_immediate.c
  13. 25
    24
      src/mesa/pipe/i965simple/brw_cc.c
  14. 1
    2
      src/mesa/pipe/i965simple/brw_context.h
  15. 6
    36
      src/mesa/pipe/i965simple/brw_state.c
  16. 5
    8
      src/mesa/pipe/i965simple/brw_wm.c
  17. 1
    1
      src/mesa/pipe/i965simple/brw_wm_state.c
  18. 4
    9
      src/mesa/pipe/p_context.h
  19. 16
    20
      src/mesa/pipe/p_state.h
  20. 3
    7
      src/mesa/pipe/softpipe/sp_context.c
  21. 4
    5
      src/mesa/pipe/softpipe/sp_context.h
  22. 4
    4
      src/mesa/pipe/softpipe/sp_quad.c
  23. 2
    2
      src/mesa/pipe/softpipe/sp_quad_alpha_test.c
  24. 7
    18
      src/mesa/pipe/softpipe/sp_quad_stencil.c
  25. 1
    8
      src/mesa/pipe/softpipe/sp_state.h
  26. 6
    32
      src/mesa/pipe/softpipe/sp_state_blend.c
  27. 4
    4
      src/mesa/pipe/softpipe/sp_state_derived.c
  28. 0
    1
      src/mesa/sources
  29. 1
    2
      src/mesa/state_tracker/st_atom.c
  30. 1
    2
      src/mesa/state_tracker/st_atom.h
  31. 0
    92
      src/mesa/state_tracker/st_atom_alphatest.c
  32. 31
    24
      src/mesa/state_tracker/st_atom_depth.c
  33. 11
    29
      src/mesa/state_tracker/st_cache.c
  34. 3
    6
      src/mesa/state_tracker/st_cache.h
  35. 13
    22
      src/mesa/state_tracker/st_cb_clear.c
  36. 1
    1
      src/mesa/state_tracker/st_cb_drawpixels.c
  37. 1
    1
      src/mesa/state_tracker/st_context.h

+ 0
- 4
src/mesa/pipe/cell/ppu/cell_context.c View File

@@ -176,10 +176,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)


/* 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;

+ 1
- 2
src/mesa/pipe/cell/ppu/cell_context.h View File

@@ -40,10 +40,9 @@ struct cell_context

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;

+ 1
- 8
src/mesa/pipe/cell/ppu/cell_state.h View File

@@ -27,13 +27,6 @@ cell_set_framebuffer_state( struct pipe_context *,
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 *);
@@ -57,7 +50,7 @@ cell_delete_sampler_state(struct pipe_context *, void *);

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 *);

+ 5
- 35
src/mesa/pipe/cell/ppu/cell_state_blend.c View File

@@ -69,44 +69,14 @@ void cell_set_blend_color( struct pipe_context *pipe,
}


/** 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;
}

@@ -116,7 +86,7 @@ cell_bind_depth_stencil_state(struct pipe_context *pipe,
{
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;
}

+ 3
- 10
src/mesa/pipe/cso_cache/cso_cache.c View File

@@ -78,7 +78,7 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
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:
@@ -90,9 +90,6 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
case CSO_VERTEX_SHADER:
hash = sc->vs_hash;
break;
case CSO_ALPHA_TEST:
hash = sc->alpha_hash;
break;
}

return hash;
@@ -105,16 +102,14 @@ static int _cso_size_for_type(enum cso_cache_type type)
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;
}
@@ -169,7 +164,6 @@ struct cso_cache *cso_cache_create(void)
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;
}
@@ -183,6 +177,5 @@ void cso_cache_delete(struct cso_cache *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);
}

+ 4
- 10
src/mesa/pipe/cso_cache/cso_cache.h View File

@@ -40,7 +40,6 @@
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;
@@ -54,8 +53,8 @@ struct cso_blend {
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;
};

@@ -79,19 +78,14 @@ struct cso_sampler {
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);

+ 0
- 1
src/mesa/pipe/failover/fo_context.h View File

@@ -70,7 +70,6 @@ struct failover_context {

/* 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;

+ 9
- 51
src/mesa/pipe/failover/fo_state.c View File

@@ -45,45 +45,6 @@
* 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 *
@@ -149,13 +110,13 @@ failover_set_clip_state( struct pipe_context *pipe,

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;
}
@@ -168,7 +129,7 @@ failover_bind_depth_stencil_state(struct pipe_context *pipe,
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
@@ -178,8 +139,8 @@ failover_delete_depth_stencil_state(struct pipe_context *pipe,
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);
@@ -434,18 +395,15 @@ failover_set_vertex_element(struct pipe_context *pipe,
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;

+ 2
- 6
src/mesa/pipe/failover/fo_state_emit.c View File

@@ -55,10 +55,6 @@ failover_state_emit( struct failover_context *failover )
{
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 );
@@ -70,8 +66,8 @@ failover_state_emit( struct failover_context *failover )
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 );

+ 0
- 4
src/mesa/pipe/i915simple/i915_context.h View File

@@ -146,9 +146,6 @@ struct i915_sampler_state {
const struct pipe_sampler_state *templ;
};

struct i915_alpha_test_state {
unsigned LIS6;
};

struct i915_texture {
struct pipe_texture base;
@@ -186,7 +183,6 @@ struct i915_context

/* 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;

+ 29
- 57
src/mesa/pipe/i915simple/i915_state.c View File

@@ -284,13 +284,13 @@ static void i915_delete_sampler_state(struct pipe_context *pipe,

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 |
@@ -299,12 +299,12 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
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 |
@@ -315,14 +315,14 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
(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 |
@@ -363,6 +363,15 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
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;
}

@@ -383,39 +392,6 @@ static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
}


static void *
i915_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha_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 )
{
@@ -674,10 +650,6 @@ static void i915_set_vertex_element( struct pipe_context *pipe,
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;
@@ -686,9 +658,9 @@ 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.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;

+ 1
- 5
src/mesa/pipe/i915simple/i915_state_immediate.c View File

@@ -159,10 +159,6 @@ static void upload_S6( struct i915_context *i915 )
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;
@@ -178,7 +174,7 @@ static void upload_S6( struct i915_context *i915 )
}

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
};


+ 25
- 24
src/mesa/pipe/i965simple/brw_cc.c View File

@@ -156,38 +156,37 @@ static void upload_cc_unit( struct brw_context *brw )
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;
}

@@ -228,11 +227,13 @@ static void upload_cc_unit( struct brw_context *brw )
/* 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;
}

+ 1
- 2
src/mesa/pipe/i965simple/brw_context.h View File

@@ -479,9 +479,8 @@ struct brw_context


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];

+ 6
- 36
src/mesa/pipe/i965simple/brw_state.c View File

@@ -116,9 +116,9 @@ static void brw_delete_sampler_state(struct pipe_context *pipe,

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,
@@ -126,7 +126,7 @@ 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;
}
@@ -137,32 +137,6 @@ static void brw_delete_depth_stencil_state(struct pipe_context *pipe,
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
*/
@@ -415,10 +389,6 @@ static void brw_delete_rasterizer_state(struct pipe_context *pipe,
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;
@@ -427,9 +397,9 @@ brw_init_state_functions( struct brw_context *brw )
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;

+ 5
- 8
src/mesa/pipe/i965simple/brw_wm.c View File

@@ -93,15 +93,14 @@ static void brw_wm_populate_key( struct brw_context *brw,

/* 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;

@@ -109,13 +108,11 @@ static void brw_wm_populate_key( struct brw_context *brw,
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;
}


+ 1
- 1
src/mesa/pipe/i965simple/brw_wm_state.c View File

@@ -122,7 +122,7 @@ static void upload_wm_unit(struct brw_context *brw )

/* 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;

+ 4
- 9
src/mesa/pipe/p_context.h View File

@@ -102,11 +102,6 @@ struct pipe_context {
/*
* 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 *);
@@ -122,10 +117,10 @@ struct pipe_context {
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 *);

+ 16
- 20
src/mesa/pipe/p_state.h View File

@@ -147,7 +147,7 @@ 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? */
@@ -156,28 +156,24 @@ struct pipe_depth_stencil_state
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;


+ 3
- 7
src/mesa/pipe/softpipe/sp_context.c View File

@@ -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;

+ 4
- 5
src/mesa/pipe/softpipe/sp_context.h View File

@@ -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;

+ 4
- 4
src/mesa/pipe/softpipe/sp_quad.c View File

@@ -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 );
}


+ 2
- 2
src/mesa/pipe/softpipe/sp_quad_alpha_test.c View File

@@ -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;

+ 7
- 18
src/mesa/pipe/softpipe/sp_quad_stencil.c View File

@@ -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 */


+ 1
- 8
src/mesa/pipe/softpipe/sp_state.h View File

@@ -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 *);


+ 6
- 32
src/mesa/pipe/softpipe/sp_state_blend.c View File

@@ -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

+ 4
- 4
src/mesa/pipe/softpipe/sp_state_derived.c View File

@@ -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;

+ 0
- 1
src/mesa/sources View File

@@ -201,7 +201,6 @@ PIPEUTIL_SOURCES = \

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 \

+ 1
- 2
src/mesa/state_tracker/st_atom.c View File

@@ -45,7 +45,7 @@
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,
@@ -59,7 +59,6 @@ static const struct st_tracked_state *atoms[] =
&st_update_texture,
&st_update_vs_constants,
&st_update_fs_constants,
&st_update_alpha_test,
&st_update_pixel_transfer
};


+ 1
- 2
src/mesa/state_tracker/st_atom.h View File

@@ -46,7 +46,7 @@ void st_validate_state( struct st_context *st );

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;
@@ -57,7 +57,6 @@ const struct st_tracked_state st_update_sampler;
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;



+ 0
- 92
src/mesa/state_tracker/st_atom_alphatest.c View File

@@ -1,92 +0,0 @@
/**************************************************************************
*
* 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
};

+ 31
- 24
src/mesa/state_tracker/st_atom_depth.c View File

@@ -91,10 +91,10 @@ gl_stencil_op_to_pipe(GLenum func)
}

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));

@@ -107,40 +107,47 @@ update_depth_stencil(struct st_context *st)
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
};

+ 11
- 29
src/mesa/state_tracker/st_cache.c View File

@@ -87,24 +87,25 @@ st_cached_sampler_state(struct st_context *st,
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(
@@ -167,22 +168,3 @@ st_cached_vs_state(struct st_context *st,
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));
}

+ 3
- 6
src/mesa/state_tracker/st_cache.h View File

@@ -39,9 +39,6 @@ struct pipe_blend_state;
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,
@@ -51,9 +48,9 @@ const struct cso_sampler *
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,

+ 13
- 22
src/mesa/state_tracker/st_cb_clear.c View File

@@ -272,14 +272,6 @@ clear_with_quad(GLcontext *ctx,
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 */
{
@@ -304,8 +296,8 @@ clear_with_quad(GLcontext *ctx,

/* 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;
@@ -314,17 +306,17 @@ clear_with_quad(GLcontext *ctx,
}

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 */
@@ -381,9 +373,8 @@ clear_with_quad(GLcontext *ctx,
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);

+ 1
- 1
src/mesa/state_tracker/st_cb_drawpixels.c View File

@@ -789,7 +789,7 @@ compatible_formats(GLenum format, GLenum type, enum pipe_format pipeFormat)
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)

+ 1
- 1
src/mesa/state_tracker/st_context.h View File

@@ -97,7 +97,7 @@ struct st_context
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;

Loading…
Cancel
Save