mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
ilo: initialize alpha test state in ilo_gpe_init_dsa
This could speed up BLEND_STATE and COLOR_CALC_STATE emission a bit.
This commit is contained in:
parent
02496cd2b6
commit
e292b9362a
5 changed files with 46 additions and 38 deletions
|
|
@ -660,7 +660,7 @@ gen6_pipeline_wm(struct ilo_3d_pipeline *p,
|
|||
DIRTY(RASTERIZER) || session->kernel_bo_changed) {
|
||||
const int num_samplers = ilo->sampler[PIPE_SHADER_FRAGMENT].count;
|
||||
const bool dual_blend = ilo->blend->dual_blend;
|
||||
const bool cc_may_kill = (ilo->dsa->alpha.enabled ||
|
||||
const bool cc_may_kill = (ilo->dsa->dw_alpha ||
|
||||
ilo->blend->alpha_to_coverage);
|
||||
|
||||
if (p->dev->gen == ILO_GEN(6) && session->hw_ctx_changed)
|
||||
|
|
@ -803,7 +803,7 @@ gen6_pipeline_state_cc(struct ilo_3d_pipeline *p,
|
|||
/* BLEND_STATE */
|
||||
if (DIRTY(BLEND) || DIRTY(FB) || DIRTY(DSA)) {
|
||||
p->state.BLEND_STATE = gen6_emit_BLEND_STATE(p->dev,
|
||||
ilo->blend, &ilo->fb, &ilo->dsa->alpha, p->cp);
|
||||
ilo->blend, &ilo->fb, ilo->dsa, p->cp);
|
||||
|
||||
session->cc_state_blend_changed = true;
|
||||
}
|
||||
|
|
@ -812,7 +812,7 @@ gen6_pipeline_state_cc(struct ilo_3d_pipeline *p,
|
|||
if (DIRTY(DSA) || DIRTY(STENCIL_REF) || DIRTY(BLEND_COLOR)) {
|
||||
p->state.COLOR_CALC_STATE =
|
||||
gen6_emit_COLOR_CALC_STATE(p->dev, &ilo->stencil_ref,
|
||||
ilo->dsa->alpha.ref_value, &ilo->blend_color, p->cp);
|
||||
ilo->dsa->alpha_ref, &ilo->blend_color, p->cp);
|
||||
|
||||
session->cc_state_cc_changed = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ gen7_pipeline_wm(struct ilo_3d_pipeline *p,
|
|||
{
|
||||
/* 3DSTATE_WM */
|
||||
if (DIRTY(FS) || DIRTY(BLEND) || DIRTY(DSA) || DIRTY(RASTERIZER)) {
|
||||
const bool cc_may_kill = (ilo->dsa->alpha.enabled ||
|
||||
const bool cc_may_kill = (ilo->dsa->dw_alpha ||
|
||||
ilo->blend->alpha_to_coverage);
|
||||
|
||||
if (p->dev->gen == ILO_GEN(7) && session->hw_ctx_changed)
|
||||
|
|
|
|||
|
|
@ -155,7 +155,8 @@ struct ilo_dsa_state {
|
|||
/* DEPTH_STENCIL_STATE */
|
||||
uint32_t payload[3];
|
||||
|
||||
struct pipe_alpha_state alpha;
|
||||
uint32_t dw_alpha;
|
||||
ubyte alpha_ref;
|
||||
};
|
||||
|
||||
struct ilo_blend_cso {
|
||||
|
|
|
|||
|
|
@ -226,6 +226,28 @@ gen6_translate_shadow_func(unsigned func)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a pipe DSA test function to the matching hardware compare
|
||||
* function.
|
||||
*/
|
||||
static int
|
||||
gen6_translate_dsa_func(unsigned func)
|
||||
{
|
||||
switch (func) {
|
||||
case PIPE_FUNC_NEVER: return BRW_COMPAREFUNCTION_NEVER;
|
||||
case PIPE_FUNC_LESS: return BRW_COMPAREFUNCTION_LESS;
|
||||
case PIPE_FUNC_EQUAL: return BRW_COMPAREFUNCTION_EQUAL;
|
||||
case PIPE_FUNC_LEQUAL: return BRW_COMPAREFUNCTION_LEQUAL;
|
||||
case PIPE_FUNC_GREATER: return BRW_COMPAREFUNCTION_GREATER;
|
||||
case PIPE_FUNC_NOTEQUAL: return BRW_COMPAREFUNCTION_NOTEQUAL;
|
||||
case PIPE_FUNC_GEQUAL: return BRW_COMPAREFUNCTION_GEQUAL;
|
||||
case PIPE_FUNC_ALWAYS: return BRW_COMPAREFUNCTION_ALWAYS;
|
||||
default:
|
||||
assert(!"unknown depth/stencil/alpha test function");
|
||||
return BRW_COMPAREFUNCTION_NEVER;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ve_init_cso(const struct ilo_dev_info *dev,
|
||||
const struct pipe_vertex_element *state,
|
||||
|
|
@ -1585,13 +1607,11 @@ ilo_gpe_init_dsa(const struct ilo_dev_info *dev,
|
|||
const struct pipe_depth_state *depth = &state->depth;
|
||||
const struct pipe_stencil_state *stencil0 = &state->stencil[0];
|
||||
const struct pipe_stencil_state *stencil1 = &state->stencil[1];
|
||||
const struct pipe_alpha_state *alpha = &state->alpha;
|
||||
uint32_t *dw;
|
||||
|
||||
ILO_GPE_VALID_GEN(dev, 6, 7);
|
||||
|
||||
/* copy alpha state for later use */
|
||||
dsa->alpha = state->alpha;
|
||||
|
||||
STATIC_ASSERT(Elements(dsa->payload) >= 3);
|
||||
dw = dsa->payload;
|
||||
|
||||
|
|
@ -1658,6 +1678,17 @@ ilo_gpe_init_dsa(const struct ilo_dev_info *dev,
|
|||
dw[2] |= gen6_translate_dsa_func(depth->func) << 27;
|
||||
else
|
||||
dw[2] |= BRW_COMPAREFUNCTION_ALWAYS << 27;
|
||||
|
||||
/* dw_alpha will be ORed to BLEND_STATE */
|
||||
if (alpha->enabled) {
|
||||
dsa->dw_alpha = 1 << 16 |
|
||||
gen6_translate_dsa_func(alpha->func) << 13;
|
||||
}
|
||||
else {
|
||||
dsa->dw_alpha = 0;
|
||||
}
|
||||
|
||||
dsa->alpha_ref = float_to_ubyte(alpha->ref_value);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -2031,7 +2031,7 @@ gen6_emit_CC_VIEWPORT(const struct ilo_dev_info *dev,
|
|||
static inline uint32_t
|
||||
gen6_emit_COLOR_CALC_STATE(const struct ilo_dev_info *dev,
|
||||
const struct pipe_stencil_ref *stencil_ref,
|
||||
float alpha_ref,
|
||||
ubyte alpha_ref,
|
||||
const struct pipe_blend_color *blend_color,
|
||||
struct ilo_cp *cp)
|
||||
{
|
||||
|
|
@ -2047,7 +2047,7 @@ gen6_emit_COLOR_CALC_STATE(const struct ilo_dev_info *dev,
|
|||
dw[0] = stencil_ref->ref_value[0] << 24 |
|
||||
stencil_ref->ref_value[1] << 16 |
|
||||
BRW_ALPHATEST_FORMAT_UNORM8;
|
||||
dw[1] = float_to_ubyte(alpha_ref);
|
||||
dw[1] = alpha_ref;
|
||||
dw[2] = fui(blend_color->color[0]);
|
||||
dw[3] = fui(blend_color->color[1]);
|
||||
dw[4] = fui(blend_color->color[2]);
|
||||
|
|
@ -2056,33 +2056,11 @@ gen6_emit_COLOR_CALC_STATE(const struct ilo_dev_info *dev,
|
|||
return state_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a pipe DSA test function to the matching hardware compare
|
||||
* function.
|
||||
*/
|
||||
static int
|
||||
gen6_translate_dsa_func(unsigned func)
|
||||
{
|
||||
switch (func) {
|
||||
case PIPE_FUNC_NEVER: return BRW_COMPAREFUNCTION_NEVER;
|
||||
case PIPE_FUNC_LESS: return BRW_COMPAREFUNCTION_LESS;
|
||||
case PIPE_FUNC_EQUAL: return BRW_COMPAREFUNCTION_EQUAL;
|
||||
case PIPE_FUNC_LEQUAL: return BRW_COMPAREFUNCTION_LEQUAL;
|
||||
case PIPE_FUNC_GREATER: return BRW_COMPAREFUNCTION_GREATER;
|
||||
case PIPE_FUNC_NOTEQUAL: return BRW_COMPAREFUNCTION_NOTEQUAL;
|
||||
case PIPE_FUNC_GEQUAL: return BRW_COMPAREFUNCTION_GEQUAL;
|
||||
case PIPE_FUNC_ALWAYS: return BRW_COMPAREFUNCTION_ALWAYS;
|
||||
default:
|
||||
assert(!"unknown depth/stencil/alpha test function");
|
||||
return BRW_COMPAREFUNCTION_NEVER;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
gen6_emit_BLEND_STATE(const struct ilo_dev_info *dev,
|
||||
const struct ilo_blend_state *blend,
|
||||
const struct ilo_fb_state *fb,
|
||||
const struct pipe_alpha_state *alpha,
|
||||
const struct ilo_dsa_state *dsa,
|
||||
struct ilo_cp *cp)
|
||||
{
|
||||
const int state_align = 64 / 4;
|
||||
|
|
@ -2101,7 +2079,7 @@ gen6_emit_BLEND_STATE(const struct ilo_dev_info *dev,
|
|||
assert(num_targets <= 8);
|
||||
|
||||
if (!num_targets) {
|
||||
if (!alpha->enabled)
|
||||
if (!dsa->dw_alpha)
|
||||
return 0;
|
||||
/* to be able to reference alpha func */
|
||||
num_targets = 1;
|
||||
|
|
@ -2195,10 +2173,8 @@ gen6_emit_BLEND_STATE(const struct ilo_dev_info *dev,
|
|||
* "Alpha Test can only be enabled if Pixel Shader outputs a float
|
||||
* alpha value."
|
||||
*/
|
||||
if (alpha->enabled && !rt_is_pure_integer) {
|
||||
dw[1] |= 1 << 16 |
|
||||
gen6_translate_dsa_func(alpha->func) << 13;
|
||||
}
|
||||
if (!rt_is_pure_integer)
|
||||
dw[1] |= dsa->dw_alpha;
|
||||
|
||||
dw += 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue