#include "colormac.h"
#include "context.h"
#include "texformat.h"
#include "texstore.h"
#if FEATURE_EXT_texture_sRGB
static INLINE GLfloat
nonlinear_to_linear(GLubyte cs8)
{
static GLfloat table[256];
static GLboolean tableReady = GL_FALSE;
if (!tableReady) {
GLuint i;
for (i = 0; i < 256; i++) {
const GLfloat cs = UBYTE_TO_FLOAT(i);
if (cs <= 0.04045) {
table[i] = cs / 12.92;
}
else {
table[i] = _mesa_pow((cs + 0.055) / 1.055, 2.4);
}
}
tableReady = GL_TRUE;
}
return table[cs8];
}
#endif
#define DIM 1
#include "texformat_tmp.h"
#define DIM 2
#include "texformat_tmp.h"
#define DIM 3
#include "texformat_tmp.h"
static void fetch_null_texel( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
(void) texImage; (void) i; (void) j; (void) k;
texel[RCOMP] = 0;
texel[GCOMP] = 0;
texel[BCOMP] = 0;
texel[ACOMP] = 0;
_mesa_warning(NULL, "fetch_null_texel() called!");
}
static void fetch_null_texelf( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
(void) texImage; (void) i; (void) j; (void) k;
texel[RCOMP] = 0.0;
texel[GCOMP] = 0.0;
texel[BCOMP] = 0.0;
texel[ACOMP] = 0.0;
_mesa_warning(NULL, "fetch_null_texelf() called!");
}
static void store_null_texel(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
(void) texImage;
(void) i;
(void) j;
(void) k;
(void) texel;
}
const struct gl_texture_format _mesa_texformat_rgba = {
MESA_FORMAT_RGBA,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
CHAN_BITS,
CHAN_BITS,
CHAN_BITS,
CHAN_BITS,
0,
0,
0,
0,
0,
4 * sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_rgba,
fetch_texel_2d_rgba,
fetch_texel_3d_rgba,
fetch_texel_1d_f_rgba,
fetch_texel_2d_f_rgba,
fetch_texel_3d_f_rgba,
store_texel_rgba
};
const struct gl_texture_format _mesa_texformat_rgb = {
MESA_FORMAT_RGB,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
CHAN_BITS,
CHAN_BITS,
CHAN_BITS,
0,
0,
0,
0,
0,
0,
3 * sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_rgb,
fetch_texel_2d_rgb,
fetch_texel_3d_rgb,
fetch_texel_1d_f_rgb,
fetch_texel_2d_f_rgb,
fetch_texel_3d_f_rgb,
store_texel_rgb
};
const struct gl_texture_format _mesa_texformat_alpha = {
MESA_FORMAT_ALPHA,
GL_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
CHAN_BITS,
0,
0,
0,
0,
0,
sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_alpha,
fetch_texel_2d_alpha,
fetch_texel_3d_alpha,
NULL,
NULL,
NULL,
store_texel_alpha
};
const struct gl_texture_format _mesa_texformat_luminance = {
MESA_FORMAT_LUMINANCE,
GL_LUMINANCE,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
CHAN_BITS,
0,
0,
0,
0,
sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_luminance,
fetch_texel_2d_luminance,
fetch_texel_3d_luminance,
NULL,
NULL,
NULL,
store_texel_luminance
};
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
MESA_FORMAT_LUMINANCE_ALPHA,
GL_LUMINANCE_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
CHAN_BITS,
CHAN_BITS,
0,
0,
0,
0,
2 * sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_luminance_alpha,
fetch_texel_2d_luminance_alpha,
fetch_texel_3d_luminance_alpha,
NULL,
NULL,
NULL,
store_texel_luminance_alpha
};
const struct gl_texture_format _mesa_texformat_intensity = {
MESA_FORMAT_INTENSITY,
GL_INTENSITY,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
CHAN_BITS,
0,
0,
0,
sizeof(GLchan),
_mesa_texstore_rgba,
fetch_texel_1d_intensity,
fetch_texel_2d_intensity,
fetch_texel_3d_intensity,
NULL,
NULL,
NULL,
store_texel_intensity
};
#if FEATURE_EXT_texture_sRGB
const struct gl_texture_format _mesa_texformat_srgb8 = {
MESA_FORMAT_SRGB8,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
0,
0,
0,
0,
0,
0,
3,
_mesa_texstore_srgb8,
NULL,
NULL,
NULL,
fetch_texel_1d_srgb8,
fetch_texel_2d_srgb8,
fetch_texel_3d_srgb8,
store_texel_srgb8
};
const struct gl_texture_format _mesa_texformat_srgba8 = {
MESA_FORMAT_SRGBA8,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
8,
0,
0,
0,
0,
0,
4,
_mesa_texstore_srgba8,
NULL,
NULL,
NULL,
fetch_texel_1d_srgba8,
fetch_texel_2d_srgba8,
fetch_texel_3d_srgba8,
store_texel_srgba8
};
const struct gl_texture_format _mesa_texformat_sl8 = {
MESA_FORMAT_SL8,
GL_LUMINANCE,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
8,
0,
0,
0,
0,
1,
_mesa_texstore_sl8,
NULL,
NULL,
NULL,
fetch_texel_1d_sl8,
fetch_texel_2d_sl8,
fetch_texel_3d_sl8,
store_texel_sl8
};
const struct gl_texture_format _mesa_texformat_sla8 = {
MESA_FORMAT_SLA8,
GL_LUMINANCE_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
8,
8,
0,
0,
0,
0,
2,
_mesa_texstore_sla8,
NULL,
NULL,
NULL,
fetch_texel_1d_sla8,
fetch_texel_2d_sla8,
fetch_texel_3d_sla8,
store_texel_sla8
};
#endif
const struct gl_texture_format _mesa_texformat_rgba_float32 = {
MESA_FORMAT_RGBA_FLOAT32,
GL_RGBA,
GL_FLOAT,
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
0,
0,
0,
0,
0,
4 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_rgba_f32,
fetch_texel_2d_f_rgba_f32,
fetch_texel_3d_f_rgba_f32,
store_texel_rgba_f32
};
const struct gl_texture_format _mesa_texformat_rgba_float16 = {
MESA_FORMAT_RGBA_FLOAT16,
GL_RGBA,
GL_FLOAT,
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
0,
0,
0,
0,
0,
4 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_rgba_f16,
fetch_texel_2d_f_rgba_f16,
fetch_texel_3d_f_rgba_f16,
store_texel_rgba_f16
};
const struct gl_texture_format _mesa_texformat_rgb_float32 = {
MESA_FORMAT_RGB_FLOAT32,
GL_RGB,
GL_FLOAT,
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
0,
0,
0,
0,
0,
0,
3 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_rgb_f32,
fetch_texel_2d_f_rgb_f32,
fetch_texel_3d_f_rgb_f32,
store_texel_rgb_f32
};
const struct gl_texture_format _mesa_texformat_rgb_float16 = {
MESA_FORMAT_RGB_FLOAT16,
GL_RGB,
GL_FLOAT,
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
0,
0,
0,
0,
0,
0,
3 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_rgb_f16,
fetch_texel_2d_f_rgb_f16,
fetch_texel_3d_f_rgb_f16,
store_texel_rgb_f16
};
const struct gl_texture_format _mesa_texformat_alpha_float32 = {
MESA_FORMAT_ALPHA_FLOAT32,
GL_ALPHA,
GL_FLOAT,
0,
0,
0,
8 * sizeof(GLfloat),
0,
0,
0,
0,
0,
1 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_alpha_f32,
fetch_texel_2d_f_alpha_f32,
fetch_texel_3d_f_alpha_f32,
store_texel_alpha_f32
};
const struct gl_texture_format _mesa_texformat_alpha_float16 = {
MESA_FORMAT_ALPHA_FLOAT16,
GL_ALPHA,
GL_FLOAT,
0,
0,
0,
8 * sizeof(GLhalfARB),
0,
0,
0,
0,
0,
1 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_alpha_f16,
fetch_texel_2d_f_alpha_f16,
fetch_texel_3d_f_alpha_f16,
store_texel_alpha_f16
};
const struct gl_texture_format _mesa_texformat_luminance_float32 = {
MESA_FORMAT_LUMINANCE_FLOAT32,
GL_LUMINANCE,
GL_FLOAT,
0,
0,
0,
0,
8 * sizeof(GLfloat),
0,
0,
0,
0,
1 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_luminance_f32,
fetch_texel_2d_f_luminance_f32,
fetch_texel_3d_f_luminance_f32,
store_texel_luminance_f32
};
const struct gl_texture_format _mesa_texformat_luminance_float16 = {
MESA_FORMAT_LUMINANCE_FLOAT16,
GL_LUMINANCE,
GL_FLOAT,
0,
0,
0,
0,
8 * sizeof(GLhalfARB),
0,
0,
0,
0,
1 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_luminance_f16,
fetch_texel_2d_f_luminance_f16,
fetch_texel_3d_f_luminance_f16,
store_texel_luminance_f16
};
const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
GL_LUMINANCE_ALPHA,
GL_FLOAT,
0,
0,
0,
8 * sizeof(GLfloat),
8 * sizeof(GLfloat),
0,
0,
0,
0,
2 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_luminance_alpha_f32,
fetch_texel_2d_f_luminance_alpha_f32,
fetch_texel_3d_f_luminance_alpha_f32,
store_texel_luminance_alpha_f32
};
const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
GL_LUMINANCE_ALPHA,
GL_FLOAT,
0,
0,
0,
8 * sizeof(GLhalfARB),
8 * sizeof(GLhalfARB),
0,
0,
0,
0,
2 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_luminance_alpha_f16,
fetch_texel_2d_f_luminance_alpha_f16,
fetch_texel_3d_f_luminance_alpha_f16,
store_texel_luminance_alpha_f16
};
const struct gl_texture_format _mesa_texformat_intensity_float32 = {
MESA_FORMAT_INTENSITY_FLOAT32,
GL_INTENSITY,
GL_FLOAT,
0,
0,
0,
0,
0,
8 * sizeof(GLfloat),
0,
0,
0,
1 * sizeof(GLfloat),
_mesa_texstore_rgba_float32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_intensity_f32,
fetch_texel_2d_f_intensity_f32,
fetch_texel_3d_f_intensity_f32,
store_texel_intensity_f32
};
const struct gl_texture_format _mesa_texformat_intensity_float16 = {
MESA_FORMAT_INTENSITY_FLOAT16,
GL_INTENSITY,
GL_FLOAT,
0,
0,
0,
0,
0,
8 * sizeof(GLhalfARB),
0,
0,
0,
1 * sizeof(GLhalfARB),
_mesa_texstore_rgba_float16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_intensity_f16,
fetch_texel_2d_f_intensity_f16,
fetch_texel_3d_f_intensity_f16,
store_texel_intensity_f16
};
const struct gl_texture_format _mesa_texformat_rgba8888 = {
MESA_FORMAT_RGBA8888,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
8,
0,
0,
0,
0,
0,
4,
_mesa_texstore_rgba8888,
fetch_texel_1d_rgba8888,
fetch_texel_2d_rgba8888,
fetch_texel_3d_rgba8888,
NULL,
NULL,
NULL,
store_texel_rgba8888
};
const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
MESA_FORMAT_RGBA8888_REV,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
8,
0,
0,
0,
0,
0,
4,
_mesa_texstore_rgba8888,
fetch_texel_1d_rgba8888_rev,
fetch_texel_2d_rgba8888_rev,
fetch_texel_3d_rgba8888_rev,
NULL,
NULL,
NULL,
store_texel_rgba8888_rev
};
const struct gl_texture_format _mesa_texformat_argb8888 = {
MESA_FORMAT_ARGB8888,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
8,
0,
0,
0,
0,
0,
4,
_mesa_texstore_argb8888,
fetch_texel_1d_argb8888,
fetch_texel_2d_argb8888,
fetch_texel_3d_argb8888,
NULL,
NULL,
NULL,
store_texel_argb8888
};
const struct gl_texture_format _mesa_texformat_argb8888_rev = {
MESA_FORMAT_ARGB8888_REV,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
8,
0,
0,
0,
0,
0,
4,
_mesa_texstore_argb8888,
fetch_texel_1d_argb8888_rev,
fetch_texel_2d_argb8888_rev,
fetch_texel_3d_argb8888_rev,
NULL,
NULL,
NULL,
store_texel_argb8888_rev
};
const struct gl_texture_format _mesa_texformat_rgb888 = {
MESA_FORMAT_RGB888,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
0,
0,
0,
0,
0,
0,
3,
_mesa_texstore_rgb888,
fetch_texel_1d_rgb888,
fetch_texel_2d_rgb888,
fetch_texel_3d_rgb888,
NULL,
NULL,
NULL,
store_texel_rgb888
};
const struct gl_texture_format _mesa_texformat_bgr888 = {
MESA_FORMAT_BGR888,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
8,
8,
8,
0,
0,
0,
0,
0,
0,
3,
_mesa_texstore_bgr888,
fetch_texel_1d_bgr888,
fetch_texel_2d_bgr888,
fetch_texel_3d_bgr888,
NULL,
NULL,
NULL,
store_texel_bgr888
};
const struct gl_texture_format _mesa_texformat_rgb565 = {
MESA_FORMAT_RGB565,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
5,
6,
5,
0,
0,
0,
0,
0,
0,
2,
_mesa_texstore_rgb565,
fetch_texel_1d_rgb565,
fetch_texel_2d_rgb565,
fetch_texel_3d_rgb565,
NULL,
NULL,
NULL,
store_texel_rgb565
};
const struct gl_texture_format _mesa_texformat_rgb565_rev = {
MESA_FORMAT_RGB565_REV,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
5,
6,
5,
0,
0,
0,
0,
0,
0,
2,
_mesa_texstore_rgb565,
fetch_texel_1d_rgb565_rev,
fetch_texel_2d_rgb565_rev,
fetch_texel_3d_rgb565_rev,
NULL,
NULL,
NULL,
store_texel_rgb565_rev
};
const struct gl_texture_format _mesa_texformat_argb4444 = {
MESA_FORMAT_ARGB4444,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
4,
4,
4,
4,
0,
0,
0,
0,
0,
2,
_mesa_texstore_argb4444,
fetch_texel_1d_argb4444,
fetch_texel_2d_argb4444,
fetch_texel_3d_argb4444,
NULL,
NULL,
NULL,
store_texel_argb4444
};
const struct gl_texture_format _mesa_texformat_argb4444_rev = {
MESA_FORMAT_ARGB4444_REV,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
4,
4,
4,
4,
0,
0,
0,
0,
0,
2,
_mesa_texstore_argb4444,
fetch_texel_1d_argb4444_rev,
fetch_texel_2d_argb4444_rev,
fetch_texel_3d_argb4444_rev,
NULL,
NULL,
NULL,
store_texel_argb4444_rev
};
const struct gl_texture_format _mesa_texformat_argb1555 = {
MESA_FORMAT_ARGB1555,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
5,
5,
5,
1,
0,
0,
0,
0,
0,
2,
_mesa_texstore_argb1555,
fetch_texel_1d_argb1555,
fetch_texel_2d_argb1555,
fetch_texel_3d_argb1555,
NULL,
NULL,
NULL,
store_texel_argb1555
};
const struct gl_texture_format _mesa_texformat_argb1555_rev = {
MESA_FORMAT_ARGB1555_REV,
GL_RGBA,
GL_UNSIGNED_NORMALIZED_ARB,
5,
5,
5,
1,
0,
0,
0,
0,
0,
2,
_mesa_texstore_argb1555,
fetch_texel_1d_argb1555_rev,
fetch_texel_2d_argb1555_rev,
fetch_texel_3d_argb1555_rev,
NULL,
NULL,
NULL,
store_texel_argb1555_rev
};
const struct gl_texture_format _mesa_texformat_al88 = {
MESA_FORMAT_AL88,
GL_LUMINANCE_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
8,
8,
0,
0,
0,
0,
2,
_mesa_texstore_al88,
fetch_texel_1d_al88,
fetch_texel_2d_al88,
fetch_texel_3d_al88,
NULL,
NULL,
NULL,
store_texel_al88
};
const struct gl_texture_format _mesa_texformat_al88_rev = {
MESA_FORMAT_AL88_REV,
GL_LUMINANCE_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
8,
8,
0,
0,
0,
0,
2,
_mesa_texstore_al88,
fetch_texel_1d_al88_rev,
fetch_texel_2d_al88_rev,
fetch_texel_3d_al88_rev,
NULL,
NULL,
NULL,
store_texel_al88_rev
};
const struct gl_texture_format _mesa_texformat_rgb332 = {
MESA_FORMAT_RGB332,
GL_RGB,
GL_UNSIGNED_NORMALIZED_ARB,
3,
3,
2,
0,
0,
0,
0,
0,
0,
1,
_mesa_texstore_rgb332,
fetch_texel_1d_rgb332,
fetch_texel_2d_rgb332,
fetch_texel_3d_rgb332,
NULL,
NULL,
NULL,
store_texel_rgb332
};
const struct gl_texture_format _mesa_texformat_a8 = {
MESA_FORMAT_A8,
GL_ALPHA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
8,
0,
0,
0,
0,
0,
1,
_mesa_texstore_a8,
fetch_texel_1d_a8,
fetch_texel_2d_a8,
fetch_texel_3d_a8,
NULL,
NULL,
NULL,
store_texel_a8
};
const struct gl_texture_format _mesa_texformat_l8 = {
MESA_FORMAT_L8,
GL_LUMINANCE,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
8,
0,
0,
0,
0,
1,
_mesa_texstore_a8,
fetch_texel_1d_l8,
fetch_texel_2d_l8,
fetch_texel_3d_l8,
NULL,
NULL,
NULL,
store_texel_l8
};
const struct gl_texture_format _mesa_texformat_i8 = {
MESA_FORMAT_I8,
GL_INTENSITY,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
8,
0,
0,
0,
1,
_mesa_texstore_a8,
fetch_texel_1d_i8,
fetch_texel_2d_i8,
fetch_texel_3d_i8,
NULL,
NULL,
NULL,
store_texel_i8
};
const struct gl_texture_format _mesa_texformat_ci8 = {
MESA_FORMAT_CI8,
GL_COLOR_INDEX,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
8,
0,
0,
1,
_mesa_texstore_ci8,
fetch_texel_1d_ci8,
fetch_texel_2d_ci8,
fetch_texel_3d_ci8,
NULL,
NULL,
NULL,
store_texel_ci8
};
const struct gl_texture_format _mesa_texformat_ycbcr = {
MESA_FORMAT_YCBCR,
GL_YCBCR_MESA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
_mesa_texstore_ycbcr,
fetch_texel_1d_ycbcr,
fetch_texel_2d_ycbcr,
fetch_texel_3d_ycbcr,
NULL,
NULL,
NULL,
store_texel_ycbcr
};
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
MESA_FORMAT_YCBCR_REV,
GL_YCBCR_MESA,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
_mesa_texstore_ycbcr,
fetch_texel_1d_ycbcr_rev,
fetch_texel_2d_ycbcr_rev,
fetch_texel_3d_ycbcr_rev,
NULL,
NULL,
NULL,
store_texel_ycbcr_rev
};
const struct gl_texture_format _mesa_texformat_z24_s8 = {
MESA_FORMAT_Z24_S8,
GL_DEPTH_STENCIL_EXT,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
0,
24,
8,
4,
_mesa_texstore_z24_s8,
NULL,
NULL,
NULL,
fetch_texel_1d_f_z24_s8,
fetch_texel_2d_f_z24_s8,
fetch_texel_3d_f_z24_s8,
store_texel_z24_s8
};
const struct gl_texture_format _mesa_texformat_z16 = {
MESA_FORMAT_Z16,
GL_DEPTH_COMPONENT,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
0,
sizeof(GLushort) * 8,
0,
sizeof(GLushort),
_mesa_texstore_z16,
NULL,
NULL,
NULL,
fetch_texel_1d_f_z16,
fetch_texel_2d_f_z16,
fetch_texel_3d_f_z16,
store_texel_z16
};
const struct gl_texture_format _mesa_texformat_z32 = {
MESA_FORMAT_Z32,
GL_DEPTH_COMPONENT,
GL_UNSIGNED_NORMALIZED_ARB,
0,
0,
0,
0,
0,
0,
0,
sizeof(GLuint) * 8,
0,
sizeof(GLuint),
_mesa_texstore_z32,
NULL,
NULL,
NULL,
fetch_texel_1d_f_z32,
fetch_texel_2d_f_z32,
fetch_texel_3d_f_z32,
store_texel_z32
};
const struct gl_texture_format _mesa_null_texformat = {
-1,
0,
GL_NONE,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
NULL,
fetch_null_texel,
fetch_null_texel,
fetch_null_texel,
fetch_null_texelf,
fetch_null_texelf,
fetch_null_texelf,
store_null_texel
};
const struct gl_texture_format *
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
{
(void) format;
(void) type;
switch (internalFormat) {
case 4:
case GL_RGBA:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
return &_mesa_texformat_rgba;
case GL_RGBA8:
return &_mesa_texformat_rgba8888;
case GL_RGB5_A1:
return &_mesa_texformat_argb1555;
case GL_RGBA2:
return &_mesa_texformat_argb4444_rev;
case GL_RGBA4:
return &_mesa_texformat_argb4444;
case 3:
case GL_RGB:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
return &_mesa_texformat_rgb;
case GL_RGB8:
return &_mesa_texformat_rgb888;
case GL_R3_G3_B2:
return &_mesa_texformat_rgb332;
case GL_RGB4:
return &_mesa_texformat_rgb565_rev;
case GL_RGB5:
return &_mesa_texformat_rgb565;
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA12:
case GL_ALPHA16:
return &_mesa_texformat_alpha;
case GL_ALPHA8:
return &_mesa_texformat_a8;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
return &_mesa_texformat_luminance;
case GL_LUMINANCE8:
return &_mesa_texformat_l8;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
case GL_LUMINANCE6_ALPHA2:
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
return &_mesa_texformat_luminance_alpha;
case GL_LUMINANCE8_ALPHA8:
return &_mesa_texformat_al88;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY12:
case GL_INTENSITY16:
return &_mesa_texformat_intensity;
case GL_INTENSITY8:
return &_mesa_texformat_i8;
case GL_COLOR_INDEX:
case GL_COLOR_INDEX1_EXT:
case GL_COLOR_INDEX2_EXT:
case GL_COLOR_INDEX4_EXT:
case GL_COLOR_INDEX12_EXT:
case GL_COLOR_INDEX16_EXT:
case GL_COLOR_INDEX8_EXT:
return &_mesa_texformat_ci8;
default:
;
}
if (ctx->Extensions.SGIX_depth_texture ||
ctx->Extensions.ARB_depth_texture) {
switch (internalFormat) {
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24_SGIX:
case GL_DEPTH_COMPONENT32_SGIX:
return &_mesa_texformat_z32;
case GL_DEPTH_COMPONENT16_SGIX:
return &_mesa_texformat_z16;
default:
;
}
}
if (ctx->Extensions.ARB_texture_compression) {
switch (internalFormat) {
case GL_COMPRESSED_ALPHA_ARB:
return &_mesa_texformat_alpha;
case GL_COMPRESSED_LUMINANCE_ARB:
return &_mesa_texformat_luminance;
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
return &_mesa_texformat_luminance_alpha;
case GL_COMPRESSED_INTENSITY_ARB:
return &_mesa_texformat_intensity;
case GL_COMPRESSED_RGB_ARB:
if (ctx->Extensions.TDFX_texture_compression_FXT1)
return &_mesa_texformat_rgb_fxt1;
else if (ctx->Extensions.EXT_texture_compression_s3tc ||
ctx->Extensions.S3_s3tc)
return &_mesa_texformat_rgb_dxt1;
else
return &_mesa_texformat_rgb;
case GL_COMPRESSED_RGBA_ARB:
if (ctx->Extensions.TDFX_texture_compression_FXT1)
return &_mesa_texformat_rgba_fxt1;
else if (ctx->Extensions.EXT_texture_compression_s3tc ||
ctx->Extensions.S3_s3tc)
return &_mesa_texformat_rgba_dxt3;
else
return &_mesa_texformat_rgba;
default:
;
}
}
if (ctx->Extensions.MESA_ycbcr_texture) {
if (internalFormat == GL_YCBCR_MESA) {
if (type == GL_UNSIGNED_SHORT_8_8_MESA)
return &_mesa_texformat_ycbcr;
else
return &_mesa_texformat_ycbcr_rev;
}
}
if (ctx->Extensions.TDFX_texture_compression_FXT1) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
return &_mesa_texformat_rgb_fxt1;
case GL_COMPRESSED_RGBA_FXT1_3DFX:
return &_mesa_texformat_rgba_fxt1;
default:
;
}
}
if (ctx->Extensions.EXT_texture_compression_s3tc) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return &_mesa_texformat_rgb_dxt1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return &_mesa_texformat_rgba_dxt1;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
return &_mesa_texformat_rgba_dxt3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return &_mesa_texformat_rgba_dxt5;
default:
;
}
}
if (ctx->Extensions.S3_s3tc) {
switch (internalFormat) {
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
return &_mesa_texformat_rgb_dxt1;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
return &_mesa_texformat_rgba_dxt3;
default:
;
}
}
if (ctx->Extensions.ARB_texture_float) {
switch (internalFormat) {
case GL_ALPHA16F_ARB:
return &_mesa_texformat_alpha_float16;
case GL_ALPHA32F_ARB:
return &_mesa_texformat_alpha_float32;
case GL_LUMINANCE16F_ARB:
return &_mesa_texformat_luminance_float16;
case GL_LUMINANCE32F_ARB:
return &_mesa_texformat_luminance_float32;
case GL_LUMINANCE_ALPHA16F_ARB:
return &_mesa_texformat_luminance_alpha_float16;
case GL_LUMINANCE_ALPHA32F_ARB:
return &_mesa_texformat_luminance_alpha_float32;
case GL_INTENSITY16F_ARB:
return &_mesa_texformat_intensity_float16;
case GL_INTENSITY32F_ARB:
return &_mesa_texformat_intensity_float32;
case GL_RGB16F_ARB:
return &_mesa_texformat_rgb_float16;
case GL_RGB32F_ARB:
return &_mesa_texformat_rgb_float32;
case GL_RGBA16F_ARB:
return &_mesa_texformat_rgba_float16;
case GL_RGBA32F_ARB:
return &_mesa_texformat_rgba_float32;
default:
;
}
}
if (ctx->Extensions.EXT_packed_depth_stencil) {
switch (internalFormat) {
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
return &_mesa_texformat_z24_s8;
default:
;
}
}
#if FEATURE_EXT_texture_sRGB
if (ctx->Extensions.EXT_texture_sRGB) {
switch (internalFormat) {
case GL_SRGB_EXT:
case GL_SRGB8_EXT:
return &_mesa_texformat_srgb8;
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
return &_mesa_texformat_srgba8;
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
return &_mesa_texformat_sl8;
case GL_SLUMINANCE_ALPHA_EXT:
case GL_SLUMINANCE8_ALPHA8_EXT:
return &_mesa_texformat_sla8;
case GL_COMPRESSED_SRGB_EXT:
return &_mesa_texformat_srgb8;
case GL_COMPRESSED_SRGB_ALPHA_EXT:
return &_mesa_texformat_srgba8;
case GL_COMPRESSED_SLUMINANCE_EXT:
return &_mesa_texformat_sl8;
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
return &_mesa_texformat_sla8;
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
return &_mesa_texformat_srgb8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
return &_mesa_texformat_srgba8;
default:
;
}
}
#endif
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
return NULL;
}