core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

texcompress_fxt1.c File Reference


Detailed Description

GL_EXT_texture_compression_fxt1 support.

#include "glheader.h"
#include "imports.h"
#include "colormac.h"
#include "context.h"
#include "convolve.h"
#include "image.h"
#include "mipmap.h"
#include "texcompress.h"
#include "texformat.h"
#include "texstore.h"

Defines

#define MAX_COMP   4
#define MAX_VECT   4
#define N_TEXELS   32
#define LL_N_REP   50
#define LL_RMS_D   10
#define LL_RMS_E   255
#define ALPHA_TS   2
#define ISTBLACK(v)   (*((GLuint *)(v)) == 0)
#define FX64_NATIVE   1
#define FX64_MOV32(a, b)   a = b
#define FX64_OR32(a, b)   a |= b
#define FX64_SHL(a, c)   a <<= c
#define F(i)   (GLfloat)1
#define SAFECDOT   1
#define MAKEIVEC(NV, NC, IV, B, V0, V1)
#define CALCCDOT(TEXEL, NV, NC, IV, B, V)
#define CC_SEL(cc, which)   (((GLuint *)(cc))[(which) / 32] >> ((which) & 31))
#define UP5(c)   _rgb_scale_5[(c) & 31]
#define UP6(c, b)   _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]
#define LERP(n, t, c0, c1)   (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)

Typedefs

typedef uint64_t Fx64

Functions

static void fxt1_encode (GLuint width, GLuint height, GLint comps, const void *source, GLint srcRowStride, void *dest, GLint destRowStride)
void fxt1_decode_1 (const void *texture, GLint stride, GLint i, GLint j, GLchan *rgba)
void _mesa_init_texture_fxt1 (GLcontext *ctx)
 Called during context initialization.
static GLboolean texstore_rgb_fxt1 (TEXSTORE_PARAMS)
 Called via TexFormat->StoreImage to store an RGB_FXT1 texture.
static GLboolean texstore_rgba_fxt1 (TEXSTORE_PARAMS)
 Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.
static void fetch_texel_2d_rgba_fxt1 (const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel)
static void fetch_texel_2d_f_rgba_fxt1 (const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel)
static void fetch_texel_2d_rgb_fxt1 (const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel)
static void fetch_texel_2d_f_rgb_fxt1 (const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel)
static GLint fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv, GLubyte input[MAX_COMP], GLint nc)
static GLint fxt1_worst (GLfloat vec[MAX_COMP], GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
static GLint fxt1_variance (GLdouble variance[MAX_COMP], GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
static GLint fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv, GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
static GLint fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv, GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
static void fxt1_quantize_CHROMA (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP])
static void fxt1_quantize_ALPHA0 (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP], GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
static void fxt1_quantize_ALPHA1 (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP])
static void fxt1_quantize_HI (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP], GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
static void fxt1_quantize_MIXED1 (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP])
static void fxt1_quantize_MIXED0 (GLuint *cc, GLubyte input[N_TEXELS][MAX_COMP])
static void fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps)
static void fxt1_decode_1HI (const GLubyte *code, GLint t, GLchan *rgba)
static void fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLchan *rgba)
static void fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLchan *rgba)
static void fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLchan *rgba)

Variables

struct gl_texture_format _mesa_texformat_rgb_fxt1
struct gl_texture_format _mesa_texformat_rgba_fxt1
static const GLubyte _rgb_scale_5 []
static const GLubyte _rgb_scale_6 []


Define Documentation

#define ALPHA_TS   2

#define CALCCDOT ( TEXEL,
NV,
NC,
IV,
B,
 ) 

Value:

do {                                  \
      GLfloat dot = 0.0F;                \
      for (i = 0; i < NC; i++) {         \
         dot += V[i] * IV[i];            \
      }                                  \
      TEXEL = (GLint)(dot + B);          \
      if (SAFECDOT) {                    \
         if (TEXEL < 0) {                \
            TEXEL = 0;                   \
         } else if (TEXEL > NV) {        \
            TEXEL = NV;                  \
         }                               \
      }                                  \
   } while (0)

