This could speed up BLEND_STATE and COLOR_CALC_STATE emission a bit.
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)
/* 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;
}
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;
}
{
/* 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)
/* DEPTH_STENCIL_STATE */
uint32_t payload[3];
- struct pipe_alpha_state alpha;
+ uint32_t dw_alpha;
+ ubyte alpha_ref;
};
struct ilo_blend_cso {
}
}
+/**
+ * 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,
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;
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
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)
{
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]);
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;
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;
* "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;
}