panfrost: Use _PU for non-dithered formats

This is required to disable dithering on a per-draw basis when OPAQUE
output is used (bypassing the blender which normally uses the
round_to_framebuffer_precision flag to do the same).

This functionally reverts:

   ebc07f4b2f ("panfrost: Remove padded unorm blendable formats")
   fae90a7940 ("panfrost: Always pick dithered tb formats")

while adding the functionality to make them useful.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12152>
This commit is contained in:
Alyssa Rosenzweig 2021-08-10 12:58:56 -04:00 committed by Marge Bot
parent 07607c8443
commit 7eb2559198
10 changed files with 28 additions and 19 deletions

View file

@ -236,6 +236,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, mali_ptr *blend_sha
unsigned rt_count = batch->key.nr_cbufs;
struct panfrost_context *ctx = batch->ctx;
const struct panfrost_blend_state *so = ctx->blend;
bool dithered = so->base.dither;
/* Always have at least one render target for depth-only passes */
for (unsigned i = 0; i < MAX2(rt_count, 1); ++i) {
@ -262,7 +263,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, mali_ptr *blend_sha
pan_pack(packed, BLEND, cfg) {
cfg.srgb = util_format_is_srgb(format);
cfg.load_destination = info.load_dest;
cfg.round_to_fb_precision = !ctx->blend->base.dither;
cfg.round_to_fb_precision = !dithered;
cfg.alpha_to_one = ctx->blend->base.alpha_to_one;
#if PAN_ARCH >= 6
cfg.bifrost.constant = pack_blend_constant(format, cons);
@ -317,7 +318,7 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, mali_ptr *blend_sha
*/
cfg.fixed_function.num_comps = 4;
cfg.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, format);
panfrost_format_to_bifrost_blend(dev, format, dithered);
cfg.fixed_function.conversion.register_format =
fs->info.bifrost.blend[i].format;
cfg.fixed_function.rt = i;
@ -884,7 +885,7 @@ panfrost_upload_rt_conversion_sysval(struct panfrost_batch *batch,
if (rt < batch->key.nr_cbufs && batch->key.cbufs[rt]) {
enum pipe_format format = batch->key.cbufs[rt]->format;
uniform->u[0] =
pan_blend_get_bifrost_desc(dev, format, rt, size) >> 32;
pan_blend_get_bifrost_desc(dev, format, rt, size, false) >> 32;
} else {
pan_pack(&uniform->u[0], BIFROST_INTERNAL_CONVERSION, cfg)
cfg.memory_format = dev->formats[PIPE_FORMAT_NONE].hw;

View file

@ -526,7 +526,7 @@ pan_blend_create_shader(const struct panfrost_device *dev,
uint64_t
pan_blend_get_bifrost_desc(const struct panfrost_device *dev,
enum pipe_format fmt, unsigned rt,
unsigned force_size)
unsigned force_size, bool dithered)
{
const struct util_format_description *desc = util_format_description(fmt);
uint64_t res;
@ -573,7 +573,7 @@ pan_blend_get_bifrost_desc(const struct panfrost_device *dev,
}
cfg.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, fmt);
panfrost_format_to_bifrost_blend(dev, fmt, dithered);
}
return res;
@ -644,7 +644,7 @@ pan_blend_get_shader_locked(const struct panfrost_device *dev,
if (pan_is_bifrost(dev)) {
inputs.blend.bifrost_blend_desc =
pan_blend_get_bifrost_desc(dev, key.format, key.rt, 0);
pan_blend_get_bifrost_desc(dev, key.format, key.rt, 0, false);
}
struct pan_shader_info info;

View file

@ -144,7 +144,7 @@ pan_blend_create_shader(const struct panfrost_device *dev,
uint64_t
pan_blend_get_bifrost_desc(const struct panfrost_device *dev,
enum pipe_format fmt, unsigned rt,
unsigned force_size);
unsigned force_size, bool dithered);
/* Take blend_shaders.lock before calling this function and release it when
* you're done with the shader variant object.

View file

@ -255,7 +255,7 @@ pan_blitter_emit_bifrost_blend(const struct panfrost_device *dev,
cfg.bifrost.equation.color_mask = 0xf;
cfg.bifrost.internal.fixed_function.num_comps = 4;
cfg.bifrost.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, iview->format);
panfrost_format_to_bifrost_blend(dev, iview->format, false);
cfg.bifrost.internal.fixed_function.conversion.register_format =
blit_type_to_reg_fmt(type);

View file

@ -49,15 +49,18 @@
[PIPE_FORMAT_##pipe] = { \
MALI_COLOR_BUFFER_INTERNAL_FORMAT_## internal, \
MALI_MFBD_COLOR_FORMAT_## writeback, \
MALI_BLEND_AU_ ## internal | (srgb ? (1 << 20) : 0) | \
PAN_V6_SWIZZLE(R, G, B, A) \
{ MALI_BLEND_PU_ ## internal | (srgb ? (1 << 20) : 0) | \
PAN_V6_SWIZZLE(R, G, B, A), \
MALI_BLEND_AU_ ## internal | (srgb ? (1 << 20) : 0) | \
PAN_V6_SWIZZLE(R, G, B, A) } \
}
#else
#define BFMT2(pipe, internal, writeback, srgb) \
[PIPE_FORMAT_##pipe] = { \
MALI_COLOR_BUFFER_INTERNAL_FORMAT_## internal, \
MALI_MFBD_COLOR_FORMAT_## writeback, \
MALI_BLEND_AU_ ## internal | (srgb ? (1 << 20) : 0) \
{ MALI_BLEND_PU_ ## internal | (srgb ? (1 << 20) : 0), \
MALI_BLEND_AU_ ## internal | (srgb ? (1 << 20) : 0) } \
}
#endif

View file

@ -42,7 +42,9 @@ struct panfrost_format {
struct pan_blendable_format {
/* enum mali_color_buffer_internal_format */ uint16_t internal;
/* enum mali_mfbd_color_format */ uint16_t writeback;
mali_pixel_format bifrost;
/* Indexed by the dithered? flag. So _PU first, then _AU */
mali_pixel_format bifrost[2];
};
extern const struct pan_blendable_format panfrost_blendable_formats_v6[PIPE_FORMAT_COUNT];

View file

@ -73,11 +73,12 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
unsigned
panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
enum pipe_format format)
enum pipe_format format,
bool dithered)
{
mali_pixel_format pixfmt = (dev->arch >= 7) ?
panfrost_blendable_formats_v7[format].bifrost :
panfrost_blendable_formats_v6[format].bifrost;
panfrost_blendable_formats_v7[format].bifrost[dithered] :
panfrost_blendable_formats_v6[format].bifrost[dithered];
return pixfmt ?: dev->formats[format].hw;
}