#define CC_SEL ( cc,
which   )     (((GLuint *)(cc))[(which) / 32] >> ((which) & 31))

#define F (  )     (GLfloat)1

#define FX64_MOV32 ( a,
 )     a = b

#define FX64_NATIVE   1

#define FX64_OR32 ( a,
 )     a |= b

#define FX64_SHL ( a,
 )     a <<= c

#define ISTBLACK (  )     (*((GLuint *)(v)) == 0)

#define LERP ( n,
t,
c0,
c1   )     (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)

#define LL_N_REP   50

#define LL_RMS_D   10

#define LL_RMS_E   255

#define MAKEIVEC ( NV,
NC,
IV,
B,
V0,
V1   ) 

Value:

do {                                  \
      /* compute interpolation vector */ \
      GLfloat d2 = 0.0F;                 \
      GLfloat rd2;                       \
                                         \
      for (i = 0; i < NC; i++) {         \
         IV[i] = (V1[i] - V0[i]) * F(i); \
         d2 += IV[i] * IV[i];            \
      }                                  \
      rd2 = (GLfloat)NV / d2;            \
      B = 0;                             \
      for (i = 0; i < NC; i++) {         \
         IV[i] *= F(i);                  \
         B -= IV[i] * V0[i];             \
         IV[i] *= rd2;                   \
      }                                  \
      B = B * rd2 + 0.5f;                \
   } while (0)

#define MAX_COMP   4

#define MAX_VECT   4

#define N_TEXELS   32

#define SAFECDOT   1

#define UP5 (  )     _rgb_scale_5[(c) & 31]

#define UP6 ( c,
 )     _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]


Typedef Documentation

typedef uint64_t Fx64


Function Documentation

void _mesa_init_texture_fxt1 ( GLcontext ctx  ) 

Called during context initialization.

static void fetch_texel_2d_f_rgb_fxt1 ( const struct gl_texture_image texImage,
GLint  i,
GLint  j,
GLint  k,
GLfloat *  texel 
) [static]

static void fetch_texel_2d_f_rgba_fxt1 ( const struct gl_texture_image texImage,
GLint  i,
GLint  j,
GLint  k,
GLfloat *  texel 
) [static]

static void fetch_texel_2d_rgb_fxt1 ( const struct gl_texture_image texImage,
GLint  i,
GLint  j,
GLint  k,
GLchan *  texel 
) [static]

static void fetch_texel_2d_rgba_fxt1 ( const struct gl_texture_image texImage,
GLint  i,
GLint  j,
GLint  k,
GLchan *  texel 
) [static]

static GLint fxt1_bestcol ( GLfloat  vec[][MAX_COMP],
GLint  nv,
GLubyte  input[MAX_COMP],
GLint  nc 
) [static]

static GLint fxt1_choose ( GLfloat  vec[][MAX_COMP],
GLint  nv,
GLubyte  input[N_TEXELS][MAX_COMP],
GLint  nc,
GLint  n 
) [static]

void fxt1_decode_1 ( const void *  texture,
GLint  stride,
GLint  i,
GLint  j,
GLchan *  rgba 
)

static void fxt1_decode_1ALPHA ( const GLubyte *  code,
GLint  t,
GLchan *  rgba 
) [static]

static void fxt1_decode_1CHROMA ( const GLubyte *  code,
GLint  t,
GLchan *  rgba 
) [static]

static void fxt1_decode_1HI ( const GLubyte *  code,
GLint  t,
GLchan *  rgba 
) [static]

static void fxt1_decode_1MIXED ( const GLubyte *  code,
GLint  t,
GLchan *  rgba 
) [static]

static void fxt1_encode ( GLuint  width,
GLuint  height,
GLint  comps,
const void *  source,
GLint  srcRowStride,
void *  dest,
GLint  destRowStride 
) [static]

