📄 texformat_tmp.h
字号:
#if DIM == 3
static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 2);
dst[0] = rgba[RCOMP];
dst[1] = rgba[ACOMP];
}
#endif
/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
texel[GCOMP] =
texel[BCOMP] = texel[RCOMP];
UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[1]));
}
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = _mesa_half_to_float(src[0]);
texel[ACOMP] = _mesa_half_to_float(src[1]);
}
#if DIM == 3
static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 2);
dst[0] = _mesa_float_to_half(rgba[RCOMP]);
dst[1] = _mesa_float_to_half(rgba[ACOMP]);
}
#endif
/* MESA_FORMAT_INTENSITY_F32 *************************************************/
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(intensity_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = texel[RCOMP];
}
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
* returning 4 GLfloats.
*/
static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = src[0];
}
#if DIM == 3
static void store_texel_intensity_f32(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
dst[0] = rgba[RCOMP];
}
#endif
/* MESA_FORMAT_INTENSITY_F16 *************************************************/
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(intensity_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = texel[RCOMP];
}
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = _mesa_half_to_float(src[0]);
}
#if DIM == 3
static void store_texel_intensity_f16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
dst[0] = _mesa_float_to_half(rgba[RCOMP]);
}
#endif
/*
* Begin Hardware formats
*/
/* MESA_FORMAT_RGBA8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */
static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 24) );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
}
/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
}
#if DIM == 3
static void store_texel_rgba8888(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLuint *dst = UINT_ADDR(texImage, i, j, k);
*dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
}
#endif
/* MESA_FORMAT_RGBA888_REV ***************************************************/
/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) );
}
/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLfloats */
static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
#if DIM == 3
static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLuint *dst = UINT_ADDR(texImage, i, j, k);
*dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
}
#endif
/* MESA_FORMAT_ARGB8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
static void FETCH(argb8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) );
}
/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */
static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
#if DIM == 3
static void store_texel_argb8888(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLuint *dst = UINT_ADDR(texImage, i, j, k);
*dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
}
#endif
/* MESA_FORMAT_ARGB8888_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLchans */
static void FETCH(argb8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 24) );
texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
}
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
}
#if DIM == 3
static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLuint *dst = UINT_ADDR(texImage, i, j, k);
*dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
}
#endif
/* MESA_FORMAT_RGB888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
static void FETCH(rgb888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
texel[ACOMP] = CHAN_MAX;
}
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */
static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
texel[ACOMP] = 1.0F;
}
#if DIM == 3
static void store_texel_rgb888(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
dst[0] = rgba[RCOMP];
dst[1] = rgba[GCOMP];
dst[2] = rgba[BCOMP];
}
#endif
/* MESA_FORMAT_BGR888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
static void FETCH(bgr888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
texel[BCOMP] = UBYTE_TO_CHAN( src[2] );
texel[ACOMP] = CHAN_MAX;
}
/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLfloats */
static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
texel[ACOMP] = 1.0F;
}
#if DIM == 3
static void store_texel_bgr888(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
dst[0] = rgba[BCOMP];
dst[1] = rgba[GCOMP];
dst[2] = rgba[RCOMP];
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -