diff options
author | Chia-I Wu <[email protected]> | 2013-08-08 13:18:17 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-08-08 13:30:34 +0800 |
commit | e292b9362a95569331131a0601a29e8b62ae9d6e (patch) | |
tree | 7a91c7d0edb7984663c45852a1fe6a0fc35129d3 /src | |
parent | 02496cd2b63cb53cd4dba8aa25b35dffc3c5aaa0 (diff) |
ilo: initialize alpha test state in ilo_gpe_init_dsa
This could speed up BLEND_STATE and COLOR_CALC_STATE emission a bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.h | 36 |
5 files changed, 46 insertions, 38 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index 880e10b9688..36441b848e8 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -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; } diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c index 18ec65a85ab..270cde25d84 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c @@ -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) diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h index 73a94304bf4..f0768b9de5c 100644 --- a/src/gallium/drivers/ilo/ilo_gpe.h +++ b/src/gallium/drivers/ilo/ilo_gpe.h @@ -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 { diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.c b/src/gallium/drivers/ilo/ilo_gpe_gen6.c index c64d9f6050f..c086ae5887d 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.c @@ -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 diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.h b/src/gallium/drivers/ilo/ilo_gpe_gen6.h index 2897885cc63..9e5be13accd 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.h +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.h @@ -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; } |