panfrost: XMLify blend equation
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>
This commit is contained in:
parent
6beac11868
commit
bf6d548787
|
@ -66,7 +66,7 @@ struct panfrost_blend_shader_final {
|
|||
};
|
||||
|
||||
struct panfrost_blend_equation_final {
|
||||
struct mali_blend_equation *equation;
|
||||
struct mali_blend_equation_packed equation;
|
||||
float constant;
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,7 @@ struct panfrost_blend_rt {
|
|||
* fixed-function configuration for this blend state */
|
||||
|
||||
bool has_fixed_function;
|
||||
struct mali_blend_equation equation;
|
||||
struct mali_blend_equation_packed equation;
|
||||
|
||||
/* Mask of blend color components read */
|
||||
unsigned constant_mask;
|
||||
|
|
|
@ -129,12 +129,8 @@ panfrost_create_blend_state(struct pipe_context *pipe,
|
|||
&rt->equation,
|
||||
&rt->constant_mask);
|
||||
|
||||
if (rt->has_fixed_function) {
|
||||
rt->opaque =
|
||||
(rt->equation.rgb_mode == 0x122) &&
|
||||
(rt->equation.alpha_mode == 0x122) &&
|
||||
(rt->equation.color_mask == 0xf);
|
||||
}
|
||||
if (rt->has_fixed_function)
|
||||
rt->opaque = (rt->equation.opaque[0] == 0xf0122122);
|
||||
|
||||
rt->load_dest = util_blend_uses_dest(pipe)
|
||||
|| pipe.colormask != 0xF;
|
||||
|
@ -241,12 +237,12 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
|
|||
rt->constant_mask)) {
|
||||
struct panfrost_blend_final final = {
|
||||
.equation = {
|
||||
.equation = &rt->equation,
|
||||
.equation = rt->equation,
|
||||
.constant = constant
|
||||
},
|
||||
.load_dest = rt->load_dest,
|
||||
.opaque = rt->opaque,
|
||||
.no_colour = (rt->equation.color_mask == 0x0)
|
||||
.no_colour = rt->no_colour
|
||||
};
|
||||
|
||||
return final;
|
||||
|
|
|
@ -342,19 +342,17 @@ panfrost_constant_mask(unsigned *factors, unsigned num_factors)
|
|||
bool
|
||||
panfrost_make_fixed_blend_mode(
|
||||
struct pipe_rt_blend_state blend,
|
||||
struct mali_blend_equation *out,
|
||||
struct mali_blend_equation_packed *out,
|
||||
unsigned *constant_mask)
|
||||
{
|
||||
/* Gallium and Mali represent colour masks identically. XXX: Static
|
||||
* assert for future proof */
|
||||
|
||||
out->color_mask = blend.colormask;
|
||||
|
||||
/* If no blending is enabled, default back on `replace` mode */
|
||||
|
||||
if (!blend.blend_enable) {
|
||||
out->rgb_mode = 0x122;
|
||||
out->alpha_mode = 0x122;
|
||||
pan_pack(out, BLEND_EQUATION, cfg) {
|
||||
cfg.color_mask = blend.colormask;
|
||||
cfg.rgb_mode = cfg.alpha_mode = 0x122;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -384,8 +382,11 @@ panfrost_make_fixed_blend_mode(
|
|||
&alpha_mode))
|
||||
return false;
|
||||
|
||||
out->rgb_mode = rgb_mode;
|
||||
out->alpha_mode = alpha_mode;
|
||||
pan_pack(out, BLEND_EQUATION, cfg) {
|
||||
cfg.color_mask = blend.colormask;
|
||||
cfg.rgb_mode = rgb_mode;
|
||||
cfg.alpha_mode = alpha_mode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ struct panfrost_blend_state;
|
|||
bool
|
||||
panfrost_make_fixed_blend_mode(
|
||||
const struct pipe_rt_blend_state blend,
|
||||
struct mali_blend_equation *out,
|
||||
struct mali_blend_equation_packed *out,
|
||||
unsigned *constant_mask);
|
||||
|
||||
bool
|
||||
|
|
|
@ -610,7 +610,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
|
|||
blend[0].is_shader);
|
||||
|
||||
if (!blend[0].is_shader) {
|
||||
fragmeta->blend.equation = *blend[0].equation.equation;
|
||||
fragmeta->blend.equation = blend[0].equation.equation;
|
||||
fragmeta->blend.constant = blend[0].equation.constant;
|
||||
}
|
||||
|
||||
|
@ -684,7 +684,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
|
|||
const struct util_format_description *format_desc;
|
||||
format_desc = util_format_description(format);
|
||||
|
||||
brts[i].equation = *blend[i].equation.equation;
|
||||
brts[i].equation = blend[i].equation.equation;
|
||||
|
||||
/* TODO: this is a bit more complicated */
|
||||
brts[i].constant = blend[i].equation.constant;
|
||||
|
@ -705,7 +705,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
|
|||
if (blend[i].is_shader) {
|
||||
mrts[i].blend.shader = blend[i].shader.gpu | blend[i].shader.first_tag;
|
||||
} else {
|
||||
mrts[i].blend.equation = *blend[i].equation.equation;
|
||||
mrts[i].blend.equation = blend[i].equation.equation;
|
||||
mrts[i].blend.constant = blend[i].equation.constant;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,18 +135,6 @@ struct mali_blend_mode {
|
|||
unsigned complement_dominant : 1;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct mali_blend_equation {
|
||||
/* Of type mali_blend_mode */
|
||||
unsigned rgb_mode : 12;
|
||||
unsigned alpha_mode : 12;
|
||||
|
||||
unsigned zero1 : 4;
|
||||
|
||||
/* Corresponds to MALI_MASK_* above and glColorMask arguments */
|
||||
|
||||
unsigned color_mask : 4;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* Compressed per-pixel formats. Each of these formats expands to one to four
|
||||
* floating-point or integer numbers, as defined by the OpenGL specification.
|
||||
* There are various places in OpenGL where the user can specify a compressed
|
||||
|
@ -281,7 +269,7 @@ union midgard_blend {
|
|||
mali_ptr shader;
|
||||
|
||||
struct {
|
||||
struct mali_blend_equation equation;
|
||||
struct mali_blend_equation_packed equation;
|
||||
float constant;
|
||||
};
|
||||
};
|
||||
|
@ -324,7 +312,7 @@ struct bifrost_blend_rt {
|
|||
*/
|
||||
u16 constant;
|
||||
|
||||
struct mali_blend_equation equation;
|
||||
struct mali_blend_equation_packed equation;
|
||||
|
||||
/*
|
||||
* - 0x19 normally
|
||||
|
|
|
@ -228,16 +228,6 @@ static const struct pandecode_flag_info clear_flag_info[] = {
|
|||
};
|
||||
#undef FLAG_INFO
|
||||
|
||||
#define FLAG_INFO(flag) { MALI_MASK_##flag, "MALI_MASK_" #flag }
|
||||
static const struct pandecode_flag_info mask_flag_info[] = {
|
||||
FLAG_INFO(R),
|
||||
FLAG_INFO(G),
|
||||
FLAG_INFO(B),
|
||||
FLAG_INFO(A),
|
||||
{}
|
||||
};
|
||||
#undef FLAG_INFO
|
||||
|
||||
#define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
|
||||
static const struct pandecode_flag_info u3_flag_info[] = {
|
||||
FLAG_INFO(HAS_MSAA),
|
||||
|
@ -1147,26 +1137,6 @@ pandecode_shader_address(const char *name, mali_ptr ptr)
|
|||
return shader_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
pandecode_blend_equation(const struct mali_blend_equation *blend)
|
||||
{
|
||||
if (blend->zero1)
|
||||
pandecode_msg("XXX: blend zero tripped: %X\n", blend->zero1);
|
||||
|
||||
pandecode_log(".equation = {\n");
|
||||
pandecode_indent++;
|
||||
|
||||
pandecode_prop("rgb_mode = 0x%X", blend->rgb_mode);
|
||||
pandecode_prop("alpha_mode = 0x%X", blend->alpha_mode);
|
||||
|
||||
pandecode_log(".color_mask = ");
|
||||
pandecode_log_decoded_flags(mask_flag_info, blend->color_mask);
|
||||
pandecode_log_cont(",\n");
|
||||
|
||||
pandecode_indent--;
|
||||
pandecode_log("},\n");
|
||||
}
|
||||
|
||||
/* Decodes a Bifrost blend constant. See the notes in bifrost_blend_rt */
|
||||
|
||||
static unsigned
|
||||
|
@ -1192,7 +1162,7 @@ pandecode_bifrost_blend(void *descs, int job_no, int rt_no)
|
|||
b->constant, decode_bifrost_constant(b->constant));
|
||||
|
||||
/* TODO figure out blend shader enable bit */
|
||||
pandecode_blend_equation(&b->equation);
|
||||
DUMP_CL("Equation", BLEND_EQUATION, &b->equation, 2);
|
||||
|
||||
pandecode_prop("unk2 = 0x%" PRIx16, b->unk2);
|
||||
pandecode_prop("index = 0x%" PRIx16, b->index);
|
||||
|
@ -1258,7 +1228,7 @@ pandecode_midgard_blend(union midgard_blend *blend, bool is_shader)
|
|||
if (is_shader) {
|
||||
pandecode_shader_address("shader", blend->shader);
|
||||
} else {
|
||||
pandecode_blend_equation(&blend->equation);
|
||||
DUMP_CL("Equation", BLEND_EQUATION, &blend->equation, 2);
|
||||
pandecode_prop("constant = %f", blend->constant);
|
||||
}
|
||||
|
||||
|
|
|
@ -256,6 +256,12 @@
|
|||
<field name="Divisor" size="32" start="3:0" type="uint"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Blend Equation" size="1">
|
||||
<field name="RGB Mode" size="12" start="0" type="uint"/>
|
||||
<field name="Alpha Mode" size="12" start="12" type="uint"/>
|
||||
<field name="Color mask" size="4" start="28" type="uint" default="15"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Blend Flags" size="1">
|
||||
<field name="Load destination" size="1" start="0" type="bool" default="false"/>
|
||||
<field name="Midgard blend shader" size="1" start="1" type="bool" default="false"/>
|
||||
|
|
|
@ -216,12 +216,18 @@ panfrost_load_midg(
|
|||
cfg.depth_pass = MALI_STENCIL_OP_REPLACE;
|
||||
};
|
||||
|
||||
struct mali_blend_equation_packed eq;
|
||||
|
||||
pan_pack(&eq, BLEND_EQUATION, cfg) {
|
||||
cfg.rgb_mode = 0x122;
|
||||
cfg.alpha_mode = 0x122;
|
||||
|
||||
if (loc < FRAG_RESULT_DATA0)
|
||||
cfg.color_mask = 0x0;
|
||||
}
|
||||
|
||||
union midgard_blend replace = {
|
||||
.equation = {
|
||||
.rgb_mode = 0x122,
|
||||
.alpha_mode = 0x122,
|
||||
.color_mask = MALI_MASK_R | MALI_MASK_G | MALI_MASK_B | MALI_MASK_A,
|
||||
}
|
||||
.equation = eq
|
||||
};
|
||||
|
||||
if (blend_shader)
|
||||
|
@ -269,9 +275,6 @@ panfrost_load_midg(
|
|||
if (pool->dev->quirks & MIDGARD_SFBD) {
|
||||
shader_meta.unknown2_4 |= (0x10 | MALI_NO_DITHER);
|
||||
shader_meta.blend = replace;
|
||||
|
||||
if (loc < FRAG_RESULT_DATA0)
|
||||
shader_meta.blend.equation.color_mask = 0x0;
|
||||
}
|
||||
|
||||
if (loc == FRAG_RESULT_DEPTH) {
|
||||
|
|
Loading…
Reference in New Issue