Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5062 → Rev 5063

/contrib/sdk/sources/Mesa/src/gallium/auxiliary/os/os_time.c
35,14 → 35,8
 
#include "pipe/p_config.h"
 
#if defined(PIPE_OS_UNIX)
# include <time.h> /* timeval */
# include <sys/time.h> /* timeval */
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
# include <windows.h>
#else
# error Unsupported OS
#endif
 
#include "os_time.h"
 
50,32 → 44,8
int64_t
os_time_get_nano(void)
{
#if defined(PIPE_OS_LINUX)
 
struct timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
return tv.tv_nsec + tv.tv_sec*INT64_C(1000000000);
 
#elif defined(PIPE_OS_UNIX)
 
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_usec*INT64_C(1000) + tv.tv_sec*INT64_C(1000000000);
 
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
 
static LARGE_INTEGER frequency;
LARGE_INTEGER counter;
if(!frequency.QuadPart)
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&counter);
return counter.QuadPart*INT64_C(1000000000)/frequency.QuadPart;
 
#else
 
#error Unsupported OS
 
#endif
}
 
 
/contrib/sdk/sources/Mesa/src/gallium/auxiliary/util/u_format_s3tc.c
111,7 → 111,10
util_dl_proc fetch_2d_texel_rgba_dxt3;
util_dl_proc fetch_2d_texel_rgba_dxt5;
util_dl_proc tx_compress_dxtn;
char *force_s3tc_enable;
 
return;
#if 0
if (!first_time)
return;
first_time = FALSE;
119,10 → 122,17
if (util_format_s3tc_enabled)
return;
 
library = util_dl_open(DXTN_LIBNAME);
// library = util_dl_open(DXTN_LIBNAME);
if (!library) {
if ((force_s3tc_enable = getenv("force_s3tc_enable")) &&
!strcmp(force_s3tc_enable, "true")) {
debug_printf("couldn't open " DXTN_LIBNAME ", enabling DXTn due to "
"force_s3tc_enable=true environment variable\n");
util_format_s3tc_enabled = TRUE;
} else {
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
"compression/decompression unavailable\n");
}
return;
}
 
155,6 → 165,7
util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt5;
util_format_dxtn_pack = (util_format_dxtn_pack_t)tx_compress_dxtn;
util_format_s3tc_enabled = TRUE;
#endif
}
 
 
240,7 → 251,7
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height,
util_format_dxtn_fetch_t fetch,
unsigned block_size, boolean srgb)
unsigned block_size)
{
const unsigned bw = 4, bh = 4, comps = 4;
unsigned x, y, i, j;
251,13 → 262,8
for(i = 0; i < bw; ++i) {
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
fetch(0, src, i, j, dst);
if (srgb) {
dst[0] = util_format_srgb_to_linear_8unorm(dst[0]);
dst[1] = util_format_srgb_to_linear_8unorm(dst[1]);
dst[2] = util_format_srgb_to_linear_8unorm(dst[2]);
}
}
}
src += block_size;
}
src_row += src_stride;
272,8 → 278,7
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, FALSE);
util_format_dxt1_rgb_fetch, 8);
}
 
void
284,8 → 289,7
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, FALSE);
util_format_dxt1_rgba_fetch, 8);
}
 
void
296,8 → 300,7
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, FALSE);
util_format_dxt3_rgba_fetch, 16);
}
 
void
308,8 → 311,7
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, FALSE);
util_format_dxt5_rgba_fetch, 16);
}
 
static INLINE void
317,7 → 319,7
const uint8_t *src_row, unsigned src_stride,
unsigned width, unsigned height,
util_format_dxtn_fetch_t fetch,
unsigned block_size, boolean srgb)
unsigned block_size)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
328,16 → 330,9
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
uint8_t tmp[4];
fetch(0, src, i, j, tmp);
if (srgb) {
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
}
else {
dst[0] = ubyte_to_float(tmp[0]);
dst[1] = ubyte_to_float(tmp[1]);
dst[2] = ubyte_to_float(tmp[2]);
}
dst[3] = ubyte_to_float(tmp[3]);
}
}
355,8 → 350,7
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, FALSE);
util_format_dxt1_rgb_fetch, 8);
}
 
void
367,8 → 361,7
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, FALSE);
util_format_dxt1_rgba_fetch, 8);
}
 
void
379,8 → 372,7
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, FALSE);
util_format_dxt3_rgba_fetch, 16);
}
 
void
391,8 → 383,7
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, FALSE);
util_format_dxt5_rgba_fetch, 16);
}
 
 
400,63 → 391,55
* Block compression.
*/
 
static INLINE void
util_format_dxtn_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
void
util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height,
enum util_format_dxtn format,
unsigned block_size, boolean srgb)
unsigned width, unsigned height)
{
const unsigned bw = 4, bh = 4, comps = 4;
const unsigned bw = 4, bh = 4, bytes_per_block = 8;
unsigned x, y, i, j, k;
for(y = 0; y < height; y += bh) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += bw) {
uint8_t tmp[4][4][4]; /* [bh][bw][comps] */
uint8_t tmp[4][4][3]; /* [bh][bw][comps] */
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
uint8_t src_tmp;
for(k = 0; k < 3; ++k) {
src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + k];
if (srgb) {
tmp[j][i][k] = util_format_linear_to_srgb_8unorm(src_tmp);
tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*4 + k];
}
else {
tmp[j][i][k] = src_tmp;
}
}
/* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */
tmp[j][i][3] = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + 3];
util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, 0);
dst += bytes_per_block;
}
}
/* even for dxt1_rgb have 4 src comps */
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0);
dst += block_size;
}
dst_row += dst_stride / sizeof(*dst_row);
}
 
}
 
void
util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, FALSE);
}
 
void
util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, FALSE);
const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 8;
unsigned x, y, i, j, k;
for(y = 0; y < height; y += bh) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += bw) {
uint8_t tmp[4][4][4]; /* [bh][bw][comps] */
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
for(k = 0; k < comps; ++k) {
tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k];
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, 0);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
}
}
 
void
util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
463,10 → 446,25
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, FALSE);
const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 16;
unsigned x, y, i, j, k;
for(y = 0; y < height; y += bh) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += bw) {
uint8_t tmp[4][4][4]; /* [bh][bw][comps] */
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
for(k = 0; k < comps; ++k) {
tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k];
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, 0);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
}
}
 
void
util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
473,66 → 471,74
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, FALSE);
const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 16;
unsigned x, y, i, j, k;
 
for(y = 0; y < height; y += bh) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += bw) {
uint8_t tmp[4][4][4]; /* [bh][bw][comps] */
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
for(k = 0; k < comps; ++k) {
tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k];
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, 0);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
}
}
 
static INLINE void
util_format_dxtn_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
void
util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src, unsigned src_stride,
unsigned width, unsigned height,
enum util_format_dxtn format,
unsigned block_size, boolean srgb)
unsigned width, unsigned height)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 4) {
uint8_t tmp[4][4][4];
uint8_t tmp[4][4][3];
for(j = 0; j < 4; ++j) {
for(i = 0; i < 4; ++i) {
float src_tmp;
for(k = 0; k < 3; ++k) {
src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k];
if (srgb) {
tmp[j][i][k] = util_format_linear_float_to_srgb_8unorm(src_tmp);
tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]);
}
else {
tmp[j][i][k] = float_to_ubyte(src_tmp);
}
}
/* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */
src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + 3];
tmp[j][i][3] = float_to_ubyte(src_tmp);
util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, 0);
dst += 8;
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0);
dst += block_size;
}
dst_row += 4*dst_stride/sizeof(*dst_row);
}
}
 
void
util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, FALSE);
}
 
void
util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
const float *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, FALSE);
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 4) {
uint8_t tmp[4][4][4];
for(j = 0; j < 4; ++j) {
for(i = 0; i < 4; ++i) {
for(k = 0; k < 4; ++k) {
tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]);
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, 0);
dst += 8;
}
dst_row += 4*dst_stride/sizeof(*dst_row);
}
}
 
void
util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
539,10 → 545,24
const float *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, FALSE);
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 4) {
uint8_t tmp[4][4][4];
for(j = 0; j < 4; ++j) {
for(i = 0; i < 4; ++i) {
for(k = 0; k < 4; ++k) {
tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]);
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, 0);
dst += 16;
}
dst_row += 4*dst_stride/sizeof(*dst_row);
}
}
 
void
util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
549,245 → 569,173
const float *src, unsigned src_stride,
unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, FALSE);
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 4) {
uint8_t tmp[4][4][4];
for(j = 0; j < 4; ++j) {
for(i = 0; i < 4; ++i) {
for(k = 0; k < 4; ++k) {
tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]);
}
}
}
util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, 0);
dst += 16;
}
dst_row += 4*dst_stride/sizeof(*dst_row);
}
}
 
 
/*
* SRGB variants.
*
* FIXME: shunts to RGB for now
*/
 
void
util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
dst[3] = 255;
util_format_dxt1_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
dst[3] = tmp[3];
util_format_dxt1_rgb_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
dst[3] = tmp[3];
util_format_dxt1_rgb_fetch_rgba_8unorm(dst, src, i, j);
}
 
void
util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]);
dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]);
dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]);
dst[3] = tmp[3];
util_format_dxt1_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
dst[3] = 1.0f;
util_format_dxt1_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp[4];
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
dst[3] = ubyte_to_float(tmp[3]);
util_format_dxt1_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
 
void
util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
dst[3] = ubyte_to_float(tmp[3]);
util_format_dxt3_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
uint8_t tmp[4];
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]);
dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]);
dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]);
dst[3] = ubyte_to_float(tmp[3]);
util_format_dxt3_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, TRUE);
util_format_dxt3_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
 
void
util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, TRUE);
util_format_dxt5_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, TRUE);
util_format_dxt5_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, TRUE);
util_format_dxt5_rgba_fetch_rgba_8unorm(dst, src, i, j);
}
 
void
util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, TRUE);
util_format_dxt1_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, TRUE);
util_format_dxt1_rgb_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, TRUE);
util_format_dxt1_rgb_fetch_rgba_float(dst, src, i, j);
}
 
void
util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride,
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, TRUE);
util_format_dxt1_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, TRUE);
util_format_dxt1_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, TRUE);
util_format_dxt1_rgba_fetch_rgba_float(dst, src, i, j);
}
 
void
util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, TRUE);
util_format_dxt3_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, TRUE);
util_format_dxt3_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, TRUE);
util_format_dxt3_rgba_fetch_rgba_float(dst, src, i, j);
}
 
void
util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, TRUE);
util_format_dxt5_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, TRUE);
util_format_dxt5_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height);
}
 
void
util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, TRUE);
util_format_dxt5_rgba_fetch_rgba_float(dst, src, i, j);
}
 
/contrib/sdk/sources/Mesa/src/gallium/auxiliary/util/u_format_srgb.c
0,0 → 1,148
/* 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,
};
 
/contrib/sdk/sources/Mesa/src/gallium/auxiliary/util/u_format_table.c
0,0 → 1,28411
/* This file is autogenerated by u_format_table.py from u_format.csv. 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.
*
**************************************************************************/
 
#include "u_format.h"
#include "u_format_s3tc.h"
#include "u_format_rgtc.h"
#include "u_format_latc.h"
#include "u_format_etc.h"
 
 
#include "pipe/p_compiler.h"
#include "u_math.h"
#include "u_half.h"
#include "u_format.h"
#include "u_format_other.h"
#include "u_format_srgb.h"
#include "u_format_yuv.h"
#include "u_format_zs.h"
 
union util_format_none {
uint8_t value;
struct {
uint8_t r;
} chan;
};
 
