mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-20 14:20:36 +02:00
panfrost: Move the blend constant mask extraction out of make_fixed_blend_mode()
This way we can get a constant mask for the blend shader case too. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7066>
This commit is contained in:
parent
4441e80355
commit
78ec5225c2
3 changed files with 22 additions and 28 deletions
|
|
@ -125,11 +125,9 @@ panfrost_create_blend_state(struct pipe_context *pipe,
|
|||
continue;
|
||||
}
|
||||
|
||||
rt->constant_mask = panfrost_blend_constant_mask(&pipe);
|
||||
rt->has_fixed_function =
|
||||
panfrost_make_fixed_blend_mode(
|
||||
pipe,
|
||||
&rt->equation,
|
||||
&rt->constant_mask);
|
||||
panfrost_make_fixed_blend_mode(pipe, &rt->equation);
|
||||
|
||||
/* v6 doesn't support blend constants in FF blend equations. */
|
||||
if (rt->has_fixed_function && version == 6 && rt->constant_mask)
|
||||
|
|
|
|||
|
|
@ -256,22 +256,28 @@ to_panfrost_function(unsigned blend_func,
|
|||
* the factors for constants used to create a mask to check later. */
|
||||
|
||||
static unsigned
|
||||
panfrost_constant_mask(unsigned *factors, unsigned num_factors)
|
||||
panfrost_blend_factor_constant_mask(enum pipe_blendfactor factor)
|
||||
{
|
||||
unsigned mask = 0;
|
||||
|
||||
for (unsigned i = 0; i < num_factors; ++i) {
|
||||
unsigned factor = uncomplement_factor(factors[i]);
|
||||
|
||||
if (factor == PIPE_BLENDFACTOR_CONST_COLOR)
|
||||
mask |= 0b0111; /* RGB */
|
||||
else if (factor == PIPE_BLENDFACTOR_CONST_ALPHA)
|
||||
mask |= 0b1000; /* A */
|
||||
}
|
||||
factor = uncomplement_factor(factor);
|
||||
if (factor == PIPE_BLENDFACTOR_CONST_COLOR)
|
||||
mask |= 0b0111; /* RGB */
|
||||
else if (factor == PIPE_BLENDFACTOR_CONST_ALPHA)
|
||||
mask |= 0b1000; /* A */
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
unsigned
|
||||
panfrost_blend_constant_mask(const struct pipe_rt_blend_state *blend)
|
||||
{
|
||||
return panfrost_blend_factor_constant_mask(blend->rgb_src_factor) |
|
||||
panfrost_blend_factor_constant_mask(blend->rgb_dst_factor) |
|
||||
panfrost_blend_factor_constant_mask(blend->alpha_src_factor) |
|
||||
panfrost_blend_factor_constant_mask(blend->alpha_dst_factor);
|
||||
}
|
||||
|
||||
/* Create the descriptor for a fixed blend mode given the corresponding Gallium
|
||||
* state, if possible. Return true and write out the blend descriptor into
|
||||
* blend_equation. If it is not possible with the fixed function
|
||||
|
|
@ -280,8 +286,7 @@ panfrost_constant_mask(unsigned *factors, unsigned num_factors)
|
|||
|
||||
bool
|
||||
panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state blend,
|
||||
struct MALI_BLEND_EQUATION *equation,
|
||||
unsigned *constant_mask)
|
||||
struct MALI_BLEND_EQUATION *equation)
|
||||
{
|
||||
/* If no blending is enabled, default back on `replace` mode */
|
||||
|
||||
|
|
@ -296,17 +301,6 @@ panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state blend,
|
|||
return true;
|
||||
}
|
||||
|
||||
/* At draw-time, we'll need to analyze the blend constant, so
|
||||
* precompute a mask for it -- even if we don't end up able to use
|
||||
* fixed-function blending */
|
||||
|
||||
unsigned factors[] = {
|
||||
blend.rgb_src_factor, blend.rgb_dst_factor,
|
||||
blend.alpha_src_factor, blend.alpha_dst_factor,
|
||||
};
|
||||
|
||||
*constant_mask = panfrost_constant_mask(factors, ARRAY_SIZE(factors));
|
||||
|
||||
/* Try to compile the actual fixed-function blend */
|
||||
if (!to_panfrost_function(blend.rgb_func, blend.rgb_src_factor,
|
||||
blend.rgb_dst_factor,
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@
|
|||
|
||||
struct panfrost_blend_state;
|
||||
|
||||
unsigned
|
||||
panfrost_blend_constant_mask(const struct pipe_rt_blend_state *blend);
|
||||
|
||||
bool
|
||||
panfrost_make_fixed_blend_mode(const struct pipe_rt_blend_state blend,
|
||||
struct MALI_BLEND_EQUATION *equation,
|
||||
unsigned *constant_mask);
|
||||
struct MALI_BLEND_EQUATION *equation);
|
||||
|
||||
bool
|
||||
panfrost_can_fixed_blend(enum pipe_format format);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue