mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-14 14:28:08 +02:00
panfrost: Fix blend fixed-function prototype
Needs to be broken up into different functions for disjoint state. Simpler prototypes and allows matching to CSOs. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>
This commit is contained in:
parent
5d3e2b5e9e
commit
b2affb6cc5
3 changed files with 41 additions and 53 deletions
|
|
@ -144,10 +144,16 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc
|
||||||
sizeof(pan_blend.constants));
|
sizeof(pan_blend.constants));
|
||||||
|
|
||||||
/* First, we'll try fixed function, matching equation and constant */
|
/* First, we'll try fixed function, matching equation and constant */
|
||||||
if (pan_blend_can_fixed_function(dev, &pan_blend, rti)) {
|
const struct pan_blend_equation eq = pan_blend.rts[rti].equation;
|
||||||
const struct pan_blend_equation eq = pan_blend.rts[rti].equation;
|
unsigned constant_mask = pan_blend_constant_mask(eq);
|
||||||
unsigned constant_mask = pan_blend_constant_mask(eq);
|
|
||||||
|
|
||||||
|
bool ff = pan_blend_can_fixed_function(eq);
|
||||||
|
ff &= pan_blend_is_homogenous_constant(constant_mask, ctx->blend_color.color);
|
||||||
|
ff &= (pan_blend_supports_constant(dev->arch, rti) || !constant_mask);
|
||||||
|
ff &= !pan_blend.logicop_enable;
|
||||||
|
ff &= panfrost_blendable_formats[fmt].internal;
|
||||||
|
|
||||||
|
if (ff) {
|
||||||
struct panfrost_blend_final final = {
|
struct panfrost_blend_final final = {
|
||||||
.load_dest = pan_blend_reads_dest(pan_blend.rts[rti].equation),
|
.load_dest = pan_blend_reads_dest(pan_blend.rts[rti].equation),
|
||||||
.equation.constant = pan_blend_get_constant(constant_mask, ctx->blend_color.color),
|
.equation.constant = pan_blend_get_constant(constant_mask, ctx->blend_color.color),
|
||||||
|
|
|
||||||
|
|
@ -86,61 +86,34 @@ pan_blend_constant_mask(const struct pan_blend_equation eq)
|
||||||
blend_factor_constant_mask(eq.alpha_dst_factor);
|
blend_factor_constant_mask(eq.alpha_dst_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
/* Only "homogenous" (scalar or vector with all components equal) constants are
|
||||||
can_blend_constant(const struct panfrost_device *dev,
|
* valid for fixed-function, so check for this condition */
|
||||||
const struct pan_blend_state *state,
|
|
||||||
unsigned rt)
|
bool
|
||||||
|
pan_blend_is_homogenous_constant(unsigned mask, float *constants)
|
||||||
{
|
{
|
||||||
unsigned constant_mask = pan_blend_constant_mask(state->rts[rt].equation);
|
float constant = pan_blend_get_constant(mask, constants);
|
||||||
if (!constant_mask)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
/* v6 doesn't support blend constants in FF blend equations. */
|
u_foreach_bit(i, mask) {
|
||||||
if (dev->arch == 6)
|
if (constants[i] != constant)
|
||||||
return false;
|
|
||||||
|
|
||||||
/* v7 only uses the constant from RT 0 (TODO: what if it's the same
|
|
||||||
* constant? or a constant is shared?) */
|
|
||||||
if (dev->arch == 7 && rt > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float constant = pan_blend_get_constant(constant_mask, state->constants);
|
|
||||||
|
|
||||||
u_foreach_bit(i, constant_mask) {
|
|
||||||
if (state->constants[i] != constant)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Determines if an equation can run in fixed function */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pan_blend_can_fixed_function(const struct panfrost_device *dev,
|
pan_blend_can_fixed_function(const struct pan_blend_equation equation)
|
||||||
const struct pan_blend_state *state,
|
|
||||||
unsigned rt)
|
|
||||||
{
|
{
|
||||||
const struct pan_blend_rt_state *rt_state = &state->rts[rt];
|
return !equation.blend_enable ||
|
||||||
|
(can_fixed_function_equation(equation.rgb_func,
|
||||||
/* LogicOp requires a blend shader */
|
equation.rgb_src_factor,
|
||||||
if (state->logicop_enable)
|
equation.rgb_dst_factor) &&
|
||||||
return false;
|
can_fixed_function_equation(equation.alpha_func,
|
||||||
|
equation.alpha_src_factor,
|
||||||
/* Not all formats can be blended by fixed-function hardware */
|
equation.alpha_dst_factor));
|
||||||
if (!panfrost_blendable_formats[rt_state->format].internal)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!rt_state->equation.blend_enable)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!can_blend_constant(dev, state, rt))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return can_fixed_function_equation(rt_state->equation.rgb_func,
|
|
||||||
rt_state->equation.rgb_src_factor,
|
|
||||||
rt_state->equation.rgb_dst_factor) &&
|
|
||||||
can_fixed_function_equation(rt_state->equation.alpha_func,
|
|
||||||
rt_state->equation.alpha_src_factor,
|
|
||||||
rt_state->equation.alpha_dst_factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum mali_blend_operand_c
|
static enum mali_blend_operand_c
|
||||||
|
|
@ -312,8 +285,6 @@ pan_blend_to_fixed_function_equation(ASSERTED const struct panfrost_device *dev,
|
||||||
{
|
{
|
||||||
const struct pan_blend_rt_state *rt_state = &state->rts[rt];
|
const struct pan_blend_rt_state *rt_state = &state->rts[rt];
|
||||||
|
|
||||||
assert(pan_blend_can_fixed_function(dev, state, rt));
|
|
||||||
|
|
||||||
/* If no blending is enabled, default back on `replace` mode */
|
/* If no blending is enabled, default back on `replace` mode */
|
||||||
if (!rt_state->equation.blend_enable) {
|
if (!rt_state->equation.blend_enable) {
|
||||||
equation->color_mask = rt_state->equation.color_mask;
|
equation->color_mask = rt_state->equation.color_mask;
|
||||||
|
|
|
||||||
|
|
@ -100,9 +100,7 @@ bool
|
||||||
pan_blend_reads_dest(const struct pan_blend_equation eq);
|
pan_blend_reads_dest(const struct pan_blend_equation eq);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pan_blend_can_fixed_function(const struct panfrost_device *dev,
|
pan_blend_can_fixed_function(const struct pan_blend_equation equation);
|
||||||
const struct pan_blend_state *state,
|
|
||||||
unsigned rt);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pan_blend_is_opaque(const struct pan_blend_equation eq);
|
pan_blend_is_opaque(const struct pan_blend_equation eq);
|
||||||
|
|
@ -120,6 +118,19 @@ pan_blend_get_constant(unsigned mask, float *constants)
|
||||||
return mask ? constants[ffs(mask) - 1] : 0.0;
|
return mask ? constants[ffs(mask) - 1] : 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* v6 doesn't support blend constants in FF blend equations whatsoever, and v7
|
||||||
|
* only uses the constant from RT 0 (TODO: what if it's the same constant? or a
|
||||||
|
* constant is shared?) */
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
pan_blend_supports_constant(unsigned arch, unsigned rt)
|
||||||
|
{
|
||||||
|
return !((arch == 6) || (arch == 7 && rt > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
pan_blend_is_homogenous_constant(unsigned mask, float *constants);
|
||||||
|
|
||||||
void
|
void
|
||||||
pan_blend_to_fixed_function_equation(const struct panfrost_device *dev,
|
pan_blend_to_fixed_function_equation(const struct panfrost_device *dev,
|
||||||
const struct pan_blend_state *state,
|
const struct pan_blend_state *state,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue