diff options
author | Roland Scheidegger <[email protected]> | 2014-03-20 16:27:57 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2014-03-21 17:23:38 +0100 |
commit | 2aa77f2777ad35d7fe249939b0d828306f13eade (patch) | |
tree | 9190683a399a45d0c012f39033c49e0569c1c504 /src/gallium | |
parent | 19ba573a57ff6125a26ff9ae94cf43c36129645f (diff) |
gallium: add b5g6r5 srgb format
GL generally doesn't seem to allow srgb formats with less (or more) than 8 bit
for the rgb channels, though some hw could easily do it (typically for formats
with up to 10 bits for the rgb channels, at least for formats with less than 8
bits support is likely widespread even). While it may be true there aren't
really any benefits for such formats, we need for it for d3d, though luckily
only for b5g6r5_srgb it seems.
So add this format along with the util code for conversion - since that util
code is heavily tuned for 8bit srgb this isn't really all that well optimized
and rounding doesn't seem right but at least it should give some halfway
meaningful results.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.csv | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format_pack.py | 16 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_format.h | 2 |
4 files changed, 21 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 8fb068b8177..8aa5c364de9 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -373,3 +373,6 @@ PIPE_FORMAT_R16A16_SINT , plain, 1, 1, sp16 , sp16 , , , x00 PIPE_FORMAT_R32A32_UINT , plain, 1, 1, up32 , up32 , , , x00y, rgb PIPE_FORMAT_R32A32_SINT , plain, 1, 1, sp32 , sp32 , , , x00y, rgb PIPE_FORMAT_R10G10B10A2_UINT , plain, 1, 1, up10 , up10 , up10, up2 , xyzw, rgb + +PIPE_FORMAT_B5G6R5_SRGB , plain, 1, 1, un5 , un6 , un5 , , zyx1, srgb + diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 747e1429d48..1dd5d52f1e6 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -906,6 +906,8 @@ util_format_srgb(enum pipe_format format) return PIPE_FORMAT_DXT3_SRGBA; case PIPE_FORMAT_DXT5_RGBA: return PIPE_FORMAT_DXT5_SRGBA; + case PIPE_FORMAT_B5G6R5_UNORM: + return PIPE_FORMAT_B5G6R5_SRGB; default: return PIPE_FORMAT_NONE; } @@ -949,6 +951,8 @@ util_format_linear(enum pipe_format format) return PIPE_FORMAT_DXT3_RGBA; case PIPE_FORMAT_DXT5_SRGBA: return PIPE_FORMAT_DXT5_RGBA; + case PIPE_FORMAT_B5G6R5_SRGB: + return PIPE_FORMAT_B5G6R5_UNORM; default: return format; } diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index d1f68c80422..8072fdb138b 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -272,8 +272,11 @@ def conversion_expr(src_channel, if src_colorspace == SRGB: assert src_channel.type == UNSIGNED assert src_channel.norm - assert src_channel.size == 8 + assert src_channel.size <= 8 + assert src_channel.size >= 4 assert dst_colorspace == RGB + if src_channel.size < 8: + value = '%s << %x | %s >> %x' % (value, 8 - src_channel.size, value, 2 * src_channel.size - 8) if dst_channel.type == FLOAT: return 'util_format_srgb_8unorm_to_linear_float(%s)' % value else: @@ -284,15 +287,20 @@ def conversion_expr(src_channel, elif dst_colorspace == SRGB: assert dst_channel.type == UNSIGNED assert dst_channel.norm - assert dst_channel.size == 8 + assert dst_channel.size <= 8 assert src_colorspace == RGB if src_channel.type == FLOAT: - return 'util_format_linear_float_to_srgb_8unorm(%s)' % value + value = 'util_format_linear_float_to_srgb_8unorm(%s)' % value else: assert src_channel.type == UNSIGNED assert src_channel.norm assert src_channel.size == 8 - return 'util_format_linear_to_srgb_8unorm(%s)' % value + value = 'util_format_linear_to_srgb_8unorm(%s)' % value + # XXX rounding is all wrong. + if dst_channel.size < 8: + return '%s >> %x' % (value, 8 - dst_channel.size) + else: + return value elif src_colorspace == ZS: pass elif dst_colorspace == ZS: diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 34ab66250fd..a7fdcd0f4a7 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -342,6 +342,8 @@ enum pipe_format { PIPE_FORMAT_R32A32_SINT = 252, PIPE_FORMAT_R10G10B10A2_UINT = 253, + PIPE_FORMAT_B5G6R5_SRGB = 254, + PIPE_FORMAT_COUNT }; |