📄 texformat_tmp.h
字号:
/* * Mesa 3-D graphics library * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul 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, sublicense, * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL 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 texformat_tmp.h * Texel fetch functions template. * * This template file is used by texformat.c to generate texel fetch functions * for 1-D, 2-D and 3-D texture images. * * It should be expanded by defining \p DIM as the number texture dimensions * (1, 2 or 3). According to the value of \p DIM a series of macros is defined * for the texel lookup in the gl_texture_image::Data. * * \sa texformat.c and FetchTexel. * * \author Gareth Hughes * \author Brian Paul */#if DIM == 1#define TEXEL_ADDR( type, image, i, j, k, size ) \ ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))#define FETCH(x) fetch_texel_1d_##x#elif DIM == 2#define TEXEL_ADDR( type, image, i, j, k, size ) \ ((void) (k), \ ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))#define FETCH(x) fetch_texel_2d_##x#elif DIM == 3#define TEXEL_ADDR( type, image, i, j, k, size ) \ ((type *)(image)->Data + ((image)->ImageOffsets[k] \ + (image)->RowStride * (j) + (i)) * (size))#define FETCH(x) fetch_texel_3d_##x#else#error illegal number of texture dimensions#endif/* MESA_FORMAT_RGBA **********************************************************//* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */static void FETCH(rgba)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); COPY_CHAN4( texel, src );}/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */static void FETCH(f_rgba)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); texel[RCOMP] = CHAN_TO_FLOAT(src[0]); texel[GCOMP] = CHAN_TO_FLOAT(src[1]); texel[BCOMP] = CHAN_TO_FLOAT(src[2]); texel[ACOMP] = CHAN_TO_FLOAT(src[3]);}#if DIM == 3/* Store a GLchan RGBA texel */static void store_texel_rgba(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 4); dst[0] = rgba[RCOMP]; dst[1] = rgba[GCOMP]; dst[2] = rgba[BCOMP]; dst[3] = rgba[ACOMP];}#endif/* MESA_FORMAT_RGB ***********************************************************//* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */static void FETCH(rgb)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); texel[RCOMP] = src[0]; texel[GCOMP] = src[1]; texel[BCOMP] = src[2]; texel[ACOMP] = CHAN_MAX;}/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */static void FETCH(f_rgb)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); texel[RCOMP] = CHAN_TO_FLOAT(src[0]); texel[GCOMP] = CHAN_TO_FLOAT(src[1]); texel[BCOMP] = CHAN_TO_FLOAT(src[2]); texel[ACOMP] = 1.0F;}#if DIM == 3static void store_texel_rgb(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 3); dst[0] = rgba[RCOMP]; dst[1] = rgba[GCOMP]; dst[2] = rgba[BCOMP];}#endif/* MESA_FORMAT_ALPHA *********************************************************//* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */static void FETCH(alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = 0; texel[ACOMP] = src[0];}#if DIM == 3static void store_texel_alpha(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); dst[0] = rgba[ACOMP];}#endif/* MESA_FORMAT_LUMINANCE *****************************************************//* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */static void FETCH(luminance)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = src[0]; texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_luminance(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); dst[0] = rgba[RCOMP];}#endif/* MESA_FORMAT_LUMINANCE_ALPHA ***********************************************//* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 2); texel[RCOMP] = src[0]; texel[GCOMP] = src[0]; texel[BCOMP] = src[0]; texel[ACOMP] = src[1];}#if DIM == 3static void store_texel_luminance_alpha(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 2); dst[0] = rgba[RCOMP]; dst[1] = rgba[ACOMP];}#endif/* MESA_FORMAT_INTENSITY *****************************************************//* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */static void FETCH(intensity)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ){ const GLchan *src = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); texel[RCOMP] = src[0]; texel[GCOMP] = src[0]; texel[BCOMP] = src[0]; texel[ACOMP] = src[0];}#if DIM == 3static void store_texel_intensity(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLchan *rgba = (const GLchan *) texel; GLchan *dst = TEXEL_ADDR(GLchan, texImage, i, j, k, 1); dst[0] = rgba[RCOMP];}#endif/* MESA_FORMAT_Z32 ***********************************************************//* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, * returning 1 GLfloat. * Note: no GLchan version of this function. */static void FETCH(f_z32)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); texel[0] = src[0] * (1.0F / 0xffffffff);}#if DIM == 3static void store_texel_z32(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLuint *depth = (const GLuint *) texel; GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); dst[0] = *depth;}#endif/* MESA_FORMAT_Z16 ***********************************************************//* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, * returning 1 GLfloat. * Note: no GLchan version of this function. */static void FETCH(f_z16)(const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[0] = src[0] * (1.0F / 65535.0F);}#if DIM == 3static void store_texel_z16(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLushort *depth = (const GLushort *) texel; GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); dst[0] = *depth;}#endif/* MESA_FORMAT_RGBA_F32 ******************************************************//* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats. */static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); texel[RCOMP] = src[0]; texel[GCOMP] = src[1]; texel[BCOMP] = src[2]; texel[ACOMP] = src[3];}#if DIM == 3static void store_texel_rgba_f32(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLfloat *depth = (const GLfloat *) texel; GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); dst[0] = depth[RCOMP]; dst[1] = depth[GCOMP]; dst[2] = depth[BCOMP]; dst[3] = depth[ACOMP];}#endif/* MESA_FORMAT_RGBA_F16 ******************************************************//* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, * returning 4 GLfloats. */static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); texel[RCOMP] = _mesa_half_to_float(src[0]); texel[GCOMP] = _mesa_half_to_float(src[1]); texel[BCOMP] = _mesa_half_to_float(src[2]); texel[ACOMP] = _mesa_half_to_float(src[3]);}#if DIM == 3static void store_texel_rgba_f16(struct gl_texture_image *texImage, GLint i, GLint j, GLint k, const void *texel){ const GLfloat *depth = (const GLfloat *) texel; GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); dst[0] = _mesa_float_to_half(*depth);}#endif/* MESA_FORMAT_RGB_F32 *******************************************************//* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, * returning 4 GLfloats. */static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ){ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); texel[RCOMP] = src[0]; texel[GCOMP] = src[1]; texel[BCOMP] = src[2]; texel[ACOMP] = 1.0F;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -