mesa/src/mesa
Neil Roberts a4ab08bf45 format_utils: Use a more precise conversion when decreasing bits
When converting to a format that has fewer bits the previous code was just
shifting off the bits. This doesn't provide very accurate results. For example
when converting from 8 bits to 5 bits it is equivalent to doing this:

x * 32 / 256

This works as if it's taking a value from a range where 256 represents 1.0 and
scaling it down to a range where 32 represents 1.0. However this is not
correct because it is actually 255 and 31 that represent 1.0.

We can do better with a formula like this:

(x * 31 + 127) / 255

The +127 is to make it round correctly.

The new code has a special case to use uint64_t when the result of the
multiplication would overflow an unsigned int. This function is inline and
only ever called with constant values so hopefully the if statements will be
folded.

The main incentive to do this is to make the CPU conversion path pick the same
values as the hardware would if it did the conversion. This fixes failures
with the ‘texsubimage pbo’ test when using the patches from here:

http://lists.freedesktop.org/archives/mesa-dev/2015-January/074312.html

v2: Use 64-bit arithmetic when src_bits+dst_bits > 32

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
2015-01-16 13:53:15 +00:00
..
drivers i965/gen6: Fix crash with VS+TF after rendering with GS 2015-01-16 14:16:59 +01:00
main format_utils: Use a more precise conversion when decreasing bits 2015-01-16 13:53:15 +00:00
math mesa: Refactor viewport transform computation. 2014-10-24 19:21:20 +02:00
program program: remove extern "C" usage in sampler.cpp 2014-12-16 07:52:41 -07:00
sparc
state_tracker mesa: rename RGBA8888_* format constants to something appropriate. 2015-01-14 07:57:31 +01:00
swrast mesa: rename RGBA8888_* format constants to something appropriate. 2015-01-14 07:57:31 +01:00
swrast_setup swrast: Fix vertex color in _swsetup_Translate() 2014-04-24 08:16:00 -06:00
tnl mesa: Replace IS_NEGATIVE(x) with x < 0.0f. 2014-09-25 13:57:29 -07:00
tnl_dd tnl_dd: Remove dead t_dd_vb.c. 2014-12-12 12:11:47 -08:00
vbo vbo: ignore primitive restart if FixedIndex is enabled in DrawArrays 2015-01-07 12:06:42 +01:00
x86 mesa: remove long dead 3Dnow optimisation 2014-12-13 12:15:25 +11:00
x86-64 x86-64: Remove calling_convention.txt. 2014-12-12 12:11:50 -08:00
.gitignore
Android.gen.mk st/mesa: Generate format_info.c in Android builds 2014-10-03 01:25:32 +01:00
Android.libmesa_dricore.mk mesa: Add SSE 4.1 optimisation for glDrawElements. 2014-11-06 11:39:59 -08:00
Android.libmesa_glsl_utils.mk util: Include in Android builds 2014-10-03 01:25:28 +01:00
Android.libmesa_st_mesa.mk mesa: Add SSE 4.1 optimisation for glDrawElements. 2014-11-06 11:39:59 -08:00
Android.mesa_gen_matypes.mk android, mesa_gen_matypes: pull in timespec POSIX definition 2014-06-09 22:51:34 +01:00
Android.mk
gl.pc.in
Makefile.am mesa: Autogenerate format_unpack.c 2015-01-12 11:20:28 +01:00
Makefile.sources util: Move main/set to util/hash_set 2015-01-15 13:21:27 -08:00
SConscript mesa: Autogenerate format_unpack.c 2015-01-12 11:20:28 +01:00