View file

@ -50,6 +50,7 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
unsigned
panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
enum pipe_format format);
enum pipe_format format,
bool dithered);
#endif /* PAN_UTIL_H */

View file

@ -513,6 +513,7 @@ panvk_emit_bifrost_blend(const struct panvk_device *dev,
const struct pan_blend_state *blend = &pipeline->blend.state;
const struct panfrost_device *pdev = &dev->physical_device->pdev;
const struct pan_blend_rt_state *rts = &blend->rts[rt];
bool dithered = false;
pan_pack(bd, BLEND, cfg) {
if (!blend->rt_count || !rts->equation.color_mask) {
@ -523,7 +524,7 @@ panvk_emit_bifrost_blend(const struct panvk_device *dev,
cfg.srgb = util_format_is_srgb(rts->format);
cfg.load_destination = pan_blend_reads_dest(blend->rts[rt].equation);
cfg.round_to_fb_precision = true;
cfg.round_to_fb_precision = !dithered;
const struct util_format_description *format_desc =
util_format_description(rts->format);
@ -552,7 +553,7 @@ panvk_emit_bifrost_blend(const struct panvk_device *dev,
*/
cfg.bifrost.internal.fixed_function.num_comps = 4;
cfg.bifrost.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(pdev, rts->format);
panfrost_format_to_bifrost_blend(pdev, rts->format, dithered);
cfg.bifrost.internal.fixed_function.conversion.register_format =
bifrost_blend_type_from_nir(pipeline->fs.info.bifrost.blend[rt].type);
cfg.bifrost.internal.fixed_function.rt = rt;

View file

@ -272,7 +272,7 @@ panvk_meta_clear_attachments_emit_rsd(struct panfrost_device *pdev,
cfg.bifrost.equation.color_mask = 0xf;
cfg.bifrost.internal.fixed_function.num_comps = 4;
cfg.bifrost.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(pdev, format);
panfrost_format_to_bifrost_blend(pdev, format, false);
cfg.bifrost.internal.fixed_function.conversion.register_format =
shader_info->bifrost.blend[rt].format;
} else {