diff options
author | marha <marha@users.sourceforge.net> | 2011-11-04 08:57:20 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-11-04 08:57:20 +0100 |
commit | 02f377d5e2dd18537d0807ad63675a0970b5a37d (patch) | |
tree | 1814c826db4d95a30ad71431d9c84b8d2611ec18 /mesalib/src/gallium/auxiliary | |
parent | 6f4feafd4d22beaabfb0202e66b0dea9047ee084 (diff) | |
download | vcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.tar.gz vcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.tar.bz2 vcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.zip |
xserver pixman mesa git update 4 nov 2011
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_r11g11b10f.h | 66 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_table.py | 2 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 13 |
3 files changed, 64 insertions, 17 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_r11g11b10f.h b/mesalib/src/gallium/auxiliary/util/u_format_r11g11b10f.h index 8e0572aa7..6bb430296 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_r11g11b10f.h +++ b/mesalib/src/gallium/auxiliary/util/u_format_r11g11b10f.h @@ -27,6 +27,7 @@ * below. */ +#define UF11(e, m) ((e << 6) | (m)) #define UF11_EXPONENT_BIAS 15 #define UF11_EXPONENT_BITS 0x1F #define UF11_EXPONENT_SHIFT 6 @@ -34,10 +35,11 @@ #define UF11_MANTISSA_SHIFT (23 - UF11_EXPONENT_SHIFT) #define UF11_MAX_EXPONENT (UF11_EXPONENT_BITS << UF11_EXPONENT_SHIFT) +#define UF10(e, m) ((e << 5) | (m)) #define UF10_EXPONENT_BIAS 15 #define UF10_EXPONENT_BITS 0x1F #define UF10_EXPONENT_SHIFT 5 -#define UF10_MANTISSA_BITS 0x3F +#define UF10_MANTISSA_BITS 0x1F #define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT) #define UF10_MAX_EXPONENT (UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT) @@ -58,14 +60,30 @@ static INLINE unsigned f32_to_uf11(float val) int exponent = ((f32.ui >> 23) & 0xff) - 127; int mantissa = f32.ui & 0x007fffff; - if (sign) return 0; - if (exponent == 128) { /* Infinity or NaN */ + /* From the GL_EXT_packed_float spec: + * + * "Additionally: negative infinity is converted to zero; positive + * infinity is converted to positive infinity; and both positive and + * negative NaN are converted to positive NaN." + */ uf11 = UF11_MAX_EXPONENT; - if (mantissa) uf11 |= (mantissa & UF11_MANTISSA_BITS); - } - else if (exponent > 15) { /* Overflow - flush to Infinity */ - uf11 = UF11_MAX_EXPONENT; + if (mantissa) { + uf11 |= 1; /* NaN */ + } else { + if (sign) + uf11 = 0; /* 0.0 */ + } + } else if (sign) { + return 0; + } else if (val > 65024.0f) { + /* From the GL_EXT_packed_float spec: + * + * "Likewise, finite positive values greater than 65024 (the maximum + * finite representable unsigned 11-bit floating-point value) are + * converted to 65024." + */ + uf11 = UF11(30, 63); } else if (exponent > -15) { /* Representable value */ exponent += UF11_EXPONENT_BIAS; @@ -128,14 +146,30 @@ static INLINE unsigned f32_to_uf10(float val) int exponent = ((f32.ui >> 23) & 0xff) - 127; int mantissa = f32.ui & 0x007fffff; - if (sign) return 0; - - if (exponent == 128) { /* Infinity or NaN */ - uf10 = UF10_MAX_EXPONENT; - if (mantissa) uf10 |= (mantissa & UF10_MANTISSA_BITS); - } - else if (exponent > 15) { /* Overflow - flush to Infinity */ + if (exponent == 128) { + /* From the GL_EXT_packed_float spec: + * + * "Additionally: negative infinity is converted to zero; positive + * infinity is converted to positive infinity; and both positive and + * negative NaN are converted to positive NaN." + */ uf10 = UF10_MAX_EXPONENT; + if (mantissa) { + uf10 |= 1; /* NaN */ + } else { + if (sign) + uf10 = 0; /* 0.0 */ + } + } else if (sign) { + return 0; + } else if (val > 64512.0f) { /* Overflow - flush to Infinity */ + /* From the GL_EXT_packed_float spec: + * + * "Likewise, finite positive values greater than 64512 (the maximum + * finite representable unsigned 10-bit floating-point value) are + * converted to 64512." + */ + uf10 = UF10(30, 31); } else if (exponent > -15) { /* Representable value */ exponent += UF10_EXPONENT_BIAS; @@ -153,8 +187,8 @@ static INLINE float uf10_to_f32(uint16_t val) uint32_t ui; } f32; - int exponent = (val & 0x07c0) >> UF10_EXPONENT_SHIFT; - int mantissa = (val & 0x003f); + int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT; + int mantissa = (val & 0x001f); f32.f = 0.0; diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py index 250a53598..703d99959 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_table.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py @@ -115,7 +115,7 @@ def write_format_table(formats): if channel.size: print " {%s, %s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, sep, "xyzw"[i], channel.name) else: - print " {0, 0, 0}%s" % (sep,) + print " {0, 0, 0, 0}%s" % (sep,) print " }," print " {" for i in range(4): diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index c74c1da76..b9295f4f8 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -574,6 +574,19 @@ util_bitcount(unsigned n) /** + * Convert from little endian to CPU byte order. + */ + +#ifdef PIPE_ARCH_BIG_ENDIAN +#define util_le32_to_cpu(x) util_bswap32(x) +#define util_le16_to_cpu(x) util_bswap16(x) +#else +#define util_le32_to_cpu(x) (x) +#define util_le16_to_cpu(x) (x) +#endif + + +/** * Reverse byte order of a 32 bit word. */ static INLINE uint32_t |