diff options
-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 }; |