panfrost: Distribute out constant colour code

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>
This commit is contained in:
Alyssa Rosenzweig 2021-05-14 15:23:44 -04:00 committed by Marge Bot
parent b82ac27ec3
commit 6ca84265e4
3 changed files with 13 additions and 18 deletions

View file

@ -182,12 +182,7 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc
ctx->blend_color.color);
if (ff) {
struct panfrost_blend_final final = {
.equation.constant = pan_blend_get_constant(
blend->info[rti].constant_mask,
ctx->blend_color.color),
};
struct panfrost_blend_final final = {};
return final;
}

View file

@ -44,10 +44,6 @@ struct panfrost_blend_shader_final {
unsigned first_tag;
};
struct panfrost_blend_equation_final {
float constant;
};
struct pan_blend_info {
unsigned constant_mask : 4;
bool fixed_function : 1;
@ -69,11 +65,7 @@ struct panfrost_blend_state {
struct panfrost_blend_final {
/* Set for a shader, clear for an equation */
bool is_shader;
union {
struct panfrost_blend_shader_final shader;
struct panfrost_blend_equation_final equation;
};
struct panfrost_blend_shader_final shader;
};
void

View file

@ -367,7 +367,11 @@ panfrost_emit_bifrost_blend(struct panfrost_batch *batch,
chan_size = MAX2(format_desc->channel[0].size, chan_size);
/* Fixed point constant */
u16 constant = blend[i].equation.constant * ((1 << chan_size) - 1);
float constant_f = pan_blend_get_constant(
info.constant_mask,
ctx->blend_color.color);
u16 constant = constant_f * ((1 << chan_size) - 1);
constant <<= 16 - chan_size;
cfg.bifrost.constant = constant;
@ -439,7 +443,9 @@ panfrost_emit_midgard_blend(struct panfrost_batch *batch,
if (blend[i].is_shader) {
cfg.midgard.shader_pc = blend[i].shader.gpu | blend[i].shader.first_tag;
} else {
cfg.midgard.constant = blend[i].equation.constant;
cfg.midgard.constant = pan_blend_get_constant(
info.constant_mask,
ctx->blend_color.color);
}
}
@ -582,7 +588,9 @@ panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx,
state->sfbd_blend_shader = blend[0].shader.gpu |
blend[0].shader.first_tag;
} else {
state->sfbd_blend_constant = blend[0].equation.constant;
state->sfbd_blend_constant = pan_blend_get_constant(
so->info[0].constant_mask,
ctx->blend_color.color);
}
} else if (dev->quirks & MIDGARD_SFBD) {
/* If there is no colour buffer, leaving fields default is