we don't need the accessor methods in virgl so far, only the description tables, so drop all the extra stuff for now. this introduces the python from mesa to generate our cut down tablemacos/master
parent
3a04ee4a16
commit
d01f462c53
Can't render this file because it contains an unexpected character in line 8 and column 3.
|
@ -1,472 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
|
|
||||||
#include "u_math.h" |
|
||||||
#include "u_format_other.h" |
|
||||||
#include "u_format_rgb9e5.h" |
|
||||||
#include "u_format_r11g11b10f.h" |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint8_t *src = src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
rgb9e5_to_float3(value, dst); |
|
||||||
dst[3] = 1; /* a */ |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const float *src = src_row; |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = float3_to_rgb9e5(src); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*(uint32_t *)dst = value; |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
rgb9e5_to_float3(value, dst); |
|
||||||
dst[3] = 1; /* a */ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
float p[3]; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint8_t *src = src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
rgb9e5_to_float3(value, p); |
|
||||||
dst[0] = float_to_ubyte(p[0]); /* r */ |
|
||||||
dst[1] = float_to_ubyte(p[1]); /* g */ |
|
||||||
dst[2] = float_to_ubyte(p[2]); /* b */ |
|
||||||
dst[3] = 255; /* a */ |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
float p[3]; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value; |
|
||||||
p[0] = ubyte_to_float(src[0]); |
|
||||||
p[1] = ubyte_to_float(src[1]); |
|
||||||
p[2] = ubyte_to_float(src[2]); |
|
||||||
value = float3_to_rgb9e5(p); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*(uint32_t *)dst = value; |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint8_t *src = src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
r11g11b10f_to_float3(value, dst); |
|
||||||
dst[3] = 1; /* a */ |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const float *src = src_row; |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = float3_to_r11g11b10f(src); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*(uint32_t *)dst = value; |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
r11g11b10f_to_float3(value, dst); |
|
||||||
dst[3] = 1; /* a */ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
float p[3]; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint8_t *src = src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value = *(const uint32_t *)src; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
r11g11b10f_to_float3(value, p); |
|
||||||
dst[0] = float_to_ubyte(p[0]); /* r */ |
|
||||||
dst[1] = float_to_ubyte(p[1]); /* g */ |
|
||||||
dst[2] = float_to_ubyte(p[2]); /* b */ |
|
||||||
dst[3] = 255; /* a */ |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
float p[3]; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint32_t value; |
|
||||||
p[0] = ubyte_to_float(src[0]); |
|
||||||
p[1] = ubyte_to_float(src[1]); |
|
||||||
p[2] = ubyte_to_float(src[2]); |
|
||||||
value = float3_to_r11g11b10f(p); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*(uint32_t *)dst = value; |
|
||||||
src += 4; |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PIPE_FORMAT_R8G8Bx_SNORM |
|
||||||
* |
|
||||||
* A.k.a. D3DFMT_CxV8U8 |
|
||||||
*/ |
|
||||||
|
|
||||||
static uint8_t |
|
||||||
r8g8bx_derive(int16_t r, int16_t g) |
|
||||||
{ |
|
||||||
/* Derive blue from red and green components.
|
|
||||||
* Apparently, we must always use integers to perform calculations, |
|
||||||
* otherwise the results won't match D3D's CxV8U8 definition. |
|
||||||
*/ |
|
||||||
return (uint8_t)sqrtf(0x7f * 0x7f - r * r - g * g) * 0xff / 0x7f; |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
|
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint16_t *src = (const uint16_t *)src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint16_t value = *src++; |
|
||||||
int16_t r, g; |
|
||||||
|
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
|
|
||||||
r = ((int16_t)(value << 8)) >> 8; |
|
||||||
g = ((int16_t)(value << 0)) >> 8; |
|
||||||
|
|
||||||
dst[0] = (float)(r * (1.0f/0x7f)); /* r */ |
|
||||||
dst[1] = (float)(g * (1.0f/0x7f)); /* g */ |
|
||||||
dst[2] = r8g8bx_derive(r, g) * (1.0f/0xff); /* b */ |
|
||||||
dst[3] = 1.0f; /* a */ |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint16_t *src = (const uint16_t *)src_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint16_t value = *src++; |
|
||||||
int16_t r, g; |
|
||||||
|
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
|
|
||||||
r = ((int16_t)(value << 8)) >> 8; |
|
||||||
g = ((int16_t)(value << 0)) >> 8; |
|
||||||
|
|
||||||
dst[0] = (uint8_t)(((uint16_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ |
|
||||||
dst[1] = (uint8_t)(((uint16_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ |
|
||||||
dst[2] = r8g8bx_derive(r, g); /* b */ |
|
||||||
dst[3] = 255; /* a */ |
|
||||||
dst += 4; |
|
||||||
} |
|
||||||
src_row += src_stride; |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const float *src = src_row; |
|
||||||
uint16_t *dst = (uint16_t *)dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint16_t value = 0; |
|
||||||
|
|
||||||
value |= (uint16_t)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; |
|
||||||
value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; |
|
||||||
|
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
|
|
||||||
*dst++ = value; |
|
||||||
|
|
||||||
src += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
|
|
||||||
for(y = 0; y < height; y += 1) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint16_t *dst = (uint16_t *)dst_row; |
|
||||||
for(x = 0; x < width; x += 1) { |
|
||||||
uint16_t value = 0; |
|
||||||
|
|
||||||
value |= src[0] >> 1; |
|
||||||
value |= (src[1] >> 1) << 8; |
|
||||||
|
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
|
|
||||||
*dst++ = value; |
|
||||||
|
|
||||||
src += 4; |
|
||||||
} |
|
||||||
dst_row += dst_stride; |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
uint16_t value = *(const uint16_t *)src; |
|
||||||
int16_t r, g; |
|
||||||
|
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
|
|
||||||
r = ((int16_t)(value << 8)) >> 8; |
|
||||||
g = ((int16_t)(value << 0)) >> 8; |
|
||||||
|
|
||||||
dst[0] = r * (1.0f/0x7f); /* r */ |
|
||||||
dst[1] = g * (1.0f/0x7f); /* g */ |
|
||||||
dst[2] = r8g8bx_derive(r, g) * (1.0f/0xff); /* b */ |
|
||||||
dst[3] = 1.0f; /* a */ |
|
||||||
} |
|
@ -1,134 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_FORMAT_OTHER_H_ |
|
||||||
#define U_FORMAT_OTHER_H_ |
|
||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h" |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
#endif /* U_FORMAT_OTHER_H_ */ |
|
@ -0,0 +1,699 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
''' |
||||||
|
/************************************************************************** |
||||||
|
* |
||||||
|
* Copyright 2009-2010 VMware, Inc. |
||||||
|
* All Rights Reserved. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the |
||||||
|
* "Software"), to deal in the Software without restriction, including |
||||||
|
* without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to |
||||||
|
* permit persons to whom the Software is furnished to do so, subject to |
||||||
|
* the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the |
||||||
|
* next paragraph) shall be included in all copies or substantial portions |
||||||
|
* of the Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
||||||
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||||
|
* |
||||||
|
**************************************************************************/ |
||||||
|
|
||||||
|
/** |
||||||
|
* @file |
||||||
|
* Pixel format packing and unpacking functions. |
||||||
|
* |
||||||
|
* @author Jose Fonseca <jfonseca@vmware.com> |
||||||
|
*/ |
||||||
|
''' |
||||||
|
|
||||||
|
|
||||||
|
from u_format_parse import * |
||||||
|
|
||||||
|
|
||||||
|
def inv_swizzles(swizzles): |
||||||
|
'''Return an array[4] of inverse swizzle terms''' |
||||||
|
'''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha''' |
||||||
|
inv_swizzle = [None]*4 |
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if swizzle < 4 and inv_swizzle[swizzle] == None: |
||||||
|
inv_swizzle[swizzle] = i |
||||||
|
return inv_swizzle |
||||||
|
|
||||||
|
def print_channels(format, func): |
||||||
|
if format.nr_channels() <= 1: |
||||||
|
func(format.le_channels, format.le_swizzles) |
||||||
|
else: |
||||||
|
print '#ifdef PIPE_ARCH_BIG_ENDIAN' |
||||||
|
func(format.be_channels, format.be_swizzles) |
||||||
|
print '#else' |
||||||
|
func(format.le_channels, format.le_swizzles) |
||||||
|
print '#endif' |
||||||
|
|
||||||
|
def generate_format_type(format): |
||||||
|
'''Generate a structure that describes the format.''' |
||||||
|
|
||||||
|
assert format.layout == PLAIN |
||||||
|
|
||||||
|
def generate_bitfields(channels, swizzles): |
||||||
|
for channel in channels: |
||||||
|
if channel.type == VOID: |
||||||
|
if channel.size: |
||||||
|
print ' unsigned %s:%u;' % (channel.name, channel.size) |
||||||
|
elif channel.type == UNSIGNED: |
||||||
|
print ' unsigned %s:%u;' % (channel.name, channel.size) |
||||||
|
elif channel.type in (SIGNED, FIXED): |
||||||
|
print ' int %s:%u;' % (channel.name, channel.size) |
||||||
|
elif channel.type == FLOAT: |
||||||
|
if channel.size == 64: |
||||||
|
print ' double %s;' % (channel.name) |
||||||
|
elif channel.size == 32: |
||||||
|
print ' float %s;' % (channel.name) |
||||||
|
else: |
||||||
|
print ' unsigned %s:%u;' % (channel.name, channel.size) |
||||||
|
else: |
||||||
|
assert 0 |
||||||
|
|
||||||
|
def generate_full_fields(channels, swizzles): |
||||||
|
for channel in channels: |
||||||
|
assert channel.size % 8 == 0 and is_pot(channel.size) |
||||||
|
if channel.type == VOID: |
||||||
|
if channel.size: |
||||||
|
print ' uint%u_t %s;' % (channel.size, channel.name) |
||||||
|
elif channel.type == UNSIGNED: |
||||||
|
print ' uint%u_t %s;' % (channel.size, channel.name) |
||||||
|
elif channel.type in (SIGNED, FIXED): |
||||||
|
print ' int%u_t %s;' % (channel.size, channel.name) |
||||||
|
elif channel.type == FLOAT: |
||||||
|
if channel.size == 64: |
||||||
|
print ' double %s;' % (channel.name) |
||||||
|
elif channel.size == 32: |
||||||
|
print ' float %s;' % (channel.name) |
||||||
|
elif channel.size == 16: |
||||||
|
print ' uint16_t %s;' % (channel.name) |
||||||
|
else: |
||||||
|
assert 0 |
||||||
|
else: |
||||||
|
assert 0 |
||||||
|
|
||||||
|
print 'union util_format_%s {' % format.short_name() |
||||||
|
|
||||||
|
if format.block_size() in (8, 16, 32, 64): |
||||||
|
print ' uint%u_t value;' % (format.block_size(),) |
||||||
|
|
||||||
|
use_bitfields = False |
||||||
|
for channel in format.le_channels: |
||||||
|
if channel.size % 8 or not is_pot(channel.size): |
||||||
|
use_bitfields = True |
||||||
|
|
||||||
|
print ' struct {' |
||||||
|
if use_bitfields: |
||||||
|
print_channels(format, generate_bitfields) |
||||||
|
else: |
||||||
|
print_channels(format, generate_full_fields) |
||||||
|
print ' } chan;' |
||||||
|
print '};' |
||||||
|
print |
||||||
|
|
||||||
|
|
||||||
|
def is_format_supported(format): |
||||||
|
'''Determines whether we actually have the plumbing necessary to generate the |
||||||
|
to read/write to/from this format.''' |
||||||
|
|
||||||
|
# FIXME: Ideally we would support any format combination here. |
||||||
|
|
||||||
|
if format.layout != PLAIN: |
||||||
|
return False |
||||||
|
|
||||||
|
for i in range(4): |
||||||
|
channel = format.le_channels[i] |
||||||
|
if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED): |
||||||
|
return False |
||||||
|
if channel.type == FLOAT and channel.size not in (16, 32, 64): |
||||||
|
return False |
||||||
|
|
||||||
|
return True |
||||||
|
|
||||||
|
def native_type(format): |
||||||
|
'''Get the native appropriate for a format.''' |
||||||
|
|
||||||
|
if format.name == 'PIPE_FORMAT_R11G11B10_FLOAT': |
||||||
|
return 'uint32_t' |
||||||
|
if format.name == 'PIPE_FORMAT_R9G9B9E5_FLOAT': |
||||||
|
return 'uint32_t' |
||||||
|
|
||||||
|
if format.layout == PLAIN: |
||||||
|
if not format.is_array(): |
||||||
|
# For arithmetic pixel formats return the integer type that matches the whole pixel |
||||||
|
return 'uint%u_t' % format.block_size() |
||||||
|
else: |
||||||
|
# For array pixel formats return the integer type that matches the color channel |
||||||
|
channel = format.array_element() |
||||||
|
if channel.type in (UNSIGNED, VOID): |
||||||
|
return 'uint%u_t' % channel.size |
||||||
|
elif channel.type in (SIGNED, FIXED): |
||||||
|
return 'int%u_t' % channel.size |
||||||
|
elif channel.type == FLOAT: |
||||||
|
if channel.size == 16: |
||||||
|
return 'uint16_t' |
||||||
|
elif channel.size == 32: |
||||||
|
return 'float' |
||||||
|
elif channel.size == 64: |
||||||
|
return 'double' |
||||||
|
else: |
||||||
|
assert False |
||||||
|
else: |
||||||
|
assert False |
||||||
|
else: |
||||||
|
assert False |
||||||
|
|
||||||
|
|
||||||
|
def intermediate_native_type(bits, sign): |
||||||
|
'''Find a native type adequate to hold intermediate results of the request bit size.''' |
||||||
|
|
||||||
|
bytes = 4 # don't use anything smaller than 32bits |
||||||
|
while bytes * 8 < bits: |
||||||
|
bytes *= 2 |
||||||
|
bits = bytes*8 |
||||||
|
|
||||||
|
if sign: |
||||||
|
return 'int%u_t' % bits |
||||||
|
else: |
||||||
|
return 'uint%u_t' % bits |
||||||
|
|
||||||
|
|
||||||
|
def get_one_shift(type): |
||||||
|
'''Get the number of the bit that matches unity for this type.''' |
||||||
|
if type.type == 'FLOAT': |
||||||
|
assert False |
||||||
|
if not type.norm: |
||||||
|
return 0 |
||||||
|
if type.type == UNSIGNED: |
||||||
|
return type.size |
||||||
|
if type.type == SIGNED: |
||||||
|
return type.size - 1 |
||||||
|
if type.type == FIXED: |
||||||
|
return type.size / 2 |
||||||
|
assert False |
||||||
|
|
||||||
|
|
||||||
|
def truncate_mantissa(x, bits): |
||||||
|
'''Truncate an integer so it can be represented exactly with a floating |
||||||
|
point mantissa''' |
||||||
|
|
||||||
|
assert isinstance(x, (int, long)) |
||||||
|
|
||||||
|
s = 1 |
||||||
|
if x < 0: |
||||||
|
s = -1 |
||||||
|
x = -x |
||||||
|
|
||||||
|
# We can represent integers up to mantissa + 1 bits exactly |
||||||
|
mask = (1 << (bits + 1)) - 1 |
||||||
|
|
||||||
|
# Slide the mask until the MSB matches |
||||||
|
shift = 0 |
||||||
|
while (x >> shift) & ~mask: |
||||||
|
shift += 1 |
||||||
|
|
||||||
|
x &= mask << shift |
||||||
|
x *= s |
||||||
|
return x |
||||||
|
|
||||||
|
|
||||||
|
def value_to_native(type, value): |
||||||
|
'''Get the value of unity for this type.''' |
||||||
|
if type.type == FLOAT: |
||||||
|
if type.size <= 32 \ |
||||||
|
and isinstance(value, (int, long)): |
||||||
|
return truncate_mantissa(value, 23) |
||||||
|
return value |
||||||
|
if type.type == FIXED: |
||||||
|
return int(value * (1 << (type.size/2))) |
||||||
|
if not type.norm: |
||||||
|
return int(value) |
||||||
|
if type.type == UNSIGNED: |
||||||
|
return int(value * ((1 << type.size) - 1)) |
||||||
|
if type.type == SIGNED: |
||||||
|
return int(value * ((1 << (type.size - 1)) - 1)) |
||||||
|
assert False |
||||||
|
|
||||||
|
|
||||||
|
def native_to_constant(type, value): |
||||||
|
'''Get the value of unity for this type.''' |
||||||
|
if type.type == FLOAT: |
||||||
|
if type.size <= 32: |
||||||
|
return "%.1ff" % float(value) |
||||||
|
else: |
||||||
|
return "%.1f" % float(value) |
||||||
|
else: |
||||||
|
return str(int(value)) |
||||||
|
|
||||||
|
|
||||||
|
def get_one(type): |
||||||
|
'''Get the value of unity for this type.''' |
||||||
|
return value_to_native(type, 1) |
||||||
|
|
||||||
|
|
||||||
|
def clamp_expr(src_channel, dst_channel, dst_native_type, value): |
||||||
|
'''Generate the expression to clamp the value in the source type to the |
||||||
|
destination type range.''' |
||||||
|
|
||||||
|
if src_channel == dst_channel: |
||||||
|
return value |
||||||
|
|
||||||
|
src_min = src_channel.min() |
||||||
|
src_max = src_channel.max() |
||||||
|
dst_min = dst_channel.min() |
||||||
|
dst_max = dst_channel.max() |
||||||
|
|
||||||
|
# Translate the destination range to the src native value |
||||||
|
dst_min_native = native_to_constant(src_channel, value_to_native(src_channel, dst_min)) |
||||||
|
dst_max_native = native_to_constant(src_channel, value_to_native(src_channel, dst_max)) |
||||||
|
|
||||||
|
if src_min < dst_min and src_max > dst_max: |
||||||
|
return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native) |
||||||
|
|
||||||
|
if src_max > dst_max: |
||||||
|
return 'MIN2(%s, %s)' % (value, dst_max_native) |
||||||
|
|
||||||
|
if src_min < dst_min: |
||||||
|
return 'MAX2(%s, %s)' % (value, dst_min_native) |
||||||
|
|
||||||
|
return value |
||||||
|
|
||||||
|
|
||||||
|
def conversion_expr(src_channel, |
||||||
|
dst_channel, dst_native_type, |
||||||
|
value, |
||||||
|
clamp=True, |
||||||
|
src_colorspace = RGB, |
||||||
|
dst_colorspace = RGB): |
||||||
|
'''Generate the expression to convert a value between two types.''' |
||||||
|
|
||||||
|
if src_colorspace != dst_colorspace: |
||||||
|
if src_colorspace == SRGB: |
||||||
|
assert src_channel.type == UNSIGNED |
||||||
|
assert src_channel.norm |
||||||
|
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: |
||||||
|
assert dst_channel.type == UNSIGNED |
||||||
|
assert dst_channel.norm |
||||||
|
assert dst_channel.size == 8 |
||||||
|
return 'util_format_srgb_to_linear_8unorm(%s)' % value |
||||||
|
elif dst_colorspace == SRGB: |
||||||
|
assert dst_channel.type == UNSIGNED |
||||||
|
assert dst_channel.norm |
||||||
|
assert dst_channel.size <= 8 |
||||||
|
assert src_colorspace == RGB |
||||||
|
if src_channel.type == FLOAT: |
||||||
|
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 |
||||||
|
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: |
||||||
|
pass |
||||||
|
else: |
||||||
|
assert 0 |
||||||
|
|
||||||
|
if src_channel == dst_channel: |
||||||
|
return value |
||||||
|
|
||||||
|
src_type = src_channel.type |
||||||
|
src_size = src_channel.size |
||||||
|
src_norm = src_channel.norm |
||||||
|
src_pure = src_channel.pure |
||||||
|
|
||||||
|
# Promote half to float |
||||||
|
if src_type == FLOAT and src_size == 16: |
||||||
|
value = 'util_half_to_float(%s)' % value |
||||||
|
src_size = 32 |
||||||
|
|
||||||
|
# Special case for float <-> ubytes for more accurate results |
||||||
|
# Done before clamping since these functions already take care of that |
||||||
|
if src_type == UNSIGNED and src_norm and src_size == 8 and dst_channel.type == FLOAT and dst_channel.size == 32: |
||||||
|
return 'ubyte_to_float(%s)' % value |
||||||
|
if src_type == FLOAT and src_size == 32 and dst_channel.type == UNSIGNED and dst_channel.norm and dst_channel.size == 8: |
||||||
|
return 'float_to_ubyte(%s)' % value |
||||||
|
|
||||||
|
if clamp: |
||||||
|
if dst_channel.type != FLOAT or src_type != FLOAT: |
||||||
|
value = clamp_expr(src_channel, dst_channel, dst_native_type, value) |
||||||
|
|
||||||
|
if src_type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED): |
||||||
|
if not src_norm and not dst_channel.norm: |
||||||
|
# neither is normalized -- just cast |
||||||
|
return '(%s)%s' % (dst_native_type, value) |
||||||
|
|
||||||
|
src_one = get_one(src_channel) |
||||||
|
dst_one = get_one(dst_channel) |
||||||
|
|
||||||
|
if src_one > dst_one and src_norm and dst_channel.norm: |
||||||
|
# We can just bitshift |
||||||
|
src_shift = get_one_shift(src_channel) |
||||||
|
dst_shift = get_one_shift(dst_channel) |
||||||
|
value = '(%s >> %s)' % (value, src_shift - dst_shift) |
||||||
|
else: |
||||||
|
# We need to rescale using an intermediate type big enough to hold the multiplication of both |
||||||
|
tmp_native_type = intermediate_native_type(src_size + dst_channel.size, src_channel.sign and dst_channel.sign) |
||||||
|
value = '((%s)%s)' % (tmp_native_type, value) |
||||||
|
value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one) |
||||||
|
value = '(%s)%s' % (dst_native_type, value) |
||||||
|
return value |
||||||
|
|
||||||
|
# Promote to either float or double |
||||||
|
if src_type != FLOAT: |
||||||
|
if src_norm or src_type == FIXED: |
||||||
|
one = get_one(src_channel) |
||||||
|
if src_size <= 23: |
||||||
|
value = '(%s * (1.0f/0x%x))' % (value, one) |
||||||
|
if dst_channel.size <= 32: |
||||||
|
value = '(float)%s' % value |
||||||
|
src_size = 32 |
||||||
|
else: |
||||||
|
# bigger than single precision mantissa, use double |
||||||
|
value = '(%s * (1.0/0x%x))' % (value, one) |
||||||
|
src_size = 64 |
||||||
|
src_norm = False |
||||||
|
else: |
||||||
|
if src_size <= 23 or dst_channel.size <= 32: |
||||||
|
value = '(float)%s' % value |
||||||
|
src_size = 32 |
||||||
|
else: |
||||||
|
# bigger than single precision mantissa, use double |
||||||
|
value = '(double)%s' % value |
||||||
|
src_size = 64 |
||||||
|
src_type = FLOAT |
||||||
|
|
||||||
|
# Convert double or float to non-float |
||||||
|
if dst_channel.type != FLOAT: |
||||||
|
if dst_channel.norm or dst_channel.type == FIXED: |
||||||
|
dst_one = get_one(dst_channel) |
||||||
|
if dst_channel.size <= 23: |
||||||
|
value = 'util_iround(%s * 0x%x)' % (value, dst_one) |
||||||
|
else: |
||||||
|
# bigger than single precision mantissa, use double |
||||||
|
value = '(%s * (double)0x%x)' % (value, dst_one) |
||||||
|
value = '(%s)%s' % (dst_native_type, value) |
||||||
|
else: |
||||||
|
# Cast double to float when converting to either half or float |
||||||
|
if dst_channel.size <= 32 and src_size > 32: |
||||||
|
value = '(float)%s' % value |
||||||
|
src_size = 32 |
||||||
|
|
||||||
|
if dst_channel.size == 16: |
||||||
|
value = 'util_float_to_half(%s)' % value |
||||||
|
elif dst_channel.size == 64 and src_size < 64: |
||||||
|
value = '(double)%s' % value |
||||||
|
|
||||||
|
return value |
||||||
|
|
||||||
|
|
||||||
|
def generate_unpack_kernel(format, dst_channel, dst_native_type): |
||||||
|
|
||||||
|
if not is_format_supported(format): |
||||||
|
return |
||||||
|
|
||||||
|
assert format.layout == PLAIN |
||||||
|
|
||||||
|
src_native_type = native_type(format) |
||||||
|
|
||||||
|
def unpack_from_bitmask(channels, swizzles): |
||||||
|
depth = format.block_size() |
||||||
|
print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth) |
||||||
|
|
||||||
|
# Declare the intermediate variables |
||||||
|
for i in range(format.nr_channels()): |
||||||
|
src_channel = channels[i] |
||||||
|
if src_channel.type == UNSIGNED: |
||||||
|
print ' uint%u_t %s;' % (depth, src_channel.name) |
||||||
|
elif src_channel.type == SIGNED: |
||||||
|
print ' int%u_t %s;' % (depth, src_channel.name) |
||||||
|
|
||||||
|
# Compute the intermediate unshifted values |
||||||
|
for i in range(format.nr_channels()): |
||||||
|
src_channel = channels[i] |
||||||
|
value = 'value' |
||||||
|
shift = src_channel.shift |
||||||
|
if src_channel.type == UNSIGNED: |
||||||
|
if shift: |
||||||
|
value = '%s >> %u' % (value, shift) |
||||||
|
if shift + src_channel.size < depth: |
||||||
|
value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) |
||||||
|
elif src_channel.type == SIGNED: |
||||||
|
if shift + src_channel.size < depth: |
||||||
|
# Align the sign bit |
||||||
|
lshift = depth - (shift + src_channel.size) |
||||||
|
value = '%s << %u' % (value, lshift) |
||||||
|
# Cast to signed |
||||||
|
value = '(int%u_t)(%s) ' % (depth, value) |
||||||
|
if src_channel.size < depth: |
||||||
|
# Align the LSB bit |
||||||
|
rshift = depth - src_channel.size |
||||||
|
value = '(%s) >> %u' % (value, rshift) |
||||||
|
else: |
||||||
|
value = None |
||||||
|
|
||||||
|
if value is not None: |
||||||
|
print ' %s = %s;' % (src_channel.name, value) |
||||||
|
|
||||||
|
# Convert, swizzle, and store final values |
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if swizzle < 4: |
||||||
|
src_channel = channels[swizzle] |
||||||
|
src_colorspace = format.colorspace |
||||||
|
if src_colorspace == SRGB and i == 3: |
||||||
|
# Alpha channel is linear |
||||||
|
src_colorspace = RGB |
||||||
|
value = src_channel.name |
||||||
|
value = conversion_expr(src_channel, |
||||||
|
dst_channel, dst_native_type, |
||||||
|
value, |
||||||
|
src_colorspace = src_colorspace) |
||||||
|
elif swizzle == SWIZZLE_0: |
||||||
|
value = '0' |
||||||
|
elif swizzle == SWIZZLE_1: |
||||||
|
value = get_one(dst_channel) |
||||||
|
elif swizzle == SWIZZLE_NONE: |
||||||
|
value = '0' |
||||||
|
else: |
||||||
|
assert False |
||||||
|
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) |
||||||
|
|
||||||
|
def unpack_from_union(channels, swizzles): |
||||||
|
print ' union util_format_%s pixel;' % format.short_name() |
||||||
|
print ' memcpy(&pixel, src, sizeof pixel);' |
||||||
|
|
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if swizzle < 4: |
||||||
|
src_channel = channels[swizzle] |
||||||
|
src_colorspace = format.colorspace |
||||||
|
if src_colorspace == SRGB and i == 3: |
||||||
|
# Alpha channel is linear |
||||||
|
src_colorspace = RGB |
||||||
|
value = 'pixel.chan.%s' % src_channel.name |
||||||
|
value = conversion_expr(src_channel, |
||||||
|
dst_channel, dst_native_type, |
||||||
|
value, |
||||||
|
src_colorspace = src_colorspace) |
||||||
|
elif swizzle == SWIZZLE_0: |
||||||
|
value = '0' |
||||||
|
elif swizzle == SWIZZLE_1: |
||||||
|
value = get_one(dst_channel) |
||||||
|
elif swizzle == SWIZZLE_NONE: |
||||||
|
value = '0' |
||||||
|
else: |
||||||
|
assert False |
||||||
|
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) |
||||||
|
|
||||||
|
if format.is_bitmask(): |
||||||
|
print_channels(format, unpack_from_bitmask) |
||||||
|
else: |
||||||
|
print_channels(format, unpack_from_union) |
||||||
|
|
||||||
|
|
||||||
|
def generate_pack_kernel(format, src_channel, src_native_type): |
||||||
|
|
||||||
|
if not is_format_supported(format): |
||||||
|
return |
||||||
|
|
||||||
|
dst_native_type = native_type(format) |
||||||
|
|
||||||
|
assert format.layout == PLAIN |
||||||
|
|
||||||
|
def pack_into_bitmask(channels, swizzles): |
||||||
|
inv_swizzle = inv_swizzles(swizzles) |
||||||
|
|
||||||
|
depth = format.block_size() |
||||||
|
print ' uint%u_t value = 0;' % depth |
||||||
|
|
||||||
|
for i in range(4): |
||||||
|
dst_channel = channels[i] |
||||||
|
shift = dst_channel.shift |
||||||
|
if inv_swizzle[i] is not None: |
||||||
|
value ='src[%u]' % inv_swizzle[i] |
||||||
|
dst_colorspace = format.colorspace |
||||||
|
if dst_colorspace == SRGB and inv_swizzle[i] == 3: |
||||||
|
# Alpha channel is linear |
||||||
|
dst_colorspace = RGB |
||||||
|
value = conversion_expr(src_channel, |
||||||
|
dst_channel, dst_native_type, |
||||||
|
value, |
||||||
|
dst_colorspace = dst_colorspace) |
||||||
|
if dst_channel.type in (UNSIGNED, SIGNED): |
||||||
|
if shift + dst_channel.size < depth: |
||||||
|
value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) |
||||||
|
if shift: |
||||||
|
value = '(%s) << %u' % (value, shift) |
||||||
|
if dst_channel.type == SIGNED: |
||||||
|
# Cast to unsigned |
||||||
|
value = '(uint%u_t)(%s) ' % (depth, value) |
||||||
|
else: |
||||||
|
value = None |
||||||
|
if value is not None: |
||||||
|
print ' value |= %s;' % (value) |
||||||
|
|
||||||
|
print ' *(uint%u_t *)dst = value;' % depth |
||||||
|
|
||||||
|
def pack_into_union(channels, swizzles): |
||||||
|
inv_swizzle = inv_swizzles(swizzles) |
||||||
|
|
||||||
|
print ' union util_format_%s pixel;' % format.short_name() |
||||||
|
|
||||||
|
for i in range(4): |
||||||
|
dst_channel = channels[i] |
||||||
|
width = dst_channel.size |
||||||
|
if inv_swizzle[i] is None: |
||||||
|
continue |
||||||
|
dst_colorspace = format.colorspace |
||||||
|
if dst_colorspace == SRGB and inv_swizzle[i] == 3: |
||||||
|
# Alpha channel is linear |
||||||
|
dst_colorspace = RGB |
||||||
|
value ='src[%u]' % inv_swizzle[i] |
||||||
|
value = conversion_expr(src_channel, |
||||||
|
dst_channel, dst_native_type, |
||||||
|
value, |
||||||
|
dst_colorspace = dst_colorspace) |
||||||
|
print ' pixel.chan.%s = %s;' % (dst_channel.name, value) |
||||||
|
|
||||||
|
print ' memcpy(dst, &pixel, sizeof pixel);' |
||||||
|
|
||||||
|
if format.is_bitmask(): |
||||||
|
print_channels(format, pack_into_bitmask) |
||||||
|
else: |
||||||
|
print_channels(format, pack_into_union) |
||||||
|
|
||||||
|
|
||||||
|
def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): |
||||||
|
'''Generate the function to unpack pixels from a particular format''' |
||||||
|
|
||||||
|
name = format.short_name() |
||||||
|
|
||||||
|
print 'static INLINE void' |
||||||
|
print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type) |
||||||
|
print '{' |
||||||
|
|
||||||
|
if is_format_supported(format): |
||||||
|
print ' unsigned x, y;' |
||||||
|
print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) |
||||||
|
print ' %s *dst = dst_row;' % (dst_native_type) |
||||||
|
print ' const uint8_t *src = src_row;' |
||||||
|
print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) |
||||||
|
|
||||||
|
generate_unpack_kernel(format, dst_channel, dst_native_type) |
||||||
|
|
||||||
|
print ' src += %u;' % (format.block_size() / 8,) |
||||||
|
print ' dst += 4;' |
||||||
|
print ' }' |
||||||
|
print ' src_row += src_stride;' |
||||||
|
print ' dst_row += dst_stride/sizeof(*dst_row);' |
||||||
|
print ' }' |
||||||
|
|
||||||
|
print '}' |
||||||
|
print |
||||||
|
|
||||||
|
|
||||||
|
def generate_format_pack(format, src_channel, src_native_type, src_suffix): |
||||||
|
'''Generate the function to pack pixels to a particular format''' |
||||||
|
|
||||||
|
name = format.short_name() |
||||||
|
|
||||||
|
print 'static INLINE void' |
||||||
|
print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type) |
||||||
|
print '{' |
||||||
|
|
||||||
|
if is_format_supported(format): |
||||||
|
print ' unsigned x, y;' |
||||||
|
print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) |
||||||
|
print ' const %s *src = src_row;' % (src_native_type) |
||||||
|
print ' uint8_t *dst = dst_row;' |
||||||
|
print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) |
||||||
|
|
||||||
|
generate_pack_kernel(format, src_channel, src_native_type) |
||||||
|
|
||||||
|
print ' src += 4;' |
||||||
|
print ' dst += %u;' % (format.block_size() / 8,) |
||||||
|
print ' }' |
||||||
|
print ' dst_row += dst_stride;' |
||||||
|
print ' src_row += src_stride/sizeof(*src_row);' |
||||||
|
print ' }' |
||||||
|
|
||||||
|
print '}' |
||||||
|
print |
||||||
|
|
||||||
|
|
||||||
|
def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix): |
||||||
|
'''Generate the function to unpack pixels from a particular format''' |
||||||
|
|
||||||
|
name = format.short_name() |
||||||
|
|
||||||
|
print 'static INLINE void' |
||||||
|
print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type) |
||||||
|
print '{' |
||||||
|
|
||||||
|
if is_format_supported(format): |
||||||
|
generate_unpack_kernel(format, dst_channel, dst_native_type) |
||||||
|
|
||||||
|
print '}' |
||||||
|
print |
||||||
|
|
||||||
|
|
||||||
|
def is_format_hand_written(format): |
||||||
|
return format.layout in ('s3tc', 'rgtc', 'etc', 'bptc', 'subsampled', 'other') or format.colorspace == ZS |
||||||
|
|
||||||
|
|
||||||
|
def generate(formats): |
||||||
|
print |
||||||
|
print '#include "pipe/p_compiler.h"' |
||||||
|
print '#include "u_math.h"' |
||||||
|
print '#include "u_half.h"' |
||||||
|
print '#include "u_format.h"' |
||||||
|
print |
||||||
|
|
@ -0,0 +1,365 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
''' |
||||||
|
/************************************************************************** |
||||||
|
* |
||||||
|
* Copyright 2009 VMware, Inc. |
||||||
|
* All Rights Reserved. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the |
||||||
|
* "Software"), to deal in the Software without restriction, including |
||||||
|
* without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to |
||||||
|
* permit persons to whom the Software is furnished to do so, subject to |
||||||
|
* the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the |
||||||
|
* next paragraph) shall be included in all copies or substantial portions |
||||||
|
* of the Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
||||||
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||||
|
* |
||||||
|
**************************************************************************/ |
||||||
|
''' |
||||||
|
|
||||||
|
|
||||||
|
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) |
||||||
|
|
||||||
|
SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) |
||||||
|
|
||||||
|
PLAIN = 'plain' |
||||||
|
|
||||||
|
RGB = 'rgb' |
||||||
|
SRGB = 'srgb' |
||||||
|
YUV = 'yuv' |
||||||
|
ZS = 'zs' |
||||||
|
|
||||||
|
|
||||||
|
def is_pot(x): |
||||||
|
return (x & (x - 1)) == 0 |
||||||
|
|
||||||
|
|
||||||
|
VERY_LARGE = 99999999999999999999999 |
||||||
|
|
||||||
|
|
||||||
|
class Channel: |
||||||
|
'''Describe the channel of a color channel.''' |
||||||
|
|
||||||
|
def __init__(self, type, norm, pure, size, name = ''): |
||||||
|
self.type = type |
||||||
|
self.norm = norm |
||||||
|
self.pure = pure |
||||||
|
self.size = size |
||||||
|
self.sign = type in (SIGNED, FIXED, FLOAT) |
||||||
|
self.name = name |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
s = str(self.type) |
||||||
|
if self.norm: |
||||||
|
s += 'n' |
||||||
|
if self.pure: |
||||||
|
s += 'p' |
||||||
|
s += str(self.size) |
||||||
|
return s |
||||||
|
|
||||||
|
def __eq__(self, other): |
||||||
|
return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size |
||||||
|
|
||||||
|
def max(self): |
||||||
|
'''Maximum representable number.''' |
||||||
|
if self.type == FLOAT: |
||||||
|
return VERY_LARGE |
||||||
|
if self.type == FIXED: |
||||||
|
return (1 << (self.size/2)) - 1 |
||||||
|
if self.norm: |
||||||
|
return 1 |
||||||
|
if self.type == UNSIGNED: |
||||||
|
return (1 << self.size) - 1 |
||||||
|
if self.type == SIGNED: |
||||||
|
return (1 << (self.size - 1)) - 1 |
||||||
|
assert False |
||||||
|
|
||||||
|
def min(self): |
||||||
|
'''Minimum representable number.''' |
||||||
|
if self.type == FLOAT: |
||||||
|
return -VERY_LARGE |
||||||
|
if self.type == FIXED: |
||||||
|
return -(1 << (self.size/2)) |
||||||
|
if self.type == UNSIGNED: |
||||||
|
return 0 |
||||||
|
if self.norm: |
||||||
|
return -1 |
||||||
|
if self.type == SIGNED: |
||||||
|
return -(1 << (self.size - 1)) |
||||||
|
assert False |
||||||
|
|
||||||
|
|
||||||
|
class Format: |
||||||
|
'''Describe a pixel format.''' |
||||||
|
|
||||||
|
def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace): |
||||||
|
self.name = name |
||||||
|
self.layout = layout |
||||||
|
self.block_width = block_width |
||||||
|
self.block_height = block_height |
||||||
|
self.le_channels = le_channels |
||||||
|
self.le_swizzles = le_swizzles |
||||||
|
self.be_channels = be_channels |
||||||
|
self.be_swizzles = be_swizzles |
||||||
|
self.name = name |
||||||
|
self.colorspace = colorspace |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.name |
||||||
|
|
||||||
|
def short_name(self): |
||||||
|
'''Make up a short norm for a format, suitable to be used as suffix in |
||||||
|
function names.''' |
||||||
|
|
||||||
|
name = self.name |
||||||
|
if name.startswith('PIPE_FORMAT_'): |
||||||
|
name = name[len('PIPE_FORMAT_'):] |
||||||
|
name = name.lower() |
||||||
|
return name |
||||||
|
|
||||||
|
def block_size(self): |
||||||
|
size = 0 |
||||||
|
for channel in self.le_channels: |
||||||
|
size += channel.size |
||||||
|
return size |
||||||
|
|
||||||
|
def nr_channels(self): |
||||||
|
nr_channels = 0 |
||||||
|
for channel in self.le_channels: |
||||||
|
if channel.size: |
||||||
|
nr_channels += 1 |
||||||
|
return nr_channels |
||||||
|
|
||||||
|
def array_element(self): |
||||||
|
if self.layout != PLAIN: |
||||||
|
return None |
||||||
|
ref_channel = self.le_channels[0] |
||||||
|
if ref_channel.type == VOID: |
||||||
|
ref_channel = self.le_channels[1] |
||||||
|
for channel in self.le_channels: |
||||||
|
if channel.size and (channel.size != ref_channel.size or channel.size % 8): |
||||||
|
return None |
||||||
|
if channel.type != VOID: |
||||||
|
if channel.type != ref_channel.type: |
||||||
|
return None |
||||||
|
if channel.norm != ref_channel.norm: |
||||||
|
return None |
||||||
|
if channel.pure != ref_channel.pure: |
||||||
|
return None |
||||||
|
return ref_channel |
||||||
|
|
||||||
|
def is_array(self): |
||||||
|
return self.array_element() != None |
||||||
|
|
||||||
|
def is_mixed(self): |
||||||
|
if self.layout != PLAIN: |
||||||
|
return False |
||||||
|
ref_channel = self.le_channels[0] |
||||||
|
if ref_channel.type == VOID: |
||||||
|
ref_channel = self.le_channels[1] |
||||||
|
for channel in self.le_channels[1:]: |
||||||
|
if channel.type != VOID: |
||||||
|
if channel.type != ref_channel.type: |
||||||
|
return True |
||||||
|
if channel.norm != ref_channel.norm: |
||||||
|
return True |
||||||
|
if channel.pure != ref_channel.pure: |
||||||
|
return True |
||||||
|
return False |
||||||
|
|
||||||
|
def is_pot(self): |
||||||
|
return is_pot(self.block_size()) |
||||||
|
|
||||||
|
def is_int(self): |
||||||
|
if self.layout != PLAIN: |
||||||
|
return False |
||||||
|
for channel in self.le_channels: |
||||||
|
if channel.type not in (VOID, UNSIGNED, SIGNED): |
||||||
|
return False |
||||||
|
return True |
||||||
|
|
||||||
|
def is_float(self): |
||||||
|
if self.layout != PLAIN: |
||||||
|
return False |
||||||
|
for channel in self.le_channels: |
||||||
|
if channel.type not in (VOID, FLOAT): |
||||||
|
return False |
||||||
|
return True |
||||||
|
|
||||||
|
def is_bitmask(self): |
||||||
|
if self.layout != PLAIN: |
||||||
|
return False |
||||||
|
if self.block_size() not in (8, 16, 32): |
||||||
|
return False |
||||||
|
for channel in self.le_channels: |
||||||
|
if channel.type not in (VOID, UNSIGNED, SIGNED): |
||||||
|
return False |
||||||
|
return True |
||||||
|
|
||||||
|
def is_pure_color(self): |
||||||
|
if self.layout != PLAIN or self.colorspace == ZS: |
||||||
|
return False |
||||||
|
pures = [channel.pure |
||||||
|
for channel in self.le_channels |
||||||
|
if channel.type != VOID] |
||||||
|
for x in pures: |
||||||
|
assert x == pures[0] |
||||||
|
return pures[0] |
||||||
|
|
||||||
|
def channel_type(self): |
||||||
|
types = [channel.type |
||||||
|
for channel in self.le_channels |
||||||
|
if channel.type != VOID] |
||||||
|
for x in types: |
||||||
|
assert x == types[0] |
||||||
|
return types[0] |
||||||
|
|
||||||
|
def is_pure_signed(self): |
||||||
|
return self.is_pure_color() and self.channel_type() == SIGNED |
||||||
|
|
||||||
|
def is_pure_unsigned(self): |
||||||
|
return self.is_pure_color() and self.channel_type() == UNSIGNED |
||||||
|
|
||||||
|
def has_channel(self, id): |
||||||
|
return self.le_swizzles[id] != SWIZZLE_NONE |
||||||
|
|
||||||
|
def has_depth(self): |
||||||
|
return self.colorspace == ZS and self.has_channel(0) |
||||||
|
|
||||||
|
def has_stencil(self): |
||||||
|
return self.colorspace == ZS and self.has_channel(1) |
||||||
|
|
||||||
|
def stride(self): |
||||||
|
return self.block_size()/8 |
||||||
|
|
||||||
|
|
||||||
|
_type_parse_map = { |
||||||
|
'': VOID, |
||||||
|
'x': VOID, |
||||||
|
'u': UNSIGNED, |
||||||
|
's': SIGNED, |
||||||
|
'h': FIXED, |
||||||
|
'f': FLOAT, |
||||||
|
} |
||||||
|
|
||||||
|
_swizzle_parse_map = { |
||||||
|
'x': SWIZZLE_X, |
||||||
|
'y': SWIZZLE_Y, |
||||||
|
'z': SWIZZLE_Z, |
||||||
|
'w': SWIZZLE_W, |
||||||
|
'0': SWIZZLE_0, |
||||||
|
'1': SWIZZLE_1, |
||||||
|
'_': SWIZZLE_NONE, |
||||||
|
} |
||||||
|
|
||||||
|
def _parse_channels(fields, layout, colorspace, swizzles): |
||||||
|
if layout == PLAIN: |
||||||
|
names = ['']*4 |
||||||
|
if colorspace in (RGB, SRGB): |
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if swizzle < 4: |
||||||
|
names[swizzle] += 'rgba'[i] |
||||||
|
elif colorspace == ZS: |
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if swizzle < 4: |
||||||
|
names[swizzle] += 'zs'[i] |
||||||
|
else: |
||||||
|
assert False |
||||||
|
for i in range(4): |
||||||
|
if names[i] == '': |
||||||
|
names[i] = 'x' |
||||||
|
else: |
||||||
|
names = ['x', 'y', 'z', 'w'] |
||||||
|
|
||||||
|
channels = [] |
||||||
|
for i in range(0, 4): |
||||||
|
field = fields[i] |
||||||
|
if field: |
||||||
|
type = _type_parse_map[field[0]] |
||||||
|
if field[1] == 'n': |
||||||
|
norm = True |
||||||
|
pure = False |
||||||
|
size = int(field[2:]) |
||||||
|
elif field[1] == 'p': |
||||||
|
pure = True |
||||||
|
norm = False |
||||||
|
size = int(field[2:]) |
||||||
|
else: |
||||||
|
norm = False |
||||||
|
pure = False |
||||||
|
size = int(field[1:]) |
||||||
|
else: |
||||||
|
type = VOID |
||||||
|
norm = False |
||||||
|
pure = False |
||||||
|
size = 0 |
||||||
|
channel = Channel(type, norm, pure, size, names[i]) |
||||||
|
channels.append(channel) |
||||||
|
|
||||||
|
return channels |
||||||
|
|
||||||
|
def parse(filename): |
||||||
|
'''Parse the format descrition in CSV format in terms of the |
||||||
|
Channel and Format classes above.''' |
||||||
|
|
||||||
|
stream = open(filename) |
||||||
|
formats = [] |
||||||
|
for line in stream: |
||||||
|
try: |
||||||
|
comment = line.index('#') |
||||||
|
except ValueError: |
||||||
|
pass |
||||||
|
else: |
||||||
|
line = line[:comment] |
||||||
|
line = line.strip() |
||||||
|
if not line: |
||||||
|
continue |
||||||
|
|
||||||
|
fields = [field.strip() for field in line.split(',')] |
||||||
|
if len (fields) == 10: |
||||||
|
fields += fields[4:9] |
||||||
|
assert len (fields) == 15 |
||||||
|
|
||||||
|
name = fields[0] |
||||||
|
layout = fields[1] |
||||||
|
block_width, block_height = map(int, fields[2:4]) |
||||||
|
colorspace = fields[9] |
||||||
|
|
||||||
|
le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] |
||||||
|
le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles) |
||||||
|
|
||||||
|
be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[14]] |
||||||
|
be_channels = _parse_channels(fields[10:14], layout, colorspace, be_swizzles) |
||||||
|
|
||||||
|
le_shift = 0 |
||||||
|
for channel in le_channels: |
||||||
|
channel.shift = le_shift |
||||||
|
le_shift += channel.size |
||||||
|
|
||||||
|
be_shift = 0 |
||||||
|
for channel in be_channels[3::-1]: |
||||||
|
channel.shift = be_shift |
||||||
|
be_shift += channel.size |
||||||
|
|
||||||
|
assert le_shift == be_shift |
||||||
|
for i in range(4): |
||||||
|
assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE) |
||||||
|
|
||||||
|
format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace) |
||||||
|
formats.append(format) |
||||||
|
return formats |
||||||
|
|
@ -1,232 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Marek Olšák <maraeo@gmail.com> |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the "Software"), |
|
||||||
* to deal in the Software without restriction, including without limitation |
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the |
|
||||||
* Software is furnished to do so, subject to the following conditions: |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the next |
|
||||||
* paragraph) shall be included in all copies or substantial portions of the |
|
||||||
* Software. |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
||||||
* DEALINGS IN THE SOFTWARE. |
|
||||||
*/ |
|
||||||
|
|
||||||
/* Based on code from The OpenGL Programming Guide / 7th Edition, Appendix J.
|
|
||||||
* Available here: http://www.opengl-redbook.com/appendices/
|
|
||||||
* The algorithm in the book contains a bug though, which is fixed in the code |
|
||||||
* below. |
|
||||||
*/ |
|
||||||
|
|
||||||
#define UF11(e, m) ((e << 6) | (m)) |
|
||||||
#define UF11_EXPONENT_BIAS 15 |
|
||||||
#define UF11_EXPONENT_BITS 0x1F |
|
||||||
#define UF11_EXPONENT_SHIFT 6 |
|
||||||
#define UF11_MANTISSA_BITS 0x3F |
|
||||||
#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 0x1F |
|
||||||
#define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT) |
|
||||||
#define UF10_MAX_EXPONENT (UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT) |
|
||||||
|
|
||||||
#define F32_INFINITY 0x7f800000 |
|
||||||
|
|
||||||
static INLINE unsigned f32_to_uf11(float val) |
|
||||||
{ |
|
||||||
union { |
|
||||||
float f; |
|
||||||
uint32_t ui; |
|
||||||
} f32 = {val}; |
|
||||||
|
|
||||||
uint16_t uf11 = 0; |
|
||||||
|
|
||||||
/* Decode little-endian 32-bit floating-point value */ |
|
||||||
int sign = (f32.ui >> 16) & 0x8000; |
|
||||||
/* Map exponent to the range [-127,128] */ |
|
||||||
int exponent = ((f32.ui >> 23) & 0xff) - 127; |
|
||||||
int mantissa = f32.ui & 0x007fffff; |
|
||||||
|
|
||||||
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 |= 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; |
|
||||||
mantissa >>= UF11_MANTISSA_SHIFT; |
|
||||||
uf11 = exponent << UF11_EXPONENT_SHIFT | mantissa; |
|
||||||
} |
|
||||||
|
|
||||||
return uf11; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE float uf11_to_f32(uint16_t val) |
|
||||||
{ |
|
||||||
union { |
|
||||||
float f; |
|
||||||
uint32_t ui; |
|
||||||
} f32; |
|
||||||
|
|
||||||
int exponent = (val & 0x07c0) >> UF11_EXPONENT_SHIFT; |
|
||||||
int mantissa = (val & 0x003f); |
|
||||||
|
|
||||||
f32.f = 0.0; |
|
||||||
|
|
||||||
if (exponent == 0) { |
|
||||||
if (mantissa != 0) { |
|
||||||
const float scale = 1.0 / (1 << 20); |
|
||||||
f32.f = scale * mantissa; |
|
||||||
} |
|
||||||
} |
|
||||||
else if (exponent == 31) { |
|
||||||
f32.ui = F32_INFINITY | mantissa; |
|
||||||
} |
|
||||||
else { |
|
||||||
float scale, decimal; |
|
||||||
exponent -= 15; |
|
||||||
if (exponent < 0) { |
|
||||||
scale = 1.0f / (1 << -exponent); |
|
||||||
} |
|
||||||
else { |
|
||||||
scale = (float) (1 << exponent); |
|
||||||
} |
|
||||||
decimal = 1.0f + (float) mantissa / 64; |
|
||||||
f32.f = scale * decimal; |
|
||||||
} |
|
||||||
|
|
||||||
return f32.f; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE unsigned f32_to_uf10(float val) |
|
||||||
{ |
|
||||||
union { |
|
||||||
float f; |
|
||||||
uint32_t ui; |
|
||||||
} f32 = {val}; |
|
||||||
|
|
||||||
uint16_t uf10 = 0; |
|
||||||
|
|
||||||
/* Decode little-endian 32-bit floating-point value */ |
|
||||||
int sign = (f32.ui >> 16) & 0x8000; |
|
||||||
/* Map exponent to the range [-127,128] */ |
|
||||||
int exponent = ((f32.ui >> 23) & 0xff) - 127; |
|
||||||
int mantissa = f32.ui & 0x007fffff; |
|
||||||
|
|
||||||
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) { |
|
||||||
/* 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; |
|
||||||
mantissa >>= UF10_MANTISSA_SHIFT; |
|
||||||
uf10 = exponent << UF10_EXPONENT_SHIFT | mantissa; |
|
||||||
} |
|
||||||
|
|
||||||
return uf10; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE float uf10_to_f32(uint16_t val) |
|
||||||
{ |
|
||||||
union { |
|
||||||
float f; |
|
||||||
uint32_t ui; |
|
||||||
} f32; |
|
||||||
|
|
||||||
int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT; |
|
||||||
int mantissa = (val & 0x001f); |
|
||||||
|
|
||||||
f32.f = 0.0; |
|
||||||
|
|
||||||
if (exponent == 0) { |
|
||||||
if (mantissa != 0) { |
|
||||||
const float scale = 1.0 / (1 << 20); |
|
||||||
f32.f = scale * mantissa; |
|
||||||
} |
|
||||||
} |
|
||||||
else if (exponent == 31) { |
|
||||||
f32.ui = F32_INFINITY | mantissa; |
|
||||||
} |
|
||||||
else { |
|
||||||
float scale, decimal; |
|
||||||
exponent -= 15; |
|
||||||
if (exponent < 0) { |
|
||||||
scale = 1.0f / (1 << -exponent); |
|
||||||
} |
|
||||||
else { |
|
||||||
scale = (float) (1 << exponent); |
|
||||||
} |
|
||||||
decimal = 1.0f + (float) mantissa / 32; |
|
||||||
f32.f = scale * decimal; |
|
||||||
} |
|
||||||
|
|
||||||
return f32.f; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE unsigned float3_to_r11g11b10f(const float rgb[3]) |
|
||||||
{ |
|
||||||
return ( f32_to_uf11(rgb[0]) & 0x7ff) | |
|
||||||
((f32_to_uf11(rgb[1]) & 0x7ff) << 11) | |
|
||||||
((f32_to_uf10(rgb[2]) & 0x3ff) << 22); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE void r11g11b10f_to_float3(unsigned rgb, float retval[3]) |
|
||||||
{ |
|
||||||
retval[0] = uf11_to_f32( rgb & 0x7ff); |
|
||||||
retval[1] = uf11_to_f32((rgb >> 11) & 0x7ff); |
|
||||||
retval[2] = uf10_to_f32((rgb >> 22) & 0x3ff); |
|
||||||
} |
|
@ -1,164 +0,0 @@ |
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Marek Olšák <maraeo@gmail.com> |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the "Software"), |
|
||||||
* to deal in the Software without restriction, including without limitation |
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the |
|
||||||
* Software is furnished to do so, subject to the following conditions: |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the next |
|
||||||
* paragraph) shall be included in all copies or substantial portions of the |
|
||||||
* Software. |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
||||||
* DEALINGS IN THE SOFTWARE. |
|
||||||
*/ |
|
||||||
|
|
||||||
/* Copied from EXT_texture_shared_exponent and edited. */ |
|
||||||
|
|
||||||
#ifndef RGB9E5_H |
|
||||||
#define RGB9E5_H |
|
||||||
|
|
||||||
#include <math.h> |
|
||||||
#include <assert.h> |
|
||||||
|
|
||||||
#define RGB9E5_EXPONENT_BITS 5 |
|
||||||
#define RGB9E5_MANTISSA_BITS 9 |
|
||||||
#define RGB9E5_EXP_BIAS 15 |
|
||||||
#define RGB9E5_MAX_VALID_BIASED_EXP 31 |
|
||||||
|
|
||||||
#define MAX_RGB9E5_EXP (RGB9E5_MAX_VALID_BIASED_EXP - RGB9E5_EXP_BIAS) |
|
||||||
#define RGB9E5_MANTISSA_VALUES (1<<RGB9E5_MANTISSA_BITS) |
|
||||||
#define MAX_RGB9E5_MANTISSA (RGB9E5_MANTISSA_VALUES-1) |
|
||||||
#define MAX_RGB9E5 (((float)MAX_RGB9E5_MANTISSA)/RGB9E5_MANTISSA_VALUES * (1<<MAX_RGB9E5_EXP)) |
|
||||||
#define EPSILON_RGB9E5 ((1.0/RGB9E5_MANTISSA_VALUES) / (1<<RGB9E5_EXP_BIAS)) |
|
||||||
|
|
||||||
typedef union { |
|
||||||
unsigned int raw; |
|
||||||
float value; |
|
||||||
struct { |
|
||||||
#if defined(MESA_BIG_ENDIAN) || defined(PIPE_ARCH_BIG_ENDIAN) |
|
||||||
unsigned int negative:1; |
|
||||||
unsigned int biasedexponent:8; |
|
||||||
unsigned int mantissa:23; |
|
||||||
#else |
|
||||||
unsigned int mantissa:23; |
|
||||||
unsigned int biasedexponent:8; |
|
||||||
unsigned int negative:1; |
|
||||||
#endif |
|
||||||
} field; |
|
||||||
} float754; |
|
||||||
|
|
||||||
typedef union { |
|
||||||
unsigned int raw; |
|
||||||
struct { |
|
||||||
#if defined(MESA_BIG_ENDIAN) || defined(PIPE_ARCH_BIG_ENDIAN) |
|
||||||
unsigned int biasedexponent:RGB9E5_EXPONENT_BITS; |
|
||||||
unsigned int b:RGB9E5_MANTISSA_BITS; |
|
||||||
unsigned int g:RGB9E5_MANTISSA_BITS; |
|
||||||
unsigned int r:RGB9E5_MANTISSA_BITS; |
|
||||||
#else |
|
||||||
unsigned int r:RGB9E5_MANTISSA_BITS; |
|
||||||
unsigned int g:RGB9E5_MANTISSA_BITS; |
|
||||||
unsigned int b:RGB9E5_MANTISSA_BITS; |
|
||||||
unsigned int biasedexponent:RGB9E5_EXPONENT_BITS; |
|
||||||
#endif |
|
||||||
} field; |
|
||||||
} rgb9e5; |
|
||||||
|
|
||||||
static INLINE float rgb9e5_ClampRange(float x) |
|
||||||
{ |
|
||||||
if (x > 0.0) { |
|
||||||
if (x >= MAX_RGB9E5) { |
|
||||||
return MAX_RGB9E5; |
|
||||||
} else { |
|
||||||
return x; |
|
||||||
} |
|
||||||
} else { |
|
||||||
/* NaN gets here too since comparisons with NaN always fail! */ |
|
||||||
return 0.0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Ok, FloorLog2 is not correct for the denorm and zero values, but we
|
|
||||||
are going to do a max of this value with the minimum rgb9e5 exponent |
|
||||||
that will hide these problem cases. */ |
|
||||||
static INLINE int rgb9e5_FloorLog2(float x) |
|
||||||
{ |
|
||||||
float754 f; |
|
||||||
|
|
||||||
f.value = x; |
|
||||||
return (f.field.biasedexponent - 127); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE unsigned float3_to_rgb9e5(const float rgb[3]) |
|
||||||
{ |
|
||||||
rgb9e5 retval; |
|
||||||
float maxrgb; |
|
||||||
int rm, gm, bm; |
|
||||||
float rc, gc, bc; |
|
||||||
int exp_shared, maxm; |
|
||||||
double denom; |
|
||||||
|
|
||||||
rc = rgb9e5_ClampRange(rgb[0]); |
|
||||||
gc = rgb9e5_ClampRange(rgb[1]); |
|
||||||
bc = rgb9e5_ClampRange(rgb[2]); |
|
||||||
|
|
||||||
maxrgb = MAX3(rc, gc, bc); |
|
||||||
exp_shared = MAX2(-RGB9E5_EXP_BIAS-1, rgb9e5_FloorLog2(maxrgb)) + 1 + RGB9E5_EXP_BIAS; |
|
||||||
assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP); |
|
||||||
assert(exp_shared >= 0); |
|
||||||
/* This pow function could be replaced by a table. */ |
|
||||||
denom = pow(2, exp_shared - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS); |
|
||||||
|
|
||||||
maxm = (int) floor(maxrgb / denom + 0.5); |
|
||||||
if (maxm == MAX_RGB9E5_MANTISSA+1) { |
|
||||||
denom *= 2; |
|
||||||
exp_shared += 1; |
|
||||||
assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP); |
|
||||||
} else { |
|
||||||
assert(maxm <= MAX_RGB9E5_MANTISSA); |
|
||||||
} |
|
||||||
|
|
||||||
rm = (int) floor(rc / denom + 0.5); |
|
||||||
gm = (int) floor(gc / denom + 0.5); |
|
||||||
bm = (int) floor(bc / denom + 0.5); |
|
||||||
|
|
||||||
assert(rm <= MAX_RGB9E5_MANTISSA); |
|
||||||
assert(gm <= MAX_RGB9E5_MANTISSA); |
|
||||||
assert(bm <= MAX_RGB9E5_MANTISSA); |
|
||||||
assert(rm >= 0); |
|
||||||
assert(gm >= 0); |
|
||||||
assert(bm >= 0); |
|
||||||
|
|
||||||
retval.field.r = rm; |
|
||||||
retval.field.g = gm; |
|
||||||
retval.field.b = bm; |
|
||||||
retval.field.biasedexponent = exp_shared; |
|
||||||
|
|
||||||
return retval.raw; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE void rgb9e5_to_float3(unsigned rgb, float retval[3]) |
|
||||||
{ |
|
||||||
rgb9e5 v; |
|
||||||
int exponent; |
|
||||||
float scale; |
|
||||||
|
|
||||||
v.raw = rgb; |
|
||||||
exponent = v.field.biasedexponent - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS; |
|
||||||
scale = (float) pow(2, exponent); |
|
||||||
|
|
||||||
retval[0] = v.field.r * scale; |
|
||||||
retval[1] = v.field.g * scale; |
|
||||||
retval[2] = v.field.b * scale; |
|
||||||
} |
|
||||||
|
|
||||||
#endif |
|
@ -1,171 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright (C) 2011 Red Hat Inc. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the "Software"), |
|
||||||
* to deal in the Software without restriction, including without limitation |
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the |
|
||||||
* Software is furnished to do so, subject to the following conditions: |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice shall be included |
|
||||||
* in all copies or substantial portions of the Software. |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
|
||||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|
||||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
||||||
* OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
#include <stdio.h> |
|
||||||
#include "u_math.h" |
|
||||||
#include "u_format.h" |
|
||||||
#include "u_format_rgtc.h" |
|
||||||
#include "util/rgtc.h" |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row,
|
|
||||||
unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_rxtc2_unorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
fprintf(stderr,"%s\n", __func__); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_rxtc2_snorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
@ -1,114 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2011 Red Hat Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
#ifndef U_FORMAT_RGTC_H_ |
|
||||||
#define U_FORMAT_RGTC_H_ |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); |
|
||||||
|
|
||||||
|
|
||||||
#endif |
|
@ -1,178 +0,0 @@ |
|||||||
/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */ |
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
/**
|
|
||||||
* @file |
|
||||||
* SRGB translation. |
|
||||||
* |
|
||||||
* @author Brian Paul <brianp@vmware.com> |
|
||||||
* @author Michal Krol <michal@vmware.com> |
|
||||||
* @author Jose Fonseca <jfonseca@vmware.com> |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "u_format_srgb.h" |
|
||||||
|
|
||||||
const float |
|
||||||
util_format_srgb_8unorm_to_linear_float_table[256] = { |
|
||||||
0.0000000e+00, 3.0352698e-04, 6.0705397e-04, 9.1058095e-04, |
|
||||||
1.2141079e-03, 1.5176349e-03, 1.8211619e-03, 2.1246889e-03, |
|
||||||
2.4282159e-03, 2.7317429e-03, 3.0352698e-03, 3.3465358e-03, |
|
||||||
3.6765073e-03, 4.0247170e-03, 4.3914420e-03, 4.7769535e-03, |
|
||||||
5.1815167e-03, 5.6053916e-03, 6.0488330e-03, 6.5120908e-03, |
|
||||||
6.9954102e-03, 7.4990320e-03, 8.0231930e-03, 8.5681256e-03, |
|
||||||
9.1340587e-03, 9.7212173e-03, 1.0329823e-02, 1.0960094e-02, |
|
||||||
1.1612245e-02, 1.2286488e-02, 1.2983032e-02, 1.3702083e-02, |
|
||||||
1.4443844e-02, 1.5208514e-02, 1.5996293e-02, 1.6807376e-02, |
|
||||||
1.7641954e-02, 1.8500220e-02, 1.9382361e-02, 2.0288563e-02, |
|
||||||
2.1219010e-02, 2.2173885e-02, 2.3153366e-02, 2.4157632e-02, |
|
||||||
2.5186860e-02, 2.6241222e-02, 2.7320892e-02, 2.8426040e-02, |
|
||||||
2.9556834e-02, 3.0713444e-02, 3.1896033e-02, 3.3104767e-02, |
|
||||||
3.4339807e-02, 3.5601315e-02, 3.6889450e-02, 3.8204372e-02, |
|
||||||
3.9546235e-02, 4.0915197e-02, 4.2311411e-02, 4.3735029e-02, |
|
||||||
4.5186204e-02, 4.6665086e-02, 4.8171824e-02, 4.9706566e-02, |
|
||||||
5.1269458e-02, 5.2860647e-02, 5.4480276e-02, 5.6128490e-02, |
|
||||||
5.7805430e-02, 5.9511238e-02, 6.1246054e-02, 6.3010018e-02, |
|
||||||
6.4803267e-02, 6.6625939e-02, 6.8478170e-02, 7.0360096e-02, |
|
||||||
7.2271851e-02, 7.4213568e-02, 7.6185381e-02, 7.8187422e-02, |
|
||||||
8.0219820e-02, 8.2282707e-02, 8.4376212e-02, 8.6500462e-02, |
|
||||||
8.8655586e-02, 9.0841711e-02, 9.3058963e-02, 9.5307467e-02, |
|
||||||
9.7587347e-02, 9.9898728e-02, 1.0224173e-01, 1.0461648e-01, |
|
||||||
1.0702310e-01, 1.0946171e-01, 1.1193243e-01, 1.1443537e-01, |
|
||||||
1.1697067e-01, 1.1953843e-01, 1.2213877e-01, 1.2477182e-01, |
|
||||||
1.2743768e-01, 1.3013648e-01, 1.3286832e-01, 1.3563333e-01, |
|
||||||
1.3843162e-01, 1.4126329e-01, 1.4412847e-01, 1.4702727e-01, |
|
||||||
1.4995979e-01, 1.5292615e-01, 1.5592646e-01, 1.5896084e-01, |
|
||||||
1.6202938e-01, 1.6513219e-01, 1.6826940e-01, 1.7144110e-01, |
|
||||||
1.7464740e-01, 1.7788842e-01, 1.8116424e-01, 1.8447499e-01, |
|
||||||
1.8782077e-01, 1.9120168e-01, 1.9461783e-01, 1.9806932e-01, |
|
||||||
2.0155625e-01, 2.0507874e-01, 2.0863687e-01, 2.1223076e-01, |
|
||||||
2.1586050e-01, 2.1952620e-01, 2.2322796e-01, 2.2696587e-01, |
|
||||||
2.3074005e-01, 2.3455058e-01, 2.3839757e-01, 2.4228112e-01, |
|
||||||
2.4620133e-01, 2.5015828e-01, 2.5415209e-01, 2.5818285e-01, |
|
||||||
2.6225066e-01, 2.6635560e-01, 2.7049779e-01, 2.7467731e-01, |
|
||||||
2.7889426e-01, 2.8314874e-01, 2.8744084e-01, 2.9177065e-01, |
|
||||||
2.9613827e-01, 3.0054379e-01, 3.0498731e-01, 3.0946892e-01, |
|
||||||
3.1398871e-01, 3.1854678e-01, 3.2314321e-01, 3.2777810e-01, |
|
||||||
3.3245154e-01, 3.3716362e-01, 3.4191442e-01, 3.4670406e-01, |
|
||||||
3.5153260e-01, 3.5640014e-01, 3.6130678e-01, 3.6625260e-01, |
|
||||||
3.7123768e-01, 3.7626212e-01, 3.8132601e-01, 3.8642943e-01, |
|
||||||
3.9157248e-01, 3.9675523e-01, 4.0197778e-01, 4.0724021e-01, |
|
||||||
4.1254261e-01, 4.1788507e-01, 4.2326767e-01, 4.2869050e-01, |
|
||||||
4.3415364e-01, 4.3965717e-01, 4.4520119e-01, 4.5078578e-01, |
|
||||||
4.5641102e-01, 4.6207700e-01, 4.6778380e-01, 4.7353150e-01, |
|
||||||
4.7932018e-01, 4.8514994e-01, 4.9102085e-01, 4.9693300e-01, |
|
||||||
5.0288646e-01, 5.0888132e-01, 5.1491767e-01, 5.2099557e-01, |
|
||||||
5.2711513e-01, 5.3327640e-01, 5.3947949e-01, 5.4572446e-01, |
|
||||||
5.5201140e-01, 5.5834039e-01, 5.6471151e-01, 5.7112483e-01, |
|
||||||
5.7758044e-01, 5.8407842e-01, 5.9061884e-01, 5.9720179e-01, |
|
||||||
6.0382734e-01, 6.1049557e-01, 6.1720656e-01, 6.2396039e-01, |
|
||||||
6.3075714e-01, 6.3759687e-01, 6.4447968e-01, 6.5140564e-01, |
|
||||||
6.5837482e-01, 6.6538730e-01, 6.7244316e-01, 6.7954247e-01, |
|
||||||
6.8668531e-01, 6.9387176e-01, 7.0110189e-01, 7.0837578e-01, |
|
||||||
7.1569350e-01, 7.2305513e-01, 7.3046074e-01, 7.3791041e-01, |
|
||||||
7.4540421e-01, 7.5294222e-01, 7.6052450e-01, 7.6815115e-01, |
|
||||||
7.7582222e-01, 7.8353779e-01, 7.9129794e-01, 7.9910274e-01, |
|
||||||
8.0695226e-01, 8.1484657e-01, 8.2278575e-01, 8.3076988e-01, |
|
||||||
8.3879901e-01, 8.4687323e-01, 8.5499261e-01, 8.6315721e-01, |
|
||||||
8.7136712e-01, 8.7962240e-01, 8.8792312e-01, 8.9626935e-01, |
|
||||||
9.0466117e-01, 9.1309865e-01, 9.2158186e-01, 9.3011086e-01, |
|
||||||
9.3868573e-01, 9.4730654e-01, 9.5597335e-01, 9.6468625e-01, |
|
||||||
9.7344529e-01, 9.8225055e-01, 9.9110210e-01, 1.0000000e+00, |
|
||||||
}; |
|
||||||
|
|
||||||
const uint8_t |
|
||||||
util_format_srgb_to_linear_8unorm_table[256] = { |
|
||||||
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
||||||
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, |
|
||||||
4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, |
|
||||||
8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, |
|
||||||
13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 20, |
|
||||||
20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, |
|
||||||
30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 37, 38, 39, 40, 41, |
|
||||||
41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, |
|
||||||
55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, |
|
||||||
71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, |
|
||||||
90, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, |
|
||||||
111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 133, |
|
||||||
134, 136, 138, 139, 141, 142, 144, 146, 147, 149, 151, 152, 154, 156, 157, 159, |
|
||||||
161, 163, 164, 166, 168, 170, 171, 173, 175, 177, 179, 181, 183, 184, 186, 188, |
|
||||||
190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, |
|
||||||
222, 224, 226, 229, 231, 233, 235, 237, 239, 242, 244, 246, 248, 250, 253, 255, |
|
||||||
}; |
|
||||||
|
|
||||||
const uint8_t |
|
||||||
util_format_linear_to_srgb_8unorm_table[256] = { |
|
||||||
0, 13, 22, 28, 34, 38, 42, 46, 50, 53, 56, 59, 61, 64, 66, 69, |
|
||||||
71, 73, 75, 77, 79, 81, 83, 85, 86, 88, 90, 92, 93, 95, 96, 98, |
|
||||||
99, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 115, 117, 118, 119, |
|
||||||
120, 121, 122, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
|
||||||
137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 151, |
|
||||||
152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 164, |
|
||||||
165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 173, 173, 174, 175, 175, 176, |
|
||||||
177, 178, 178, 179, 180, 180, 181, 182, 182, 183, 184, 185, 185, 186, 187, 187, |
|
||||||
188, 189, 189, 190, 190, 191, 192, 192, 193, 194, 194, 195, 196, 196, 197, 197, |
|
||||||
198, 199, 199, 200, 200, 201, 202, 202, 203, 203, 204, 205, 205, 206, 206, 207, |
|
||||||
208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, |
|
||||||
216, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, |
|
||||||
225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, |
|
||||||
233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, |
|
||||||
241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 246, 247, 247, 248, |
|
||||||
248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, |
|
||||||
}; |
|
||||||
|
|
||||||
const unsigned |
|
||||||
util_format_linear_to_srgb_helper_table[104] = { |
|
||||||
0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, |
|
||||||
0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, |
|
||||||
0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, |
|
||||||
0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, |
|
||||||
0x010e0033, 0x01280033, 0x01410033, 0x015b0033, |
|
||||||
0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, |
|
||||||
0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, |
|
||||||
0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, |
|
||||||
0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, |
|
||||||
0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, |
|
||||||
0x06970158, 0x07420142, 0x07e30130, 0x087b0120, |
|
||||||
0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, |
|
||||||
0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, |
|
||||||
0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, |
|
||||||
0x11070264, 0x1238023e, 0x1357021d, 0x14660201, |
|
||||||
0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, |
|
||||||
0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, |
|
||||||
0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, |
|
||||||
0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, |
|
||||||
0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, |
|
||||||
0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, |
|
||||||
0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, |
|
||||||
0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, |
|
||||||
0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, |
|
||||||
0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, |
|
||||||
0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, |
|
||||||
}; |
|
||||||
|
|
@ -1,147 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
/**
|
|
||||||
* @file |
|
||||||
* SRGB translation. |
|
||||||
* |
|
||||||
* @author Brian Paul <brianp@vmware.com> |
|
||||||
* @author Michal Krol <michal@vmware.com> |
|
||||||
* @author Jose Fonseca <jfonseca@vmware.com> |
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef U_FORMAT_SRGB_H_ |
|
||||||
#define U_FORMAT_SRGB_H_ |
|
||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h" |
|
||||||
#include "u_pack_color.h" |
|
||||||
#include "u_math.h" |
|
||||||
|
|
||||||
|
|
||||||
extern const float |
|
||||||
util_format_srgb_8unorm_to_linear_float_table[256]; |
|
||||||
|
|
||||||
extern const uint8_t |
|
||||||
util_format_srgb_to_linear_8unorm_table[256]; |
|
||||||
|
|
||||||
extern const uint8_t |
|
||||||
util_format_linear_to_srgb_8unorm_table[256]; |
|
||||||
|
|
||||||
extern const unsigned |
|
||||||
util_format_linear_to_srgb_helper_table[104]; |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a unclamped linear float to srgb value in the [0,255]. |
|
||||||
*/ |
|
||||||
static INLINE uint8_t |
|
||||||
util_format_linear_float_to_srgb_8unorm(float x) |
|
||||||
{ |
|
||||||
/* this would be exact but (probably much) slower */ |
|
||||||
if (0) { |
|
||||||
if (x >= 1.0f) |
|
||||||
return 255; |
|
||||||
else if (x >= 0.0031308f) |
|
||||||
return float_to_ubyte(1.055f * powf(x, 0.41666666f) - 0.055f); |
|
||||||
else if (x > 0.0f) |
|
||||||
return float_to_ubyte(12.92f * x); |
|
||||||
else |
|
||||||
return 0; |
|
||||||
} |
|
||||||
else { |
|
||||||
/*
|
|
||||||
* This is taken from https://gist.github.com/rygorous/2203834
|
|
||||||
* Use LUT and do linear interpolation. |
|
||||||
*/ |
|
||||||
union fi almostone, minval, f; |
|
||||||
unsigned tab, bias, scale, t; |
|
||||||
|
|
||||||
almostone.ui = 0x3f7fffff; |
|
||||||
minval.ui = (127-13) << 23; |
|
||||||
|
|
||||||
/*
|
|
||||||
* Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. |
|
||||||
* The tests are carefully written so that NaNs map to 0, same as in the |
|
||||||
* reference implementation. |
|
||||||
*/ |
|
||||||
if (!(x > minval.f)) |
|
||||||
x = minval.f; |
|
||||||
if (x > almostone.f) |
|
||||||
x = almostone.f; |
|
||||||
|
|
||||||
/* Do the table lookup and unpack bias, scale */ |
|
||||||
f.f = x; |
|
||||||
tab = util_format_linear_to_srgb_helper_table[(f.ui - minval.ui) >> 20]; |
|
||||||
bias = (tab >> 16) << 9; |
|
||||||
scale = tab & 0xffff; |
|
||||||
|
|
||||||
/* Grab next-highest mantissa bits and perform linear interpolation */ |
|
||||||
t = (f.ui >> 12) & 0xff; |
|
||||||
return (uint8_t) ((bias + scale*t) >> 16); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an 8-bit sRGB value from non-linear space to a |
|
||||||
* linear RGB value in [0, 1]. |
|
||||||
* Implemented with a 256-entry lookup table. |
|
||||||
*/ |
|
||||||
static INLINE float |
|
||||||
util_format_srgb_8unorm_to_linear_float(uint8_t x) |
|
||||||
{ |
|
||||||
return util_format_srgb_8unorm_to_linear_float_table[x]; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX These 2 functions probably don't make a lot of sense (but lots |
|
||||||
* of potential callers which most likely all don't make sense neither) |
|
||||||
*/ |
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a 8bit normalized value from linear to srgb. |
|
||||||
*/ |
|
||||||
static INLINE uint8_t |
|
||||||
util_format_linear_to_srgb_8unorm(uint8_t x) |
|
||||||
{ |
|
||||||
return util_format_linear_to_srgb_8unorm_table[x]; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a 8bit normalized value from srgb to linear. |
|
||||||
*/ |
|
||||||
static INLINE uint8_t |
|
||||||
util_format_srgb_to_linear_8unorm(uint8_t x) |
|
||||||
{ |
|
||||||
return util_format_srgb_to_linear_8unorm_table[x]; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#endif /* U_FORMAT_SRGB_H_ */ |
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,167 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
CopyRight = ''' |
||||||
|
/************************************************************************** |
||||||
|
* |
||||||
|
* Copyright 2010 VMware, Inc. |
||||||
|
* All Rights Reserved. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the |
||||||
|
* "Software"), to deal in the Software without restriction, including |
||||||
|
* without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to |
||||||
|
* permit persons to whom the Software is furnished to do so, subject to |
||||||
|
* the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the |
||||||
|
* next paragraph) shall be included in all copies or substantial portions |
||||||
|
* of the Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
||||||
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||||
|
* |
||||||
|
**************************************************************************/ |
||||||
|
''' |
||||||
|
|
||||||
|
|
||||||
|
import sys |
||||||
|
|
||||||
|
from u_format_parse import * |
||||||
|
import u_format_pack |
||||||
|
|
||||||
|
|
||||||
|
def layout_map(layout): |
||||||
|
return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper() |
||||||
|
|
||||||
|
|
||||||
|
def colorspace_map(colorspace): |
||||||
|
return 'UTIL_FORMAT_COLORSPACE_' + str(colorspace).upper() |
||||||
|
|
||||||
|
|
||||||
|
colorspace_channels_map = { |
||||||
|
'rgb': ['r', 'g', 'b', 'a'], |
||||||
|
'srgb': ['sr', 'sg', 'sb', 'a'], |
||||||
|
'zs': ['z', 's'], |
||||||
|
'yuv': ['y', 'u', 'v'], |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
type_map = { |
||||||
|
VOID: "UTIL_FORMAT_TYPE_VOID", |
||||||
|
UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED", |
||||||
|
SIGNED: "UTIL_FORMAT_TYPE_SIGNED", |
||||||
|
FIXED: "UTIL_FORMAT_TYPE_FIXED", |
||||||
|
FLOAT: "UTIL_FORMAT_TYPE_FLOAT", |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
def bool_map(value): |
||||||
|
if value: |
||||||
|
return "TRUE" |
||||||
|
else: |
||||||
|
return "FALSE" |
||||||
|
|
||||||
|
|
||||||
|
swizzle_map = { |
||||||
|
SWIZZLE_X: "UTIL_FORMAT_SWIZZLE_X", |
||||||
|
SWIZZLE_Y: "UTIL_FORMAT_SWIZZLE_Y", |
||||||
|
SWIZZLE_Z: "UTIL_FORMAT_SWIZZLE_Z", |
||||||
|
SWIZZLE_W: "UTIL_FORMAT_SWIZZLE_W", |
||||||
|
SWIZZLE_0: "UTIL_FORMAT_SWIZZLE_0", |
||||||
|
SWIZZLE_1: "UTIL_FORMAT_SWIZZLE_1", |
||||||
|
SWIZZLE_NONE: "UTIL_FORMAT_SWIZZLE_NONE", |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
def write_format_table(formats): |
||||||
|
print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */' |
||||||
|
print |
||||||
|
# This will print the copyright message on the top of this file |
||||||
|
print CopyRight.strip() |
||||||
|
print |
||||||
|
print '#include "u_format.h"' |
||||||
|
print |
||||||
|
|
||||||
|
u_format_pack.generate(formats) |
||||||
|
|
||||||
|
def do_channel_array(channels, swizzles): |
||||||
|
print " {" |
||||||
|
for i in range(4): |
||||||
|
channel = channels[i] |
||||||
|
if i < 3: |
||||||
|
sep = "," |
||||||
|
else: |
||||||
|
sep = "" |
||||||
|
if channel.size: |
||||||
|
print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name) |
||||||
|
else: |
||||||
|
print " {0, 0, 0, 0, 0}%s" % (sep,) |
||||||
|
print " }," |
||||||
|
|
||||||
|
def do_swizzle_array(channels, swizzles): |
||||||
|
print " {" |
||||||
|
for i in range(4): |
||||||
|
swizzle = swizzles[i] |
||||||
|
if i < 3: |
||||||
|
sep = "," |
||||||
|
else: |
||||||
|
sep = "" |
||||||
|
try: |
||||||
|
comment = colorspace_channels_map[format.colorspace][i] |
||||||
|
except (KeyError, IndexError): |
||||||
|
comment = 'ignored' |
||||||
|
print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) |
||||||
|
print " }," |
||||||
|
|
||||||
|
for format in formats: |
||||||
|
print 'const struct util_format_description' |
||||||
|
print 'util_format_%s_description = {' % (format.short_name(),) |
||||||
|
print " %s," % (format.name,) |
||||||
|
print " \"%s\"," % (format.name,) |
||||||
|
print " \"%s\"," % (format.short_name(),) |
||||||
|
print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) |
||||||
|
print " %s," % (layout_map(format.layout),) |
||||||
|
print " %u,\t/* nr_channels */" % (format.nr_channels(),) |
||||||
|
print " %s,\t/* is_array */" % (bool_map(format.is_array()),) |
||||||
|
print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) |
||||||
|
print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) |
||||||
|
u_format_pack.print_channels(format, do_channel_array) |
||||||
|
u_format_pack.print_channels(format, do_swizzle_array) |
||||||
|
print " %s," % (colorspace_map(format.colorspace),) |
||||||
|
print "};" |
||||||
|
print |
||||||
|
|
||||||
|
print "const struct util_format_description *" |
||||||
|
print "util_format_description(enum pipe_format format)" |
||||||
|
print "{" |
||||||
|
print " if (format >= PIPE_FORMAT_COUNT) {" |
||||||
|
print " return NULL;" |
||||||
|
print " }" |
||||||
|
print |
||||||
|
print " switch (format) {" |
||||||
|
for format in formats: |
||||||
|
print " case %s:" % format.name |
||||||
|
print " return &util_format_%s_description;" % (format.short_name(),) |
||||||
|
print " default:" |
||||||
|
print " return NULL;" |
||||||
|
print " }" |
||||||
|
print "}" |
||||||
|
print |
||||||
|
|
||||||
|
|
||||||
|
def main(): |
||||||
|
|
||||||
|
formats = [] |
||||||
|
for arg in sys.argv[1:]: |
||||||
|
formats.extend(parse(arg)) |
||||||
|
write_format_table(formats) |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
main() |
File diff suppressed because it is too large
Load Diff
@ -1,364 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file |
|
||||||
* YUV colorspace conversion. |
|
||||||
* |
|
||||||
* @author Brian Paul <brianp@vmware.com> |
|
||||||
* @author Michal Krol <michal@vmware.com> |
|
||||||
* @author Jose Fonseca <jfonseca@vmware.com> |
|
||||||
* |
|
||||||
* See also: |
|
||||||
* - http://www.fourcc.org/fccyvrgb.php
|
|
||||||
* - http://msdn.microsoft.com/en-us/library/ms893078
|
|
||||||
* - http://en.wikipedia.org/wiki/YUV
|
|
||||||
*/ |
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_FORMAT_YUV_H_ |
|
||||||
#define U_FORMAT_YUV_H_ |
|
||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h" |
|
||||||
#include "u_math.h" |
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Ensure we use consistent and right floating formulas, with enough |
|
||||||
* precision in the coefficients. |
|
||||||
*/ |
|
||||||
|
|
||||||
static INLINE void |
|
||||||
util_format_rgb_float_to_yuv(float r, float g, float b, |
|
||||||
uint8_t *y, uint8_t *u, uint8_t *v) |
|
||||||
{ |
|
||||||
const float _r = CLAMP(r, 0.0f, 1.0f); |
|
||||||
const float _g = CLAMP(g, 0.0f, 1.0f); |
|
||||||
const float _b = CLAMP(b, 0.0f, 1.0f); |
|
||||||
|
|
||||||
const float scale = 255.0f; |
|
||||||
|
|
||||||
const int _y = scale * ( (0.257f * _r) + (0.504f * _g) + (0.098f * _b)); |
|
||||||
const int _u = scale * (-(0.148f * _r) - (0.291f * _g) + (0.439f * _b)); |
|
||||||
const int _v = scale * ( (0.439f * _r) - (0.368f * _g) - (0.071f * _b)); |
|
||||||
|
|
||||||
*y = _y + 16;
|
|
||||||
*u = _u + 128;
|
|
||||||
*v = _v + 128;
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static INLINE void |
|
||||||
util_format_yuv_to_rgb_float(uint8_t y, uint8_t u, uint8_t v, |
|
||||||
float *r, float *g, float *b) |
|
||||||
{ |
|
||||||
const int _y = y - 16; |
|
||||||
const int _u = u - 128; |
|
||||||
const int _v = v - 128; |
|
||||||
|
|
||||||
const float y_factor = 255.0f / 219.0f; |
|
||||||
|
|
||||||
const float scale = 1.0f / 255.0f; |
|
||||||
|
|
||||||
*r = scale * (y_factor * _y + 1.596f * _v); |
|
||||||
*g = scale * (y_factor * _y - 0.391f * _u - 0.813f * _v); |
|
||||||
*b = scale * (y_factor * _y + 2.018f * _u ); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static INLINE void |
|
||||||
util_format_rgb_8unorm_to_yuv(uint8_t r, uint8_t g, uint8_t b, |
|
||||||
uint8_t *y, uint8_t *u, uint8_t *v) |
|
||||||
{ |
|
||||||
*y = (( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16; |
|
||||||
*u = (( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128; |
|
||||||
*v = (( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static INLINE void |
|
||||||
util_format_yuv_to_rgb_8unorm(uint8_t y, uint8_t u, uint8_t v, |
|
||||||
uint8_t *r, uint8_t *g, uint8_t *b) |
|
||||||
{ |
|
||||||
const int _y = y - 16; |
|
||||||
const int _u = u - 128; |
|
||||||
const int _v = v - 128; |
|
||||||
|
|
||||||
const int _r = (298 * _y + 409 * _v + 128) >> 8; |
|
||||||
const int _g = (298 * _y - 100 * _u - 208 * _v + 128) >> 8; |
|
||||||
const int _b = (298 * _y + 516 * _u + 128) >> 8; |
|
||||||
|
|
||||||
*r = CLAMP(_r, 0, 255); |
|
||||||
*g = CLAMP(_g, 0, 255); |
|
||||||
*b = CLAMP(_b, 0, 255); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
/* XXX: Stubbed for now */ |
|
||||||
void |
|
||||||
util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
void |
|
||||||
util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
void |
|
||||||
util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
void |
|
||||||
util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
void |
|
||||||
util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
void |
|
||||||
util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
void |
|
||||||
util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_r8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_r8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_r8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_r8g8_r8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_b8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_b8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_b8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_g8r8_b8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, |
|
||||||
unsigned i, unsigned j); |
|
||||||
|
|
||||||
#endif /* U_FORMAT_YUV_H_ */ |
|
@ -1,973 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
|
|
||||||
#include "u_debug.h" |
|
||||||
#include "u_math.h" |
|
||||||
#include "u_format_zs.h" |
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* z32_unorm conversion functions |
|
||||||
*/ |
|
||||||
|
|
||||||
static INLINE uint16_t |
|
||||||
z32_unorm_to_z16_unorm(uint32_t z) |
|
||||||
{ |
|
||||||
/* z * 0xffff / 0xffffffff */ |
|
||||||
return z >> 16; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE uint32_t |
|
||||||
z16_unorm_to_z32_unorm(uint16_t z) |
|
||||||
{ |
|
||||||
/* z * 0xffffffff / 0xffff */ |
|
||||||
return (z << 16) | z; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE uint32_t |
|
||||||
z32_unorm_to_z24_unorm(uint32_t z) |
|
||||||
{ |
|
||||||
/* z * 0xffffff / 0xffffffff */ |
|
||||||
return z >> 8; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE uint32_t |
|
||||||
z24_unorm_to_z32_unorm(uint32_t z) |
|
||||||
{ |
|
||||||
/* z * 0xffffffff / 0xffffff */ |
|
||||||
return (z << 8) | (z >> 16); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* z32_float conversion functions |
|
||||||
*/ |
|
||||||
|
|
||||||
static INLINE uint16_t |
|
||||||
z32_float_to_z16_unorm(float z) |
|
||||||
{ |
|
||||||
const float scale = 0xffff; |
|
||||||
return (uint16_t)(z * scale + 0.5f); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE float |
|
||||||
z16_unorm_to_z32_float(uint16_t z) |
|
||||||
{ |
|
||||||
const float scale = 1.0 / 0xffff; |
|
||||||
return (float)(z * scale); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE uint32_t |
|
||||||
z32_float_to_z24_unorm(float z) |
|
||||||
{ |
|
||||||
const double scale = 0xffffff; |
|
||||||
return (uint32_t)(z * scale) & 0xffffff; |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE float |
|
||||||
z24_unorm_to_z32_float(uint32_t z) |
|
||||||
{ |
|
||||||
const double scale = 1.0 / 0xffffff; |
|
||||||
return (float)(z * scale); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE uint32_t |
|
||||||
z32_float_to_z32_unorm(float z) |
|
||||||
{ |
|
||||||
const double scale = 0xffffffff; |
|
||||||
return (uint32_t)(z * scale); |
|
||||||
} |
|
||||||
|
|
||||||
static INLINE float |
|
||||||
z32_unorm_to_z32_float(uint32_t z) |
|
||||||
{ |
|
||||||
const double scale = 1.0 / 0xffffffff; |
|
||||||
return (float)(z * scale); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint16_t *src = (const uint16_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint16_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
*dst++ = z16_unorm_to_z32_float(value); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint16_t *dst = (uint16_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint16_t value; |
|
||||||
value = z32_float_to_z16_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const uint16_t *src = (const uint16_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint16_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
*dst++ = z16_unorm_to_z32_unorm(value); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
uint16_t *dst = (uint16_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint16_t value; |
|
||||||
value = z32_unorm_to_z16_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap16(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z32_unorm_to_z32_float(value); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value; |
|
||||||
value = z32_float_to_z32_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width * 4); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width * 4); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width * 4); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
memcpy(dst_row, src_row, width * 4); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const float *src = (const float *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst++ = z32_float_to_z32_unorm(*src++); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
float *dst = (float *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst++ = z32_unorm_to_z32_float(*src++); |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_float(value & 0xffffff); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0xff000000; |
|
||||||
value |= z32_float_to_z24_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value= *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0xff000000; |
|
||||||
value |= z32_unorm_to_z24_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value >> 24; |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0x00ffffff; |
|
||||||
value |= *src++ << 24; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_float(value >> 8); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0x000000ff; |
|
||||||
value |= z32_float_to_z24_unorm(*src++) << 8; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_unorm(value >> 8); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0x000000ff; |
|
||||||
value |= *src++ & 0xffffff00; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value & 0xff; |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *dst; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
value &= 0xffffff00; |
|
||||||
value |= *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_float(value & 0xffffff); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value; |
|
||||||
value = z32_float_to_z24_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value; |
|
||||||
value = z32_unorm_to_z24_unorm(*src++); |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const uint32_t *src = (uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_float(value >> 8); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value; |
|
||||||
value = z32_float_to_z24_unorm(*src++) << 8; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const uint32_t *src = (const uint32_t *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value = *src++; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = z24_unorm_to_z32_unorm(value >> 8); |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
uint32_t *dst = (uint32_t *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
uint32_t value; |
|
||||||
value = z32_unorm_to_z24_unorm(*src++) << 8; |
|
||||||
#ifdef PIPE_ARCH_BIG_ENDIAN |
|
||||||
value = util_bswap32(value); |
|
||||||
#endif |
|
||||||
*dst++ = value; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
float *dst = dst_row; |
|
||||||
const float *src = (const float *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst = *src; |
|
||||||
src += 2; |
|
||||||
dst += 1; |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const float *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const float *src = src_row; |
|
||||||
float *dst = (float *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst = *src; |
|
||||||
src += 1; |
|
||||||
dst += 2; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint32_t *dst = dst_row; |
|
||||||
const float *src = (const float *)src_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst = z32_float_to_z32_unorm(*src); |
|
||||||
src += 2; |
|
||||||
dst += 1; |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint32_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint32_t *src = src_row; |
|
||||||
float *dst = (float *)dst_row; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst++ = z32_unorm_to_z32_float(*src++); |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
uint8_t *dst = dst_row; |
|
||||||
const uint8_t *src = src_row + 4; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst = *src; |
|
||||||
src += 8; |
|
||||||
dst += 1; |
|
||||||
} |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
unsigned x, y; |
|
||||||
for(y = 0; y < height; ++y) { |
|
||||||
const uint8_t *src = src_row; |
|
||||||
uint8_t *dst = dst_row + 4; |
|
||||||
for(x = 0; x < width; ++x) { |
|
||||||
*dst = *src; |
|
||||||
src += 1; |
|
||||||
dst += 8; |
|
||||||
} |
|
||||||
dst_row += dst_stride/sizeof(*dst_row); |
|
||||||
src_row += src_stride/sizeof(*src_row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, |
|
||||||
const uint8_t *src_row, unsigned src_stride, |
|
||||||
unsigned width, unsigned height) |
|
||||||
{ |
|
||||||
util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row, dst_stride, |
|
||||||
src_row, src_stride, |
|
||||||
width, height); |
|
||||||
} |
|
@ -1,212 +0,0 @@ |
|||||||
/**************************************************************************
|
|
||||||
* |
|
||||||
* Copyright 2010 VMware, Inc. |
|
||||||
* All Rights Reserved. |
|
||||||
* |
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a |
|
||||||
* copy of this software and associated documentation files (the |
|
||||||
* "Software"), to deal in the Software without restriction, including |
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, |
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to |
|
||||||
* permit persons to whom the Software is furnished to do so, subject to |
|
||||||
* the following conditions: |
|
||||||
* |
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
|
||||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
||||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
||||||
* USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
* |
|
||||||
* The above copyright notice and this permission notice (including the |
|
||||||
* next paragraph) shall be included in all copies or substantial portions |
|
||||||
* of the Software. |
|
||||||
* |
|
||||||
**************************************************************************/ |
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_FORMAT_ZS_H_ |
|
||||||
#define U_FORMAT_ZS_H_ |
|
||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h" |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
|
|
||||||
void |
|
||||||
util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
|
|
||||||
void |
|
||||||
util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_sride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); |
|
||||||
#endif /* U_FORMAT_ZS_H_ */ |
|
Loading…
Reference in new issue