Let's split them out and work out the metadata at CSO time.
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>
/* Mask of blend color components read */
unsigned constant_mask;
+ /* Properties of the blend mode */
+ bool opaque, load_dest, no_colour;
+
/* Regardless of fixed-function blending, this is a map of pipe_format
* to panfrost_blend_shader */
/* Set for a shader, clear for an equation */
bool is_shader;
- /* Clear if the destination needs to be loaded from the tilebuffer */
- bool no_blending;
+ /* Set if this is the replace mode */
+ bool opaque;
+
+ /* Set if destination is loaded */
+ bool load_dest;
/* Set if the colour mask is 0x0 (nothing is written) */
bool no_colour;
#include <stdio.h>
#include "util/u_memory.h"
+#include "gallium/auxiliary/util/u_blend.h"
#include "pan_blend_shaders.h"
#include "pan_blending.h"
#include "pan_bo.h"
/* Logic ops are always shader */
if (blend->logicop_enable) {
+ rt->load_dest = true;
continue;
}
&rt->equation,
&rt->constant_mask);
- /* Regardless if that works, we also need to initialize
- * the blend shaders */
+ if (rt->has_fixed_function) {
+ rt->opaque =
+ (rt->equation.rgb_mode == 0x122) &&
+ (rt->equation.alpha_mode == 0x122) &&
+ (rt->equation.color_mask == 0xf);
+ }
- rt->shaders = _mesa_hash_table_u64_create(so);
+ rt->load_dest = util_blend_uses_dest(pipe)
+ || pipe.colormask != 0xF;
+
+ rt->no_colour = pipe.colormask == 0x0;
}
return so;
&constant,
ctx->blend_color.color,
rt->constant_mask)) {
- bool no_blending =
- (rt->equation.rgb_mode == 0x122) &&
- (rt->equation.alpha_mode == 0x122) &&
- (rt->equation.color_mask == 0xf);
-
struct panfrost_blend_final final = {
.equation = {
.equation = &rt->equation,
.constant = constant
},
- .no_blending = no_blending,
+ .load_dest = rt->load_dest,
+ .opaque = rt->opaque,
.no_colour = (rt->equation.color_mask == 0x0)
};
.work_count = shader->work_count,
.first_tag = shader->first_tag,
.gpu = bo->gpu,
- }
+ },
+ .load_dest = rt->load_dest,
};
return final;
}
SET_BIT(fragmeta->unknown2_3, MALI_CAN_DISCARD,
- !blend[0].no_blending || fs->can_discard);
+ blend[0].load_dest);
batch->draws |= PIPE_CLEAR_COLOR0;
return;
bool no_blend = true;
for (unsigned i = 0; i < rt_count; ++i)
- no_blend &= (blend[i].no_blending | blend[i].no_colour);
+ no_blend &= (!blend[i].load_dest | blend[i].no_colour);
SET_BIT(fragmeta->bifrost1.unk1, MALI_BIFROST_EARLY_Z,
!fs->can_discard && !fs->writes_depth && no_blend);
unsigned flags = 0;
pan_pack(&flags, BLEND_FLAGS, cfg) {
- if (blend[i].no_colour)
+ if (blend[i].no_colour) {
+ cfg.enable = false;
break;
+ }
batch->draws |= (PIPE_CLEAR_COLOR0 << i);
cfg.srgb = util_format_is_srgb(batch->key.cbufs[i]->format);
- cfg.load_destination = !blend[i].no_blending; /* XXX */
+ cfg.load_destination = blend[i].load_dest;
cfg.dither_disable = !batch->ctx->blend->base.dither;
if (!(dev->quirks & IS_BIFROST))
* mode (equivalent to rgb_mode = alpha_mode =
* x122, colour mask = 0xF). 0x1a allows
* blending. */
- brts[i].unk2 = blend[i].no_blending ? 0x19 : 0x1a;
+ brts[i].unk2 = blend[i].opaque ? 0x19 : 0x1a;
brts[i].shader_type = fs->blend_types[i];
}