From b6d50abd7d483029469a0faaa28e8e2f2f742c6d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 19 Sep 2007 13:05:58 -0400 Subject: [PATCH] Convert the i915 driver blend state to the new semantics. --- src/mesa/pipe/i915simple/i915_context.h | 9 +- src/mesa/pipe/i915simple/i915_state.c | 83 +++++++++++++++++-- src/mesa/pipe/i915simple/i915_state_dynamic.c | 46 +--------- .../pipe/i915simple/i915_state_immediate.c | 32 +------ 4 files changed, 88 insertions(+), 82 deletions(-) diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 9052c92d72c..ea6d1ce87bc 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -113,7 +113,12 @@ struct i915_state unsigned id; /* track lost context events */ }; - +struct i915_blend_state { + unsigned iab; + unsigned modes4; + unsigned LIS5; + unsigned LIS6; +}; struct i915_context { @@ -123,7 +128,7 @@ struct i915_context /* The most recent drawing state as set by the driver: */ - const struct pipe_blend_state *blend; + const struct i915_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 86c108978fa..4a4d26be659 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -33,7 +33,9 @@ #include "pipe/p_winsys.h" #include "i915_context.h" +#include "i915_reg.h" #include "i915_state.h" +#include "i915_state_inlines.h" /* None of this state is actually used for anything yet. */ @@ -42,25 +44,90 @@ static void * i915_create_blend_state(struct pipe_context *pipe, const struct pipe_blend_state *blend) { - struct pipe_blend_state *new_blend = malloc(sizeof(struct pipe_blend_state)); - memcpy(new_blend, blend, sizeof(struct pipe_blend_state)); + struct i915_blend_state *cso_data = calloc(1, sizeof(struct i915_blend_state)); - return new_blend; + { + unsigned eqRGB = blend->rgb_func; + unsigned srcRGB = blend->rgb_src_factor; + unsigned dstRGB = blend->rgb_dst_factor; + + unsigned eqA = blend->alpha_func; + unsigned srcA = blend->alpha_src_factor; + unsigned dstA = blend->alpha_dst_factor; + + /* Special handling for MIN/MAX filter modes handled at + * state_tracker level. + */ + + if (srcA != srcRGB || + dstA != dstRGB || + eqA != eqRGB) { + + cso_data->iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | + IAB_MODIFY_ENABLE | + IAB_ENABLE | + IAB_MODIFY_FUNC | + IAB_MODIFY_SRC_FACTOR | + IAB_MODIFY_DST_FACTOR | + SRC_ABLND_FACT(i915_translate_blend_factor(srcA)) | + DST_ABLND_FACT(i915_translate_blend_factor(dstA)) | + (i915_translate_blend_func(eqA) << IAB_FUNC_SHIFT)); + } + else { + cso_data->iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | + IAB_MODIFY_ENABLE | + 0); + } + } + + cso_data->modes4 |= (_3DSTATE_MODES_4_CMD | + ENABLE_LOGIC_OP_FUNC | + LOGIC_OP_FUNC(i915_translate_logic_op(blend->logicop_func))); + + if (blend->logicop_enable) + cso_data->LIS5 |= S5_LOGICOP_ENABLE; + + if (blend->dither) + cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE; + + if ((blend->colormask & PIPE_MASK_R) == 0) + cso_data->LIS5 |= S5_WRITEDISABLE_RED; + + if ((blend->colormask & PIPE_MASK_G) == 0) + cso_data->LIS5 |= S5_WRITEDISABLE_GREEN; + + if ((blend->colormask & PIPE_MASK_B) == 0) + cso_data->LIS5 |= S5_WRITEDISABLE_BLUE; + + if ((blend->colormask & PIPE_MASK_A) == 0) + cso_data->LIS5 |= S5_WRITEDISABLE_ALPHA; + + if (blend->blend_enable) { + unsigned funcRGB = blend->rgb_func; + unsigned srcRGB = blend->rgb_src_factor; + unsigned dstRGB = blend->rgb_dst_factor; + + cso_data->LIS6 |= (S6_CBUF_BLEND_ENABLE | + SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) | + DST_BLND_FACT(i915_translate_blend_factor(dstRGB)) | + (i915_translate_blend_func(funcRGB) << S6_CBUF_BLEND_FUNC_SHIFT)); + } + + return cso_data; } -static void i915_bind_blend_state( struct pipe_context *pipe, - void *blend ) +static void i915_bind_blend_state(struct pipe_context *pipe, + void *blend) { struct i915_context *i915 = i915_context(pipe); - i915->blend = (struct pipe_blend_state *)blend; + i915->blend = (struct i915_blend_state*)blend; i915->dirty |= I915_NEW_BLEND; } -static void i915_delete_blend_state( struct pipe_context *pipe, - void *blend ) +static void i915_delete_blend_state(struct pipe_context *pipe, void *blend) { free(blend); } diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index a9791962e2d..262ac947b8c 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -79,12 +79,8 @@ static void upload_MODES4( struct i915_context *i915 ) } /* I915_NEW_BLEND */ - { - modes4 |= (_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | - LOGIC_OP_FUNC(i915_translate_logic_op(i915->blend->logicop_func))); - } - + modes4 |= i915->blend->modes4; + /* Always, so that we know when state is in-active: */ set_dynamic_indirect( i915, @@ -201,44 +197,10 @@ const struct i915_tracked_state i915_upload_BLENDCOLOR = { 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 iab = i915->blend->iab; - 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. - */ - - if (srcA != srcRGB || - dstA != dstRGB || - eqA != eqRGB) { - - iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_ENABLE | - IAB_MODIFY_FUNC | - IAB_MODIFY_SRC_FACTOR | - IAB_MODIFY_DST_FACTOR | - SRC_ABLND_FACT(i915_translate_blend_factor(srcA)) | - DST_ABLND_FACT(i915_translate_blend_factor(dstA)) | - (i915_translate_blend_func(eqA) << IAB_FUNC_SHIFT)); - } - else { - iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - 0); - } - } - - - set_dynamic_indirect( i915, + set_dynamic_indirect( i915, I915_DYNAMIC_IAB, &iab, 1 ); diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index 73508f557fa..38cf2adc716 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -144,25 +144,7 @@ static void upload_S5( struct i915_context *i915 ) (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT)); } - /* I915_NEW_BLEND */ - if (i915->blend->logicop_enable) - LIS5 |= S5_LOGICOP_ENABLE; - - if (i915->blend->dither) - LIS5 |= S5_COLOR_DITHER_ENABLE; - - if ((i915->blend->colormask & PIPE_MASK_R) == 0) - LIS5 |= S5_WRITEDISABLE_RED; - - if ((i915->blend->colormask & PIPE_MASK_G) == 0) - LIS5 |= S5_WRITEDISABLE_GREEN; - - if ((i915->blend->colormask & PIPE_MASK_B) == 0) - LIS5 |= S5_WRITEDISABLE_BLUE; - - if ((i915->blend->colormask & PIPE_MASK_A) == 0) - LIS5 |= S5_WRITEDISABLE_ALPHA; - + LIS5 |= i915->blend->LIS5; #if 0 /* I915_NEW_RASTERIZER */ @@ -205,17 +187,7 @@ static void upload_S6( struct i915_context *i915 ) /* I915_NEW_BLEND */ - 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; - - LIS6 |= (S6_CBUF_BLEND_ENABLE | - SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) | - DST_BLND_FACT(i915_translate_blend_factor(dstRGB)) | - (i915_translate_blend_func(funcRGB) << S6_CBUF_BLEND_FUNC_SHIFT)); - } + LIS6 |= i915->blend->LIS6; /* I915_NEW_DEPTH */ -- 2.30.2