diff options
author | Zack Rusin <[email protected]> | 2007-09-14 04:08:58 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-09-18 06:31:22 -0400 |
commit | 9780327c5d95586a88fce94d7b47342355ead118 (patch) | |
tree | 9007ea135504d8fd90b49a391a43fa579b9374b5 /src/mesa/pipe/i915simple | |
parent | ffacb1c12a77d71613e8171e31ffc348959881e4 (diff) |
First stab at immutable state objects (create/bind/delete)
We want our state objects to be immutable, handled via the
create/bind/delete calls instead of struct propagation.
Only implementing the blend state to see how it would look like
and work.
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state.c | 29 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_dynamic.c | 14 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_immediate.c | 20 |
4 files changed, 45 insertions, 21 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index c30c79d83c9..215c5294fa6 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -123,8 +123,9 @@ struct i915_context /* The most recent drawing state as set by the driver: */ + const struct pipe_blend_state *blend; + struct pipe_alpha_test_state alpha_test; - struct pipe_blend_state blend; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index f5ea721cc8e..478988fd4a9 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -37,17 +37,37 @@ /* None of this state is actually used for anything yet. */ -static void i915_set_blend_state( struct pipe_context *pipe, + +static const struct pipe_blend_state * +i915_create_blend_state(struct pipe_context *pipe, + const struct pipe_blend_state *blend) +{ + /*struct i915_context *i915 = i915_context(pipe);*/ + + struct pipe_blend_state *new_blend = malloc(sizeof(struct pipe_blend_state)); + memcpy(new_blend, blend, sizeof(struct pipe_blend_state)); + + return new_blend; +} + +static void i915_bind_blend_state( struct pipe_context *pipe, const struct pipe_blend_state *blend ) { struct i915_context *i915 = i915_context(pipe); - i915->blend = *blend; + i915->blend = blend; i915->dirty |= I915_NEW_BLEND; } +static void i915_delete_blend_state( struct pipe_context *pipe, + const struct pipe_blend_state *blend ) +{ + /*struct i915_context *i915 = i915_context(pipe);*/ + free(blend); +} + static void i915_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ) { @@ -289,9 +309,12 @@ static void i915_set_vertex_element( struct pipe_context *pipe, void i915_init_state_functions( struct i915_context *i915 ) { + 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.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; - i915->pipe.set_blend_state = i915_set_blend_state; i915->pipe.set_clip_state = i915_set_clip_state; i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index e648357754f..49a30fac115 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -82,7 +82,7 @@ static void upload_MODES4( struct i915_context *i915 ) { modes4 |= (_3DSTATE_MODES_4_CMD | ENABLE_LOGIC_OP_FUNC | - LOGIC_OP_FUNC(i915_translate_logic_op(i915->blend.logicop_func))); + LOGIC_OP_FUNC(i915_translate_logic_op(i915->blend->logicop_func))); } /* Always, so that we know when state is in-active: @@ -204,13 +204,13 @@ static void upload_IAB( struct i915_context *i915 ) unsigned iab = 0; { - unsigned eqRGB = i915->blend.rgb_func; - unsigned srcRGB = i915->blend.rgb_src_factor; - unsigned dstRGB = i915->blend.rgb_dst_factor; + unsigned eqRGB = i915->blend->rgb_func; + unsigned srcRGB = i915->blend->rgb_src_factor; + unsigned dstRGB = i915->blend->rgb_dst_factor; - unsigned eqA = i915->blend.alpha_func; - unsigned srcA = i915->blend.alpha_src_factor; - unsigned dstA = i915->blend.alpha_dst_factor; + unsigned eqA = i915->blend->alpha_func; + unsigned srcA = i915->blend->alpha_src_factor; + unsigned dstA = i915->blend->alpha_dst_factor; /* Special handling for MIN/MAX filter modes handled at * state_tracker level. diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index 38a24733e12..aaca534f5ad 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -145,22 +145,22 @@ static void upload_S5( struct i915_context *i915 ) } /* I915_NEW_BLEND */ - if (i915->blend.logicop_enable) + if (i915->blend->logicop_enable) LIS5 |= S5_LOGICOP_ENABLE; - if (i915->blend.dither) + if (i915->blend->dither) LIS5 |= S5_COLOR_DITHER_ENABLE; - if ((i915->blend.colormask & PIPE_MASK_R) == 0) + if ((i915->blend->colormask & PIPE_MASK_R) == 0) LIS5 |= S5_WRITEDISABLE_RED; - if ((i915->blend.colormask & PIPE_MASK_G) == 0) + if ((i915->blend->colormask & PIPE_MASK_G) == 0) LIS5 |= S5_WRITEDISABLE_GREEN; - if ((i915->blend.colormask & PIPE_MASK_B) == 0) + if ((i915->blend->colormask & PIPE_MASK_B) == 0) LIS5 |= S5_WRITEDISABLE_BLUE; - if ((i915->blend.colormask & PIPE_MASK_A) == 0) + if ((i915->blend->colormask & PIPE_MASK_A) == 0) LIS5 |= S5_WRITEDISABLE_ALPHA; @@ -205,11 +205,11 @@ static void upload_S6( struct i915_context *i915 ) /* I915_NEW_BLEND */ - if (i915->blend.blend_enable) + if (i915->blend->blend_enable) { - unsigned funcRGB = i915->blend.rgb_func; - unsigned srcRGB = i915->blend.rgb_src_factor; - unsigned dstRGB = i915->blend.rgb_dst_factor; + unsigned funcRGB = i915->blend->rgb_func; + unsigned srcRGB = i915->blend->rgb_src_factor; + unsigned dstRGB = i915->blend->rgb_dst_factor; LIS6 |= (S6_CBUF_BLEND_ENABLE | SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) | |