aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-05-14 14:49:08 -0400
committerMarge Bot <[email protected]>2020-06-01 15:46:23 +0000
commit7de0e5500b6fbab2ed66131a7a54df9f95693a17 (patch)
treea142dc74eca9c42dbda20b2f514eb6e87e8c99a6 /src
parentff590702da3ead33976f3b764de4df78f2aa630a (diff)
panfrost: Un/pack RGB565 and RGB5A1
Basically the same as RGBA4 Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/util/pan_lower_framebuffer.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c
index e0c00decab5..cc432c4c69c 100644
--- a/src/panfrost/util/pan_lower_framebuffer.c
+++ b/src/panfrost/util/pan_lower_framebuffer.c
@@ -299,6 +299,40 @@ pan_unpack_unorm_4(nir_builder *b, nir_ssa_def *v)
nir_imm_ivec4(b, 4, 4, 4, 4));
}
+/* UNORM RGB5_A1 and RGB565 are similar */
+
+static nir_ssa_def *
+pan_pack_unorm_5551(nir_builder *b, nir_ssa_def *v)
+{
+ return pan_pack_unorm_small(b, v,
+ nir_imm_vec4_16(b, 31.0, 31.0, 31.0, 1.0),
+ nir_imm_ivec4(b, 3, 3, 3, 7));
+}
+
+static nir_ssa_def *
+pan_unpack_unorm_5551(nir_builder *b, nir_ssa_def *v)
+{
+ return pan_unpack_unorm_small(b, v,
+ nir_imm_vec4_16(b, 1.0 / 31.0, 1.0 / 31.0, 1.0 / 31.0, 1.0),
+ nir_imm_ivec4(b, 3, 3, 3, 7));
+}
+
+static nir_ssa_def *
+pan_pack_unorm_565(nir_builder *b, nir_ssa_def *v)
+{
+ return pan_pack_unorm_small(b, v,
+ nir_imm_vec4_16(b, 31.0, 63.0, 31.0, 0.0),
+ nir_imm_ivec4(b, 3, 2, 3, 0));
+}
+
+static nir_ssa_def *
+pan_unpack_unorm_565(nir_builder *b, nir_ssa_def *v)
+{
+ return pan_unpack_unorm_small(b, v,
+ nir_imm_vec4_16(b, 1.0 / 31.0, 1.0 / 63.0, 1.0 / 31.0, 0.0),
+ nir_imm_ivec4(b, 3, 2, 3, 0));
+}
+
/* Generic dispatches for un/pack regardless of format */
static bool
@@ -347,6 +381,15 @@ pan_unpack(nir_builder *b,
}
}
+ switch (desc->format) {
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
+ return pan_unpack_unorm_5551(b, packed);
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ return pan_unpack_unorm_565(b, packed);
+ default:
+ break;
+ }
+
fprintf(stderr, "%s\n", desc->name);
unreachable("Unknown format");
}
@@ -381,6 +424,15 @@ pan_pack(nir_builder *b,
}
}
+ switch (desc->format) {
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
+ return pan_pack_unorm_5551(b, unpacked);
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ return pan_pack_unorm_565(b, unpacked);
+ default:
+ break;
+ }
+
fprintf(stderr, "%s\n", desc->name);
unreachable("Unknown format");
}