diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-05-14 18:06:58 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-01 15:46:23 +0000 |
commit | 5d14757c033b78791968390201f2ece564a4c1ce (patch) | |
tree | 9d649fbd8178068db975dae66713257cbf57b817 /src/panfrost | |
parent | e24e248b84a2fbcc70cc1ee5c598e5a942effbce (diff) |
panfrost: Un/pack R11G11B10
NIR has a helper for it already; we can reuse.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/util/pan_lower_framebuffer.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c index c0239c751b3..c21d42ba4ea 100644 --- a/src/panfrost/util/pan_lower_framebuffer.c +++ b/src/panfrost/util/pan_lower_framebuffer.c @@ -416,6 +416,32 @@ pan_unpack_uint_1010102(nir_builder *b, nir_ssa_def *packed) return nir_u2u16(b, mask); } +/* NIR means we can *finally* catch a break */ + +static nir_ssa_def * +pan_pack_r11g11b10(nir_builder *b, nir_ssa_def *v) +{ + return pan_replicate_4(b, nir_format_pack_11f11f10f(b, + nir_f2f32(b, v))); +} + +static nir_ssa_def * +pan_unpack_r11g11b10(nir_builder *b, nir_ssa_def *v) +{ + nir_ssa_def *f32 = nir_format_unpack_11f11f10f(b, nir_channel(b, v, 0)); + nir_ssa_def *f16 = nir_f2f16(b, f32); + + /* Extend to vec4 with alpha */ + nir_ssa_def *components[4] = { + nir_channel(b, f16, 0), + nir_channel(b, f16, 1), + nir_channel(b, f16, 2), + nir_imm_float16(b, 1.0) + }; + + return nir_vec(b, components, 4); +} + /* Generic dispatches for un/pack regardless of format */ static bool @@ -473,6 +499,8 @@ pan_unpack(nir_builder *b, return pan_unpack_unorm_1010102(b, packed); case PIPE_FORMAT_R10G10B10A2_UINT: return pan_unpack_uint_1010102(b, packed); + case PIPE_FORMAT_R11G11B10_FLOAT: + return pan_unpack_r11g11b10(b, packed); default: break; } @@ -520,6 +548,8 @@ pan_pack(nir_builder *b, return pan_pack_unorm_1010102(b, unpacked); case PIPE_FORMAT_R10G10B10A2_UINT: return pan_pack_uint_1010102(b, unpacked); + case PIPE_FORMAT_R11G11B10_FLOAT: + return pan_pack_r11g11b10(b, unpacked); default: break; } |