Convert the i915 driver blend state to the new semantics.

This commit is contained in:
Zack Rusin
2007-09-19 13:05:58 -04:00
parent c0bf732208
commit b6d50abd7d
4 changed files with 88 additions and 82 deletions
+7 -2
View File
@@ -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;
+75 -8
View File
@@ -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);
}
+4 -42
View File
@@ -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 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);
}
}
unsigned iab = i915->blend->iab;
set_dynamic_indirect( i915,
set_dynamic_indirect( i915,
I915_DYNAMIC_IAB,
&iab,
1 );
@@ -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
*/