static GLint fxt1_lloyd ( GLfloat  vec[][MAX_COMP],
GLint  nv,
GLubyte  input[N_TEXELS][MAX_COMP],
GLint  nc,
GLint  n 
) [static]

static void fxt1_quantize ( GLuint *  cc,
const GLubyte *  lines[],
GLint  comps 
) [static]

static void fxt1_quantize_ALPHA0 ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP],
GLubyte  reord[N_TEXELS][MAX_COMP],
GLint  n 
) [static]

static void fxt1_quantize_ALPHA1 ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP] 
) [static]

static void fxt1_quantize_CHROMA ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP] 
) [static]

static void fxt1_quantize_HI ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP],
GLubyte  reord[N_TEXELS][MAX_COMP],
GLint  n 
) [static]

static void fxt1_quantize_MIXED0 ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP] 
) [static]

static void fxt1_quantize_MIXED1 ( GLuint *  cc,
GLubyte  input[N_TEXELS][MAX_COMP] 
) [static]

static GLint fxt1_variance ( GLdouble  variance[MAX_COMP],
GLubyte  input[N_TEXELS][MAX_COMP],
GLint  nc,
GLint  n 
) [static]

static GLint fxt1_worst ( GLfloat  vec[MAX_COMP],
GLubyte  input[N_TEXELS][MAX_COMP],
GLint  nc,
GLint  n 
) [static]

static GLboolean texstore_rgb_fxt1 ( TEXSTORE_PARAMS   )  [static]

Called via TexFormat->StoreImage to store an RGB_FXT1 texture.

static GLboolean texstore_rgba_fxt1 ( TEXSTORE_PARAMS   )  [static]

Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.


Variable Documentation

struct gl_texture_format _mesa_texformat_rgb_fxt1

Initial value:

 {
   MESA_FORMAT_RGB_FXT1,                
   GL_RGB,                              
   GL_UNSIGNED_NORMALIZED_ARB,          
   4,                   
   4,                   
   4,                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   texstore_rgb_fxt1,                   
   NULL,                
   fetch_texel_2d_rgb_fxt1,             
   NULL,                
   NULL,                
   fetch_texel_2d_f_rgb_fxt1,           
   NULL,                
   NULL                                 
}

struct gl_texture_format _mesa_texformat_rgba_fxt1

Initial value:

 {
   MESA_FORMAT_RGBA_FXT1,               
   GL_RGBA,                             
   GL_UNSIGNED_NORMALIZED_ARB,          
   4,                   
   4,                   
   4,                   
   1,                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   0,                                   
   texstore_rgba_fxt1,                  
   NULL,                
   fetch_texel_2d_rgba_fxt1,            
   NULL,                
   NULL,                
   fetch_texel_2d_f_rgba_fxt1,          
   NULL,                
   NULL                                 
}

const GLubyte _rgb_scale_5[] [static]

Initial value:

 {
   0,   8,   16,  25,  33,  41,  49,  58,
   66,  74,  82,  90,  99,  107, 115, 123,
   132, 140, 148, 156, 165, 173, 181, 189,
   197, 206, 214, 222, 230, 239, 247, 255
}

const GLubyte _rgb_scale_6[] [static]

Initial value:

 {
   0,   4,   8,   12,  16,  20,  24,  28,
   32,  36,  40,  45,  49,  53,  57,  61,
   65,  69,  73,  77,  81,  85,  89,  93,
   97,  101, 105, 109, 113, 117, 121, 125,
   130, 134, 138, 142, 146, 150, 154, 158,
   162, 166, 170, 174, 178, 182, 186, 190,
   194, 198, 202, 206, 210, 215, 219, 223,
   227, 231, 235, 239, 243, 247, 251, 255
}


Generated on Sun Sep 27 06:47:46 2009 for Mesa Main by  doxygen 1.5.4