panfrost: Simplify make_fixed_blend_mode prototype
blend_rt is a bitfield so in practice it will be quite small, let's save
the indirection.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>
diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c
index ffda119..1d0b2ba 100644
--- a/src/gallium/drivers/panfrost/pan_blend_cso.c
+++ b/src/gallium/drivers/panfrost/pan_blend_cso.c
@@ -110,25 +110,23 @@
assert(!blend->alpha_to_one);
for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
+ unsigned g = blend->independent_blend_enable ? c : 0;
+ struct pipe_rt_blend_state pipe = blend->rt[g];
+
struct panfrost_blend_rt *rt = &so->rt[c];
+ rt->shaders = _mesa_hash_table_u64_create(so);
- /* There are two paths. First, we would like to try a
- * fixed-function if we can */
-
- /* Without indep blending, the first RT settings replicate */
-
- if (!blend->logicop_enable) {
- unsigned g =
- blend->independent_blend_enable ? c : 0;
-
- rt->has_fixed_function =
- panfrost_make_fixed_blend_mode(
- &blend->rt[g],
- &rt->equation,
- &rt->constant_mask,
- blend->rt[g].colormask);
+ /* Logic ops are always shader */
+ if (blend->logicop_enable) {
+ continue;
}
+ rt->has_fixed_function =
+ panfrost_make_fixed_blend_mode(
+ pipe,
+ &rt->equation,
+ &rt->constant_mask);
+
/* Regardless if that works, we also need to initialize
* the blend shaders */
diff --git a/src/gallium/drivers/panfrost/pan_blending.c b/src/gallium/drivers/panfrost/pan_blending.c
index 458ab51..e112288 100644
--- a/src/gallium/drivers/panfrost/pan_blending.c
+++ b/src/gallium/drivers/panfrost/pan_blending.c
@@ -341,19 +341,18 @@
bool
panfrost_make_fixed_blend_mode(
- const struct pipe_rt_blend_state *blend,
+ struct pipe_rt_blend_state blend,
struct mali_blend_equation *out,
- unsigned *constant_mask,
- unsigned colormask)
+ unsigned *constant_mask)
{
/* Gallium and Mali represent colour masks identically. XXX: Static
* assert for future proof */
- out->color_mask = colormask;
+ out->color_mask = blend.colormask;
/* If no blending is enabled, default back on `replace` mode */
- if (!blend->blend_enable) {
+ if (!blend.blend_enable) {
out->rgb_mode = 0x122;
out->alpha_mode = 0x122;
return true;
@@ -364,8 +363,8 @@
* fixed-function blending */
unsigned factors[] = {
- blend->rgb_src_factor, blend->rgb_dst_factor,
- blend->alpha_src_factor, blend->alpha_dst_factor,
+ 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));
@@ -376,12 +375,12 @@
unsigned alpha_mode = 0;
if (!panfrost_make_fixed_blend_part(
- blend->rgb_func, blend->rgb_src_factor, blend->rgb_dst_factor,
+ blend.rgb_func, blend.rgb_src_factor, blend.rgb_dst_factor,
&rgb_mode))
return false;
if (!panfrost_make_fixed_blend_part(
- blend->alpha_func, blend->alpha_src_factor, blend->alpha_dst_factor,
+ blend.alpha_func, blend.alpha_src_factor, blend.alpha_dst_factor,
&alpha_mode))
return false;
diff --git a/src/gallium/drivers/panfrost/pan_blending.h b/src/gallium/drivers/panfrost/pan_blending.h
index 4ceaf16..123b1d1 100644
--- a/src/gallium/drivers/panfrost/pan_blending.h
+++ b/src/gallium/drivers/panfrost/pan_blending.h
@@ -33,10 +33,9 @@
bool
panfrost_make_fixed_blend_mode(
- const struct pipe_rt_blend_state *blend,
+ const struct pipe_rt_blend_state blend,
struct mali_blend_equation *out,
- unsigned *constant_mask,
- unsigned colormask);
+ unsigned *constant_mask);
bool
panfrost_can_fixed_blend(enum pipe_format format);