1 typedef unsigned int GLenum;
2 typedef unsigned char GLboolean;
5 typedef unsigned char GLubyte;
6 typedef unsigned int GLuint;
8 typedef GLubyte GLchan;
9 typedef void (*FetchTexelFuncF) (const struct gl_texture_image * texImage,
10 GLint col, GLint row, GLint img,
12 typedef void (*StoreTexelFunc) (struct gl_texture_image * texImage, GLint col,
13 GLint row, GLint img, const void *texel);
14 struct gl_texture_format {
22 GLubyte LuminanceBits;
23 GLubyte IntensityBits;
27 FetchTexelFuncF FetchTexel3Df;
28 StoreTexelFunc StoreTexel;
30 static void fxt1_encode(void);
31 static GLboolean texstore_rgba_fxt1(GLuint dims,
32 GLenum baseInternalFormat,
33 const struct gl_texture_format *dstFormat,
34 GLvoid * dstAddr, GLint dstXoffset,
35 GLint dstYoffset, GLint dstZoffset,
37 const GLuint * dstImageOffsets,
38 GLint srcWidth, GLint srcHeight,
39 GLint srcDepth, GLenum srcFormat,
40 GLenum srcType, const GLvoid * srcAddr,
41 const struct gl_pixelstore_attrib
46 static void fetch_texel_2d_rgba_fxt1(const struct gl_texture_image *texImage,
47 GLint i, GLint j, GLint k, GLchan * texel)
50 static void fetch_texel_2d_f_rgba_fxt1(const struct gl_texture_image *texImage,
51 GLint i, GLint j, GLint k,
55 const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
56 0, 0x1908, 0x8C17, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0,
57 texstore_rgba_fxt1, 0, fetch_texel_2d_rgba_fxt1,
58 0, 0, fetch_texel_2d_f_rgba_fxt1, 0,
61 typedef unsigned long long Fx64;
62 static void fxt1_quantize_CHROMA(GLuint * cc, GLubyte input[32][4])
64 const GLint n_vect = 4;
66 for (j = n_vect - 1; k >= 32 / 2; k--) {
69 static void fxt1_quantize_ALPHA1(GLuint * cc, GLubyte input[32][4])
71 const GLint n_vect = 3;
72 const GLint n_comp = 4;
73 GLfloat vec[1 + 1 + 1][4];
80 for (i = 0; i < n_comp; i++) {
82 for (j1 = 0; j1 < 2; j1++) {
83 for (j2 = 2; j2 < 4; j2++) {
85 for (i = 0; i < n_comp; i++) {
87 tv[j2][i]) * (tv[j1][i] -
95 for (i = 0; i < n_comp; i++) {
96 vec[0][i] = tv[1 - v1][i];
98 for (j = n_vect - 1; j >= 0; j--) {
99 for (i = 0; i < n_comp - 1; i++) {
100 hi |= (GLuint) (vec[j][i] / 8.0F);
103 ((Fx64 *) cc)[1] = hi;
105 static void fxt1_quantize(GLuint * cc, const GLubyte * lines[], GLint comps)
107 GLubyte input[32][4];
111 for (l = 0; l < 4; l++) {
112 for (k = 0; k < 4; k++) {
113 for (i = 0; i < comps; i++) {
116 fxt1_quantize_ALPHA1(cc, input);
119 static void fxt1_encode(void)
121 fxt1_quantize(0, 0, 0);