mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
panfrost: Honour load_dest/opaque flags
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>
This commit is contained in:
parent
919818a8a0
commit
6beac11868
3 changed files with 31 additions and 17 deletions
|
|
@ -80,6 +80,9 @@ struct panfrost_blend_rt {
|
|||
/* 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 */
|
||||
|
||||
|
|
@ -99,8 +102,11 @@ struct panfrost_blend_final {
|
|||
/* 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;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#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"
|
||||
|
|
@ -118,6 +119,7 @@ panfrost_create_blend_state(struct pipe_context *pipe,
|
|||
|
||||
/* Logic ops are always shader */
|
||||
if (blend->logicop_enable) {
|
||||
rt->load_dest = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +129,17 @@ panfrost_create_blend_state(struct pipe_context *pipe,
|
|||
&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;
|
||||
|
|
@ -230,17 +239,13 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
|
|||
&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)
|
||||
};
|
||||
|
||||
|
|
@ -273,7 +278,8 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
|
|||
.work_count = shader->work_count,
|
||||
.first_tag = shader->first_tag,
|
||||
.gpu = bo->gpu,
|
||||
}
|
||||
},
|
||||
.load_dest = rt->load_dest,
|
||||
};
|
||||
|
||||
return final;
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
@ -625,7 +625,7 @@ panfrost_frag_meta_blend_update(struct panfrost_context *ctx,
|
|||
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);
|
||||
|
|
@ -652,13 +652,15 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
|
|||
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))
|
||||
|
|
@ -693,7 +695,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
|
|||
* 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];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue