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 <jfonseca@vmware.com>
This commit is contained in:
Roland Scheidegger
2014-03-20 16:27:57 +01:00
parent 19ba573a57
commit 2aa77f2777
4 changed files with 21 additions and 4 deletions
+3
View File
@@ -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
Can't render this file because it contains an unexpected character in line 8 and column 3.
+4
View File
@@ -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;
}
+12 -4
View File
@@ -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:
+2
View File
@@ -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
};