summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric R. Smith <eric.smith@collabora.com>2024-06-04 13:38:21 -0300
committerEric Engestrom <eric@engestrom.ch>2024-08-14 11:51:13 +0200
commit3f8d9068e1c22f93530cb8352e0ae6631c49fe50 (patch)
treebd1feb0155a9d32e6551bdd03ccf23cd452d6b17
parent3610b26a3ed85615b59c307c7ee7a24a3e6ec2cb (diff)
panfrost: use RGB1 component ordering for R5G6B5 pixel formats
For some purposes (e.g. advanced blending) we need a non-zero alpha value returned from reads. This is only guaranteed on Bifrost if we explicitly request RGB1 component ordering. The default is to use RGBA component ordering, which for R5G6B5 causes 0 to be read for alpha. A complication is that the Mali fixed function hardware requires four components (which implies RGBA rather than RGB1). If fixed function blending is in use, we modify the pixel format back to RGBA when building the blend descriptor. Cc: mesa-stable Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29606> (cherry picked from commit 004e0eb3ab854957bdb798142678765360b7104b)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/panfrost/pan_cmdstream.c12
-rw-r--r--src/panfrost/lib/pan_format.c44
3 files changed, 33 insertions, 25 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 393d433dd29..8fe1d748157 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2774,7 +2774,7 @@
"description": "panfrost: use RGB1 component ordering for R5G6B5 pixel formats",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 52bacb01b31..35b82c6ef7b 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -47,6 +47,7 @@
#include "pan_cmdstream.h"
#include "pan_context.h"
#include "pan_csf.h"
+#include "pan_format.h"
#include "pan_indirect_dispatch.h"
#include "pan_jm.h"
#include "pan_job.h"
@@ -387,6 +388,17 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
panfrost_dithered_format_from_pipe_format)(format, dithered);
cfg.fixed_function.rt = i;
+#if PAN_ARCH >= 7
+ if (cfg.mode == MALI_BLEND_MODE_FIXED_FUNCTION &&
+ (cfg.fixed_function.conversion.memory_format & 0xff) ==
+ MALI_RGB_COMPONENT_ORDER_RGB1) {
+ /* fixed function does not like RGB1 as the component order */
+ /* force this field to be the default 0 (RGBA) */
+ cfg.fixed_function.conversion.memory_format &= ~0xff;
+ cfg.fixed_function.conversion.memory_format |=
+ MALI_RGB_COMPONENT_ORDER_RGBA;
+ }
+#endif
#if PAN_ARCH <= 7
if (!info.opaque) {
cfg.fixed_function.alpha_zero_nop = info.alpha_zero_nop;
diff --git a/src/panfrost/lib/pan_format.c b/src/panfrost/lib/pan_format.c
index c5cccee8993..20513c65990 100644
--- a/src/panfrost/lib/pan_format.c
+++ b/src/panfrost/lib/pan_format.c
@@ -30,18 +30,26 @@
/* Convenience */
-#define MALI_BLEND_AU_R8G8B8A8 (MALI_RGBA8_TB << 12)
-#define MALI_BLEND_PU_R8G8B8A8 (MALI_RGBA8_TB << 12)
-#define MALI_BLEND_AU_R10G10B10A2 (MALI_RGB10_A2_TB << 12)
-#define MALI_BLEND_PU_R10G10B10A2 (MALI_RGB10_A2_TB << 12)
-#define MALI_BLEND_AU_R8G8B8A2 (MALI_RGB8_A2_AU << 12)
-#define MALI_BLEND_PU_R8G8B8A2 (MALI_RGB8_A2_PU << 12)
-#define MALI_BLEND_AU_R4G4B4A4 (MALI_RGBA4_AU << 12)
-#define MALI_BLEND_PU_R4G4B4A4 (MALI_RGBA4_PU << 12)
-#define MALI_BLEND_AU_R5G6B5A0 (MALI_R5G6B5_AU << 12)
-#define MALI_BLEND_PU_R5G6B5A0 (MALI_R5G6B5_PU << 12)
-#define MALI_BLEND_AU_R5G5B5A1 (MALI_RGB5_A1_AU << 12)
-#define MALI_BLEND_PU_R5G5B5A1 (MALI_RGB5_A1_PU << 12)
+#if PAN_ARCH == 6
+#define MALI_RGBA_SWIZZLE PAN_V6_SWIZZLE(R, G, B, A)
+#define MALI_RGB1_SWIZZLE PAN_V6_SWIZZLE(R, G, B, A)
+#else
+#define MALI_RGBA_SWIZZLE MALI_RGB_COMPONENT_ORDER_RGBA
+#define MALI_RGB1_SWIZZLE MALI_RGB_COMPONENT_ORDER_RGB1
+#endif
+
+#define MALI_BLEND_AU_R8G8B8A8 (MALI_RGBA8_TB << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_PU_R8G8B8A8 (MALI_RGBA8_TB << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_AU_R10G10B10A2 (MALI_RGB10_A2_TB << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_PU_R10G10B10A2 (MALI_RGB10_A2_TB << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_AU_R8G8B8A2 (MALI_RGB8_A2_AU << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_PU_R8G8B8A2 (MALI_RGB8_A2_PU << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_AU_R4G4B4A4 (MALI_RGBA4_AU << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_PU_R4G4B4A4 (MALI_RGBA4_PU << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_AU_R5G6B5A0 (MALI_R5G6B5_AU << 12) | MALI_RGB1_SWIZZLE
+#define MALI_BLEND_PU_R5G6B5A0 (MALI_R5G6B5_PU << 12) | MALI_RGB1_SWIZZLE
+#define MALI_BLEND_AU_R5G5B5A1 (MALI_RGB5_A1_AU << 12) | MALI_RGBA_SWIZZLE
+#define MALI_BLEND_PU_R5G5B5A1 (MALI_RGB5_A1_PU << 12) | MALI_RGBA_SWIZZLE
#if PAN_ARCH <= 5
#define BFMT2(pipe, internal, writeback, srgb) \
@@ -50,18 +58,6 @@
MALI_COLOR_FORMAT_##writeback, \
{ 0, 0 }, \
}
-#elif PAN_ARCH == 6
-#define BFMT2(pipe, internal, writeback, srgb) \
- [PIPE_FORMAT_##pipe] = { \
- MALI_COLOR_BUFFER_INTERNAL_FORMAT_##internal, \
- MALI_COLOR_FORMAT_##writeback, \
- { \
- 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] = { \