Mesa (main): panfrost: Use _PU for non-dithered formats
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 18:32:47 UTC 2021
Module: Mesa
Branch: main
Commit: 7eb2559198d730e78b8e73e9af224e98f93cd4f3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7eb2559198d730e78b8e73e9af224e98f93cd4f3
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Tue Aug 10 12:58:56 2021 -0400
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:
ebc07f4b2f3 ("panfrost: Remove padded unorm blendable formats")
fae90a79404 ("panfrost: Always pick dithered tb formats")
while adding the functionality to make them useful.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12152>
---
src/gallium/drivers/panfrost/pan_cmdstream.c | 7 ++++---
src/panfrost/lib/pan_blend.c | 6 +++---
src/panfrost/lib/pan_blend.h | 2 +-
src/panfrost/lib/pan_blitter.c | 2 +-
src/panfrost/lib/pan_format.c | 9 ++++++---
src/panfrost/lib/pan_format.h | 4 +++-
src/panfrost/lib/pan_util.c | 7 ++++---
src/panfrost/lib/pan_util.h | 3 ++-
src/panfrost/vulkan/panvk_cs.c | 5 +++--
src/panfrost/vulkan/panvk_meta.c | 2 +-
10 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 23f6544c191..450dcaf7aaf 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -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;
diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c
index d018f397768..1f55d09177e 100644
--- a/src/panfrost/lib/pan_blend.c
+++ b/src/panfrost/lib/pan_blend.c
@@ -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;
diff --git a/src/panfrost/lib/pan_blend.h b/src/panfrost/lib/pan_blend.h
index 080130202c4..2a95503262a 100644
--- a/src/panfrost/lib/pan_blend.h
+++ b/src/panfrost/lib/pan_blend.h
@@ -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.
diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c
index 13cb0290d04..7aeb985c4b9 100644
--- a/src/panfrost/lib/pan_blitter.c
+++ b/src/panfrost/lib/pan_blitter.c
@@ -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);
diff --git a/src/panfrost/lib/pan_format.c b/src/panfrost/lib/pan_format.c
index d3f645194da..45c0580fcd7 100644
--- a/src/panfrost/lib/pan_format.c
+++ b/src/panfrost/lib/pan_format.c
@@ -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
diff --git a/src/panfrost/lib/pan_format.h b/src/panfrost/lib/pan_format.h
index 244a2f2302e..b0dd038e54a 100644
--- a/src/panfrost/lib/pan_format.h
+++ b/src/panfrost/lib/pan_format.h
@@ -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];
diff --git a/src/panfrost/lib/pan_util.c b/src/panfrost/lib/pan_util.c
index e974b224456..2746ada1491 100644
--- a/src/panfrost/lib/pan_util.c
+++ b/src/panfrost/lib/pan_util.c
@@ -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;
}
diff --git a/src/panfrost/lib/pan_util.h b/src/panfrost/lib/pan_util.h
index 7a84633d303..439085950d7 100644
--- a/src/panfrost/lib/pan_util.h
+++ b/src/panfrost/lib/pan_util.h
@@ -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 */
diff --git a/src/panfrost/vulkan/panvk_cs.c b/src/panfrost/vulkan/panvk_cs.c
index b24cba8d3c8..0623d748bd6 100644
--- a/src/panfrost/vulkan/panvk_cs.c
+++ b/src/panfrost/vulkan/panvk_cs.c
@@ -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;
diff --git a/src/panfrost/vulkan/panvk_meta.c b/src/panfrost/vulkan/panvk_meta.c
index 657a3c4324f..dfe692dd622 100644
--- a/src/panfrost/vulkan/panvk_meta.c
+++ b/src/panfrost/vulkan/panvk_meta.c
@@ -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 {
More information about the mesa-commit
mailing list