[Pixman] [RFC, PATCH 0/8] Floating point pipeline
Bill Spitzak
spitzak at gmail.com
Sun Aug 26 18:28:06 PDT 2012
On 08/25/2012 06:45 PM, Søren Sandmann Pedersen wrote:
> Also note that the linear->sRGB scanline store routine is probably
> slower with these patches because it now uses a binary search instead
> of a simple table lookup. If someone has better suggestions here, I'm
> definitely interested.
I would use a set of bits at the top of the floating point number to
index a table of linear approximations. Each entry in the table produces
an A and B floating point value and the result is Ax+B.
Interesting 32-bit floating point numbers in hex:
0.0 0x00000000
0.0031308 0x3b4d2e1c (end of linear part of sRGB)
1.0 0x3f800000
I would use some if statements to evenly divide the area between just
before .0031308 and 1.0 into whatever number of segments you want.
Numbers before this go into a single bin for the linear part of sRGB.
Zero and all negative numbers go into a bin producing a horizontal line
at zero, and 1.0 and above into a bin producing a horizontal line at 255.
The integer part of the floating point result is the 8-bit number. I
also very much recommend that the fractional part be used for error
diffusion, it is added to the next result, and a random starting point
is chosen for each scan line. This will make gradients look much, much
nicer.
You can also choose much larger B values such that the resulting
floating point answers all have the same exponent. This will allow the
8-bit values to be directly extracted from the resulting floating point.
More information about the Pixman
mailing list