Mesa (staging/21.1): panfrost: Fix format definitions to match gallium expectations
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 18 20:57:53 UTC 2021
Module: Mesa
Branch: staging/21.1
Commit: aa4fc65a1b1a387f05e9535fcf028a2e33666db4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa4fc65a1b1a387f05e9535fcf028a2e33666db4
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Tue May 4 08:44:35 2021 +0200
panfrost: Fix format definitions to match gallium expectations
Gallium wants the depth or stencil component replicated on all .XYZW.
That's easily done on pre-v7 since we can forge all the swizzles we
want, but Bifrost v7 only supports a few combinations, so we have to
combine the user swizzle with our own 'replicate' swizzle to make it
work. Note that v7 has a trick to make border color work when the GRBA
order is chosen: they apply the red border color to the green component.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10612>
(cherry picked from commit f08c14138aeb13b7d3c9c73574c32c8ec1cf4edd)
---
.pick_status.json | 2 +-
src/panfrost/lib/pan_format.c | 23 ++++++++++++-----------
src/panfrost/lib/pan_texture.c | 20 +++++++++++++++++++-
3 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 52f29411911..a4d012e4f4c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3838,7 +3838,7 @@
"description": "panfrost: Fix format definitions to match gallium expectations",
"nominated": false,
"nomination_type": null,
- "resolution": 4,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/panfrost/lib/pan_format.c b/src/panfrost/lib/pan_format.c
index c3a5f07a2c8..2431406610d 100644
--- a/src/panfrost/lib/pan_format.c
+++ b/src/panfrost/lib/pan_format.c
@@ -99,6 +99,7 @@ panfrost_blend_format(enum pipe_format format)
#define V6_000R PAN_V6_SWIZZLE(0, 0, 0, R)
#define V6_0R00 PAN_V6_SWIZZLE(0, R, 0, 0)
#define V6_0A00 PAN_V6_SWIZZLE(0, A, 0, 0)
+#define V6_AAAA PAN_V6_SWIZZLE(A, A, A, A)
#define V6_A001 PAN_V6_SWIZZLE(A, 0, 0, 1)
#define V6_ABG1 PAN_V6_SWIZZLE(A, B, G, 1)
#define V6_ABGR PAN_V6_SWIZZLE(A, B, G, R)
@@ -241,14 +242,14 @@ const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT] = {
PAN_V6(R32G32B32_SSCALED, RGB32I, RGB1, L, V___),
PAN_V6(R32G32B32A32_SSCALED, RGBA32I, RGBA, L, V___),
PAN_V6(R3G3B2_UNORM, RGB332_UNORM, RGB1, L, VT__),
- PAN_V6(Z16_UNORM, R16_UNORM, R000, L, _T_Z),
- PAN_V6(Z24_UNORM_S8_UINT, Z24X8_UNORM, R000, L, _T_Z),
- PAN_V6(Z24X8_UNORM, Z24X8_UNORM, R000, L, _T_Z),
- PAN_V6(Z32_FLOAT, R32F, R000, L, _T_Z),
- PAN_V6(Z32_FLOAT_S8X24_UINT, R32F, R000, L, _T_Z),
- PAN_V6(X32_S8X24_UINT, R32UI, 0R00, L, _T__),
- PAN_V6(X24S8_UINT, RGBA8UI, 0A00, L, _T_Z),
- PAN_V6(S8_UINT, R8UI, 0R00, L, _T__),
+ PAN_V6(Z16_UNORM, R16_UNORM, RRRR, L, _T_Z),
+ PAN_V6(Z24_UNORM_S8_UINT, Z24X8_UNORM, RRRR, L, _T_Z),
+ PAN_V6(Z24X8_UNORM, Z24X8_UNORM, RRRR, L, _T_Z),
+ PAN_V6(Z32_FLOAT, R32F, RRRR, L, _T_Z),
+ PAN_V6(Z32_FLOAT_S8X24_UINT, R32F, RRRR, L, _T_Z),
+ PAN_V6(X32_S8X24_UINT, R32UI, RRRR, L, _T__),
+ PAN_V6(X24S8_UINT, RGBA8UI, AAAA, L, _T_Z),
+ PAN_V6(S8_UINT, R8UI, RRRR, L, _T__),
PAN_V6(R32_FIXED, R32_FIXED, R001, L, V___),
PAN_V6(R32G32_FIXED, RG32_FIXED, RG01, L, V___),
PAN_V6(R32G32B32_FIXED, RGB32_FIXED, RGB1, L, V___),
@@ -498,9 +499,9 @@ const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT] = {
PAN_V7(Z24X8_UNORM, Z24X8_UNORM, RGBA, L, _T_Z),
PAN_V7(Z32_FLOAT, R32F, RGBA, L, _T_Z),
PAN_V7(Z32_FLOAT_S8X24_UINT, R32F, RGBA, L, _T_Z),
- PAN_V7(X32_S8X24_UINT, S8X24, RGBA, L, _T__),
- PAN_V7(X24S8_UINT, TILEBUFFER_NATIVE /* XXX: Deduplicate enum */, RGBA, L, _T_Z),
- PAN_V7(S8_UINT, S8, RGBA, L, _T__),
+ PAN_V7(X32_S8X24_UINT, S8X24, GRBA, L, _T__),
+ PAN_V7(X24S8_UINT, TILEBUFFER_NATIVE /* XXX: Deduplicate enum */, GRBA, L, _T_Z),
+ PAN_V7(S8_UINT, S8, GRBA, L, _T__),
PAN_V7(R32_FIXED, R32_FIXED, RGB1, L, V___),
PAN_V7(R32G32_FIXED, RG32_FIXED, RGB1, L, V___),
PAN_V7(R32G32B32_FIXED, RGB32_FIXED, RGB1, L, V___),
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index bb4f78cab35..3b895e1076b 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -415,12 +415,30 @@ panfrost_new_texture(const struct panfrost_device *dev,
void *out, const struct panfrost_ptr *payload)
{
const struct pan_image_layout *layout = &iview->image->layout;
- unsigned swizzle = panfrost_translate_swizzle_4(iview->swizzle);
enum pipe_format format = iview->format;
+ unsigned swizzle;
if (drm_is_afbc(layout->modifier))
format = panfrost_afbc_format_fixup(dev, format);
+ if (dev->arch == 7 && util_format_is_depth_or_stencil(format)) {
+ /* v7 doesn't have an _RRRR component order, combine the
+ * user swizzle with a .XXXX swizzle to emulate that.
+ */
+ static const unsigned char replicate_x[4] = {
+ PIPE_SWIZZLE_X, PIPE_SWIZZLE_X,
+ PIPE_SWIZZLE_X, PIPE_SWIZZLE_X,
+ };
+ unsigned char patched_swizzle[4];
+
+ util_format_compose_swizzles(replicate_x,
+ iview->swizzle,
+ patched_swizzle);
+ swizzle = panfrost_translate_swizzle_4(patched_swizzle);
+ } else {
+ swizzle = panfrost_translate_swizzle_4(iview->swizzle);
+ }
+
bool manual_stride =
panfrost_needs_explicit_stride(dev, iview);
More information about the mesa-commit
mailing list