static INLINE void
util_format_none_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_none_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) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[0], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_none_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_none_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_none_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_b8g8r8a8_unorm {
uint32_t value;
struct {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_b8g8r8a8_unorm_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;
uint32_t b;
uint32_t g;
uint32_t r;
uint32_t a;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_b8g8r8a8_unorm_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 = 0;
value |= (float_to_ubyte(src[2])) & 0xff;
value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
value |= ((float_to_ubyte(src[0])) & 0xff) << 16;
value |= (float_to_ubyte(src[3])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_b8g8r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
uint32_t a;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_b8g8r8a8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
uint32_t a;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_b8g8r8a8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[2]) & 0xff;
value |= ((src[1]) & 0xff) << 8;
value |= ((src[0]) & 0xff) << 16;
value |= (src[3]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_b8g8r8x8_unorm {
uint32_t value;
struct {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_b8g8r8x8_unorm_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;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_b8g8r8x8_unorm_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 = 0;
value |= (float_to_ubyte(src[2])) & 0xff;
value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
value |= ((float_to_ubyte(src[0])) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_b8g8r8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_b8g8r8x8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value) & 0xff;
g = (value >> 8) & 0xff;
r = (value >> 16) & 0xff;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_b8g8r8x8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[2]) & 0xff;
value |= ((src[1]) & 0xff) << 8;
value |= ((src[0]) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8r8g8b8_unorm {
uint32_t value;
struct {
uint8_t a;
uint8_t r;
uint8_t g;
uint8_t b;
} chan;
};
 
static INLINE void
util_format_a8r8g8b8_unorm_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;
uint32_t a;
uint32_t r;
uint32_t g;
uint32_t b;
a = (value) & 0xff;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8r8g8b8_unorm_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 = 0;
value |= (float_to_ubyte(src[3])) & 0xff;
value |= ((float_to_ubyte(src[0])) & 0xff) << 8;
value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
value |= (float_to_ubyte(src[2])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t a;
uint32_t r;
uint32_t g;
uint32_t b;
a = (value) & 0xff;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_a8r8g8b8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t a;
uint32_t r;
uint32_t g;
uint32_t b;
a = (value) & 0xff;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8r8g8b8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[3]) & 0xff;
value |= ((src[0]) & 0xff) << 8;
value |= ((src[1]) & 0xff) << 16;
value |= (src[2]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_x8r8g8b8_unorm {
uint32_t value;
struct {
uint8_t x;
uint8_t r;
uint8_t g;
uint8_t b;
} chan;
};
 
static INLINE void
util_format_x8r8g8b8_unorm_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;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_x8r8g8b8_unorm_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 = 0;
value |= ((float_to_ubyte(src[0])) & 0xff) << 8;
value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
value |= (float_to_ubyte(src[2])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_x8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_x8r8g8b8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
b = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_x8r8g8b8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((src[0]) & 0xff) << 8;
value |= ((src[1]) & 0xff) << 16;
value |= (src[2]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8b8g8r8_unorm {
uint32_t value;
struct {
uint8_t a;
uint8_t b;
uint8_t g;
uint8_t r;
} chan;
};
 
static INLINE void
util_format_a8b8g8r8_unorm_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;
uint32_t a;
uint32_t b;
uint32_t g;
uint32_t r;
a = (value) & 0xff;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8b8g8r8_unorm_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 = 0;
value |= (float_to_ubyte(src[3])) & 0xff;
value |= ((float_to_ubyte(src[2])) & 0xff) << 8;
value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
value |= (float_to_ubyte(src[0])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t a;
uint32_t b;
uint32_t g;
uint32_t r;
a = (value) & 0xff;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_a8b8g8r8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t a;
uint32_t b;
uint32_t g;
uint32_t r;
a = (value) & 0xff;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8b8g8r8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[3]) & 0xff;
value |= ((src[2]) & 0xff) << 8;
value |= ((src[1]) & 0xff) << 16;
value |= (src[0]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_x8b8g8r8_unorm {
uint32_t value;
struct {
uint8_t x;
uint8_t b;
uint8_t g;
uint8_t r;
} chan;
};
 
static INLINE void
util_format_x8b8g8r8_unorm_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;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_x8b8g8r8_unorm_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 = 0;
value |= ((float_to_ubyte(src[2])) & 0xff) << 8;
value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
value |= (float_to_ubyte(src[0])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_x8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_x8b8g8r8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t b;
uint32_t g;
uint32_t r;
b = (value >> 8) & 0xff;
g = (value >> 16) & 0xff;
r = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_x8b8g8r8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((src[2]) & 0xff) << 8;
value |= ((src[1]) & 0xff) << 16;
value |= (src[0]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8x8_unorm {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8g8b8x8_unorm_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;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_unorm_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 = 0;
value |= (float_to_ubyte(src[0])) & 0xff;
value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8x8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[0]) & 0xff;
value |= ((src[1]) & 0xff) << 8;
value |= ((src[2]) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8_unorm {
uint8_t value;
struct {
uint8_t rgb;
} chan;
};
 
static INLINE void
util_format_l8_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = ubyte_to_float(rgb); /* r */
dst[1] = ubyte_to_float(rgb); /* g */
dst[2] = ubyte_to_float(rgb); /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_unorm_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) {
uint8_t value = 0;
value |= float_to_ubyte(src[0]);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = ubyte_to_float(rgb); /* r */
dst[1] = ubyte_to_float(rgb); /* g */
dst[2] = ubyte_to_float(rgb); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= src[0];
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8_unorm {
uint8_t value;
struct {
uint8_t a;
} chan;
};
 
static INLINE void
util_format_a8_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_unorm_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) {
uint8_t value = 0;
value |= float_to_ubyte(src[3]);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_a8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= src[3];
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i8_unorm {
uint8_t value;
struct {
uint8_t rgba;
} chan;
};
 
static INLINE void
util_format_i8_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = ubyte_to_float(rgba); /* r */
dst[1] = ubyte_to_float(rgba); /* g */
dst[2] = ubyte_to_float(rgba); /* b */
dst[3] = ubyte_to_float(rgba); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_unorm_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) {
uint8_t value = 0;
value |= float_to_ubyte(src[0]);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = ubyte_to_float(rgba); /* r */
dst[1] = ubyte_to_float(rgba); /* g */
dst[2] = ubyte_to_float(rgba); /* b */
dst[3] = ubyte_to_float(rgba); /* a */
}
 
static INLINE void
util_format_i8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = rgba; /* r */
dst[1] = rgba; /* g */
dst[2] = rgba; /* b */
dst[3] = rgba; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= src[0];
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l4a4_unorm {
uint8_t value;
struct {
unsigned rgb:4;
unsigned a:4;
} chan;
};
 
static INLINE void
util_format_l4a4_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
uint8_t a;
rgb = (value) & 0xf;
a = value >> 4;
dst[0] = (float)(rgb * (1.0f/0xf)); /* r */
dst[1] = (float)(rgb * (1.0f/0xf)); /* g */
dst[2] = (float)(rgb * (1.0f/0xf)); /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l4a4_unorm_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) {
uint8_t value = 0;
value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf;
value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
uint8_t a;
rgb = (value) & 0xf;
a = value >> 4;
dst[0] = (float)(rgb * (1.0f/0xf)); /* r */
dst[1] = (float)(rgb * (1.0f/0xf)); /* g */
dst[2] = (float)(rgb * (1.0f/0xf)); /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
}
 
static INLINE void
util_format_l4a4_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
uint8_t a;
rgb = (value) & 0xf;
a = value >> 4;
dst[0] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* r */
dst[1] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* g */
dst[2] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* b */
dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l4a4_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= ((uint8_t)(src[0] >> 4)) & 0xf;
value |= ((uint8_t)(src[3] >> 4)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8a8_unorm {
uint16_t value;
struct {
uint8_t rgb;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_l8a8_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = ubyte_to_float(rgb); /* r */
dst[1] = ubyte_to_float(rgb); /* g */
dst[2] = ubyte_to_float(rgb); /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_unorm_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) {
uint16_t value = 0;
value |= (float_to_ubyte(src[0])) & 0xff;
value |= (float_to_ubyte(src[3])) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = ubyte_to_float(rgb); /* r */
dst[1] = ubyte_to_float(rgb); /* g */
dst[2] = ubyte_to_float(rgb); /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_l8a8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (src[0]) & 0xff;
value |= (src[3]) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16_unorm {
uint16_t value;
struct {
uint16_t rgb;
} chan;
};
 
static INLINE void
util_format_l16_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_unorm_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) {
uint16_t value = 0;
value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (uint8_t)(rgb >> 8); /* r */
dst[1] = (uint8_t)(rgb >> 8); /* g */
dst[2] = (uint8_t)(rgb >> 8); /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a16_unorm {
uint16_t value;
struct {
uint16_t a;
} chan;
};
 
static INLINE void
util_format_a16_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_unorm_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) {
uint16_t value = 0;
value |= (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
}
 
static INLINE void
util_format_a16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(a >> 8); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i16_unorm {
uint16_t value;
struct {
uint16_t rgba;
} chan;
};
 
static INLINE void
util_format_i16_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */
dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_unorm_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) {
uint16_t value = 0;
value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */
dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */
}
 
static INLINE void
util_format_i16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (uint8_t)(rgba >> 8); /* r */
dst[1] = (uint8_t)(rgba >> 8); /* g */
dst[2] = (uint8_t)(rgba >> 8); /* b */
dst[3] = (uint8_t)(rgba >> 8); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16a16_unorm {
uint32_t value;
struct {
uint16_t rgb;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_l16a16_unorm_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;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_unorm_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 = 0;
value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
}
 
static INLINE void
util_format_l16a16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (uint8_t)(rgb >> 8); /* r */
dst[1] = (uint8_t)(rgb >> 8); /* g */
dst[2] = (uint8_t)(rgb >> 8); /* b */
dst[3] = (uint8_t)(a >> 8); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8_snorm {
uint8_t value;
struct {
int8_t a;
} chan;
};
 
static INLINE void
util_format_a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
}
 
static INLINE void
util_format_a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)(src[3] >> 1)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8_snorm {
uint8_t value;
struct {
int8_t rgb;
} chan;
};
 
static INLINE void
util_format_l8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8a8_snorm {
uint16_t value;
struct {
int8_t rgb;
int8_t a;
} chan;
};
 
static INLINE void
util_format_l8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
}
 
static INLINE void
util_format_l8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */
dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i8_snorm {
uint8_t value;
struct {
int8_t rgba;
} chan;
};
 
static INLINE void
util_format_i8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */
dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */
dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */
dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */
dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */
}
 
static INLINE void
util_format_i8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* b */
dst[3] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a16_snorm {
uint16_t value;
struct {
int16_t a;
} chan;
};
 
static INLINE void
util_format_a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
}
 
static INLINE void
util_format_a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16_snorm {
uint16_t value;
struct {
int16_t rgb;
} chan;
};
 
static INLINE void
util_format_l16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16a16_snorm {
uint32_t value;
struct {
int16_t rgb;
int16_t a;
} chan;
};
 
static INLINE void
util_format_l16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
}
 
static INLINE void
util_format_l16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */
dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i16_snorm {
uint16_t value;
struct {
int16_t rgba;
} chan;
};
 
static INLINE void
util_format_i16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */
dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */
dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */
dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */
dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */
}
 
static INLINE void
util_format_i16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (uint8_t)(MAX2(rgba, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(rgba, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(rgba, 0) >> 7); /* b */
dst[3] = (uint8_t)(MAX2(rgba, 0) >> 7); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a16_float {
uint16_t value;
struct {
uint16_t a;
} chan;
};
 
static INLINE void
util_format_a16_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) {
union util_format_a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_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) {
union util_format_a16_float pixel;
pixel.chan.a = util_float_to_half(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
}
 
static INLINE void
util_format_a16_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;
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) {
union util_format_a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_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;
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) {
union util_format_a16_float pixel;
pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16_float {
uint16_t value;
struct {
uint16_t rgb;
} chan;
};
 
static INLINE void
util_format_l16_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) {
union util_format_l16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_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) {
union util_format_l16_float pixel;
pixel.chan.rgb = util_float_to_half(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l16_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;
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) {
union util_format_l16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_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;
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) {
union util_format_l16_float pixel;
pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16a16_float {
uint32_t value;
struct {
uint16_t rgb;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_l16a16_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) {
union util_format_l16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_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) {
union util_format_l16a16_float pixel;
pixel.chan.rgb = util_float_to_half(src[0]);
pixel.chan.a = util_float_to_half(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
}
 
static INLINE void
util_format_l16a16_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;
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) {
union util_format_l16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */
dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_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;
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) {
union util_format_l16a16_float pixel;
pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i16_float {
uint16_t value;
struct {
uint16_t rgba;
} chan;
};
 
static INLINE void
util_format_i16_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) {
union util_format_i16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgba); /* r */
dst[1] = util_half_to_float(pixel.chan.rgba); /* g */
dst[2] = util_half_to_float(pixel.chan.rgba); /* b */
dst[3] = util_half_to_float(pixel.chan.rgba); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_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) {
union util_format_i16_float pixel;
pixel.chan.rgba = util_float_to_half(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_i16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.rgba); /* r */
dst[1] = util_half_to_float(pixel.chan.rgba); /* g */
dst[2] = util_half_to_float(pixel.chan.rgba); /* b */
dst[3] = util_half_to_float(pixel.chan.rgba); /* a */
}
 
static INLINE void
util_format_i16_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;
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) {
union util_format_i16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* b */
dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_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;
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) {
union util_format_i16_float pixel;
pixel.chan.rgba = util_float_to_half((float)(src[0] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a32_float {
uint32_t value;
struct {
float a;
} chan;
};
 
static INLINE void
util_format_a32_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) {
union util_format_a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_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) {
union util_format_a32_float pixel;
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_a32_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;
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) {
union util_format_a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = float_to_ubyte(pixel.chan.a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_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;
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) {
union util_format_a32_float pixel;
pixel.chan.a = ubyte_to_float(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32_float {
uint32_t value;
struct {
float rgb;
} chan;
};
 
static INLINE void
util_format_l32_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) {
union util_format_l32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_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) {
union util_format_l32_float pixel;
pixel.chan.rgb = src[0];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l32_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;
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) {
union util_format_l32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */
dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */
dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_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;
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) {
union util_format_l32_float pixel;
pixel.chan.rgb = ubyte_to_float(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32a32_float {
uint64_t value;
struct {
float rgb;
float a;
} chan;
};
 
static INLINE void
util_format_l32a32_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) {
union util_format_l32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_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) {
union util_format_l32a32_float pixel;
pixel.chan.rgb = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_l32a32_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;
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) {
union util_format_l32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */
dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */
dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */
dst[3] = float_to_ubyte(pixel.chan.a); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_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;
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) {
union util_format_l32a32_float pixel;
pixel.chan.rgb = ubyte_to_float(src[0]);
pixel.chan.a = ubyte_to_float(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i32_float {
uint32_t value;
struct {
float rgba;
} chan;
};
 
static INLINE void
util_format_i32_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) {
union util_format_i32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgba; /* r */
dst[1] = pixel.chan.rgba; /* g */
dst[2] = pixel.chan.rgba; /* b */
dst[3] = pixel.chan.rgba; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_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) {
union util_format_i32_float pixel;
pixel.chan.rgba = src[0];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_i32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgba; /* r */
dst[1] = pixel.chan.rgba; /* g */
dst[2] = pixel.chan.rgba; /* b */
dst[3] = pixel.chan.rgba; /* a */
}
 
static INLINE void
util_format_i32_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;
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) {
union util_format_i32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.rgba); /* r */
dst[1] = float_to_ubyte(pixel.chan.rgba); /* g */
dst[2] = float_to_ubyte(pixel.chan.rgba); /* b */
dst[3] = float_to_ubyte(pixel.chan.rgba); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_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;
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) {
union util_format_i32_float pixel;
pixel.chan.rgba = ubyte_to_float(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8sg8sb8ux8u_norm {
uint32_t value;
struct {
int8_t r;
int8_t g;
uint8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8sg8sb8ux8u_norm_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;
int32_t r;
int32_t g;
uint32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = (value >> 16) & 0xff;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8sg8sb8ux8u_norm_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 = 0;
value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8sg8sb8ux8u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
uint32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = (value >> 16) & 0xff;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8sg8sb8ux8u_norm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
uint32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = (value >> 16) & 0xff;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
dst[2] = b; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8sg8sb8ux8u_norm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((uint32_t)(src[0] >> 1)) & 0xff) ;
value |= (uint32_t)((((uint32_t)(src[1] >> 1)) & 0xff) << 8) ;
value |= ((src[2]) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r5sg5sb6u_norm {
uint16_t value;
struct {
int r:5;
int g:5;
unsigned b:6;
} chan;
};
 
static INLINE void
util_format_r5sg5sb6u_norm_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) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
uint16_t b;
r = ((int16_t)(value << 11) ) >> 11;
g = ((int16_t)(value << 6) ) >> 11;
b = value >> 10;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = (float)(g * (1.0f/0xf)); /* g */
dst[2] = (float)(b * (1.0f/0x3f)); /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r5sg5sb6u_norm_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) {
uint16_t value = 0;
value |= (uint16_t)(((uint16_t)util_iround(CLAMP(src[0], -1, 1) * 0xf)) & 0x1f) ;
value |= (uint16_t)((((uint16_t)util_iround(CLAMP(src[1], -1, 1) * 0xf)) & 0x1f) << 5) ;
value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x3f)) << 10;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r5sg5sb6u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
uint16_t b;
r = ((int16_t)(value << 11) ) >> 11;
g = ((int16_t)(value << 6) ) >> 11;
b = value >> 10;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = (float)(g * (1.0f/0xf)); /* g */
dst[2] = (float)(b * (1.0f/0x3f)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r5sg5sb6u_norm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
uint16_t b;
r = ((int16_t)(value << 11) ) >> 11;
g = ((int16_t)(value << 6) ) >> 11;
b = value >> 10;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0xf); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0xf); /* g */
dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x3f); /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r5sg5sb6u_norm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint16_t)(src[0] >> 4)) & 0x1f) ;
value |= (uint16_t)((((uint16_t)(src[1] >> 4)) & 0x1f) << 5) ;
value |= ((uint16_t)(src[2] >> 2)) << 10;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r64_float {
uint64_t value;
struct {
double r;
} chan;
};
 
static INLINE void
util_format_r64_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) {
union util_format_r64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64_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) {
union util_format_r64_float pixel;
pixel.chan.r = (double)src[0];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r64_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;
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) {
union util_format_r64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64_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;
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) {
union util_format_r64_float pixel;
pixel.chan.r = (double)(src[0] * (1.0f/0xff));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r64g64_float {
struct {
double r;
double g;
} chan;
};
 
static INLINE void
util_format_r64g64_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) {
union util_format_r64g64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64_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) {
union util_format_r64g64_float pixel;
pixel.chan.r = (double)src[0];
pixel.chan.g = (double)src[1];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r64g64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r64g64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r64g64_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;
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) {
union util_format_r64g64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64_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;
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) {
union util_format_r64g64_float pixel;
pixel.chan.r = (double)(src[0] * (1.0f/0xff));
pixel.chan.g = (double)(src[1] * (1.0f/0xff));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r64g64b64_float {
struct {
double r;
double g;
double b;
} chan;
};
 
static INLINE void
util_format_r64g64b64_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) {
union util_format_r64g64b64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 24;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64b64_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) {
union util_format_r64g64b64_float pixel;
pixel.chan.r = (double)src[0];
pixel.chan.g = (double)src[1];
pixel.chan.b = (double)src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 24;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r64g64b64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r64g64b64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r64g64b64_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;
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) {
union util_format_r64g64b64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */
dst[3] = 255; /* a */
src += 24;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64b64_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;
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) {
union util_format_r64g64b64_float pixel;
pixel.chan.r = (double)(src[0] * (1.0f/0xff));
pixel.chan.g = (double)(src[1] * (1.0f/0xff));
pixel.chan.b = (double)(src[2] * (1.0f/0xff));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 24;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r64g64b64a64_float {
struct {
double r;
double g;
double b;
double a;
} chan;
};
 
static INLINE void
util_format_r64g64b64a64_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) {
union util_format_r64g64b64a64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
src += 32;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64b64a64_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) {
union util_format_r64g64b64a64_float pixel;
pixel.chan.r = (double)src[0];
pixel.chan.g = (double)src[1];
pixel.chan.b = (double)src[2];
pixel.chan.a = (double)src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 32;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r64g64b64a64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r64g64b64a64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r64g64b64a64_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;
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) {
union util_format_r64g64b64a64_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */
dst[3] = (uint8_t)util_iround(CLAMP(pixel.chan.a, 0, 1) * 0xff); /* a */
src += 32;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r64g64b64a64_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;
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) {
union util_format_r64g64b64a64_float pixel;
pixel.chan.r = (double)(src[0] * (1.0f/0xff));
pixel.chan.g = (double)(src[1] * (1.0f/0xff));
pixel.chan.b = (double)(src[2] * (1.0f/0xff));
pixel.chan.a = (double)(src[3] * (1.0f/0xff));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 32;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_float {
uint32_t value;
struct {
float r;
} chan;
};
 
static INLINE void
util_format_r32_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) {
union util_format_r32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_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) {
union util_format_r32_float pixel;
pixel.chan.r = src[0];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_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;
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) {
union util_format_r32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_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;
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) {
union util_format_r32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_float {
uint64_t value;
struct {
float r;
float g;
} chan;
};
 
static INLINE void
util_format_r32g32_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) {
union util_format_r32g32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_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) {
union util_format_r32g32_float pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_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;
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) {
union util_format_r32g32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = float_to_ubyte(pixel.chan.g); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_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;
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) {
union util_format_r32g32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
pixel.chan.g = ubyte_to_float(src[1]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_float {
struct {
float r;
float g;
float b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_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) {
union util_format_r32g32b32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_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) {
union util_format_r32g32b32_float pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_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;
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) {
union util_format_r32g32b32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = float_to_ubyte(pixel.chan.g); /* g */
dst[2] = float_to_ubyte(pixel.chan.b); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_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;
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) {
union util_format_r32g32b32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
pixel.chan.g = ubyte_to_float(src[1]);
pixel.chan.b = ubyte_to_float(src[2]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_float {
struct {
float r;
float g;
float b;
float a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_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) {
union util_format_r32g32b32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_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) {
union util_format_r32g32b32a32_float pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32g32b32a32_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;
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) {
union util_format_r32g32b32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = float_to_ubyte(pixel.chan.g); /* g */
dst[2] = float_to_ubyte(pixel.chan.b); /* b */
dst[3] = float_to_ubyte(pixel.chan.a); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_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;
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) {
union util_format_r32g32b32a32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
pixel.chan.g = ubyte_to_float(src[1]);
pixel.chan.b = ubyte_to_float(src[2]);
pixel.chan.a = ubyte_to_float(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_unorm {
uint32_t value;
struct {
uint32_t r;
} chan;
};
 
static INLINE void
util_format_r32_unorm_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;
uint32_t r;
r = value;
dst[0] = (float)(r * (1.0/0xffffffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_unorm_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 = 0;
value |= (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = (float)(r * (1.0/0xffffffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = (uint8_t)(r >> 24); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_unorm {
uint64_t value;
struct {
uint32_t r;
uint32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_unorm_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) {
union util_format_r32g32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_unorm_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) {
union util_format_r32g32_unorm pixel;
pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_unorm pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_unorm {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_unorm_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) {
union util_format_r32g32b32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_unorm_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) {
union util_format_r32g32b32_unorm pixel;
pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_unorm pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_unorm {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_unorm_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) {
union util_format_r32g32b32a32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_unorm_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) {
union util_format_r32g32b32a32_unorm pixel;
pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff);
pixel.chan.a = (uint32_t)(CLAMP(src[3], 0, 1) * (double)0xffffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */
}
 
static INLINE void
util_format_r32g32b32a32_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */
dst[3] = (uint8_t)(pixel.chan.a >> 24); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_unorm pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff);
pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0xffffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_uscaled {
uint32_t value;
struct {
uint32_t r;
} chan;
};
 
static INLINE void
util_format_r32_uscaled_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;
uint32_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_uscaled_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 = 0;
value |= (uint32_t)CLAMP(src[0], 0, 4294967295);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = (uint8_t)(((uint64_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_uscaled {
uint64_t value;
struct {
uint32_t r;
uint32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_uscaled_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) {
union util_format_r32g32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_uscaled_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) {
union util_format_r32g32_uscaled pixel;
pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uscaled pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_uscaled {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_uscaled_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) {
union util_format_r32g32b32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_uscaled_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) {
union util_format_r32g32b32_uscaled pixel;
pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uscaled pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_uscaled {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_uscaled_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) {
union util_format_r32g32b32a32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uscaled_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) {
union util_format_r32g32b32a32_uscaled pixel;
pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295);
pixel.chan.a = (uint32_t)CLAMP(src[3], 0, 4294967295);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32g32b32a32_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint64_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uscaled pixel;
pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_snorm {
uint32_t value;
struct {
int32_t r;
} chan;
};
 
static INLINE void
util_format_r32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (uint8_t)(MAX2(r, 0) >> 23); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_snorm {
uint64_t value;
struct {
int32_t r;
int32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_snorm pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_snorm pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_snorm {
struct {
int32_t r;
int32_t g;
int32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_snorm pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_snorm pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_snorm {
struct {
int32_t r;
int32_t g;
int32_t b;
int32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_snorm pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff);
pixel.chan.a = (int32_t)(CLAMP(src[3], -1, 1) * (double)0x7fffffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */
}
 
static INLINE void
util_format_r32g32b32a32_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */
dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 23); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_snorm pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff);
pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x7fffffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_sscaled {
uint32_t value;
struct {
int32_t r;
} chan;
};
 
static INLINE void
util_format_r32_sscaled_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;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_sscaled_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 = 0;
value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648, 2147483647)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (uint8_t)(((uint64_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x1 / 0xff)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_sscaled {
uint64_t value;
struct {
int32_t r;
int32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_sscaled_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) {
union util_format_r32g32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_sscaled_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) {
union util_format_r32g32_sscaled pixel;
pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sscaled pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_sscaled {
struct {
int32_t r;
int32_t g;
int32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_sscaled_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) {
union util_format_r32g32b32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_sscaled_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) {
union util_format_r32g32b32_sscaled pixel;
pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sscaled pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_sscaled {
struct {
int32_t r;
int32_t g;
int32_t b;
int32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_sscaled_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) {
union util_format_r32g32b32a32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sscaled_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) {
union util_format_r32g32b32a32_sscaled pixel;
pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647);
pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648, 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32g32b32a32_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sscaled pixel;
pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_float {
uint16_t value;
struct {
uint16_t r;
} chan;
};
 
static INLINE void
util_format_r16_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) {
union util_format_r16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_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) {
union util_format_r16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_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;
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) {
union util_format_r16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_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;
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) {
union util_format_r16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_float {
uint32_t value;
struct {
uint16_t r;
uint16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_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) {
union util_format_r16g16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_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) {
union util_format_r16g16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
pixel.chan.g = util_float_to_half(src[1]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_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;
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) {
union util_format_r16g16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_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;
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) {
union util_format_r16g16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_float {
struct {
uint16_t r;
uint16_t g;
uint16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_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) {
union util_format_r16g16b16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_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) {
union util_format_r16g16b16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
pixel.chan.g = util_float_to_half(src[1]);
pixel.chan.b = util_float_to_half(src[2]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_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;
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) {
union util_format_r16g16b16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
dst[3] = 255; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_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;
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) {
union util_format_r16g16b16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_float {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_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) {
union util_format_r16g16b16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_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) {
union util_format_r16g16b16a16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
pixel.chan.g = util_float_to_half(src[1]);
pixel.chan.b = util_float_to_half(src[2]);
pixel.chan.a = util_float_to_half(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
}
 
static INLINE void
util_format_r16g16b16a16_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;
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) {
union util_format_r16g16b16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_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;
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) {
union util_format_r16g16b16a16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_unorm {
uint16_t value;
struct {
uint16_t r;
} chan;
};
 
static INLINE void
util_format_r16_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_unorm_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) {
uint16_t value = 0;
value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (uint8_t)(r >> 8); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_unorm {
uint32_t value;
struct {
uint16_t r;
uint16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_unorm_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;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = (float)(g * (1.0f/0xffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_unorm_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 = 0;
value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
value |= ((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = (float)(g * (1.0f/0xffff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (uint8_t)(r >> 8); /* r */
dst[1] = (uint8_t)(g >> 8); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
value |= ((uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_unorm {
struct {
uint16_t r;
uint16_t g;
uint16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_unorm_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) {
union util_format_r16g16b16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_unorm_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) {
union util_format_r16g16b16_unorm pixel;
pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
dst[3] = 255; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_unorm pixel;
pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_unorm {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_unorm_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) {
union util_format_r16g16b16a16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_unorm_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) {
union util_format_r16g16b16a16_unorm pixel;
pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
pixel.chan.a = (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */
}
 
static INLINE void
util_format_r16g16b16a16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
dst[3] = (uint8_t)(pixel.chan.a >> 8); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_unorm pixel;
pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_uscaled {
uint16_t value;
struct {
uint16_t r;
} chan;
};
 
static INLINE void
util_format_r16_uscaled_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_uscaled_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) {
uint16_t value = 0;
value |= (uint16_t)CLAMP(src[0], 0, 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_uscaled {
uint32_t value;
struct {
uint16_t r;
uint16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_uscaled_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;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_uscaled_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 = 0;
value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff;
value |= ((uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_uscaled {
struct {
uint16_t r;
uint16_t g;
uint16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_uscaled_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) {
union util_format_r16g16b16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_uscaled_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) {
union util_format_r16g16b16_uscaled pixel;
pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uscaled pixel;
pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_uscaled {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_uscaled_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) {
union util_format_r16g16b16a16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uscaled_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) {
union util_format_r16g16b16a16_uscaled pixel;
pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r16g16b16a16_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint32_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uscaled pixel;
pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_snorm {
uint16_t value;
struct {
int16_t r;
} chan;
};
 
static INLINE void
util_format_r16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_snorm {
uint32_t value;
struct {
int16_t r;
int16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(g * (1.0f/0x7fff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(g * (1.0f/0x7fff)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(g, 0) >> 7); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_snorm {
struct {
int16_t r;
int16_t g;
int16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_snorm pixel;
pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
dst[3] = 255; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_snorm pixel;
pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_snorm {
uint64_t value;
struct {
int16_t r;
int16_t g;
int16_t b;
int16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_snorm pixel;
pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
pixel.chan.a = (int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */
}
 
static INLINE void
util_format_r16g16b16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 7); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_snorm pixel;
pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_sscaled {
uint16_t value;
struct {
int16_t r;
} chan;
};
 
static INLINE void
util_format_r16_sscaled_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) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_sscaled_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) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_sscaled {
uint32_t value;
struct {
int16_t r;
int16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_sscaled_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;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_sscaled_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 = 0;
value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_sscaled {
struct {
int16_t r;
int16_t g;
int16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_sscaled_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) {
union util_format_r16g16b16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_sscaled_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) {
union util_format_r16g16b16_sscaled pixel;
pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sscaled pixel;
pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_sscaled {
uint64_t value;
struct {
int16_t r;
int16_t g;
int16_t b;
int16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_sscaled_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) {
union util_format_r16g16b16a16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sscaled_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) {
union util_format_r16g16b16a16_sscaled pixel;
pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = (float)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r16g16b16a16_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sscaled pixel;
pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_unorm {
uint8_t value;
struct {
uint8_t r;
} chan;
};
 
static INLINE void
util_format_r8_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_unorm_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) {
uint8_t value = 0;
value |= float_to_ubyte(src[0]);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= src[0];
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_unorm {
uint16_t value;
struct {
uint8_t r;
uint8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_unorm_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) {
uint16_t value = 0;
value |= (float_to_ubyte(src[0])) & 0xff;
value |= (float_to_ubyte(src[1])) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (src[0]) & 0xff;
value |= (src[1]) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_unorm {
struct {
uint8_t r;
uint8_t g;
uint8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_unorm_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) {
union util_format_r8g8b8_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = ubyte_to_float(pixel.chan.r); /* r */
dst[1] = ubyte_to_float(pixel.chan.g); /* g */
dst[2] = ubyte_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_unorm_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) {
union util_format_r8g8b8_unorm pixel;
pixel.chan.r = float_to_ubyte(src[0]);
pixel.chan.g = float_to_ubyte(src[1]);
pixel.chan.b = float_to_ubyte(src[2]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = ubyte_to_float(pixel.chan.r); /* r */
dst[1] = ubyte_to_float(pixel.chan.g); /* g */
dst[2] = ubyte_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 255; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_unorm pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_unorm {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_unorm_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;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_unorm_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 = 0;
value |= (float_to_ubyte(src[0])) & 0xff;
value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
value |= (float_to_ubyte(src[3])) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = ubyte_to_float(g); /* g */
dst[2] = ubyte_to_float(b); /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_r8g8b8a8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = r; /* r */
dst[1] = g; /* g */
dst[2] = b; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (src[0]) & 0xff;
value |= ((src[1]) & 0xff) << 8;
value |= ((src[2]) & 0xff) << 16;
value |= (src[3]) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_uscaled {
uint8_t value;
struct {
uint8_t r;
} chan;
};
 
static INLINE void
util_format_r8_uscaled_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_uscaled_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) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[0], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_uscaled {
uint16_t value;
struct {
uint8_t r;
uint8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_uscaled_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_uscaled_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) {
uint16_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff;
value |= ((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_uscaled {
struct {
uint8_t r;
uint8_t g;
uint8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_uscaled_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) {
union util_format_r8g8b8_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_uscaled_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) {
union util_format_r8g8b8_uscaled pixel;
pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255);
pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255);
pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uscaled pixel;
pixel.chan.r = (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_uscaled {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_uscaled_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;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = (float)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uscaled_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 = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = (float)a; /* a */
}
 
static INLINE void
util_format_r8g8b8a8_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint32_t)MIN2(a, 1)) * 0xff / 0x1); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff;
value |= (((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8;
value |= (((uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16;
value |= ((uint8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_snorm {
uint8_t value;
struct {
int8_t r;
} chan;
};
 
static INLINE void
util_format_r8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_snorm {
uint16_t value;
struct {
int8_t r;
int8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
value |= (uint16_t)(((int8_t)(src[1] >> 1)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_snorm {
struct {
int8_t r;
int8_t g;
int8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_snorm pixel;
pixel.chan.r = (int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f);
pixel.chan.g = (int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f);
pixel.chan.b = (int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)MAX2(pixel.chan.r, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(pixel.chan.g, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(pixel.chan.b, 0)) * 0xff / 0x7f); /* b */
dst[3] = 255; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_snorm pixel;
pixel.chan.r = (int8_t)(src[0] >> 1);
pixel.chan.g = (int8_t)(src[1] >> 1);
pixel.chan.b = (int8_t)(src[2] >> 1);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_snorm {
uint32_t value;
struct {
int8_t r;
int8_t g;
int8_t b;
int8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = (float)(b * (1.0f/0x7f)); /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = (float)(b * (1.0f/0x7f)); /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
}
 
static INLINE void
util_format_r8g8b8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */
dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)(src[3] >> 1)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_sscaled {
uint8_t value;
struct {
int8_t r;
} chan;
};
 
static INLINE void
util_format_r8_sscaled_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) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_sscaled_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) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (float)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_sscaled {
uint16_t value;
struct {
int8_t r;
int8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_sscaled_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) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_sscaled_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) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ;
value |= (uint16_t)(((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_sscaled {
struct {
int8_t r;
int8_t g;
int8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_sscaled_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) {
union util_format_r8g8b8_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_sscaled_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) {
union util_format_r8g8b8_sscaled pixel;
pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127);
pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127);
pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)pixel.chan.r; /* r */
dst[1] = (float)pixel.chan.g; /* g */
dst[2] = (float)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sscaled pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sscaled pixel;
pixel.chan.r = (int8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
pixel.chan.g = (int8_t)(((uint32_t)src[1]) * 0x1 / 0xff);
pixel.chan.b = (int8_t)(((uint32_t)src[2]) * 0x1 / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_sscaled {
uint32_t value;
struct {
int8_t r;
int8_t g;
int8_t b;
int8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_sscaled_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;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = (float)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sscaled_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 = 0;
value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = (float)a; /* a */
}
 
static INLINE void
util_format_r8g8b8a8_sscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)CLAMP(b, 0, 1)) * 0xff / 0x1); /* b */
dst[3] = (uint8_t)(((uint32_t)CLAMP(a, 0, 1)) * 0xff / 0x1); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ;
value |= (uint32_t)((((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_fixed {
uint32_t value;
struct {
int32_t r;
} chan;
};
 
static INLINE void
util_format_r32_fixed_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) {
union util_format_r32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_fixed_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) {
union util_format_r32_fixed pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_fixed_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_fixed_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32_fixed pixel;
pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_fixed {
uint64_t value;
struct {
int32_t r;
int32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_fixed_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) {
union util_format_r32g32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_fixed_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) {
union util_format_r32g32_fixed pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_fixed_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
dst[2] = 0; /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_fixed_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_fixed pixel;
pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_fixed {
struct {
int32_t r;
int32_t g;
int32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_fixed_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) {
union util_format_r32g32b32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_fixed_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) {
union util_format_r32g32b32_fixed pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_fixed_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */
dst[3] = 255; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_fixed_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_fixed pixel;
pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_fixed {
struct {
int32_t r;
int32_t g;
int32_t b;
int32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_fixed_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) {
union util_format_r32g32b32a32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_fixed_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) {
union util_format_r32g32b32a32_fixed pixel;
pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000);
pixel.chan.a = (int32_t)(CLAMP(src[3], -65536, 65535) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */
}
 
static INLINE void
util_format_r32g32b32a32_fixed_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_fixed pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */
dst[3] = (uint8_t)util_iround((CLAMP(pixel.chan.a, 0, 65536) * (1.0/0x10000)) * 0xff); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_fixed_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_fixed pixel;
pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000);
pixel.chan.a = (int32_t)((float)(src[3] * (1.0f/0xff)) * (double)0x10000);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r10g10b10x2_uscaled {
uint32_t value;
struct {
unsigned r:10;
unsigned g:10;
unsigned b:10;
unsigned x:2;
} chan;
};
 
static INLINE void
util_format_r10g10b10x2_uscaled_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;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0x3ff;
g = (value >> 10) & 0x3ff;
b = (value >> 20) & 0x3ff;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_uscaled_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 = 0;
value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff;
value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0x3ff;
g = (value >> 10) & 0x3ff;
b = (value >> 20) & 0x3ff;
dst[0] = (float)r; /* r */
dst[1] = (float)g; /* g */
dst[2] = (float)b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r10g10b10x2_uscaled_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0x3ff;
g = (value >> 10) & 0x3ff;
b = (value >> 20) & 0x3ff;
dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_uscaled_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff;
value |= (((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10;
value |= (((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) << 20;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r10g10b10x2_snorm {
uint32_t value;
struct {
int r:10;
int g:10;
int b:10;
unsigned x:2;
} chan;
};
 
static INLINE void
util_format_r10g10b10x2_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 22) ) >> 22;
g = ((int32_t)(value << 12) ) >> 22;
b = ((int32_t)(value << 2) ) >> 22;
dst[0] = (float)(r * (1.0f/0x1ff)); /* r */
dst[1] = (float)(g * (1.0f/0x1ff)); /* g */
dst[2] = (float)(b * (1.0f/0x1ff)); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ;
value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 22) ) >> 22;
g = ((int32_t)(value << 12) ) >> 22;
b = ((int32_t)(value << 2) ) >> 22;
dst[0] = (float)(r * (1.0f/0x1ff)); /* r */
dst[1] = (float)(g * (1.0f/0x1ff)); /* g */
dst[2] = (float)(b * (1.0f/0x1ff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r10g10b10x2_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 22) ) >> 22;
g = ((int32_t)(value << 12) ) >> 22;
b = ((int32_t)(value << 2) ) >> 22;
dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */
dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */
dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r10g10b10x2_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) ;
value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) << 20) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r4a4_unorm {
uint8_t value;
struct {
unsigned a:4;
unsigned r:4;
} chan;
};
 
static INLINE void
util_format_r4a4_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
uint8_t r;
a = (value) & 0xf;
r = value >> 4;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r4a4_unorm_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) {
uint8_t value = 0;
value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) & 0xf;
value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t a;
uint8_t r;
a = (value) & 0xf;
r = value >> 4;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
}
 
static INLINE void
util_format_r4a4_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
uint8_t r;
a = (value) & 0xf;
r = value >> 4;
dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r4a4_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= ((uint8_t)(src[3] >> 4)) & 0xf;
value |= ((uint8_t)(src[0] >> 4)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a4r4_unorm {
uint8_t value;
struct {
unsigned r:4;
unsigned a:4;
} chan;
};
 
static INLINE void
util_format_a4r4_unorm_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) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
uint8_t a;
r = (value) & 0xf;
a = value >> 4;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a4r4_unorm_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) {
uint8_t value = 0;
value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf;
value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a4r4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t r;
uint8_t a;
r = (value) & 0xf;
a = value >> 4;
dst[0] = (float)(r * (1.0f/0xf)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xf)); /* a */
}
 
static INLINE void
util_format_a4r4_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
uint8_t a;
r = (value) & 0xf;
a = value >> 4;
dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a4r4_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= ((uint8_t)(src[0] >> 4)) & 0xf;
value |= ((uint8_t)(src[3] >> 4)) << 4;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8a8_unorm {
uint16_t value;
struct {
uint8_t r;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_r8a8_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_unorm_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) {
uint16_t value = 0;
value |= (float_to_ubyte(src[0])) & 0xff;
value |= (float_to_ubyte(src[3])) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_r8a8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (src[0]) & 0xff;
value |= (src[3]) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8r8_unorm {
uint16_t value;
struct {
uint8_t a;
uint8_t r;
} chan;
};
 
static INLINE void
util_format_a8r8_unorm_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) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
uint16_t r;
a = (value) & 0xff;
r = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8r8_unorm_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) {
uint16_t value = 0;
value |= (float_to_ubyte(src[3])) & 0xff;
value |= (float_to_ubyte(src[0])) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t a;
uint16_t r;
a = (value) & 0xff;
r = value >> 8;
dst[0] = ubyte_to_float(r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = ubyte_to_float(a); /* a */
}
 
static INLINE void
util_format_a8r8_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
uint16_t r;
a = (value) & 0xff;
r = value >> 8;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8r8_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (src[3]) & 0xff;
value |= (src[0]) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_uint {
uint8_t value;
struct {
uint8_t r;
} chan;
};
 
static INLINE void
util_format_r8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)MIN2(src[0], 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t r;
r = value;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[0], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_uint {
uint16_t value;
struct {
uint8_t r;
uint8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
value |= ((uint8_t)MIN2(src[1], 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t g;
r = (value) & 0xff;
g = value >> 8;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_uint {
struct {
uint8_t r;
uint8_t g;
uint8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uint pixel;
pixel.chan.r = (uint8_t)MIN2(src[0], 255);
pixel.chan.g = (uint8_t)MIN2(src[1], 255);
pixel.chan.b = (uint8_t)MIN2(src[2], 255);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_uint pixel;
pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255);
pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255);
pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_uint {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = (unsigned)b; /* b */
dst[3] = (unsigned)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8;
value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16;
value |= ((uint8_t)MIN2(src[3], 255)) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = (unsigned)b; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_r8g8b8a8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
a = value >> 24;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8_sint {
uint8_t value;
struct {
int8_t r;
} chan;
};
 
static INLINE void
util_format_r8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t r;
r = (int8_t)(value) ;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8_sint {
uint16_t value;
struct {
int8_t r;
int8_t g;
} chan;
};
 
static INLINE void
util_format_r8g8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t g;
r = ((int16_t)(value << 8) ) >> 8;
g = ((int16_t)(value) ) >> 8;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = (unsigned)MAX2(g, 0); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)MIN2(src[1], 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8_sint {
struct {
int8_t r;
int8_t g;
int8_t b;
} chan;
};
 
static INLINE void
util_format_r8g8b8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sint pixel;
pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127);
pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127);
pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r8g8b8_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = 1; /* a */
src += 3;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r8g8b8_sint pixel;
pixel.chan.r = (int8_t)MIN2(src[0], 127);
pixel.chan.g = (int8_t)MIN2(src[1], 127);
pixel.chan.b = (int8_t)MIN2(src[2], 127);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 3;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8a8_sint {
uint32_t value;
struct {
int8_t r;
int8_t g;
int8_t b;
int8_t a;
} chan;
};
 
static INLINE void
util_format_r8g8b8a8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_r8g8b8a8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
int32_t a;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
a = ((int32_t)(value) ) >> 24;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = (unsigned)MAX2(g, 0); /* g */
dst[2] = (unsigned)MAX2(b, 0); /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ;
value |= (uint32_t)(((int8_t)MIN2(src[3], 127)) << 24) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_uint {
uint16_t value;
struct {
uint16_t r;
} chan;
};
 
static INLINE void
util_format_r16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)MIN2(src[0], 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
r = value;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)CLAMP(src[0], 0, 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_uint {
uint32_t value;
struct {
uint16_t r;
uint16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
value |= ((uint16_t)MIN2(src[1], 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
r = (value) & 0xffff;
g = value >> 16;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_uint {
struct {
uint16_t r;
uint16_t g;
uint16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uint pixel;
pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_uint pixel;
pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_uint {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = (unsigned)pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uint pixel;
pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
pixel.chan.a = (uint16_t)MIN2(src[3], 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = (unsigned)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r16g16b16a16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = (int)pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_uint pixel;
pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16_sint {
uint16_t value;
struct {
int16_t r;
} chan;
};
 
static INLINE void
util_format_r16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
r = (int16_t)(value) ;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16_sint {
uint32_t value;
struct {
int16_t r;
int16_t g;
} chan;
};
 
static INLINE void
util_format_r16g16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
r = ((int32_t)(value << 16) ) >> 16;
g = ((int32_t)(value) ) >> 16;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = (unsigned)MAX2(g, 0); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)MIN2(src[1], 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16_sint {
struct {
int16_t r;
int16_t g;
int16_t b;
} chan;
};
 
static INLINE void
util_format_r16g16b16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sint pixel;
pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = 1; /* a */
src += 6;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16_sint pixel;
pixel.chan.r = (int16_t)MIN2(src[0], 32767);
pixel.chan.g = (int16_t)MIN2(src[1], 32767);
pixel.chan.b = (int16_t)MIN2(src[2], 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 6;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16a16_sint {
uint64_t value;
struct {
int16_t r;
int16_t g;
int16_t b;
int16_t a;
} chan;
};
 
static INLINE void
util_format_r16g16b16a16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = (int)pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sint pixel;
pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16a16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = (int)pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r16g16b16a16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16a16_sint pixel;
pixel.chan.r = (int16_t)MIN2(src[0], 32767);
pixel.chan.g = (int16_t)MIN2(src[1], 32767);
pixel.chan.b = (int16_t)MIN2(src[2], 32767);
pixel.chan.a = (int16_t)MIN2(src[3], 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_uint {
uint32_t value;
struct {
uint32_t r;
} chan;
};
 
static INLINE void
util_format_r32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= src[0];
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
r = value;
dst[0] = (int)MIN2(r, 2147483647); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)MAX2(src[0], 0);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_uint {
uint64_t value;
struct {
uint32_t r;
uint32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_uint pixel;
pixel.chan.r = (uint32_t)MAX2(src[0], 0);
pixel.chan.g = (uint32_t)MAX2(src[1], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_uint {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_uint pixel;
pixel.chan.r = (uint32_t)MAX2(src[0], 0);
pixel.chan.g = (uint32_t)MAX2(src[1], 0);
pixel.chan.b = (uint32_t)MAX2(src[2], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_uint {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32g32b32a32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_uint pixel;
pixel.chan.r = (uint32_t)MAX2(src[0], 0);
pixel.chan.g = (uint32_t)MAX2(src[1], 0);
pixel.chan.b = (uint32_t)MAX2(src[2], 0);
pixel.chan.a = (uint32_t)MAX2(src[3], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32_sint {
uint32_t value;
struct {
int32_t r;
} chan;
};
 
static INLINE void
util_format_r32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(src[0]) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
r = (int32_t)(value) ;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32_sint {
uint64_t value;
struct {
int32_t r;
int32_t g;
} chan;
};
 
static INLINE void
util_format_r32g32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = 0; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32_sint pixel;
pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32_sint {
struct {
int32_t r;
int32_t g;
int32_t b;
} chan;
};
 
static INLINE void
util_format_r32g32b32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = 1; /* a */
src += 12;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32_sint pixel;
pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 12;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32a32_sint {
struct {
int32_t r;
int32_t g;
int32_t b;
int32_t a;
} chan;
};
 
static INLINE void
util_format_r32g32b32a32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32g32b32a32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32a32_sint pixel;
pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8_uint {
uint8_t value;
struct {
uint8_t a;
} chan;
};
 
static INLINE void
util_format_a8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)MIN2(src[3], 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_a8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[3], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i8_uint {
uint8_t value;
struct {
uint8_t rgba;
} chan;
};
 
static INLINE void
util_format_i8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = (unsigned)rgba; /* r */
dst[1] = (unsigned)rgba; /* g */
dst[2] = (unsigned)rgba; /* b */
dst[3] = (unsigned)rgba; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)MIN2(src[0], 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = (unsigned)rgba; /* r */
dst[1] = (unsigned)rgba; /* g */
dst[2] = (unsigned)rgba; /* b */
dst[3] = (unsigned)rgba; /* a */
}
 
static INLINE void
util_format_i8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgba;
rgba = value;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[0], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8_uint {
uint8_t value;
struct {
uint8_t rgb;
} chan;
};
 
static INLINE void
util_format_l8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)MIN2(src[0], 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
uint8_t rgb;
rgb = value;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)CLAMP(src[0], 0, 255);
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8a8_uint {
uint16_t value;
struct {
uint8_t rgb;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_l8a8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = (unsigned)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
value |= ((uint8_t)MIN2(src[3], 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_l8a8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
uint16_t a;
rgb = (value) & 0xff;
a = value >> 8;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a8_sint {
uint8_t value;
struct {
int8_t a;
} chan;
};
 
static INLINE void
util_format_a8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)CLAMP(src[3], -128, 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_a8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t a;
a = (int8_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)MIN2(src[3], 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i8_sint {
uint8_t value;
struct {
int8_t rgba;
} chan;
};
 
static INLINE void
util_format_i8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
}
 
static INLINE void
util_format_i8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgba;
rgba = (int8_t)(value) ;
dst[0] = (unsigned)MAX2(rgba, 0); /* r */
dst[1] = (unsigned)MAX2(rgba, 0); /* g */
dst[2] = (unsigned)MAX2(rgba, 0); /* b */
dst[3] = (unsigned)MAX2(rgba, 0); /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8_sint {
uint8_t value;
struct {
int8_t rgb;
} chan;
};
 
static INLINE void
util_format_l8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint8_t value = *(const uint8_t *)src;
int8_t rgb;
rgb = (int8_t)(value) ;
dst[0] = (unsigned)MAX2(rgb, 0); /* r */
dst[1] = (unsigned)MAX2(rgb, 0); /* g */
dst[2] = (unsigned)MAX2(rgb, 0); /* b */
dst[3] = 1; /* a */
src += 1;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint8_t value = 0;
value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
*(uint8_t *)dst = value;
src += 4;
dst += 1;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l8a8_sint {
uint16_t value;
struct {
int8_t rgb;
int8_t a;
} chan;
};
 
static INLINE void
util_format_l8a8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_l8a8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
int16_t a;
rgb = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (unsigned)MAX2(rgb, 0); /* r */
dst[1] = (unsigned)MAX2(rgb, 0); /* g */
dst[2] = (unsigned)MAX2(rgb, 0); /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a16_uint {
uint16_t value;
struct {
uint16_t a;
} chan;
};
 
static INLINE void
util_format_a16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)MIN2(src[3], 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_a16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)CLAMP(src[3], 0, 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i16_uint {
uint16_t value;
struct {
uint16_t rgba;
} chan;
};
 
static INLINE void
util_format_i16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (unsigned)rgba; /* r */
dst[1] = (unsigned)rgba; /* g */
dst[2] = (unsigned)rgba; /* b */
dst[3] = (unsigned)rgba; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)MIN2(src[0], 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (unsigned)rgba; /* r */
dst[1] = (unsigned)rgba; /* g */
dst[2] = (unsigned)rgba; /* b */
dst[3] = (unsigned)rgba; /* a */
}
 
static INLINE void
util_format_i16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgba;
rgba = value;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)CLAMP(src[0], 0, 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16_uint {
uint16_t value;
struct {
uint16_t rgb;
} chan;
};
 
static INLINE void
util_format_l16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)MIN2(src[0], 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t rgb;
rgb = value;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)CLAMP(src[0], 0, 65535);
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16a16_uint {
uint32_t value;
struct {
uint16_t rgb;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_l16a16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = (unsigned)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
value |= ((uint16_t)MIN2(src[3], 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (unsigned)rgb; /* r */
dst[1] = (unsigned)rgb; /* g */
dst[2] = (unsigned)rgb; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_l16a16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
uint32_t a;
rgb = (value) & 0xffff;
a = value >> 16;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a16_sint {
uint16_t value;
struct {
int16_t a;
} chan;
};
 
static INLINE void
util_format_a16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)CLAMP(src[3], -32768, 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_a16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t a;
a = (int16_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)MIN2(src[3], 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i16_sint {
uint16_t value;
struct {
int16_t rgba;
} chan;
};
 
static INLINE void
util_format_i16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (int)rgba; /* r */
dst[1] = (int)rgba; /* g */
dst[2] = (int)rgba; /* b */
dst[3] = (int)rgba; /* a */
}
 
static INLINE void
util_format_i16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgba;
rgba = (int16_t)(value) ;
dst[0] = (unsigned)MAX2(rgba, 0); /* r */
dst[1] = (unsigned)MAX2(rgba, 0); /* g */
dst[2] = (unsigned)MAX2(rgba, 0); /* b */
dst[3] = (unsigned)MAX2(rgba, 0); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16_sint {
uint16_t value;
struct {
int16_t rgb;
} chan;
};
 
static INLINE void
util_format_l16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t rgb;
rgb = (int16_t)(value) ;
dst[0] = (unsigned)MAX2(rgb, 0); /* r */
dst[1] = (unsigned)MAX2(rgb, 0); /* g */
dst[2] = (unsigned)MAX2(rgb, 0); /* b */
dst[3] = 1; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l16a16_sint {
uint32_t value;
struct {
int16_t rgb;
int16_t a;
} chan;
};
 
static INLINE void
util_format_l16a16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (int)rgb; /* r */
dst[1] = (int)rgb; /* g */
dst[2] = (int)rgb; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_l16a16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
int32_t a;
rgb = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (unsigned)MAX2(rgb, 0); /* r */
dst[1] = (unsigned)MAX2(rgb, 0); /* g */
dst[2] = (unsigned)MAX2(rgb, 0); /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a32_uint {
uint32_t value;
struct {
uint32_t a;
} chan;
};
 
static INLINE void
util_format_a32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= src[3];
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
}
 
static INLINE void
util_format_a32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t a;
a = value;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)MIN2(a, 2147483647); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)MAX2(src[3], 0);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i32_uint {
uint32_t value;
struct {
uint32_t rgba;
} chan;
};
 
static INLINE void
util_format_i32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgba;
rgba = value;
dst[0] = rgba; /* r */
dst[1] = rgba; /* g */
dst[2] = rgba; /* b */
dst[3] = rgba; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= src[0];
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t rgba;
rgba = value;
dst[0] = rgba; /* r */
dst[1] = rgba; /* g */
dst[2] = rgba; /* b */
dst[3] = rgba; /* a */
}
 
static INLINE void
util_format_i32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgba;
rgba = value;
dst[0] = (int)MIN2(rgba, 2147483647); /* r */
dst[1] = (int)MIN2(rgba, 2147483647); /* g */
dst[2] = (int)MIN2(rgba, 2147483647); /* b */
dst[3] = (int)MIN2(rgba, 2147483647); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)MAX2(src[0], 0);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32_uint {
uint32_t value;
struct {
uint32_t rgb;
} chan;
};
 
static INLINE void
util_format_l32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
rgb = value;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= src[0];
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
rgb = value;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t rgb;
rgb = value;
dst[0] = (int)MIN2(rgb, 2147483647); /* r */
dst[1] = (int)MIN2(rgb, 2147483647); /* g */
dst[2] = (int)MIN2(rgb, 2147483647); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)MAX2(src[0], 0);
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32a32_uint {
uint64_t value;
struct {
uint32_t rgb;
uint32_t a;
} chan;
};
 
static INLINE void
util_format_l32a32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_uint pixel;
pixel.chan.rgb = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_l32a32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.rgb, 2147483647); /* r */
dst[1] = (int)MIN2(pixel.chan.rgb, 2147483647); /* g */
dst[2] = (int)MIN2(pixel.chan.rgb, 2147483647); /* b */
dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_uint pixel;
pixel.chan.rgb = (uint32_t)MAX2(src[0], 0);
pixel.chan.a = (uint32_t)MAX2(src[3], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_a32_sint {
uint32_t value;
struct {
int32_t a;
} chan;
};
 
static INLINE void
util_format_a32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t a;
a = (int32_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(src[3]) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t a;
a = (int32_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = a; /* a */
}
 
static INLINE void
util_format_a32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t a;
a = (int32_t)(value) ;
dst[0] = 0; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)MIN2(src[3], 2147483647)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_i32_sint {
uint32_t value;
struct {
int32_t rgba;
} chan;
};
 
static INLINE void
util_format_i32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgba;
rgba = (int32_t)(value) ;
dst[0] = rgba; /* r */
dst[1] = rgba; /* g */
dst[2] = rgba; /* b */
dst[3] = rgba; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(src[0]) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_i32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t rgba;
rgba = (int32_t)(value) ;
dst[0] = rgba; /* r */
dst[1] = rgba; /* g */
dst[2] = rgba; /* b */
dst[3] = rgba; /* a */
}
 
static INLINE void
util_format_i32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgba;
rgba = (int32_t)(value) ;
dst[0] = (unsigned)MAX2(rgba, 0); /* r */
dst[1] = (unsigned)MAX2(rgba, 0); /* g */
dst[2] = (unsigned)MAX2(rgba, 0); /* b */
dst[3] = (unsigned)MAX2(rgba, 0); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_i32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32_sint {
uint32_t value;
struct {
int32_t rgb;
} chan;
};
 
static INLINE void
util_format_l32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
rgb = (int32_t)(value) ;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(src[0]) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
rgb = (int32_t)(value) ;
dst[0] = rgb; /* r */
dst[1] = rgb; /* g */
dst[2] = rgb; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_l32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t rgb;
rgb = (int32_t)(value) ;
dst[0] = (unsigned)MAX2(rgb, 0); /* r */
dst[1] = (unsigned)MAX2(rgb, 0); /* g */
dst[2] = (unsigned)MAX2(rgb, 0); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_l32a32_sint {
uint64_t value;
struct {
int32_t rgb;
int32_t a;
} chan;
};
 
static INLINE void
util_format_l32a32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_sint pixel;
pixel.chan.rgb = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_l32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_l32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.rgb; /* r */
dst[1] = pixel.chan.rgb; /* g */
dst[2] = pixel.chan.rgb; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_l32a32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.rgb, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.rgb, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.rgb, 0); /* b */
dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_l32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_l32a32_sint pixel;
pixel.chan.rgb = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8x8_snorm {
uint32_t value;
struct {
int8_t r;
int8_t g;
int8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8g8b8x8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = (float)(b * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = (float)(g * (1.0f/0x7f)); /* g */
dst[2] = (float)(b * (1.0f/0x7f)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8x8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8x8_srgb {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8g8b8x8_srgb_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;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */
dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */
dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_srgb_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 = 0;
value |= (util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff;
value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8;
value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */
dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */
dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8x8_srgb_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */
dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */
dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */
dst[3] = 255; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_srgb_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (util_format_linear_to_srgb_8unorm(src[0])) & 0xff;
value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8;
value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8x8_uint {
uint32_t value;
struct {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8g8b8x8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = (unsigned)b; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8;
value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = (unsigned)r; /* r */
dst[1] = (unsigned)g; /* g */
dst[2] = (unsigned)b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8x8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t g;
uint32_t b;
r = (value) & 0xff;
g = (value >> 8) & 0xff;
b = (value >> 16) & 0xff;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8g8b8x8_sint {
uint32_t value;
struct {
int8_t r;
int8_t g;
int8_t b;
uint8_t x;
} chan;
};
 
static INLINE void
util_format_r8g8b8x8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (int)r; /* r */
dst[1] = (int)g; /* g */
dst[2] = (int)b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r8g8b8x8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t g;
int32_t b;
r = ((int32_t)(value << 24) ) >> 24;
g = ((int32_t)(value << 16) ) >> 24;
b = ((int32_t)(value << 8) ) >> 24;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = (unsigned)MAX2(g, 0); /* g */
dst[2] = (unsigned)MAX2(b, 0); /* b */
dst[3] = 1; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8g8b8x8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ;
value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16x16_unorm {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t x;
} chan;
};
 
static INLINE void
util_format_r16g16b16x16_unorm_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) {
union util_format_r16g16b16x16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_unorm_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) {
union util_format_r16g16b16x16_unorm pixel;
pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16x16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16x16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_unorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_unorm pixel;
pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16x16_snorm {
uint64_t value;
struct {
int16_t r;
int16_t g;
int16_t b;
uint16_t x;
} chan;
};
 
static INLINE void
util_format_r16g16b16x16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_snorm pixel;
pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16x16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16x16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_snorm pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_snorm pixel;
pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16x16_float {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t x;
} chan;
};
 
static INLINE void
util_format_r16g16b16x16_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) {
union util_format_r16g16b16x16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_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) {
union util_format_r16g16b16x16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
pixel.chan.g = util_float_to_half(src[1]);
pixel.chan.b = util_float_to_half(src[2]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16x16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = util_half_to_float(pixel.chan.g); /* g */
dst[2] = util_half_to_float(pixel.chan.b); /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16x16_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;
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) {
union util_format_r16g16b16x16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
dst[3] = 255; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_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;
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) {
union util_format_r16g16b16x16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16x16_uint {
uint64_t value;
struct {
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t x;
} chan;
};
 
static INLINE void
util_format_r16g16b16x16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_uint pixel;
pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16x16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)pixel.chan.r; /* r */
dst[1] = (unsigned)pixel.chan.g; /* g */
dst[2] = (unsigned)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16x16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_uint pixel;
pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16g16b16x16_sint {
uint64_t value;
struct {
int16_t r;
int16_t g;
int16_t b;
uint16_t x;
} chan;
};
 
static INLINE void
util_format_r16g16b16x16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_sint pixel;
pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16g16b16x16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)pixel.chan.r; /* r */
dst[1] = (int)pixel.chan.g; /* g */
dst[2] = (int)pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r16g16b16x16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = 1; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16g16b16x16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r16g16b16x16_sint pixel;
pixel.chan.r = (int16_t)MIN2(src[0], 32767);
pixel.chan.g = (int16_t)MIN2(src[1], 32767);
pixel.chan.b = (int16_t)MIN2(src[2], 32767);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32x32_float {
struct {
float r;
float g;
float b;
uint32_t x;
} chan;
};
 
static INLINE void
util_format_r32g32b32x32_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) {
union util_format_r32g32b32x32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_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) {
union util_format_r32g32b32x32_float pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32x32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32x32_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;
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) {
union util_format_r32g32b32x32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = float_to_ubyte(pixel.chan.g); /* g */
dst[2] = float_to_ubyte(pixel.chan.b); /* b */
dst[3] = 255; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_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;
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) {
union util_format_r32g32b32x32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
pixel.chan.g = ubyte_to_float(src[1]);
pixel.chan.b = ubyte_to_float(src[2]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32x32_uint {
struct {
uint32_t r;
uint32_t g;
uint32_t b;
uint32_t x;
} chan;
};
 
static INLINE void
util_format_r32g32b32x32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_uint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32x32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32x32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_uint pixel;
pixel.chan.r = (uint32_t)MAX2(src[0], 0);
pixel.chan.g = (uint32_t)MAX2(src[1], 0);
pixel.chan.b = (uint32_t)MAX2(src[2], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32g32b32x32_sint {
struct {
int32_t r;
int32_t g;
int32_t b;
uint32_t x;
} chan;
};
 
static INLINE void
util_format_r32g32b32x32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_sint pixel;
pixel.chan.r = src[0];
pixel.chan.g = src[1];
pixel.chan.b = src[2];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32g32b32x32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = pixel.chan.g; /* g */
dst[2] = pixel.chan.b; /* b */
dst[3] = 1; /* a */
}
 
static INLINE void
util_format_r32g32b32x32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
dst[3] = 1; /* a */
src += 16;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32g32b32x32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32g32b32x32_sint pixel;
pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 16;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8a8_snorm {
uint16_t value;
struct {
int8_t r;
int8_t a;
} chan;
};
 
static INLINE void
util_format_r8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (float)(r * (1.0f/0x7f)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7f)); /* a */
}
 
static INLINE void
util_format_r8a8_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16a16_unorm {
uint32_t value;
struct {
uint16_t r;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16a16_unorm_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;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_unorm_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 = 0;
value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (float)(r * (1.0f/0xffff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0xffff)); /* a */
}
 
static INLINE void
util_format_r16a16_unorm_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (uint8_t)(r >> 8); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(a >> 8); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_unorm_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16a16_snorm {
uint32_t value;
struct {
int16_t r;
int16_t a;
} chan;
};
 
static INLINE void
util_format_r16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
}
 
static INLINE void
util_format_r16a16_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 uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_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;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16a16_float {
uint32_t value;
struct {
uint16_t r;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16a16_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) {
union util_format_r16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_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) {
union util_format_r16a16_float pixel;
pixel.chan.r = util_float_to_half(src[0]);
pixel.chan.a = util_float_to_half(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = util_half_to_float(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = util_half_to_float(pixel.chan.a); /* a */
}
 
static INLINE void
util_format_r16a16_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;
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) {
union util_format_r16a16_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_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;
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) {
union util_format_r16a16_float pixel;
pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32a32_float {
uint64_t value;
struct {
float r;
float a;
} chan;
};
 
static INLINE void
util_format_r32a32_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) {
union util_format_r32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_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) {
union util_format_r32a32_float pixel;
pixel.chan.r = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32a32_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;
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) {
union util_format_r32a32_float pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = float_to_ubyte(pixel.chan.r); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = float_to_ubyte(pixel.chan.a); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_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;
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) {
union util_format_r32a32_float pixel;
pixel.chan.r = ubyte_to_float(src[0]);
pixel.chan.a = ubyte_to_float(src[3]);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8a8_uint {
uint16_t value;
struct {
uint8_t r;
uint8_t a;
} chan;
};
 
static INLINE void
util_format_r8a8_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
value |= ((uint8_t)MIN2(src[3], 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_r8a8_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
uint16_t r;
uint16_t a;
r = (value) & 0xff;
a = value >> 8;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r8a8_sint {
uint16_t value;
struct {
int8_t r;
int8_t a;
} chan;
};
 
static INLINE void
util_format_r8a8_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_r8a8_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint16_t value = *(const uint16_t *)src;
int16_t r;
int16_t a;
r = ((int16_t)(value << 8) ) >> 8;
a = ((int16_t)(value) ) >> 8;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 2;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint16_t value = 0;
value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ;
*(uint16_t *)dst = value;
src += 4;
dst += 2;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16a16_uint {
uint32_t value;
struct {
uint16_t r;
uint16_t a;
} chan;
};
 
static INLINE void
util_format_r16a16_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
value |= ((uint16_t)MIN2(src[3], 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (unsigned)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)a; /* a */
}
 
static INLINE void
util_format_r16a16_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
uint32_t r;
uint32_t a;
r = (value) & 0xffff;
a = value >> 16;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r16a16_sint {
uint32_t value;
struct {
int16_t r;
int16_t a;
} chan;
};
 
static INLINE void
util_format_r16a16_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (int)r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)a; /* a */
}
 
static INLINE void
util_format_r16a16_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
uint32_t value = *(const uint32_t *)src;
int32_t r;
int32_t a;
r = ((int32_t)(value << 16) ) >> 16;
a = ((int32_t)(value) ) >> 16;
dst[0] = (unsigned)MAX2(r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(a, 0); /* a */
src += 4;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
uint32_t value = 0;
value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ;
*(uint32_t *)dst = value;
src += 4;
dst += 4;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32a32_uint {
uint64_t value;
struct {
uint32_t r;
uint32_t a;
} chan;
};
 
static INLINE void
util_format_r32a32_uint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_uint pixel;
pixel.chan.r = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32a32_uint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_uint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_uint pixel;
pixel.chan.r = (uint32_t)MAX2(src[0], 0);
pixel.chan.a = (uint32_t)MAX2(src[3], 0);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
union util_format_r32a32_sint {
uint64_t value;
struct {
int32_t r;
int32_t a;
} chan;
};
 
static INLINE void
util_format_r32a32_sint_unpack_signed(int *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) {
int *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const int *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_sint pixel;
pixel.chan.r = src[0];
pixel.chan.a = src[3];
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
static INLINE void
util_format_r32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
{
union util_format_r32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = pixel.chan.r; /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = pixel.chan.a; /* a */
}
 
static INLINE void
util_format_r32a32_sint_unpack_unsigned(unsigned *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) {
unsigned *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_sint pixel;
memcpy(&pixel, src, sizeof pixel);
dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
dst[1] = 0; /* g */
dst[2] = 0; /* b */
dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
src += 8;
dst += 4;
}
src_row += src_stride;
dst_row += dst_stride/sizeof(*dst_row);
}
}
 
static INLINE void
util_format_r32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
{
unsigned x, y;
for(y = 0; y < height; y += 1) {
const unsigned *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
union util_format_r32a32_sint pixel;
pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
memcpy(dst, &pixel, sizeof pixel);
src += 4;
dst += 8;
}
dst_row += dst_stride;
src_row += src_stride/sizeof(*src_row);
}
}
 
const struct util_format_description
util_format_none_description = {
PIPE_FORMAT_NONE,
"PIPE_FORMAT_NONE",
"none",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_none_unpack_rgba_8unorm,
&util_format_none_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_none_unpack_rgba_float,
&util_format_none_pack_rgba_float,
&util_format_none_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_b8g8r8a8_unorm_description = {
PIPE_FORMAT_B8G8R8A8_UNORM,
"PIPE_FORMAT_B8G8R8A8_UNORM",
"b8g8r8a8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_Z, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_b8g8r8a8_unorm_unpack_rgba_8unorm,
&util_format_b8g8r8a8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_b8g8r8a8_unorm_unpack_rgba_float,
&util_format_b8g8r8a8_unorm_pack_rgba_float,
&util_format_b8g8r8a8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_b8g8r8x8_unorm_description = {
PIPE_FORMAT_B8G8R8X8_UNORM,
"PIPE_FORMAT_B8G8R8X8_UNORM",
"b8g8r8x8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_Z, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_b8g8r8x8_unorm_unpack_rgba_8unorm,
&util_format_b8g8r8x8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_b8g8r8x8_unorm_unpack_rgba_float,
&util_format_b8g8r8x8_unorm_pack_rgba_float,
&util_format_b8g8r8x8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8r8g8b8_unorm_description = {
PIPE_FORMAT_A8R8G8B8_UNORM,
"PIPE_FORMAT_A8R8G8B8_UNORM",
"a8r8g8b8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_Z, /* g */
UTIL_FORMAT_SWIZZLE_W, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a8r8g8b8_unorm_unpack_rgba_8unorm,
&util_format_a8r8g8b8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a8r8g8b8_unorm_unpack_rgba_float,
&util_format_a8r8g8b8_unorm_pack_rgba_float,
&util_format_a8r8g8b8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_x8r8g8b8_unorm_description = {
PIPE_FORMAT_X8R8G8B8_UNORM,
"PIPE_FORMAT_X8R8G8B8_UNORM",
"x8r8g8b8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_Z, /* g */
UTIL_FORMAT_SWIZZLE_W, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_x8r8g8b8_unorm_unpack_rgba_8unorm,
&util_format_x8r8g8b8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_x8r8g8b8_unorm_unpack_rgba_float,
&util_format_x8r8g8b8_unorm_pack_rgba_float,
&util_format_x8r8g8b8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8b8g8r8_unorm_description = {
PIPE_FORMAT_A8B8G8R8_UNORM,
"PIPE_FORMAT_A8B8G8R8_UNORM",
"a8b8g8r8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */
},
{
UTIL_FORMAT_SWIZZLE_W, /* r */
UTIL_FORMAT_SWIZZLE_Z, /* g */
UTIL_FORMAT_SWIZZLE_Y, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a8b8g8r8_unorm_unpack_rgba_8unorm,
&util_format_a8b8g8r8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a8b8g8r8_unorm_unpack_rgba_float,
&util_format_a8b8g8r8_unorm_pack_rgba_float,
&util_format_a8b8g8r8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_x8b8g8r8_unorm_description = {
PIPE_FORMAT_X8B8G8R8_UNORM,
"PIPE_FORMAT_X8B8G8R8_UNORM",
"x8b8g8r8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */
},
{
UTIL_FORMAT_SWIZZLE_W, /* r */
UTIL_FORMAT_SWIZZLE_Z, /* g */
UTIL_FORMAT_SWIZZLE_Y, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_x8b8g8r8_unorm_unpack_rgba_8unorm,
&util_format_x8b8g8r8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_x8b8g8r8_unorm_unpack_rgba_float,
&util_format_x8b8g8r8_unorm_pack_rgba_float,
&util_format_x8b8g8r8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8x8_unorm_description = {
PIPE_FORMAT_R8G8B8X8_UNORM,
"PIPE_FORMAT_R8G8B8X8_UNORM",
"r8g8b8x8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8x8_unorm_unpack_rgba_8unorm,
&util_format_r8g8b8x8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8x8_unorm_unpack_rgba_float,
&util_format_r8g8b8x8_unorm_pack_rgba_float,
&util_format_r8g8b8x8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8_unorm_description = {
PIPE_FORMAT_L8_UNORM,
"PIPE_FORMAT_L8_UNORM",
"l8_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l8_unorm_unpack_rgba_8unorm,
&util_format_l8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l8_unorm_unpack_rgba_float,
&util_format_l8_unorm_pack_rgba_float,
&util_format_l8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8_unorm_description = {
PIPE_FORMAT_A8_UNORM,
"PIPE_FORMAT_A8_UNORM",
"a8_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a8_unorm_unpack_rgba_8unorm,
&util_format_a8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a8_unorm_unpack_rgba_float,
&util_format_a8_unorm_pack_rgba_float,
&util_format_a8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i8_unorm_description = {
PIPE_FORMAT_I8_UNORM,
"PIPE_FORMAT_I8_UNORM",
"i8_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i8_unorm_unpack_rgba_8unorm,
&util_format_i8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i8_unorm_unpack_rgba_float,
&util_format_i8_unorm_pack_rgba_float,
&util_format_i8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l4a4_unorm_description = {
PIPE_FORMAT_L4A4_UNORM,
"PIPE_FORMAT_L4A4_UNORM",
"l4a4_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l4a4_unorm_unpack_rgba_8unorm,
&util_format_l4a4_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l4a4_unorm_unpack_rgba_float,
&util_format_l4a4_unorm_pack_rgba_float,
&util_format_l4a4_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8a8_unorm_description = {
PIPE_FORMAT_L8A8_UNORM,
"PIPE_FORMAT_L8A8_UNORM",
"l8a8_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l8a8_unorm_unpack_rgba_8unorm,
&util_format_l8a8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l8a8_unorm_unpack_rgba_float,
&util_format_l8a8_unorm_pack_rgba_float,
&util_format_l8a8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16_unorm_description = {
PIPE_FORMAT_L16_UNORM,
"PIPE_FORMAT_L16_UNORM",
"l16_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16_unorm_unpack_rgba_8unorm,
&util_format_l16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16_unorm_unpack_rgba_float,
&util_format_l16_unorm_pack_rgba_float,
&util_format_l16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a16_unorm_description = {
PIPE_FORMAT_A16_UNORM,
"PIPE_FORMAT_A16_UNORM",
"a16_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a16_unorm_unpack_rgba_8unorm,
&util_format_a16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a16_unorm_unpack_rgba_float,
&util_format_a16_unorm_pack_rgba_float,
&util_format_a16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i16_unorm_description = {
PIPE_FORMAT_I16_UNORM,
"PIPE_FORMAT_I16_UNORM",
"i16_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i16_unorm_unpack_rgba_8unorm,
&util_format_i16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i16_unorm_unpack_rgba_float,
&util_format_i16_unorm_pack_rgba_float,
&util_format_i16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16a16_unorm_description = {
PIPE_FORMAT_L16A16_UNORM,
"PIPE_FORMAT_L16A16_UNORM",
"l16a16_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16a16_unorm_unpack_rgba_8unorm,
&util_format_l16a16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16a16_unorm_unpack_rgba_float,
&util_format_l16a16_unorm_pack_rgba_float,
&util_format_l16a16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8_snorm_description = {
PIPE_FORMAT_A8_SNORM,
"PIPE_FORMAT_A8_SNORM",
"a8_snorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a8_snorm_unpack_rgba_8unorm,
&util_format_a8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a8_snorm_unpack_rgba_float,
&util_format_a8_snorm_pack_rgba_float,
&util_format_a8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8_snorm_description = {
PIPE_FORMAT_L8_SNORM,
"PIPE_FORMAT_L8_SNORM",
"l8_snorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l8_snorm_unpack_rgba_8unorm,
&util_format_l8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l8_snorm_unpack_rgba_float,
&util_format_l8_snorm_pack_rgba_float,
&util_format_l8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8a8_snorm_description = {
PIPE_FORMAT_L8A8_SNORM,
"PIPE_FORMAT_L8A8_SNORM",
"l8a8_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l8a8_snorm_unpack_rgba_8unorm,
&util_format_l8a8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l8a8_snorm_unpack_rgba_float,
&util_format_l8a8_snorm_pack_rgba_float,
&util_format_l8a8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i8_snorm_description = {
PIPE_FORMAT_I8_SNORM,
"PIPE_FORMAT_I8_SNORM",
"i8_snorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i8_snorm_unpack_rgba_8unorm,
&util_format_i8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i8_snorm_unpack_rgba_float,
&util_format_i8_snorm_pack_rgba_float,
&util_format_i8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a16_snorm_description = {
PIPE_FORMAT_A16_SNORM,
"PIPE_FORMAT_A16_SNORM",
"a16_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a16_snorm_unpack_rgba_8unorm,
&util_format_a16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a16_snorm_unpack_rgba_float,
&util_format_a16_snorm_pack_rgba_float,
&util_format_a16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16_snorm_description = {
PIPE_FORMAT_L16_SNORM,
"PIPE_FORMAT_L16_SNORM",
"l16_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16_snorm_unpack_rgba_8unorm,
&util_format_l16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16_snorm_unpack_rgba_float,
&util_format_l16_snorm_pack_rgba_float,
&util_format_l16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16a16_snorm_description = {
PIPE_FORMAT_L16A16_SNORM,
"PIPE_FORMAT_L16A16_SNORM",
"l16a16_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16a16_snorm_unpack_rgba_8unorm,
&util_format_l16a16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16a16_snorm_unpack_rgba_float,
&util_format_l16a16_snorm_pack_rgba_float,
&util_format_l16a16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i16_snorm_description = {
PIPE_FORMAT_I16_SNORM,
"PIPE_FORMAT_I16_SNORM",
"i16_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i16_snorm_unpack_rgba_8unorm,
&util_format_i16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i16_snorm_unpack_rgba_float,
&util_format_i16_snorm_pack_rgba_float,
&util_format_i16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a16_float_description = {
PIPE_FORMAT_A16_FLOAT,
"PIPE_FORMAT_A16_FLOAT",
"a16_float",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a16_float_unpack_rgba_8unorm,
&util_format_a16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a16_float_unpack_rgba_float,
&util_format_a16_float_pack_rgba_float,
&util_format_a16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16_float_description = {
PIPE_FORMAT_L16_FLOAT,
"PIPE_FORMAT_L16_FLOAT",
"l16_float",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16_float_unpack_rgba_8unorm,
&util_format_l16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16_float_unpack_rgba_float,
&util_format_l16_float_pack_rgba_float,
&util_format_l16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16a16_float_description = {
PIPE_FORMAT_L16A16_FLOAT,
"PIPE_FORMAT_L16A16_FLOAT",
"l16a16_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l16a16_float_unpack_rgba_8unorm,
&util_format_l16a16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l16a16_float_unpack_rgba_float,
&util_format_l16a16_float_pack_rgba_float,
&util_format_l16a16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i16_float_description = {
PIPE_FORMAT_I16_FLOAT,
"PIPE_FORMAT_I16_FLOAT",
"i16_float",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i16_float_unpack_rgba_8unorm,
&util_format_i16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i16_float_unpack_rgba_float,
&util_format_i16_float_pack_rgba_float,
&util_format_i16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a32_float_description = {
PIPE_FORMAT_A32_FLOAT,
"PIPE_FORMAT_A32_FLOAT",
"a32_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a32_float_unpack_rgba_8unorm,
&util_format_a32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a32_float_unpack_rgba_float,
&util_format_a32_float_pack_rgba_float,
&util_format_a32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32_float_description = {
PIPE_FORMAT_L32_FLOAT,
"PIPE_FORMAT_L32_FLOAT",
"l32_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l32_float_unpack_rgba_8unorm,
&util_format_l32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l32_float_unpack_rgba_float,
&util_format_l32_float_pack_rgba_float,
&util_format_l32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32a32_float_description = {
PIPE_FORMAT_L32A32_FLOAT,
"PIPE_FORMAT_L32A32_FLOAT",
"l32a32_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_l32a32_float_unpack_rgba_8unorm,
&util_format_l32a32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_l32a32_float_unpack_rgba_float,
&util_format_l32a32_float_pack_rgba_float,
&util_format_l32a32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i32_float_description = {
PIPE_FORMAT_I32_FLOAT,
"PIPE_FORMAT_I32_FLOAT",
"i32_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_i32_float_unpack_rgba_8unorm,
&util_format_i32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_i32_float_unpack_rgba_float,
&util_format_i32_float_pack_rgba_float,
&util_format_i32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8sg8sb8ux8u_norm_description = {
PIPE_FORMAT_R8SG8SB8UX8U_NORM,
"PIPE_FORMAT_R8SG8SB8UX8U_NORM",
"r8sg8sb8ux8u_norm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
TRUE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8sg8sb8ux8u_norm_unpack_rgba_8unorm,
&util_format_r8sg8sb8ux8u_norm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8sg8sb8ux8u_norm_unpack_rgba_float,
&util_format_r8sg8sb8ux8u_norm_pack_rgba_float,
&util_format_r8sg8sb8ux8u_norm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r5sg5sb6u_norm_description = {
PIPE_FORMAT_R5SG5SB6U_NORM,
"PIPE_FORMAT_R5SG5SB6U_NORM",
"r5sg5sb6u_norm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
TRUE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 5}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 6, 10}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r5sg5sb6u_norm_unpack_rgba_8unorm,
&util_format_r5sg5sb6u_norm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r5sg5sb6u_norm_unpack_rgba_float,
&util_format_r5sg5sb6u_norm_pack_rgba_float,
&util_format_r5sg5sb6u_norm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_s8_uint_description = {
PIPE_FORMAT_S8_UINT,
"PIPE_FORMAT_S8_UINT",
"s8_uint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_NONE, /* z */
UTIL_FORMAT_SWIZZLE_X, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
&util_format_s8_uint_unpack_s_8uint,
&util_format_s8_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z16_unorm_description = {
PIPE_FORMAT_Z16_UNORM,
"PIPE_FORMAT_Z16_UNORM",
"z16_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = z */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_NONE, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z16_unorm_unpack_z_32unorm,
&util_format_z16_unorm_pack_z_32unorm,
&util_format_z16_unorm_unpack_z_float,
&util_format_z16_unorm_pack_z_float,
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z32_unorm_description = {
PIPE_FORMAT_Z32_UNORM,
"PIPE_FORMAT_Z32_UNORM",
"z32_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = z */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_NONE, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z32_unorm_unpack_z_32unorm,
&util_format_z32_unorm_pack_z_32unorm,
&util_format_z32_unorm_unpack_z_float,
&util_format_z32_unorm_pack_z_float,
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z32_float_description = {
PIPE_FORMAT_Z32_FLOAT,
"PIPE_FORMAT_Z32_FLOAT",
"z32_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = z */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_NONE, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z32_float_unpack_z_32unorm,
&util_format_z32_float_pack_z_32unorm,
&util_format_z32_float_unpack_z_float,
&util_format_z32_float_pack_z_float,
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z24_unorm_s8_uint_description = {
PIPE_FORMAT_Z24_UNORM_S8_UINT,
"PIPE_FORMAT_Z24_UNORM_S8_UINT",
"z24_unorm_s8_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
TRUE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0}, /* x = z */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24}, /* y = s */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_Y, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z24_unorm_s8_uint_unpack_z_32unorm,
&util_format_z24_unorm_s8_uint_pack_z_32unorm,
&util_format_z24_unorm_s8_uint_unpack_z_float,
&util_format_z24_unorm_s8_uint_pack_z_float,
&util_format_z24_unorm_s8_uint_unpack_s_8uint,
&util_format_z24_unorm_s8_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_s8_uint_z24_unorm_description = {
PIPE_FORMAT_S8_UINT_Z24_UNORM,
"PIPE_FORMAT_S8_UINT_Z24_UNORM",
"s8_uint_z24_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
TRUE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8}, /* y = z */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* z */
UTIL_FORMAT_SWIZZLE_X, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_s8_uint_z24_unorm_unpack_z_32unorm,
&util_format_s8_uint_z24_unorm_pack_z_32unorm,
&util_format_s8_uint_z24_unorm_unpack_z_float,
&util_format_s8_uint_z24_unorm_pack_z_float,
&util_format_s8_uint_z24_unorm_unpack_s_8uint,
&util_format_s8_uint_z24_unorm_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_x24s8_uint_description = {
PIPE_FORMAT_X24S8_UINT,
"PIPE_FORMAT_X24S8_UINT",
"x24s8_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 0}, /* x = x */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24}, /* y = s */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_NONE, /* z */
UTIL_FORMAT_SWIZZLE_Y, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
&util_format_x24s8_uint_unpack_s_8uint,
&util_format_x24s8_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_s8x24_uint_description = {
PIPE_FORMAT_S8X24_UINT,
"PIPE_FORMAT_S8X24_UINT",
"s8x24_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 8}, /* y = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_NONE, /* z */
UTIL_FORMAT_SWIZZLE_X, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
&util_format_s8x24_uint_unpack_s_8uint,
&util_format_s8x24_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z24x8_unorm_description = {
PIPE_FORMAT_Z24X8_UNORM,
"PIPE_FORMAT_Z24X8_UNORM",
"z24x8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0}, /* x = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}, /* y = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_NONE, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z24x8_unorm_unpack_z_32unorm,
&util_format_z24x8_unorm_pack_z_32unorm,
&util_format_z24x8_unorm_unpack_z_float,
&util_format_z24x8_unorm_pack_z_float,
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_x8z24_unorm_description = {
PIPE_FORMAT_X8Z24_UNORM,
"PIPE_FORMAT_X8Z24_UNORM",
"x8z24_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8}, /* y = z */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* z */
UTIL_FORMAT_SWIZZLE_NONE, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_x8z24_unorm_unpack_z_32unorm,
&util_format_x8z24_unorm_pack_z_32unorm,
&util_format_x8z24_unorm_unpack_z_float,
&util_format_x8z24_unorm_pack_z_float,
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_z32_float_s8x24_uint_description = {
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT,
"PIPE_FORMAT_Z32_FLOAT_S8X24_UINT",
"z32_float_s8x24_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
TRUE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = z */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32}, /* y = s */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40}, /* z = x */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* z */
UTIL_FORMAT_SWIZZLE_Y, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
&util_format_z32_float_s8x24_uint_unpack_z_32unorm,
&util_format_z32_float_s8x24_uint_pack_z_32unorm,
&util_format_z32_float_s8x24_uint_unpack_z_float,
&util_format_z32_float_s8x24_uint_pack_z_float,
&util_format_z32_float_s8x24_uint_unpack_s_8uint,
&util_format_z32_float_s8x24_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_x32_s8x24_uint_description = {
PIPE_FORMAT_X32_S8X24_UINT,
"PIPE_FORMAT_X32_S8X24_UINT",
"x32_s8x24_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32}, /* y = s */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40}, /* z = x */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_NONE, /* z */
UTIL_FORMAT_SWIZZLE_Y, /* s */
UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
UTIL_FORMAT_SWIZZLE_NONE /* ignored */
},
UTIL_FORMAT_COLORSPACE_ZS,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
&util_format_x32_s8x24_uint_unpack_s_8uint,
&util_format_x32_s8x24_uint_pack_s_8uint,
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_uyvy_description = {
PIPE_FORMAT_UYVY,
"PIPE_FORMAT_UYVY",
"uyvy",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_1 /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_uyvy_unpack_rgba_8unorm,
&util_format_uyvy_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_uyvy_unpack_rgba_float,
&util_format_uyvy_pack_rgba_float,
&util_format_uyvy_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_yuyv_description = {
PIPE_FORMAT_YUYV,
"PIPE_FORMAT_YUYV",
"yuyv",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_1 /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_yuyv_unpack_rgba_8unorm,
&util_format_yuyv_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_yuyv_unpack_rgba_float,
&util_format_yuyv_pack_rgba_float,
&util_format_yuyv_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_b8g8_unorm_description = {
PIPE_FORMAT_R8G8_B8G8_UNORM,
"PIPE_FORMAT_R8G8_B8G8_UNORM",
"r8g8_b8g8_unorm",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm,
&util_format_r8g8_b8g8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_b8g8_unorm_unpack_rgba_float,
&util_format_r8g8_b8g8_unorm_pack_rgba_float,
&util_format_r8g8_b8g8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_g8r8_g8b8_unorm_description = {
PIPE_FORMAT_G8R8_G8B8_UNORM,
"PIPE_FORMAT_G8R8_G8B8_UNORM",
"g8r8_g8b8_unorm",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm,
&util_format_g8r8_g8b8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_g8r8_g8b8_unorm_unpack_rgba_float,
&util_format_g8r8_g8b8_unorm_pack_rgba_float,
&util_format_g8r8_g8b8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_g8r8_b8r8_unorm_description = {
PIPE_FORMAT_G8R8_B8R8_UNORM,
"PIPE_FORMAT_G8R8_B8R8_UNORM",
"g8r8_b8r8_unorm",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm,
&util_format_g8r8_b8r8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_g8r8_b8r8_unorm_unpack_rgba_float,
&util_format_g8r8_b8r8_unorm_pack_rgba_float,
&util_format_g8r8_b8r8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_r8b8_unorm_description = {
PIPE_FORMAT_R8G8_R8B8_UNORM,
"PIPE_FORMAT_R8G8_R8B8_UNORM",
"r8g8_r8b8_unorm",
{2, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_SUBSAMPLED,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm,
&util_format_r8g8_r8b8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_r8b8_unorm_unpack_rgba_float,
&util_format_r8g8_r8b8_unorm_pack_rgba_float,
&util_format_r8g8_r8b8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r11g11b10_float_description = {
PIPE_FORMAT_R11G11B10_FLOAT,
"PIPE_FORMAT_R11G11B10_FLOAT",
"r11g11b10_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r11g11b10_float_unpack_rgba_8unorm,
&util_format_r11g11b10_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r11g11b10_float_unpack_rgba_float,
&util_format_r11g11b10_float_pack_rgba_float,
&util_format_r11g11b10_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r9g9b9e5_float_description = {
PIPE_FORMAT_R9G9B9E5_FLOAT,
"PIPE_FORMAT_R9G9B9E5_FLOAT",
"r9g9b9e5_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r9g9b9e5_float_unpack_rgba_8unorm,
&util_format_r9g9b9e5_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r9g9b9e5_float_unpack_rgba_float,
&util_format_r9g9b9e5_float_pack_rgba_float,
&util_format_r9g9b9e5_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r1_unorm_description = {
PIPE_FORMAT_R1_UNORM,
"PIPE_FORMAT_R1_UNORM",
"r1_unorm",
{8, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
1, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r1_unorm_unpack_rgba_8unorm,
&util_format_r1_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r1_unorm_unpack_rgba_float,
&util_format_r1_unorm_pack_rgba_float,
&util_format_r1_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8bx_snorm_description = {
PIPE_FORMAT_R8G8Bx_SNORM,
"PIPE_FORMAT_R8G8Bx_SNORM",
"r8g8bx_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
2, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = y */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8bx_snorm_unpack_rgba_8unorm,
&util_format_r8g8bx_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8bx_snorm_unpack_rgba_float,
&util_format_r8g8bx_snorm_pack_rgba_float,
&util_format_r8g8bx_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r64_float_description = {
PIPE_FORMAT_R64_FLOAT,
"PIPE_FORMAT_R64_FLOAT",
"r64_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r64_float_unpack_rgba_8unorm,
&util_format_r64_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r64_float_unpack_rgba_float,
&util_format_r64_float_pack_rgba_float,
&util_format_r64_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r64g64_float_description = {
PIPE_FORMAT_R64G64_FLOAT,
"PIPE_FORMAT_R64G64_FLOAT",
"r64g64_float",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r64g64_float_unpack_rgba_8unorm,
&util_format_r64g64_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r64g64_float_unpack_rgba_float,
&util_format_r64g64_float_pack_rgba_float,
&util_format_r64g64_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r64g64b64_float_description = {
PIPE_FORMAT_R64G64B64_FLOAT,
"PIPE_FORMAT_R64G64B64_FLOAT",
"r64g64b64_float",
{1, 1, 192}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r64g64b64_float_unpack_rgba_8unorm,
&util_format_r64g64b64_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r64g64b64_float_unpack_rgba_float,
&util_format_r64g64b64_float_pack_rgba_float,
&util_format_r64g64b64_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r64g64b64a64_float_description = {
PIPE_FORMAT_R64G64B64A64_FLOAT,
"PIPE_FORMAT_R64G64B64A64_FLOAT",
"r64g64b64a64_float",
{1, 1, 256}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128}, /* z = b */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 192} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r64g64b64a64_float_unpack_rgba_8unorm,
&util_format_r64g64b64a64_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r64g64b64a64_float_unpack_rgba_float,
&util_format_r64g64b64a64_float_pack_rgba_float,
&util_format_r64g64b64a64_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_float_description = {
PIPE_FORMAT_R32_FLOAT,
"PIPE_FORMAT_R32_FLOAT",
"r32_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_float_unpack_rgba_8unorm,
&util_format_r32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_float_unpack_rgba_float,
&util_format_r32_float_pack_rgba_float,
&util_format_r32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_float_description = {
PIPE_FORMAT_R32G32_FLOAT,
"PIPE_FORMAT_R32G32_FLOAT",
"r32g32_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_float_unpack_rgba_8unorm,
&util_format_r32g32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_float_unpack_rgba_float,
&util_format_r32g32_float_pack_rgba_float,
&util_format_r32g32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_float_description = {
PIPE_FORMAT_R32G32B32_FLOAT,
"PIPE_FORMAT_R32G32B32_FLOAT",
"r32g32b32_float",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_float_unpack_rgba_8unorm,
&util_format_r32g32b32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_float_unpack_rgba_float,
&util_format_r32g32b32_float_pack_rgba_float,
&util_format_r32g32b32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_float_description = {
PIPE_FORMAT_R32G32B32A32_FLOAT,
"PIPE_FORMAT_R32G32B32A32_FLOAT",
"r32g32b32a32_float",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_float_unpack_rgba_8unorm,
&util_format_r32g32b32a32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_float_unpack_rgba_float,
&util_format_r32g32b32a32_float_pack_rgba_float,
&util_format_r32g32b32a32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_unorm_description = {
PIPE_FORMAT_R32_UNORM,
"PIPE_FORMAT_R32_UNORM",
"r32_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_unorm_unpack_rgba_8unorm,
&util_format_r32_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_unorm_unpack_rgba_float,
&util_format_r32_unorm_pack_rgba_float,
&util_format_r32_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_unorm_description = {
PIPE_FORMAT_R32G32_UNORM,
"PIPE_FORMAT_R32G32_UNORM",
"r32g32_unorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_unorm_unpack_rgba_8unorm,
&util_format_r32g32_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_unorm_unpack_rgba_float,
&util_format_r32g32_unorm_pack_rgba_float,
&util_format_r32g32_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_unorm_description = {
PIPE_FORMAT_R32G32B32_UNORM,
"PIPE_FORMAT_R32G32B32_UNORM",
"r32g32b32_unorm",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_unorm_unpack_rgba_8unorm,
&util_format_r32g32b32_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_unorm_unpack_rgba_float,
&util_format_r32g32b32_unorm_pack_rgba_float,
&util_format_r32g32b32_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_unorm_description = {
PIPE_FORMAT_R32G32B32A32_UNORM,
"PIPE_FORMAT_R32G32B32A32_UNORM",
"r32g32b32a32_unorm",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_unorm_unpack_rgba_8unorm,
&util_format_r32g32b32a32_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_unorm_unpack_rgba_float,
&util_format_r32g32b32a32_unorm_pack_rgba_float,
&util_format_r32g32b32a32_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_uscaled_description = {
PIPE_FORMAT_R32_USCALED,
"PIPE_FORMAT_R32_USCALED",
"r32_uscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_uscaled_unpack_rgba_8unorm,
&util_format_r32_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_uscaled_unpack_rgba_float,
&util_format_r32_uscaled_pack_rgba_float,
&util_format_r32_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_uscaled_description = {
PIPE_FORMAT_R32G32_USCALED,
"PIPE_FORMAT_R32G32_USCALED",
"r32g32_uscaled",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_uscaled_unpack_rgba_8unorm,
&util_format_r32g32_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_uscaled_unpack_rgba_float,
&util_format_r32g32_uscaled_pack_rgba_float,
&util_format_r32g32_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_uscaled_description = {
PIPE_FORMAT_R32G32B32_USCALED,
"PIPE_FORMAT_R32G32B32_USCALED",
"r32g32b32_uscaled",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_uscaled_unpack_rgba_8unorm,
&util_format_r32g32b32_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_uscaled_unpack_rgba_float,
&util_format_r32g32b32_uscaled_pack_rgba_float,
&util_format_r32g32b32_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_uscaled_description = {
PIPE_FORMAT_R32G32B32A32_USCALED,
"PIPE_FORMAT_R32G32B32A32_USCALED",
"r32g32b32a32_uscaled",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_uscaled_unpack_rgba_8unorm,
&util_format_r32g32b32a32_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_uscaled_unpack_rgba_float,
&util_format_r32g32b32a32_uscaled_pack_rgba_float,
&util_format_r32g32b32a32_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_snorm_description = {
PIPE_FORMAT_R32_SNORM,
"PIPE_FORMAT_R32_SNORM",
"r32_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_snorm_unpack_rgba_8unorm,
&util_format_r32_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_snorm_unpack_rgba_float,
&util_format_r32_snorm_pack_rgba_float,
&util_format_r32_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_snorm_description = {
PIPE_FORMAT_R32G32_SNORM,
"PIPE_FORMAT_R32G32_SNORM",
"r32g32_snorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_snorm_unpack_rgba_8unorm,
&util_format_r32g32_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_snorm_unpack_rgba_float,
&util_format_r32g32_snorm_pack_rgba_float,
&util_format_r32g32_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_snorm_description = {
PIPE_FORMAT_R32G32B32_SNORM,
"PIPE_FORMAT_R32G32B32_SNORM",
"r32g32b32_snorm",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_snorm_unpack_rgba_8unorm,
&util_format_r32g32b32_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_snorm_unpack_rgba_float,
&util_format_r32g32b32_snorm_pack_rgba_float,
&util_format_r32g32b32_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_snorm_description = {
PIPE_FORMAT_R32G32B32A32_SNORM,
"PIPE_FORMAT_R32G32B32A32_SNORM",
"r32g32b32a32_snorm",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_snorm_unpack_rgba_8unorm,
&util_format_r32g32b32a32_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_snorm_unpack_rgba_float,
&util_format_r32g32b32a32_snorm_pack_rgba_float,
&util_format_r32g32b32a32_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_sscaled_description = {
PIPE_FORMAT_R32_SSCALED,
"PIPE_FORMAT_R32_SSCALED",
"r32_sscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_sscaled_unpack_rgba_8unorm,
&util_format_r32_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_sscaled_unpack_rgba_float,
&util_format_r32_sscaled_pack_rgba_float,
&util_format_r32_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_sscaled_description = {
PIPE_FORMAT_R32G32_SSCALED,
"PIPE_FORMAT_R32G32_SSCALED",
"r32g32_sscaled",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_sscaled_unpack_rgba_8unorm,
&util_format_r32g32_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_sscaled_unpack_rgba_float,
&util_format_r32g32_sscaled_pack_rgba_float,
&util_format_r32g32_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_sscaled_description = {
PIPE_FORMAT_R32G32B32_SSCALED,
"PIPE_FORMAT_R32G32B32_SSCALED",
"r32g32b32_sscaled",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_sscaled_unpack_rgba_8unorm,
&util_format_r32g32b32_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_sscaled_unpack_rgba_float,
&util_format_r32g32b32_sscaled_pack_rgba_float,
&util_format_r32g32b32_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_sscaled_description = {
PIPE_FORMAT_R32G32B32A32_SSCALED,
"PIPE_FORMAT_R32G32B32A32_SSCALED",
"r32g32b32a32_sscaled",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_sscaled_unpack_rgba_8unorm,
&util_format_r32g32b32a32_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_sscaled_unpack_rgba_float,
&util_format_r32g32b32a32_sscaled_pack_rgba_float,
&util_format_r32g32b32a32_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_float_description = {
PIPE_FORMAT_R16_FLOAT,
"PIPE_FORMAT_R16_FLOAT",
"r16_float",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16_float_unpack_rgba_8unorm,
&util_format_r16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16_float_unpack_rgba_float,
&util_format_r16_float_pack_rgba_float,
&util_format_r16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_float_description = {
PIPE_FORMAT_R16G16_FLOAT,
"PIPE_FORMAT_R16G16_FLOAT",
"r16g16_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16_float_unpack_rgba_8unorm,
&util_format_r16g16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16_float_unpack_rgba_float,
&util_format_r16g16_float_pack_rgba_float,
&util_format_r16g16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_float_description = {
PIPE_FORMAT_R16G16B16_FLOAT,
"PIPE_FORMAT_R16G16B16_FLOAT",
"r16g16b16_float",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16_float_unpack_rgba_8unorm,
&util_format_r16g16b16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16_float_unpack_rgba_float,
&util_format_r16g16b16_float_pack_rgba_float,
&util_format_r16g16b16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_float_description = {
PIPE_FORMAT_R16G16B16A16_FLOAT,
"PIPE_FORMAT_R16G16B16A16_FLOAT",
"r16g16b16a16_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16a16_float_unpack_rgba_8unorm,
&util_format_r16g16b16a16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16a16_float_unpack_rgba_float,
&util_format_r16g16b16a16_float_pack_rgba_float,
&util_format_r16g16b16a16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_unorm_description = {
PIPE_FORMAT_R16_UNORM,
"PIPE_FORMAT_R16_UNORM",
"r16_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16_unorm_unpack_rgba_8unorm,
&util_format_r16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16_unorm_unpack_rgba_float,
&util_format_r16_unorm_pack_rgba_float,
&util_format_r16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_unorm_description = {
PIPE_FORMAT_R16G16_UNORM,
"PIPE_FORMAT_R16G16_UNORM",
"r16g16_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16_unorm_unpack_rgba_8unorm,
&util_format_r16g16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16_unorm_unpack_rgba_float,
&util_format_r16g16_unorm_pack_rgba_float,
&util_format_r16g16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_unorm_description = {
PIPE_FORMAT_R16G16B16_UNORM,
"PIPE_FORMAT_R16G16B16_UNORM",
"r16g16b16_unorm",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16_unorm_unpack_rgba_8unorm,
&util_format_r16g16b16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16_unorm_unpack_rgba_float,
&util_format_r16g16b16_unorm_pack_rgba_float,
&util_format_r16g16b16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_unorm_description = {
PIPE_FORMAT_R16G16B16A16_UNORM,
"PIPE_FORMAT_R16G16B16A16_UNORM",
"r16g16b16a16_unorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16a16_unorm_unpack_rgba_8unorm,
&util_format_r16g16b16a16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16a16_unorm_unpack_rgba_float,
&util_format_r16g16b16a16_unorm_pack_rgba_float,
&util_format_r16g16b16a16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_uscaled_description = {
PIPE_FORMAT_R16_USCALED,
"PIPE_FORMAT_R16_USCALED",
"r16_uscaled",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16_uscaled_unpack_rgba_8unorm,
&util_format_r16_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16_uscaled_unpack_rgba_float,
&util_format_r16_uscaled_pack_rgba_float,
&util_format_r16_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_uscaled_description = {
PIPE_FORMAT_R16G16_USCALED,
"PIPE_FORMAT_R16G16_USCALED",
"r16g16_uscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16_uscaled_unpack_rgba_8unorm,
&util_format_r16g16_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16_uscaled_unpack_rgba_float,
&util_format_r16g16_uscaled_pack_rgba_float,
&util_format_r16g16_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_uscaled_description = {
PIPE_FORMAT_R16G16B16_USCALED,
"PIPE_FORMAT_R16G16B16_USCALED",
"r16g16b16_uscaled",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16_uscaled_unpack_rgba_8unorm,
&util_format_r16g16b16_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16_uscaled_unpack_rgba_float,
&util_format_r16g16b16_uscaled_pack_rgba_float,
&util_format_r16g16b16_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_uscaled_description = {
PIPE_FORMAT_R16G16B16A16_USCALED,
"PIPE_FORMAT_R16G16B16A16_USCALED",
"r16g16b16a16_uscaled",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16a16_uscaled_unpack_rgba_8unorm,
&util_format_r16g16b16a16_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16a16_uscaled_unpack_rgba_float,
&util_format_r16g16b16a16_uscaled_pack_rgba_float,
&util_format_r16g16b16a16_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_snorm_description = {
PIPE_FORMAT_R16_SNORM,
"PIPE_FORMAT_R16_SNORM",
"r16_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16_snorm_unpack_rgba_8unorm,
&util_format_r16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16_snorm_unpack_rgba_float,
&util_format_r16_snorm_pack_rgba_float,
&util_format_r16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_snorm_description = {
PIPE_FORMAT_R16G16_SNORM,
"PIPE_FORMAT_R16G16_SNORM",
"r16g16_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16_snorm_unpack_rgba_8unorm,
&util_format_r16g16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16_snorm_unpack_rgba_float,
&util_format_r16g16_snorm_pack_rgba_float,
&util_format_r16g16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_snorm_description = {
PIPE_FORMAT_R16G16B16_SNORM,
"PIPE_FORMAT_R16G16B16_SNORM",
"r16g16b16_snorm",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16_snorm_unpack_rgba_8unorm,
&util_format_r16g16b16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16_snorm_unpack_rgba_float,
&util_format_r16g16b16_snorm_pack_rgba_float,
&util_format_r16g16b16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_snorm_description = {
PIPE_FORMAT_R16G16B16A16_SNORM,
"PIPE_FORMAT_R16G16B16A16_SNORM",
"r16g16b16a16_snorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16a16_snorm_unpack_rgba_8unorm,
&util_format_r16g16b16a16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16a16_snorm_unpack_rgba_float,
&util_format_r16g16b16a16_snorm_pack_rgba_float,
&util_format_r16g16b16a16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_sscaled_description = {
PIPE_FORMAT_R16_SSCALED,
"PIPE_FORMAT_R16_SSCALED",
"r16_sscaled",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16_sscaled_unpack_rgba_8unorm,
&util_format_r16_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16_sscaled_unpack_rgba_float,
&util_format_r16_sscaled_pack_rgba_float,
&util_format_r16_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_sscaled_description = {
PIPE_FORMAT_R16G16_SSCALED,
"PIPE_FORMAT_R16G16_SSCALED",
"r16g16_sscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16_sscaled_unpack_rgba_8unorm,
&util_format_r16g16_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16_sscaled_unpack_rgba_float,
&util_format_r16g16_sscaled_pack_rgba_float,
&util_format_r16g16_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_sscaled_description = {
PIPE_FORMAT_R16G16B16_SSCALED,
"PIPE_FORMAT_R16G16B16_SSCALED",
"r16g16b16_sscaled",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16_sscaled_unpack_rgba_8unorm,
&util_format_r16g16b16_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16_sscaled_unpack_rgba_float,
&util_format_r16g16b16_sscaled_pack_rgba_float,
&util_format_r16g16b16_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_sscaled_description = {
PIPE_FORMAT_R16G16B16A16_SSCALED,
"PIPE_FORMAT_R16G16B16A16_SSCALED",
"r16g16b16a16_sscaled",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16a16_sscaled_unpack_rgba_8unorm,
&util_format_r16g16b16a16_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16a16_sscaled_unpack_rgba_float,
&util_format_r16g16b16a16_sscaled_pack_rgba_float,
&util_format_r16g16b16a16_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_unorm_description = {
PIPE_FORMAT_R8_UNORM,
"PIPE_FORMAT_R8_UNORM",
"r8_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8_unorm_unpack_rgba_8unorm,
&util_format_r8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8_unorm_unpack_rgba_float,
&util_format_r8_unorm_pack_rgba_float,
&util_format_r8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_unorm_description = {
PIPE_FORMAT_R8G8_UNORM,
"PIPE_FORMAT_R8G8_UNORM",
"r8g8_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_unorm_unpack_rgba_8unorm,
&util_format_r8g8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_unorm_unpack_rgba_float,
&util_format_r8g8_unorm_pack_rgba_float,
&util_format_r8g8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_unorm_description = {
PIPE_FORMAT_R8G8B8_UNORM,
"PIPE_FORMAT_R8G8B8_UNORM",
"r8g8b8_unorm",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8_unorm_unpack_rgba_8unorm,
&util_format_r8g8b8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8_unorm_unpack_rgba_float,
&util_format_r8g8b8_unorm_pack_rgba_float,
&util_format_r8g8b8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_unorm_description = {
PIPE_FORMAT_R8G8B8A8_UNORM,
"PIPE_FORMAT_R8G8B8A8_UNORM",
"r8g8b8a8_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8a8_unorm_unpack_rgba_8unorm,
&util_format_r8g8b8a8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8a8_unorm_unpack_rgba_float,
&util_format_r8g8b8a8_unorm_pack_rgba_float,
&util_format_r8g8b8a8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_uscaled_description = {
PIPE_FORMAT_R8_USCALED,
"PIPE_FORMAT_R8_USCALED",
"r8_uscaled",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8_uscaled_unpack_rgba_8unorm,
&util_format_r8_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8_uscaled_unpack_rgba_float,
&util_format_r8_uscaled_pack_rgba_float,
&util_format_r8_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_uscaled_description = {
PIPE_FORMAT_R8G8_USCALED,
"PIPE_FORMAT_R8G8_USCALED",
"r8g8_uscaled",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_uscaled_unpack_rgba_8unorm,
&util_format_r8g8_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_uscaled_unpack_rgba_float,
&util_format_r8g8_uscaled_pack_rgba_float,
&util_format_r8g8_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_uscaled_description = {
PIPE_FORMAT_R8G8B8_USCALED,
"PIPE_FORMAT_R8G8B8_USCALED",
"r8g8b8_uscaled",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8_uscaled_unpack_rgba_8unorm,
&util_format_r8g8b8_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8_uscaled_unpack_rgba_float,
&util_format_r8g8b8_uscaled_pack_rgba_float,
&util_format_r8g8b8_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_uscaled_description = {
PIPE_FORMAT_R8G8B8A8_USCALED,
"PIPE_FORMAT_R8G8B8A8_USCALED",
"r8g8b8a8_uscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8a8_uscaled_unpack_rgba_8unorm,
&util_format_r8g8b8a8_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8a8_uscaled_unpack_rgba_float,
&util_format_r8g8b8a8_uscaled_pack_rgba_float,
&util_format_r8g8b8a8_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_snorm_description = {
PIPE_FORMAT_R8_SNORM,
"PIPE_FORMAT_R8_SNORM",
"r8_snorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8_snorm_unpack_rgba_8unorm,
&util_format_r8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8_snorm_unpack_rgba_float,
&util_format_r8_snorm_pack_rgba_float,
&util_format_r8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_snorm_description = {
PIPE_FORMAT_R8G8_SNORM,
"PIPE_FORMAT_R8G8_SNORM",
"r8g8_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_snorm_unpack_rgba_8unorm,
&util_format_r8g8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_snorm_unpack_rgba_float,
&util_format_r8g8_snorm_pack_rgba_float,
&util_format_r8g8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_snorm_description = {
PIPE_FORMAT_R8G8B8_SNORM,
"PIPE_FORMAT_R8G8B8_SNORM",
"r8g8b8_snorm",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8_snorm_unpack_rgba_8unorm,
&util_format_r8g8b8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8_snorm_unpack_rgba_float,
&util_format_r8g8b8_snorm_pack_rgba_float,
&util_format_r8g8b8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_snorm_description = {
PIPE_FORMAT_R8G8B8A8_SNORM,
"PIPE_FORMAT_R8G8B8A8_SNORM",
"r8g8b8a8_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8a8_snorm_unpack_rgba_8unorm,
&util_format_r8g8b8a8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8a8_snorm_unpack_rgba_float,
&util_format_r8g8b8a8_snorm_pack_rgba_float,
&util_format_r8g8b8a8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_sscaled_description = {
PIPE_FORMAT_R8_SSCALED,
"PIPE_FORMAT_R8_SSCALED",
"r8_sscaled",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8_sscaled_unpack_rgba_8unorm,
&util_format_r8_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8_sscaled_unpack_rgba_float,
&util_format_r8_sscaled_pack_rgba_float,
&util_format_r8_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_sscaled_description = {
PIPE_FORMAT_R8G8_SSCALED,
"PIPE_FORMAT_R8G8_SSCALED",
"r8g8_sscaled",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8_sscaled_unpack_rgba_8unorm,
&util_format_r8g8_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8_sscaled_unpack_rgba_float,
&util_format_r8g8_sscaled_pack_rgba_float,
&util_format_r8g8_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_sscaled_description = {
PIPE_FORMAT_R8G8B8_SSCALED,
"PIPE_FORMAT_R8G8B8_SSCALED",
"r8g8b8_sscaled",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8_sscaled_unpack_rgba_8unorm,
&util_format_r8g8b8_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8_sscaled_unpack_rgba_float,
&util_format_r8g8b8_sscaled_pack_rgba_float,
&util_format_r8g8b8_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_sscaled_description = {
PIPE_FORMAT_R8G8B8A8_SSCALED,
"PIPE_FORMAT_R8G8B8A8_SSCALED",
"r8g8b8a8_sscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8a8_sscaled_unpack_rgba_8unorm,
&util_format_r8g8b8a8_sscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8a8_sscaled_unpack_rgba_float,
&util_format_r8g8b8a8_sscaled_pack_rgba_float,
&util_format_r8g8b8a8_sscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_fixed_description = {
PIPE_FORMAT_R32_FIXED,
"PIPE_FORMAT_R32_FIXED",
"r32_fixed",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32_fixed_unpack_rgba_8unorm,
&util_format_r32_fixed_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32_fixed_unpack_rgba_float,
&util_format_r32_fixed_pack_rgba_float,
&util_format_r32_fixed_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_fixed_description = {
PIPE_FORMAT_R32G32_FIXED,
"PIPE_FORMAT_R32G32_FIXED",
"r32g32_fixed",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32_fixed_unpack_rgba_8unorm,
&util_format_r32g32_fixed_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32_fixed_unpack_rgba_float,
&util_format_r32g32_fixed_pack_rgba_float,
&util_format_r32g32_fixed_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_fixed_description = {
PIPE_FORMAT_R32G32B32_FIXED,
"PIPE_FORMAT_R32G32B32_FIXED",
"r32g32b32_fixed",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32_fixed_unpack_rgba_8unorm,
&util_format_r32g32b32_fixed_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32_fixed_unpack_rgba_float,
&util_format_r32g32b32_fixed_pack_rgba_float,
&util_format_r32g32b32_fixed_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_fixed_description = {
PIPE_FORMAT_R32G32B32A32_FIXED,
"PIPE_FORMAT_R32G32B32A32_FIXED",
"r32g32b32a32_fixed",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32a32_fixed_unpack_rgba_8unorm,
&util_format_r32g32b32a32_fixed_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32a32_fixed_unpack_rgba_float,
&util_format_r32g32b32a32_fixed_pack_rgba_float,
&util_format_r32g32b32a32_fixed_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r10g10b10x2_uscaled_description = {
PIPE_FORMAT_R10G10B10X2_USCALED,
"PIPE_FORMAT_R10G10B10X2_USCALED",
"r10g10b10x2_uscaled",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 10}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 20}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r10g10b10x2_uscaled_unpack_rgba_8unorm,
&util_format_r10g10b10x2_uscaled_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r10g10b10x2_uscaled_unpack_rgba_float,
&util_format_r10g10b10x2_uscaled_pack_rgba_float,
&util_format_r10g10b10x2_uscaled_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r10g10b10x2_snorm_description = {
PIPE_FORMAT_R10G10B10X2_SNORM,
"PIPE_FORMAT_R10G10B10X2_SNORM",
"r10g10b10x2_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r10g10b10x2_snorm_unpack_rgba_8unorm,
&util_format_r10g10b10x2_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r10g10b10x2_snorm_unpack_rgba_float,
&util_format_r10g10b10x2_snorm_pack_rgba_float,
&util_format_r10g10b10x2_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_yv12_description = {
PIPE_FORMAT_YV12,
"PIPE_FORMAT_YV12",
"yv12",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
4, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_W /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_yv12_unpack_rgba_8unorm,
&util_format_yv12_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_yv12_unpack_rgba_float,
&util_format_yv12_pack_rgba_float,
&util_format_yv12_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_yv16_description = {
PIPE_FORMAT_YV16,
"PIPE_FORMAT_YV16",
"yv16",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
4, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_W /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_yv16_unpack_rgba_8unorm,
&util_format_yv16_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_yv16_unpack_rgba_float,
&util_format_yv16_pack_rgba_float,
&util_format_yv16_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_iyuv_description = {
PIPE_FORMAT_IYUV,
"PIPE_FORMAT_IYUV",
"iyuv",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
4, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_W /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_iyuv_unpack_rgba_8unorm,
&util_format_iyuv_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_iyuv_unpack_rgba_float,
&util_format_iyuv_pack_rgba_float,
&util_format_iyuv_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_nv12_description = {
PIPE_FORMAT_NV12,
"PIPE_FORMAT_NV12",
"nv12",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
4, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_W /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_nv12_unpack_rgba_8unorm,
&util_format_nv12_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_nv12_unpack_rgba_float,
&util_format_nv12_pack_rgba_float,
&util_format_nv12_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_nv21_description = {
PIPE_FORMAT_NV21,
"PIPE_FORMAT_NV21",
"nv21",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_OTHER,
4, /* nr_channels */
FALSE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */
},
{
UTIL_FORMAT_SWIZZLE_X, /* y */
UTIL_FORMAT_SWIZZLE_Y, /* u */
UTIL_FORMAT_SWIZZLE_Z, /* v */
UTIL_FORMAT_SWIZZLE_W /* ignored */
},
UTIL_FORMAT_COLORSPACE_YUV,
&util_format_nv21_unpack_rgba_8unorm,
&util_format_nv21_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_nv21_unpack_rgba_float,
&util_format_nv21_pack_rgba_float,
&util_format_nv21_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r4a4_unorm_description = {
PIPE_FORMAT_R4A4_UNORM,
"PIPE_FORMAT_R4A4_UNORM",
"r4a4_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = a */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r4a4_unorm_unpack_rgba_8unorm,
&util_format_r4a4_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r4a4_unorm_unpack_rgba_float,
&util_format_r4a4_unorm_pack_rgba_float,
&util_format_r4a4_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a4r4_unorm_description = {
PIPE_FORMAT_A4R4_UNORM,
"PIPE_FORMAT_A4R4_UNORM",
"a4r4_unorm",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
FALSE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a4r4_unorm_unpack_rgba_8unorm,
&util_format_a4r4_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a4r4_unorm_unpack_rgba_float,
&util_format_a4r4_unorm_pack_rgba_float,
&util_format_a4r4_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8a8_unorm_description = {
PIPE_FORMAT_R8A8_UNORM,
"PIPE_FORMAT_R8A8_UNORM",
"r8a8_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8a8_unorm_unpack_rgba_8unorm,
&util_format_r8a8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8a8_unorm_unpack_rgba_float,
&util_format_r8a8_unorm_pack_rgba_float,
&util_format_r8a8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8r8_unorm_description = {
PIPE_FORMAT_A8R8_UNORM,
"PIPE_FORMAT_A8R8_UNORM",
"a8r8_unorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_Y, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_a8r8_unorm_unpack_rgba_8unorm,
&util_format_a8r8_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_a8r8_unorm_unpack_rgba_float,
&util_format_a8r8_unorm_pack_rgba_float,
&util_format_a8r8_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_uint_description = {
PIPE_FORMAT_R8_UINT,
"PIPE_FORMAT_R8_UINT",
"r8_uint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_uint_description = {
PIPE_FORMAT_R8G8_UINT,
"PIPE_FORMAT_R8G8_UINT",
"r8g8_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8g8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_uint_description = {
PIPE_FORMAT_R8G8B8_UINT,
"PIPE_FORMAT_R8G8B8_UINT",
"r8g8b8_uint",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8g8b8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_uint_description = {
PIPE_FORMAT_R8G8B8A8_UINT,
"PIPE_FORMAT_R8G8B8A8_UINT",
"r8g8b8a8_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8a8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8a8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8a8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8g8b8a8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8_sint_description = {
PIPE_FORMAT_R8_SINT,
"PIPE_FORMAT_R8_SINT",
"r8_sint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8_sint_description = {
PIPE_FORMAT_R8G8_SINT,
"PIPE_FORMAT_R8G8_SINT",
"r8g8_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8g8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8_sint_description = {
PIPE_FORMAT_R8G8B8_SINT,
"PIPE_FORMAT_R8G8B8_SINT",
"r8g8b8_sint",
{1, 1, 24}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8g8b8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8a8_sint_description = {
PIPE_FORMAT_R8G8B8A8_SINT,
"PIPE_FORMAT_R8G8B8A8_SINT",
"r8g8b8a8_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 24} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8a8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8a8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8a8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8g8b8a8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_uint_description = {
PIPE_FORMAT_R16_UINT,
"PIPE_FORMAT_R16_UINT",
"r16_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_uint_description = {
PIPE_FORMAT_R16G16_UINT,
"PIPE_FORMAT_R16G16_UINT",
"r16g16_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16g16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_uint_description = {
PIPE_FORMAT_R16G16B16_UINT,
"PIPE_FORMAT_R16G16B16_UINT",
"r16g16b16_uint",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16g16b16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_uint_description = {
PIPE_FORMAT_R16G16B16A16_UINT,
"PIPE_FORMAT_R16G16B16A16_UINT",
"r16g16b16a16_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16a16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16a16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16a16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16g16b16a16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16_sint_description = {
PIPE_FORMAT_R16_SINT,
"PIPE_FORMAT_R16_SINT",
"r16_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16_sint_description = {
PIPE_FORMAT_R16G16_SINT,
"PIPE_FORMAT_R16G16_SINT",
"r16g16_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16g16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16_sint_description = {
PIPE_FORMAT_R16G16B16_SINT,
"PIPE_FORMAT_R16G16B16_SINT",
"r16g16b16_sint",
{1, 1, 48}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16g16b16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16a16_sint_description = {
PIPE_FORMAT_R16G16B16A16_SINT,
"PIPE_FORMAT_R16G16B16A16_SINT",
"r16g16b16a16_sint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 48} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16a16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16a16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16a16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16g16b16a16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_uint_description = {
PIPE_FORMAT_R32_UINT,
"PIPE_FORMAT_R32_UINT",
"r32_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_uint_description = {
PIPE_FORMAT_R32G32_UINT,
"PIPE_FORMAT_R32G32_UINT",
"r32g32_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32g32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_uint_description = {
PIPE_FORMAT_R32G32B32_UINT,
"PIPE_FORMAT_R32G32B32_UINT",
"r32g32b32_uint",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32g32b32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_uint_description = {
PIPE_FORMAT_R32G32B32A32_UINT,
"PIPE_FORMAT_R32G32B32A32_UINT",
"r32g32b32a32_uint",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32a32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32a32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32a32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32g32b32a32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32_sint_description = {
PIPE_FORMAT_R32_SINT,
"PIPE_FORMAT_R32_SINT",
"r32_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32_sint_description = {
PIPE_FORMAT_R32G32_SINT,
"PIPE_FORMAT_R32G32_SINT",
"r32g32_sint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32g32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32_sint_description = {
PIPE_FORMAT_R32G32B32_SINT,
"PIPE_FORMAT_R32G32B32_SINT",
"r32g32b32_sint",
{1, 1, 96}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
3, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32g32b32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32a32_sint_description = {
PIPE_FORMAT_R32G32B32A32_SINT,
"PIPE_FORMAT_R32G32B32A32_SINT",
"r32g32b32a32_sint",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 96} /* w = a */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_W /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32a32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32a32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32a32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32g32b32a32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8_uint_description = {
PIPE_FORMAT_A8_UINT,
"PIPE_FORMAT_A8_UINT",
"a8_uint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_a8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_a8_uint_pack_signed, /* pack_rgba_sint */
&util_format_a8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i8_uint_description = {
PIPE_FORMAT_I8_UINT,
"PIPE_FORMAT_I8_UINT",
"i8_uint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_i8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_i8_uint_pack_signed, /* pack_rgba_sint */
&util_format_i8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8_uint_description = {
PIPE_FORMAT_L8_UINT,
"PIPE_FORMAT_L8_UINT",
"l8_uint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l8_uint_pack_signed, /* pack_rgba_sint */
&util_format_l8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8a8_uint_description = {
PIPE_FORMAT_L8A8_UINT,
"PIPE_FORMAT_L8A8_UINT",
"l8a8_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l8a8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l8a8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l8a8_uint_pack_signed, /* pack_rgba_sint */
&util_format_l8a8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a8_sint_description = {
PIPE_FORMAT_A8_SINT,
"PIPE_FORMAT_A8_SINT",
"a8_sint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_a8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_a8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_a8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i8_sint_description = {
PIPE_FORMAT_I8_SINT,
"PIPE_FORMAT_I8_SINT",
"i8_sint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_i8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_i8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_i8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8_sint_description = {
PIPE_FORMAT_L8_SINT,
"PIPE_FORMAT_L8_SINT",
"l8_sint",
{1, 1, 8}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l8a8_sint_description = {
PIPE_FORMAT_L8A8_SINT,
"PIPE_FORMAT_L8A8_SINT",
"l8a8_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l8a8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l8a8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l8a8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l8a8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a16_uint_description = {
PIPE_FORMAT_A16_UINT,
"PIPE_FORMAT_A16_UINT",
"a16_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_a16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_a16_uint_pack_signed, /* pack_rgba_sint */
&util_format_a16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i16_uint_description = {
PIPE_FORMAT_I16_UINT,
"PIPE_FORMAT_I16_UINT",
"i16_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_i16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_i16_uint_pack_signed, /* pack_rgba_sint */
&util_format_i16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16_uint_description = {
PIPE_FORMAT_L16_UINT,
"PIPE_FORMAT_L16_UINT",
"l16_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l16_uint_pack_signed, /* pack_rgba_sint */
&util_format_l16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16a16_uint_description = {
PIPE_FORMAT_L16A16_UINT,
"PIPE_FORMAT_L16A16_UINT",
"l16a16_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l16a16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l16a16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l16a16_uint_pack_signed, /* pack_rgba_sint */
&util_format_l16a16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a16_sint_description = {
PIPE_FORMAT_A16_SINT,
"PIPE_FORMAT_A16_SINT",
"a16_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_a16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_a16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_a16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i16_sint_description = {
PIPE_FORMAT_I16_SINT,
"PIPE_FORMAT_I16_SINT",
"i16_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_i16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_i16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_i16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16_sint_description = {
PIPE_FORMAT_L16_SINT,
"PIPE_FORMAT_L16_SINT",
"l16_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l16a16_sint_description = {
PIPE_FORMAT_L16A16_SINT,
"PIPE_FORMAT_L16A16_SINT",
"l16a16_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l16a16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l16a16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l16a16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l16a16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a32_uint_description = {
PIPE_FORMAT_A32_UINT,
"PIPE_FORMAT_A32_UINT",
"a32_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_a32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_a32_uint_pack_signed, /* pack_rgba_sint */
&util_format_a32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i32_uint_description = {
PIPE_FORMAT_I32_UINT,
"PIPE_FORMAT_I32_UINT",
"i32_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_i32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_i32_uint_pack_signed, /* pack_rgba_sint */
&util_format_i32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32_uint_description = {
PIPE_FORMAT_L32_UINT,
"PIPE_FORMAT_L32_UINT",
"l32_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l32_uint_pack_signed, /* pack_rgba_sint */
&util_format_l32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32a32_uint_description = {
PIPE_FORMAT_L32A32_UINT,
"PIPE_FORMAT_L32A32_UINT",
"l32a32_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l32a32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_l32a32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_l32a32_uint_pack_signed, /* pack_rgba_sint */
&util_format_l32a32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_a32_sint_description = {
PIPE_FORMAT_A32_SINT,
"PIPE_FORMAT_A32_SINT",
"a32_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_0, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_a32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_a32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_a32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_a32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_a32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_i32_sint_description = {
PIPE_FORMAT_I32_SINT,
"PIPE_FORMAT_I32_SINT",
"i32_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgba */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_X /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_i32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_i32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_i32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_i32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_i32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32_sint_description = {
PIPE_FORMAT_L32_SINT,
"PIPE_FORMAT_L32_SINT",
"l32_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
1, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_l32a32_sint_description = {
PIPE_FORMAT_L32A32_SINT,
"PIPE_FORMAT_L32A32_SINT",
"l32a32_sint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_X, /* g */
UTIL_FORMAT_SWIZZLE_X, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_l32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_l32a32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_l32a32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_l32a32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_l32a32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8x8_snorm_description = {
PIPE_FORMAT_R8G8B8X8_SNORM,
"PIPE_FORMAT_R8G8B8X8_SNORM",
"r8g8b8x8_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8g8b8x8_snorm_unpack_rgba_8unorm,
&util_format_r8g8b8x8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8x8_snorm_unpack_rgba_float,
&util_format_r8g8b8x8_snorm_pack_rgba_float,
&util_format_r8g8b8x8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8x8_srgb_description = {
PIPE_FORMAT_R8G8B8X8_SRGB,
"PIPE_FORMAT_R8G8B8X8_SRGB",
"r8g8b8x8_srgb",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* sr */
UTIL_FORMAT_SWIZZLE_Y, /* sg */
UTIL_FORMAT_SWIZZLE_Z, /* sb */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_SRGB,
&util_format_r8g8b8x8_srgb_unpack_rgba_8unorm,
&util_format_r8g8b8x8_srgb_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8g8b8x8_srgb_unpack_rgba_float,
&util_format_r8g8b8x8_srgb_pack_rgba_float,
&util_format_r8g8b8x8_srgb_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8x8_uint_description = {
PIPE_FORMAT_R8G8B8X8_UINT,
"PIPE_FORMAT_R8G8B8X8_UINT",
"r8g8b8x8_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8x8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8x8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8x8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8x8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8g8b8x8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8g8b8x8_sint_description = {
PIPE_FORMAT_R8G8B8X8_SINT,
"PIPE_FORMAT_R8G8B8X8_SINT",
"r8g8b8x8_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8g8b8x8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8g8b8x8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8g8b8x8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8g8b8x8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8g8b8x8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16x16_unorm_description = {
PIPE_FORMAT_R16G16B16X16_UNORM,
"PIPE_FORMAT_R16G16B16X16_UNORM",
"r16g16b16x16_unorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16x16_unorm_unpack_rgba_8unorm,
&util_format_r16g16b16x16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16x16_unorm_unpack_rgba_float,
&util_format_r16g16b16x16_unorm_pack_rgba_float,
&util_format_r16g16b16x16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16x16_snorm_description = {
PIPE_FORMAT_R16G16B16X16_SNORM,
"PIPE_FORMAT_R16G16B16X16_SNORM",
"r16g16b16x16_snorm",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16x16_snorm_unpack_rgba_8unorm,
&util_format_r16g16b16x16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16x16_snorm_unpack_rgba_float,
&util_format_r16g16b16x16_snorm_pack_rgba_float,
&util_format_r16g16b16x16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16x16_float_description = {
PIPE_FORMAT_R16G16B16X16_FLOAT,
"PIPE_FORMAT_R16G16B16X16_FLOAT",
"r16g16b16x16_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16g16b16x16_float_unpack_rgba_8unorm,
&util_format_r16g16b16x16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16g16b16x16_float_unpack_rgba_float,
&util_format_r16g16b16x16_float_pack_rgba_float,
&util_format_r16g16b16x16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16x16_uint_description = {
PIPE_FORMAT_R16G16B16X16_UINT,
"PIPE_FORMAT_R16G16B16X16_UINT",
"r16g16b16x16_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16x16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16x16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16x16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16x16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16g16b16x16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16g16b16x16_sint_description = {
PIPE_FORMAT_R16G16B16X16_SINT,
"PIPE_FORMAT_R16G16B16X16_SINT",
"r16g16b16x16_sint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16g16b16x16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16g16b16x16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16g16b16x16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16g16b16x16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16g16b16x16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32x32_float_description = {
PIPE_FORMAT_R32G32B32X32_FLOAT,
"PIPE_FORMAT_R32G32B32X32_FLOAT",
"r32g32b32x32_float",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32g32b32x32_float_unpack_rgba_8unorm,
&util_format_r32g32b32x32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32g32b32x32_float_unpack_rgba_float,
&util_format_r32g32b32x32_float_pack_rgba_float,
&util_format_r32g32b32x32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32x32_uint_description = {
PIPE_FORMAT_R32G32B32X32_UINT,
"PIPE_FORMAT_R32G32B32X32_UINT",
"r32g32b32x32_uint",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32x32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32x32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32x32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32x32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32g32b32x32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32g32b32x32_sint_description = {
PIPE_FORMAT_R32G32B32X32_SINT,
"PIPE_FORMAT_R32G32B32X32_SINT",
"r32g32b32x32_sint",
{1, 1, 128}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
4, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */
{UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_Y, /* g */
UTIL_FORMAT_SWIZZLE_Z, /* b */
UTIL_FORMAT_SWIZZLE_1 /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32g32b32x32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32g32b32x32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32g32b32x32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32g32b32x32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32g32b32x32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8a8_snorm_description = {
PIPE_FORMAT_R8A8_SNORM,
"PIPE_FORMAT_R8A8_SNORM",
"r8a8_snorm",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r8a8_snorm_unpack_rgba_8unorm,
&util_format_r8a8_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r8a8_snorm_unpack_rgba_float,
&util_format_r8a8_snorm_pack_rgba_float,
&util_format_r8a8_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16a16_unorm_description = {
PIPE_FORMAT_R16A16_UNORM,
"PIPE_FORMAT_R16A16_UNORM",
"r16a16_unorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16a16_unorm_unpack_rgba_8unorm,
&util_format_r16a16_unorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16a16_unorm_unpack_rgba_float,
&util_format_r16a16_unorm_pack_rgba_float,
&util_format_r16a16_unorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16a16_snorm_description = {
PIPE_FORMAT_R16A16_SNORM,
"PIPE_FORMAT_R16A16_SNORM",
"r16a16_snorm",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16a16_snorm_unpack_rgba_8unorm,
&util_format_r16a16_snorm_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16a16_snorm_unpack_rgba_float,
&util_format_r16a16_snorm_pack_rgba_float,
&util_format_r16a16_snorm_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16a16_float_description = {
PIPE_FORMAT_R16A16_FLOAT,
"PIPE_FORMAT_R16A16_FLOAT",
"r16a16_float",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r16a16_float_unpack_rgba_8unorm,
&util_format_r16a16_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r16a16_float_unpack_rgba_float,
&util_format_r16a16_float_pack_rgba_float,
&util_format_r16a16_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32a32_float_description = {
PIPE_FORMAT_R32A32_FLOAT,
"PIPE_FORMAT_R32A32_FLOAT",
"r32a32_float",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
&util_format_r32a32_float_unpack_rgba_8unorm,
&util_format_r32a32_float_pack_rgba_8unorm,
NULL, /* fetch_rgba_8unorm */
&util_format_r32a32_float_unpack_rgba_float,
&util_format_r32a32_float_pack_rgba_float,
&util_format_r32a32_float_fetch_rgba_float,
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
NULL, /* unpack_rgba_uint */
NULL, /* pack_rgba_uint */
NULL, /* unpack_rgba_sint */
NULL, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8a8_uint_description = {
PIPE_FORMAT_R8A8_UINT,
"PIPE_FORMAT_R8A8_UINT",
"r8a8_uint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8a8_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8a8_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8a8_uint_pack_signed, /* pack_rgba_sint */
&util_format_r8a8_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r8a8_sint_description = {
PIPE_FORMAT_R8A8_SINT,
"PIPE_FORMAT_R8A8_SINT",
"r8a8_sint",
{1, 1, 16}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r8a8_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r8a8_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r8a8_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r8a8_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16a16_uint_description = {
PIPE_FORMAT_R16A16_UINT,
"PIPE_FORMAT_R16A16_UINT",
"r16a16_uint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16a16_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16a16_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16a16_uint_pack_signed, /* pack_rgba_sint */
&util_format_r16a16_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r16a16_sint_description = {
PIPE_FORMAT_R16A16_SINT,
"PIPE_FORMAT_R16A16_SINT",
"r16a16_sint",
{1, 1, 32}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
TRUE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r16a16_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r16a16_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r16a16_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r16a16_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32a32_uint_description = {
PIPE_FORMAT_R32A32_UINT,
"PIPE_FORMAT_R32A32_UINT",
"r32a32_uint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32a32_uint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32a32_uint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32a32_uint_pack_signed, /* pack_rgba_sint */
&util_format_r32a32_uint_fetch_unsigned, /* fetch_rgba_uint */
NULL /* fetch_rgba_sint */
};
 
const struct util_format_description
util_format_r32a32_sint_description = {
PIPE_FORMAT_R32A32_SINT,
"PIPE_FORMAT_R32A32_SINT",
"r32a32_sint",
{1, 1, 64}, /* block */
UTIL_FORMAT_LAYOUT_PLAIN,
2, /* nr_channels */
TRUE, /* is_array */
FALSE, /* is_bitmask */
FALSE, /* is_mixed */
{
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */
{UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = a */
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
UTIL_FORMAT_SWIZZLE_X, /* r */
UTIL_FORMAT_SWIZZLE_0, /* g */
UTIL_FORMAT_SWIZZLE_0, /* b */
UTIL_FORMAT_SWIZZLE_Y /* a */
},
UTIL_FORMAT_COLORSPACE_RGB,
NULL, /* unpack_rgba_8unorm */
NULL, /* pack_rgba_8unorm */
NULL, /* fetch_rgba_8unorm */
NULL, /* unpack_rgba_float */
NULL, /* pack_rgba_float */
NULL, /* fetch_rgba_float */
NULL, /* unpack_z_32unorm */
NULL, /* pack_z_32unorm */
NULL, /* unpack_z_float */
NULL, /* pack_z_float */
NULL, /* unpack_s_8uint */
NULL, /* pack_s_8uint */
&util_format_r32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
&util_format_r32a32_sint_pack_unsigned, /* pack_rgba_uint */
&util_format_r32a32_sint_unpack_signed, /* unpack_rgba_sint */
&util_format_r32a32_sint_pack_signed, /* pack_rgba_sint */
NULL, /* fetch_rgba_uint */
&util_format_r32a32_sint_fetch_signed /* fetch_rgba_sint */
};
 
const struct util_format_description *
util_format_description(enum pipe_format format)
{
if (format >= PIPE_FORMAT_COUNT) {
return NULL;
}
 
switch (format) {
case PIPE_FORMAT_NONE:
return &util_format_none_description;
case PIPE_FORMAT_B8G8R8A8_UNORM:
return &util_format_b8g8r8a8_unorm_description;
case PIPE_FORMAT_B8G8R8X8_UNORM:
return &util_format_b8g8r8x8_unorm_description;
case PIPE_FORMAT_A8R8G8B8_UNORM:
return &util_format_a8r8g8b8_unorm_description;
case PIPE_FORMAT_X8R8G8B8_UNORM:
return &util_format_x8r8g8b8_unorm_description;
case PIPE_FORMAT_A8B8G8R8_UNORM:
return &util_format_a8b8g8r8_unorm_description;
case PIPE_FORMAT_X8B8G8R8_UNORM:
return &util_format_x8b8g8r8_unorm_description;
case PIPE_FORMAT_R8G8B8X8_UNORM:
return &util_format_r8g8b8x8_unorm_description;
case PIPE_FORMAT_L8_UNORM:
return &util_format_l8_unorm_description;
case PIPE_FORMAT_A8_UNORM:
return &util_format_a8_unorm_description;
case PIPE_FORMAT_I8_UNORM:
return &util_format_i8_unorm_description;
case PIPE_FORMAT_L4A4_UNORM:
return &util_format_l4a4_unorm_description;
case PIPE_FORMAT_L8A8_UNORM:
return &util_format_l8a8_unorm_description;
case PIPE_FORMAT_L16_UNORM:
return &util_format_l16_unorm_description;
case PIPE_FORMAT_A16_UNORM:
return &util_format_a16_unorm_description;
case PIPE_FORMAT_I16_UNORM:
return &util_format_i16_unorm_description;
case PIPE_FORMAT_L16A16_UNORM:
return &util_format_l16a16_unorm_description;
case PIPE_FORMAT_A8_SNORM:
return &util_format_a8_snorm_description;
case PIPE_FORMAT_L8_SNORM:
return &util_format_l8_snorm_description;
case PIPE_FORMAT_L8A8_SNORM:
return &util_format_l8a8_snorm_description;
case PIPE_FORMAT_I8_SNORM:
return &util_format_i8_snorm_description;
case PIPE_FORMAT_A16_SNORM:
return &util_format_a16_snorm_description;
case PIPE_FORMAT_L16_SNORM:
return &util_format_l16_snorm_description;
case PIPE_FORMAT_L16A16_SNORM:
return &util_format_l16a16_snorm_description;
case PIPE_FORMAT_I16_SNORM:
return &util_format_i16_snorm_description;
case PIPE_FORMAT_A16_FLOAT:
return &util_format_a16_float_description;
case PIPE_FORMAT_L16_FLOAT:
return &util_format_l16_float_description;
case PIPE_FORMAT_L16A16_FLOAT:
return &util_format_l16a16_float_description;
case PIPE_FORMAT_I16_FLOAT:
return &util_format_i16_float_description;
case PIPE_FORMAT_A32_FLOAT:
return &util_format_a32_float_description;
case PIPE_FORMAT_L32_FLOAT:
return &util_format_l32_float_description;
case PIPE_FORMAT_L32A32_FLOAT:
return &util_format_l32a32_float_description;
case PIPE_FORMAT_I32_FLOAT:
return &util_format_i32_float_description;
case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
return &util_format_r8sg8sb8ux8u_norm_description;
case PIPE_FORMAT_R5SG5SB6U_NORM:
return &util_format_r5sg5sb6u_norm_description;
case PIPE_FORMAT_S8_UINT:
return &util_format_s8_uint_description;
case PIPE_FORMAT_Z16_UNORM:
return &util_format_z16_unorm_description;
case PIPE_FORMAT_Z32_UNORM:
return &util_format_z32_unorm_description;
case PIPE_FORMAT_Z32_FLOAT:
return &util_format_z32_float_description;
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
return &util_format_z24_unorm_s8_uint_description;
case PIPE_FORMAT_S8_UINT_Z24_UNORM:
return &util_format_s8_uint_z24_unorm_description;
case PIPE_FORMAT_X24S8_UINT:
return &util_format_x24s8_uint_description;
case PIPE_FORMAT_S8X24_UINT:
return &util_format_s8x24_uint_description;
case PIPE_FORMAT_Z24X8_UNORM:
return &util_format_z24x8_unorm_description;
case PIPE_FORMAT_X8Z24_UNORM:
return &util_format_x8z24_unorm_description;
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
return &util_format_z32_float_s8x24_uint_description;
case PIPE_FORMAT_X32_S8X24_UINT:
return &util_format_x32_s8x24_uint_description;
case PIPE_FORMAT_UYVY:
return &util_format_uyvy_description;
case PIPE_FORMAT_YUYV:
return &util_format_yuyv_description;
case PIPE_FORMAT_R8G8_B8G8_UNORM:
return &util_format_r8g8_b8g8_unorm_description;
case PIPE_FORMAT_G8R8_G8B8_UNORM:
return &util_format_g8r8_g8b8_unorm_description;
case PIPE_FORMAT_G8R8_B8R8_UNORM:
return &util_format_g8r8_b8r8_unorm_description;
case PIPE_FORMAT_R8G8_R8B8_UNORM:
return &util_format_r8g8_r8b8_unorm_description;
case PIPE_FORMAT_R11G11B10_FLOAT:
return &util_format_r11g11b10_float_description;
case PIPE_FORMAT_R9G9B9E5_FLOAT:
return &util_format_r9g9b9e5_float_description;
case PIPE_FORMAT_R1_UNORM:
return &util_format_r1_unorm_description;
case PIPE_FORMAT_R8G8Bx_SNORM:
return &util_format_r8g8bx_snorm_description;
case PIPE_FORMAT_R64_FLOAT:
return &util_format_r64_float_description;
case PIPE_FORMAT_R64G64_FLOAT:
return &util_format_r64g64_float_description;
case PIPE_FORMAT_R64G64B64_FLOAT:
return &util_format_r64g64b64_float_description;
case PIPE_FORMAT_R64G64B64A64_FLOAT:
return &util_format_r64g64b64a64_float_description;
case PIPE_FORMAT_R32_FLOAT:
return &util_format_r32_float_description;
case PIPE_FORMAT_R32G32_FLOAT:
return &util_format_r32g32_float_description;
case PIPE_FORMAT_R32G32B32_FLOAT:
return &util_format_r32g32b32_float_description;
case PIPE_FORMAT_R32G32B32A32_FLOAT:
return &util_format_r32g32b32a32_float_description;
case PIPE_FORMAT_R32_UNORM:
return &util_format_r32_unorm_description;
case PIPE_FORMAT_R32G32_UNORM:
return &util_format_r32g32_unorm_description;
case PIPE_FORMAT_R32G32B32_UNORM:
return &util_format_r32g32b32_unorm_description;
case PIPE_FORMAT_R32G32B32A32_UNORM:
return &util_format_r32g32b32a32_unorm_description;
case PIPE_FORMAT_R32_USCALED:
return &util_format_r32_uscaled_description;
case PIPE_FORMAT_R32G32_USCALED:
return &util_format_r32g32_uscaled_description;
case PIPE_FORMAT_R32G32B32_USCALED:
return &util_format_r32g32b32_uscaled_description;
case PIPE_FORMAT_R32G32B32A32_USCALED:
return &util_format_r32g32b32a32_uscaled_description;
case PIPE_FORMAT_R32_SNORM:
return &util_format_r32_snorm_description;
case PIPE_FORMAT_R32G32_SNORM:
return &util_format_r32g32_snorm_description;
case PIPE_FORMAT_R32G32B32_SNORM:
return &util_format_r32g32b32_snorm_description;
case PIPE_FORMAT_R32G32B32A32_SNORM:
return &util_format_r32g32b32a32_snorm_description;
case PIPE_FORMAT_R32_SSCALED:
return &util_format_r32_sscaled_description;
case PIPE_FORMAT_R32G32_SSCALED:
return &util_format_r32g32_sscaled_description;
case PIPE_FORMAT_R32G32B32_SSCALED:
return &util_format_r32g32b32_sscaled_description;
case PIPE_FORMAT_R32G32B32A32_SSCALED:
return &util_format_r32g32b32a32_sscaled_description;
case PIPE_FORMAT_R16_FLOAT:
return &util_format_r16_float_description;
case PIPE_FORMAT_R16G16_FLOAT:
return &util_format_r16g16_float_description;
case PIPE_FORMAT_R16G16B16_FLOAT:
return &util_format_r16g16b16_float_description;
case PIPE_FORMAT_R16G16B16A16_FLOAT:
return &util_format_r16g16b16a16_float_description;
case PIPE_FORMAT_R16_UNORM:
return &util_format_r16_unorm_description;
case PIPE_FORMAT_R16G16_UNORM:
return &util_format_r16g16_unorm_description;
case PIPE_FORMAT_R16G16B16_UNORM:
return &util_format_r16g16b16_unorm_description;
case PIPE_FORMAT_R16G16B16A16_UNORM:
return &util_format_r16g16b16a16_unorm_description;
case PIPE_FORMAT_R16_USCALED:
return &util_format_r16_uscaled_description;
case PIPE_FORMAT_R16G16_USCALED:
return &util_format_r16g16_uscaled_description;
case PIPE_FORMAT_R16G16B16_USCALED:
return &util_format_r16g16b16_uscaled_description;
case PIPE_FORMAT_R16G16B16A16_USCALED:
return &util_format_r16g16b16a16_uscaled_description;
case PIPE_FORMAT_R16_SNORM:
return &util_format_r16_snorm_description;
case PIPE_FORMAT_R16G16_SNORM:
return &util_format_r16g16_snorm_description;
case PIPE_FORMAT_R16G16B16_SNORM:
return &util_format_r16g16b16_snorm_description;
case PIPE_FORMAT_R16G16B16A16_SNORM:
return &util_format_r16g16b16a16_snorm_description;
case PIPE_FORMAT_R16_SSCALED:
return &util_format_r16_sscaled_description;
case PIPE_FORMAT_R16G16_SSCALED:
return &util_format_r16g16_sscaled_description;
case PIPE_FORMAT_R16G16B16_SSCALED:
return &util_format_r16g16b16_sscaled_description;
case PIPE_FORMAT_R16G16B16A16_SSCALED:
return &util_format_r16g16b16a16_sscaled_description;
case PIPE_FORMAT_R8_UNORM:
return &util_format_r8_unorm_description;
case PIPE_FORMAT_R8G8_UNORM:
return &util_format_r8g8_unorm_description;
case PIPE_FORMAT_R8G8B8_UNORM:
return &util_format_r8g8b8_unorm_description;
case PIPE_FORMAT_R8G8B8A8_UNORM:
return &util_format_r8g8b8a8_unorm_description;
case PIPE_FORMAT_R8_USCALED:
return &util_format_r8_uscaled_description;
case PIPE_FORMAT_R8G8_USCALED:
return &util_format_r8g8_uscaled_description;
case PIPE_FORMAT_R8G8B8_USCALED:
return &util_format_r8g8b8_uscaled_description;
case PIPE_FORMAT_R8G8B8A8_USCALED:
return &util_format_r8g8b8a8_uscaled_description;
case PIPE_FORMAT_R8_SNORM:
return &util_format_r8_snorm_description;
case PIPE_FORMAT_R8G8_SNORM:
return &util_format_r8g8_snorm_description;
case PIPE_FORMAT_R8G8B8_SNORM:
return &util_format_r8g8b8_snorm_description;
case PIPE_FORMAT_R8G8B8A8_SNORM:
return &util_format_r8g8b8a8_snorm_description;
case PIPE_FORMAT_R8_SSCALED:
return &util_format_r8_sscaled_description;
case PIPE_FORMAT_R8G8_SSCALED:
return &util_format_r8g8_sscaled_description;
case PIPE_FORMAT_R8G8B8_SSCALED:
return &util_format_r8g8b8_sscaled_description;
case PIPE_FORMAT_R8G8B8A8_SSCALED:
return &util_format_r8g8b8a8_sscaled_description;
case PIPE_FORMAT_R32_FIXED:
return &util_format_r32_fixed_description;
case PIPE_FORMAT_R32G32_FIXED:
return &util_format_r32g32_fixed_description;
case PIPE_FORMAT_R32G32B32_FIXED:
return &util_format_r32g32b32_fixed_description;
case PIPE_FORMAT_R32G32B32A32_FIXED:
return &util_format_r32g32b32a32_fixed_description;
case PIPE_FORMAT_R10G10B10X2_USCALED:
return &util_format_r10g10b10x2_uscaled_description;
case PIPE_FORMAT_R10G10B10X2_SNORM:
return &util_format_r10g10b10x2_snorm_description;
case PIPE_FORMAT_YV12:
return &util_format_yv12_description;
case PIPE_FORMAT_YV16:
return &util_format_yv16_description;
case PIPE_FORMAT_IYUV:
return &util_format_iyuv_description;
case PIPE_FORMAT_NV12:
return &util_format_nv12_description;
case PIPE_FORMAT_NV21:
return &util_format_nv21_description;
case PIPE_FORMAT_R4A4_UNORM:
return &util_format_r4a4_unorm_description;
case PIPE_FORMAT_A4R4_UNORM:
return &util_format_a4r4_unorm_description;
case PIPE_FORMAT_R8A8_UNORM:
return &util_format_r8a8_unorm_description;
case PIPE_FORMAT_A8R8_UNORM:
return &util_format_a8r8_unorm_description;
case PIPE_FORMAT_R8_UINT:
return &util_format_r8_uint_description;
case PIPE_FORMAT_R8G8_UINT:
return &util_format_r8g8_uint_description;
case PIPE_FORMAT_R8G8B8_UINT:
return &util_format_r8g8b8_uint_description;
case PIPE_FORMAT_R8G8B8A8_UINT:
return &util_format_r8g8b8a8_uint_description;
case PIPE_FORMAT_R8_SINT:
return &util_format_r8_sint_description;
case PIPE_FORMAT_R8G8_SINT:
return &util_format_r8g8_sint_description;
case PIPE_FORMAT_R8G8B8_SINT:
return &util_format_r8g8b8_sint_description;
case PIPE_FORMAT_R8G8B8A8_SINT:
return &util_format_r8g8b8a8_sint_description;
case PIPE_FORMAT_R16_UINT:
return &util_format_r16_uint_description;
case PIPE_FORMAT_R16G16_UINT:
return &util_format_r16g16_uint_description;
case PIPE_FORMAT_R16G16B16_UINT:
return &util_format_r16g16b16_uint_description;
case PIPE_FORMAT_R16G16B16A16_UINT:
return &util_format_r16g16b16a16_uint_description;
case PIPE_FORMAT_R16_SINT:
return &util_format_r16_sint_description;
case PIPE_FORMAT_R16G16_SINT:
return &util_format_r16g16_sint_description;
case PIPE_FORMAT_R16G16B16_SINT:
return &util_format_r16g16b16_sint_description;
case PIPE_FORMAT_R16G16B16A16_SINT:
return &util_format_r16g16b16a16_sint_description;
case PIPE_FORMAT_R32_UINT:
return &util_format_r32_uint_description;
case PIPE_FORMAT_R32G32_UINT:
return &util_format_r32g32_uint_description;
case PIPE_FORMAT_R32G32B32_UINT:
return &util_format_r32g32b32_uint_description;
case PIPE_FORMAT_R32G32B32A32_UINT:
return &util_format_r32g32b32a32_uint_description;
case PIPE_FORMAT_R32_SINT:
return &util_format_r32_sint_description;
case PIPE_FORMAT_R32G32_SINT:
return &util_format_r32g32_sint_description;
case PIPE_FORMAT_R32G32B32_SINT:
return &util_format_r32g32b32_sint_description;
case PIPE_FORMAT_R32G32B32A32_SINT:
return &util_format_r32g32b32a32_sint_description;
case PIPE_FORMAT_A8_UINT:
return &util_format_a8_uint_description;
case PIPE_FORMAT_I8_UINT:
return &util_format_i8_uint_description;
case PIPE_FORMAT_L8_UINT:
return &util_format_l8_uint_description;
case PIPE_FORMAT_L8A8_UINT:
return &util_format_l8a8_uint_description;
case PIPE_FORMAT_A8_SINT:
return &util_format_a8_sint_description;
case PIPE_FORMAT_I8_SINT:
return &util_format_i8_sint_description;
case PIPE_FORMAT_L8_SINT:
return &util_format_l8_sint_description;
case PIPE_FORMAT_L8A8_SINT:
return &util_format_l8a8_sint_description;
case PIPE_FORMAT_A16_UINT:
return &util_format_a16_uint_description;
case PIPE_FORMAT_I16_UINT:
return &util_format_i16_uint_description;
case PIPE_FORMAT_L16_UINT:
return &util_format_l16_uint_description;
case PIPE_FORMAT_L16A16_UINT:
return &util_format_l16a16_uint_description;
case PIPE_FORMAT_A16_SINT:
return &util_format_a16_sint_description;
case PIPE_FORMAT_I16_SINT:
return &util_format_i16_sint_description;
case PIPE_FORMAT_L16_SINT:
return &util_format_l16_sint_description;
case PIPE_FORMAT_L16A16_SINT:
return &util_format_l16a16_sint_description;
case PIPE_FORMAT_A32_UINT:
return &util_format_a32_uint_description;
case PIPE_FORMAT_I32_UINT:
return &util_format_i32_uint_description;
case PIPE_FORMAT_L32_UINT:
return &util_format_l32_uint_description;
case PIPE_FORMAT_L32A32_UINT:
return &util_format_l32a32_uint_description;
case PIPE_FORMAT_A32_SINT:
return &util_format_a32_sint_description;
case PIPE_FORMAT_I32_SINT:
return &util_format_i32_sint_description;
case PIPE_FORMAT_L32_SINT:
return &util_format_l32_sint_description;
case PIPE_FORMAT_L32A32_SINT:
return &util_format_l32a32_sint_description;
case PIPE_FORMAT_R8G8B8X8_SNORM:
return &util_format_r8g8b8x8_snorm_description;
case PIPE_FORMAT_R8G8B8X8_SRGB:
return &util_format_r8g8b8x8_srgb_description;
case PIPE_FORMAT_R8G8B8X8_UINT:
return &util_format_r8g8b8x8_uint_description;
case PIPE_FORMAT_R8G8B8X8_SINT:
return &util_format_r8g8b8x8_sint_description;
case PIPE_FORMAT_R16G16B16X16_UNORM:
return &util_format_r16g16b16x16_unorm_description;
case PIPE_FORMAT_R16G16B16X16_SNORM:
return &util_format_r16g16b16x16_snorm_description;
case PIPE_FORMAT_R16G16B16X16_FLOAT:
return &util_format_r16g16b16x16_float_description;
case PIPE_FORMAT_R16G16B16X16_UINT:
return &util_format_r16g16b16x16_uint_description;
case PIPE_FORMAT_R16G16B16X16_SINT:
return &util_format_r16g16b16x16_sint_description;
case PIPE_FORMAT_R32G32B32X32_FLOAT:
return &util_format_r32g32b32x32_float_description;
case PIPE_FORMAT_R32G32B32X32_UINT:
return &util_format_r32g32b32x32_uint_description;
case PIPE_FORMAT_R32G32B32X32_SINT:
return &util_format_r32g32b32x32_sint_description;
case PIPE_FORMAT_R8A8_SNORM:
return &util_format_r8a8_snorm_description;
case PIPE_FORMAT_R16A16_UNORM:
return &util_format_r16a16_unorm_description;
case PIPE_FORMAT_R16A16_SNORM:
return &util_format_r16a16_snorm_description;
case PIPE_FORMAT_R16A16_FLOAT:
return &util_format_r16a16_float_description;
case PIPE_FORMAT_R32A32_FLOAT:
return &util_format_r32a32_float_description;
case PIPE_FORMAT_R8A8_UINT:
return &util_format_r8a8_uint_description;
case PIPE_FORMAT_R8A8_SINT:
return &util_format_r8a8_sint_description;
case PIPE_FORMAT_R16A16_UINT:
return &util_format_r16a16_uint_description;
case PIPE_FORMAT_R16A16_SINT:
return &util_format_r16a16_sint_description;
case PIPE_FORMAT_R32A32_UINT:
return &util_format_r32a32_uint_description;
case PIPE_FORMAT_R32A32_SINT:
return &util_format_r32a32_sint_description;
default:
return NULL;
}
}
 
/contrib/sdk/sources/Mesa/src/gallium/auxiliary/util/u_math.h
442,37 → 442,7
#ifndef FFS_DEFINED
#define FFS_DEFINED 1
 
#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64)
unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
#pragma intrinsic(_BitScanForward)
static INLINE
unsigned long ffs( unsigned long u )
{
unsigned long i;
if (_BitScanForward(&i, u))
return i + 1;
else
return 0;
}
#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
static INLINE
unsigned ffs( unsigned u )
{
unsigned i;
 
if (u == 0) {
return 0;
}
 
__asm bsf eax, [u]
__asm inc eax
__asm mov [i], eax
 
return i;
}
#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID)
#define ffs __builtin_ffs
#endif
 
#endif /* FFS_DEFINED */
 
/contrib/sdk/sources/Mesa/src/gallium/drivers/ilo/ilo_cp.c
41,8 → 41,8
ilo_cp_dump(struct ilo_cp *cp)
{
ilo_printf("dumping %d bytes\n", cp->used * 4);
if (cp->used)
intel_winsys_decode_commands(cp->winsys, cp->bo, cp->used * 4);
// if (cp->used)
// intel_winsys_decode_commands(cp->winsys, cp->bo, cp->used * 4);
}
 
/**
/contrib/sdk/sources/Mesa/src/gallium/winsys/intel/drm/intel_drm_winsys.c
64,7 → 64,8
gp.param = param;
gp.value = value;
 
err = drmCommandWriteRead(winsys->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
err = drmIoctl(winsys->fd, DRM_I915_GETPARAM, &gp);
 
if (err) {
*value = 0;
return false;
151,8 → 152,8
void
intel_winsys_destroy(struct intel_winsys *winsys)
{
if (winsys->decode)
drm_intel_decode_context_free(winsys->decode);
// if (winsys->decode)
// drm_intel_decode_context_free(winsys->decode);
 
drm_intel_bufmgr_destroy(winsys->bufmgr);
FREE(winsys);
341,6 → 342,7
count);
}
 
#if 0
void
intel_winsys_decode_commands(struct intel_winsys *winsys,
struct intel_bo *bo, int used)
372,6 → 374,7
 
intel_bo_unmap(bo);
}
#endif
 
void
intel_bo_reference(struct intel_bo *bo)
/contrib/sdk/sources/Mesa/src/mesa/Makefile
26,9 → 26,6
MAIN_SRC = \
drivers/common/driverfuncs.c \
drivers/common/meta.c \
drivers/dri/common/dri_util.c \
drivers/dri/common/utils.c \
drivers/dri/common/xmlconfig.c \
main/accum.c \
main/api_arrayelt.c \
main/api_exec.c \
244,7 → 241,13
x86/x86_xform4.S \
$(NULL)
 
OSMESA_SRC = \
drivers/osmesa/osmesa.c
 
I965_SRC = \
drivers/dri/common/dri_util.c \
drivers/dri/common/utils.c \
drivers/dri/common/xmlconfig.c \
drivers/dri/i965/intel_batchbuffer.c \
drivers/dri/i965/intel_blit.c \
drivers/dri/i965/intel_buffer_objects.c \
369,11 → 372,12
$(NULL)
 
MESA_OBJS = $(patsubst %.c, %.o, $(patsubst %.S, %.o, $(patsubst %.cpp, %.o, $(MAIN_SRC))))
OSMESA_OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(OSMESA_SRC)))
I965_OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(I965_SRC)))
 
# targets
 
all: i965_dri.drv
all: osmesa.dll i965_dri.drv
 
i965_dri.drv: $(I965_OBJS) $(MESA_OBJS) dri.def Makefile
$(LD) $(LDFLAGS) $(LIBPATH) -o $@ $(I965_OBJS) $(MESA_OBJS) dri.def $(LIBS)
380,6 → 384,11
# $(STRIP) $@
mv -f $@ $(SDK_DIR)/bin
 
osmesa.dll: $(MESA_OBJS) $(OSMESA_OBJS) osmesa.def Makefile
$(LD) $(LDFLAGS) $(LIBPATH) --out-implib libosmesa.dll.a -o $@ $(MESA_OBJS) $(OSMESA_OBJS) osmesa.def $(LIBS)
mv -f libosmesa.dll.a $(SDK_DIR)/lib
mv -f $@ $(SDK_DIR)/bin
 
%.o : %.c Makefile
$(CC) $(CFLAGS) -std=c99 $(MESA_DEFS) $(INC_MESA) $(INC_I965) -o $@ $<
 
/contrib/sdk/sources/Mesa/src/mesa/osmesa.def
0,0 → 1,16
;DESCRIPTION 'Mesa OSMesa lib for Win32'
VERSION 4.1
 
EXPORTS
DllStartup
OSMesaColorClamp
OSMesaCreateContext
OSMesaCreateContextExt
OSMesaDestroyContext
OSMesaMakeCurrent
OSMesaGetCurrentContext
OSMesaPixelStore
OSMesaGetIntegerv
OSMesaGetDepthBuffer
OSMesaGetColorBuffer
OSMesaGetProcAddress
/contrib/sdk/sources/Mesa/src/mesa/state_tracker/st_manager.c
631,6 → 631,7
if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE)
st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
 
#if 0
/* need to perform version check */
if (attribs->major > 1 || attribs->minor > 0) {
/* Is the actual version less than the requested version?
641,6 → 642,7
return NULL;
}
}
#endif
 
st->invalidate_on_gl_viewport =
smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);
/contrib/sdk/sources/Mesa/src/mesa/x86/assyntax.h
254,14 → 254,8
#endif /* GNU_ASSEMBLER */
#endif /* ACK_ASSEMBLER */
 
 
#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__)
#define GLNAME(a) a
#else
#define GLNAME(a) CONCAT(_,a)
#endif
 
 
/****************************************/
/* */
/* Select the various choices */
983,14 → 977,7
 
#endif
 
#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
|| (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
|| (defined(__FreeBSD__) && __FreeBSD__ >= 3) \
|| (defined(__NetBSD__) && defined(__ELF__))
#define GLNAME(a) a
#else
#define GLNAME(a) CONCAT(_, a)
#endif
 
/*
* Addressing Modes
1734,14 → 1721,6
/* Hidden symbol visibility support.
* If we build with gcc's -fvisibility=hidden flag, we'll need to change
* the symbol visibility mode to 'default'.
#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)
# define HIDDEN(x) .hidden x
#elif defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)
# pragma GCC visibility push(default)
# define HIDDEN(x) .hidden x
#else
# define HIDDEN(x)
#endif
*/
 
# define HIDDEN(x)