📄 texformat.c
字号:
/* * Mesa 3-D graphics library * Version: 6.5 * * Copyright (C) 1999-2005 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.c * Texture formats. * * \author Gareth Hughes */#include "colormac.h"#include "context.h"#include "texformat.h"#include "texstore.h"/* Texel fetch routines for all supported formats */#define DIM 1#include "texformat_tmp.h"#define DIM 2#include "texformat_tmp.h"#define DIM 3#include "texformat_tmp.h"/** * Null texel fetch function. * * Have to have this so the FetchTexel function pointer is never NULL. */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){ /* no-op */}/** * Notes about the predefined gl_texture_formats: * * 1. There are 1D, 2D and 3D functions for fetching texels from texture * images, returning both GLchan values and GLfloat values. (six * functions in total) * You don't have to provide both the GLchan and GLfloat functions; * just one or the other is OK. Mesa will use an "adaptor" to convert * between GLchan/GLfloat when needed. * Since the adaptors have small performance penalty, we provide both * GLchan and GLfloat functions for some common formats like RGB, RGBA. *//***************************************************************//** \name Default GLchan-based formats *//*@{*/const struct gl_texture_format _mesa_texformat_rgba = { MESA_FORMAT_RGBA, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ CHAN_BITS, /* RedBits */ CHAN_BITS, /* GreenBits */ CHAN_BITS, /* BlueBits */ CHAN_BITS, /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ 4 * sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba, /* StoreTexImageFunc */ fetch_texel_1d_rgba, /* FetchTexel1D */ fetch_texel_2d_rgba, /* FetchTexel2D */ fetch_texel_3d_rgba, /* FetchTexel3D */ fetch_texel_1d_f_rgba, /* FetchTexel1Df */ fetch_texel_2d_f_rgba, /* FetchTexel2Df */ fetch_texel_3d_f_rgba, /* FetchTexel3Df */ store_texel_rgba /* StoreTexel */};const struct gl_texture_format _mesa_texformat_rgb = { MESA_FORMAT_RGB, /* MesaFormat */ GL_RGB, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ CHAN_BITS, /* RedBits */ CHAN_BITS, /* GreenBits */ CHAN_BITS, /* BlueBits */ 0, /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ 3 * sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */ fetch_texel_1d_rgb, /* FetchTexel1D */ fetch_texel_2d_rgb, /* FetchTexel2D */ fetch_texel_3d_rgb, /* FetchTexel3D */ fetch_texel_1d_f_rgb, /* FetchTexel1Df */ fetch_texel_2d_f_rgb, /* FetchTexel2Df */ fetch_texel_3d_f_rgb, /* FetchTexel3Df */ store_texel_rgb /* StoreTexel */};const struct gl_texture_format _mesa_texformat_alpha = { MESA_FORMAT_ALPHA, /* MesaFormat */ GL_ALPHA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ CHAN_BITS, /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */ fetch_texel_1d_alpha, /* FetchTexel1D */ fetch_texel_2d_alpha, /* FetchTexel2D */ fetch_texel_3d_alpha, /* FetchTexel3D */ NULL, /* FetchTexel1Df */ NULL, /* FetchTexel2Df */ NULL, /* FetchTexel3Df */ store_texel_alpha /* StoreTexel */};const struct gl_texture_format _mesa_texformat_luminance = { MESA_FORMAT_LUMINANCE, /* MesaFormat */ GL_LUMINANCE, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ 0, /* AlphaBits */ CHAN_BITS, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */ fetch_texel_1d_luminance, /* FetchTexel1D */ fetch_texel_2d_luminance, /* FetchTexel2D */ fetch_texel_3d_luminance, /* FetchTexel3D */ NULL, /* FetchTexel1Df */ NULL, /* FetchTexel2Df */ NULL, /* FetchTexel3Df */ store_texel_luminance /* StoreTexel */};const struct gl_texture_format _mesa_texformat_luminance_alpha = { MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */ GL_LUMINANCE_ALPHA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ CHAN_BITS, /* AlphaBits */ CHAN_BITS, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ 2 * sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */ fetch_texel_1d_luminance_alpha, /* FetchTexel1D */ fetch_texel_2d_luminance_alpha, /* FetchTexel2D */ fetch_texel_3d_luminance_alpha, /* FetchTexel3D */ NULL, /* FetchTexel1Df */ NULL, /* FetchTexel2Df */ NULL, /* FetchTexel3Df */ store_texel_luminance_alpha /* StoreTexel */};const struct gl_texture_format _mesa_texformat_intensity = { MESA_FORMAT_INTENSITY, /* MesaFormat */ GL_INTENSITY, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ 0, /* AlphaBits */ 0, /* LuminanceBits */ CHAN_BITS, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ sizeof(GLchan), /* TexelBytes */ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */ fetch_texel_1d_intensity, /* FetchTexel1D */ fetch_texel_2d_intensity, /* FetchTexel2D */ fetch_texel_3d_intensity, /* FetchTexel3D */ NULL, /* FetchTexel1Df */ NULL, /* FetchTexel2Df */ NULL, /* FetchTexel3Df */ store_texel_intensity /* StoreTexel */};const struct gl_texture_format _mesa_texformat_depth_component_float32 = { MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */ GL_DEPTH_COMPONENT, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ 0, /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ sizeof(GLfloat) * 8, /* DepthBits */ sizeof(GLfloat) * 8, /* StencilBits */ sizeof(GLfloat), /* TexelBytes */ _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */ fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */ fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */ store_texel_depth_component_f32 /* StoreTexel */};const struct gl_texture_format _mesa_texformat_depth_component16 = { MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */ GL_DEPTH_COMPONENT, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ 0, /* GreenBits */ 0, /* BlueBits */ 0, /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ sizeof(GLushort) * 8, /* DepthBits */ sizeof(GLushort) * 8, /* StencilBits */ sizeof(GLushort), /* TexelBytes */ _mesa_texstore_depth_component16, /* StoreTexImageFunc */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */ fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */ fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */ store_texel_depth_component16 /* StoreTexel */};const struct gl_texture_format _mesa_texformat_rgba_float32 = { MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_FLOAT, /* DataType */ 8 * sizeof(GLfloat), /* RedBits */ 8 * sizeof(GLfloat), /* GreenBits */ 8 * sizeof(GLfloat), /* BlueBits */ 8 * sizeof(GLfloat), /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ 4 * sizeof(GLfloat), /* TexelBytes */ _mesa_texstore_rgba_float32, /* StoreTexImageFunc */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */ fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */ fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */ store_texel_rgba_f32 /* StoreTexel */};const struct gl_texture_format _mesa_texformat_rgba_float16 = { MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_FLOAT, /* DataType */ 8 * sizeof(GLhalfARB), /* RedBits */ 8 * sizeof(GLhalfARB), /* GreenBits */ 8 * sizeof(GLhalfARB), /* BlueBits */ 8 * sizeof(GLhalfARB), /* AlphaBits */ 0, /* LuminanceBits */ 0, /* IntensityBits */ 0, /* IndexBits */ 0, /* DepthBits */ 0, /* StencilBits */ 4 * sizeof(GLhalfARB), /* TexelBytes */ _mesa_texstore_rgba_float16, /* StoreTexImageFunc */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ NULL, /* FetchTexel1D */ fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */ fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */ fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */ store_texel_rgba_f16 /* StoreTexel */};const struct gl_texture_format _mesa_texformat_rgb_float32 = { MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */ GL_RGB, /* BaseFormat */ GL_FLOAT, /* DataType */ 8 * sizeof(GLfloat), /* RedBits */ 8 * sizeof(GLfloat), /* GreenBits */ 8 * sizeof(GLfloat), /* BlueBits */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -