#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"
assert(!blend->alpha_to_one);
for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
- struct panfrost_blend_rt *rt = &so->rt[c];
-
- /* There are two paths. First, we would like to try a
- * fixed-function if we can */
+ unsigned g = blend->independent_blend_enable ? c : 0;
+ struct pipe_rt_blend_state pipe = blend->rt[g];
- /* Without indep blending, the first RT settings replicate */
+ struct panfrost_blend_rt *rt = &so->rt[c];
+ rt->shaders = _mesa_hash_table_u64_create(so);
- if (!blend->logicop_enable) {
- unsigned g =
- blend->independent_blend_enable ? c : 0;
+ /* Logic ops are always shader */
+ if (blend->logicop_enable) {
+ rt->load_dest = true;
+ continue;
+ }
- rt->has_fixed_function =
+ rt->has_fixed_function =
panfrost_make_fixed_blend_mode(
- &blend->rt[g],
+ pipe,
&rt->equation,
- &rt->constant_mask,
- blend->rt[g].colormask);
- }
+ &rt->constant_mask);
- /* Regardless if that works, we also need to initialize
- * the blend shaders */
+ if (rt->has_fixed_function)
+ rt->opaque = (rt->equation.opaque[0] == 0xf0122122);
- 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;
void *cso)
{
struct panfrost_context *ctx = pan_context(pipe);
- struct pipe_blend_state *blend = (struct pipe_blend_state *) cso;
- struct panfrost_blend_state *pblend = (struct panfrost_blend_state *) cso;
- ctx->blend = pblend;
-
- if (!blend)
- return;
+ ctx->blend = (struct panfrost_blend_state *) cso;
}
static void
{
struct panfrost_blend_state *blend = (struct panfrost_blend_state *) cso;
- for (unsigned c = 0; c < 4; ++c) {
+ for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
struct panfrost_blend_rt *rt = &blend->rt[c];
_mesa_hash_table_u64_clear(rt->shaders, panfrost_delete_blend_shader);
}
&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,
+ .equation = rt->equation,
.constant = constant
},
- .no_blending = no_blending,
- .no_colour = (rt->equation.color_mask == 0x0)
+ .load_dest = rt->load_dest,
+ .opaque = rt->opaque,
+ .no_colour = rt->no_colour
};
return final;
.work_count = shader->work_count,
.first_tag = shader->first_tag,
.gpu = bo->gpu,
- }
+ },
+ .load_dest = rt->load_dest,
};
return final;