diff options
| author | José Fonseca <jfonseca@vmware.com> | 2010-03-02 16:00:34 +0000 |
|---|---|---|
| committer | José Fonseca <jfonseca@vmware.com> | 2010-03-02 16:00:34 +0000 |
| commit | 2998cad9ce0c2c60078a28e6a0f3f3bbda3a6535 (patch) | |
| tree | 05e79ae0d434100c0136247320dd887e40da87a5 /src/gallium/auxiliary/util/u_format_access.py | |
| parent | faf8215bae70f020420242dc812ef141fdcf5417 (diff) | |
| parent | 8598cebf43ea4e1098dbab13b037dd1de216b8b5 (diff) | |
Merge branch 'gallium-format-cleanup'
Diffstat (limited to 'src/gallium/auxiliary/util/u_format_access.py')
| -rw-r--r-- | src/gallium/auxiliary/util/u_format_access.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 1c9be1b538..00424779d2 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -37,6 +37,7 @@ ''' +import math import sys from u_format_pack import * @@ -94,6 +95,20 @@ def native_type(format): assert False +def generate_srgb_tables(): + print 'static ubyte srgb_to_linear[256] = {' + for i in range(256): + print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)) + print '};' + print + print 'static ubyte linear_to_srgb[256] = {' + print ' 0,' + for i in range(1, 256): + print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)) + print '};' + print + + def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -305,6 +320,8 @@ def main(): print '#include "u_format_pack.h"' print + generate_srgb_tables() + type = Channel(FLOAT, False, 32) native_type = 'float' suffix = '4f' |
