| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file texformat.c |
| 3 | * Texture formats. |
| 4 | * |
| 5 | * \author Gareth Hughes |
| 6 | */ |
| 7 | |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 8 | /* |
| 9 | * Mesa 3-D graphics library |
| Brian Paul | 27558a1 | 2003-03-01 01:50:20 +0000 | [diff] [blame] | 10 | * Version: 5.1 |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 11 | * |
| Brian Paul | 27558a1 | 2003-03-01 01:50:20 +0000 | [diff] [blame] | 12 | * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 13 | * |
| 14 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 15 | * copy of this software and associated documentation files (the "Software"), |
| 16 | * to deal in the Software without restriction, including without limitation |
| 17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 18 | * and/or sell copies of the Software, and to permit persons to whom the |
| 19 | * Software is furnished to do so, subject to the following conditions: |
| 20 | * |
| 21 | * The above copyright notice and this permission notice shall be included |
| 22 | * in all copies or substantial portions of the Software. |
| 23 | * |
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 25 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 27 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 28 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 32 | |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 33 | #include "glheader.h" |
| 34 | #include "colormac.h" |
| 35 | #include "context.h" |
| 36 | #include "image.h" |
| Brian Paul | 3c63452 | 2002-10-24 23:57:19 +0000 | [diff] [blame] | 37 | #include "imports.h" |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 38 | #include "mtypes.h" |
| 39 | #include "texformat.h" |
| 40 | #include "teximage.h" |
| 41 | #include "texstate.h" |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 42 | |
| 43 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 44 | /* Texel fetch routines for all supported formats |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 45 | */ |
| 46 | #define DIM 1 |
| 47 | #include "texformat_tmp.h" |
| 48 | |
| 49 | #define DIM 2 |
| 50 | #include "texformat_tmp.h" |
| 51 | |
| 52 | #define DIM 3 |
| 53 | #include "texformat_tmp.h" |
| 54 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 55 | /** |
| 56 | * Null texel fetch function. |
| 57 | * |
| 58 | * Have to have this so the FetchTexel function pointer is never NULL. |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 59 | */ |
| 60 | static void fetch_null_texel( const struct gl_texture_image *texImage, |
| 61 | GLint i, GLint j, GLint k, GLvoid *texel ) |
| 62 | { |
| 63 | GLchan *rgba = (GLchan *) texel; |
| 64 | rgba[RCOMP] = 0; |
| 65 | rgba[GCOMP] = 0; |
| 66 | rgba[BCOMP] = 0; |
| 67 | rgba[ACOMP] = 0; |
| 68 | } |
| 69 | |
| 70 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 71 | /***************************************************************/ |
| 72 | /** \name Default GLchan-based formats */ |
| 73 | /*@{*/ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 74 | |
| 75 | const struct gl_texture_format _mesa_texformat_rgba = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 76 | MESA_FORMAT_RGBA, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 77 | GL_RGBA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 78 | CHAN_BITS, /* RedBits */ |
| 79 | CHAN_BITS, /* GreenBits */ |
| 80 | CHAN_BITS, /* BlueBits */ |
| 81 | CHAN_BITS, /* AlphaBits */ |
| 82 | 0, /* LuminanceBits */ |
| 83 | 0, /* IntensityBits */ |
| 84 | 0, /* IndexBits */ |
| 85 | 0, /* DepthBits */ |
| 86 | 4 * CHAN_BITS / 8, /* TexelBytes */ |
| 87 | fetch_1d_texel_rgba, /* FetchTexel1D */ |
| 88 | fetch_2d_texel_rgba, /* FetchTexel2D */ |
| 89 | fetch_3d_texel_rgba, /* FetchTexel3D */ |
| 90 | }; |
| 91 | |
| 92 | const struct gl_texture_format _mesa_texformat_rgb = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 93 | MESA_FORMAT_RGB, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 94 | GL_RGB, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 95 | CHAN_BITS, /* RedBits */ |
| 96 | CHAN_BITS, /* GreenBits */ |
| 97 | CHAN_BITS, /* BlueBits */ |
| 98 | 0, /* AlphaBits */ |
| 99 | 0, /* LuminanceBits */ |
| 100 | 0, /* IntensityBits */ |
| 101 | 0, /* IndexBits */ |
| 102 | 0, /* DepthBits */ |
| 103 | 3 * CHAN_BITS / 8, /* TexelBytes */ |
| 104 | fetch_1d_texel_rgb, /* FetchTexel1D */ |
| 105 | fetch_2d_texel_rgb, /* FetchTexel2D */ |
| 106 | fetch_3d_texel_rgb, /* FetchTexel3D */ |
| 107 | }; |
| 108 | |
| 109 | const struct gl_texture_format _mesa_texformat_alpha = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 110 | MESA_FORMAT_ALPHA, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 111 | GL_ALPHA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 112 | 0, /* RedBits */ |
| 113 | 0, /* GreenBits */ |
| 114 | 0, /* BlueBits */ |
| 115 | CHAN_BITS, /* AlphaBits */ |
| 116 | 0, /* LuminanceBits */ |
| 117 | 0, /* IntensityBits */ |
| 118 | 0, /* IndexBits */ |
| 119 | 0, /* DepthBits */ |
| 120 | CHAN_BITS / 8, /* TexelBytes */ |
| 121 | fetch_1d_texel_alpha, /* FetchTexel1D */ |
| 122 | fetch_2d_texel_alpha, /* FetchTexel2D */ |
| 123 | fetch_3d_texel_alpha, /* FetchTexel3D */ |
| 124 | }; |
| 125 | |
| 126 | const struct gl_texture_format _mesa_texformat_luminance = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 127 | MESA_FORMAT_LUMINANCE, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 128 | GL_LUMINANCE, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 129 | 0, /* RedBits */ |
| 130 | 0, /* GreenBits */ |
| 131 | 0, /* BlueBits */ |
| 132 | 0, /* AlphaBits */ |
| 133 | CHAN_BITS, /* LuminanceBits */ |
| 134 | 0, /* IntensityBits */ |
| 135 | 0, /* IndexBits */ |
| 136 | 0, /* DepthBits */ |
| 137 | CHAN_BITS / 8, /* TexelBytes */ |
| 138 | fetch_1d_texel_luminance, /* FetchTexel1D */ |
| 139 | fetch_2d_texel_luminance, /* FetchTexel2D */ |
| 140 | fetch_3d_texel_luminance, /* FetchTexel3D */ |
| 141 | }; |
| 142 | |
| 143 | const struct gl_texture_format _mesa_texformat_luminance_alpha = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 144 | MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 145 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 146 | 0, /* RedBits */ |
| 147 | 0, /* GreenBits */ |
| 148 | 0, /* BlueBits */ |
| 149 | CHAN_BITS, /* AlphaBits */ |
| 150 | CHAN_BITS, /* LuminanceBits */ |
| 151 | 0, /* IntensityBits */ |
| 152 | 0, /* IndexBits */ |
| 153 | 0, /* DepthBits */ |
| 154 | 2 * CHAN_BITS / 8, /* TexelBytes */ |
| 155 | fetch_1d_texel_luminance_alpha, /* FetchTexel1D */ |
| 156 | fetch_2d_texel_luminance_alpha, /* FetchTexel2D */ |
| 157 | fetch_3d_texel_luminance_alpha, /* FetchTexel3D */ |
| 158 | }; |
| 159 | |
| 160 | const struct gl_texture_format _mesa_texformat_intensity = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 161 | MESA_FORMAT_INTENSITY, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 162 | GL_INTENSITY, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 163 | 0, /* RedBits */ |
| 164 | 0, /* GreenBits */ |
| 165 | 0, /* BlueBits */ |
| 166 | 0, /* AlphaBits */ |
| 167 | 0, /* LuminanceBits */ |
| 168 | CHAN_BITS, /* IntensityBits */ |
| 169 | 0, /* IndexBits */ |
| 170 | 0, /* DepthBits */ |
| 171 | CHAN_BITS / 8, /* TexelBytes */ |
| 172 | fetch_1d_texel_intensity, /* FetchTexel1D */ |
| 173 | fetch_2d_texel_intensity, /* FetchTexel2D */ |
| 174 | fetch_3d_texel_intensity, /* FetchTexel3D */ |
| 175 | }; |
| 176 | |
| 177 | const struct gl_texture_format _mesa_texformat_color_index = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 178 | MESA_FORMAT_COLOR_INDEX, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 179 | GL_COLOR_INDEX, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 180 | 0, /* RedBits */ |
| 181 | 0, /* GreenBits */ |
| 182 | 0, /* BlueBits */ |
| 183 | 0, /* AlphaBits */ |
| 184 | 0, /* LuminanceBits */ |
| 185 | 0, /* IntensityBits */ |
| 186 | CHAN_BITS, /* IndexBits */ |
| 187 | 0, /* DepthBits */ |
| 188 | CHAN_BITS / 8, /* TexelBytes */ |
| 189 | fetch_1d_texel_color_index, /* FetchTexel1D */ |
| 190 | fetch_2d_texel_color_index, /* FetchTexel2D */ |
| 191 | fetch_3d_texel_color_index, /* FetchTexel3D */ |
| 192 | }; |
| 193 | |
| 194 | const struct gl_texture_format _mesa_texformat_depth_component = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 195 | MESA_FORMAT_DEPTH_COMPONENT, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 196 | GL_DEPTH_COMPONENT, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 197 | 0, /* RedBits */ |
| 198 | 0, /* GreenBits */ |
| 199 | 0, /* BlueBits */ |
| 200 | 0, /* AlphaBits */ |
| 201 | 0, /* LuminanceBits */ |
| 202 | 0, /* IntensityBits */ |
| 203 | 0, /* IndexBits */ |
| 204 | sizeof(GLfloat) * 8, /* DepthBits */ |
| 205 | sizeof(GLfloat), /* TexelBytes */ |
| 206 | fetch_1d_texel_depth_component, /* FetchTexel1D */ |
| 207 | fetch_2d_texel_depth_component, /* FetchTexel2D */ |
| 208 | fetch_3d_texel_depth_component, /* FetchTexel3D */ |
| 209 | }; |
| 210 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 211 | /*@}*/ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 212 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 213 | |
| 214 | /***************************************************************/ |
| 215 | /** \name Hardware formats */ |
| 216 | /*@{*/ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 217 | |
| 218 | const struct gl_texture_format _mesa_texformat_rgba8888 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 219 | MESA_FORMAT_RGBA8888, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 220 | GL_RGBA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 221 | 8, /* RedBits */ |
| 222 | 8, /* GreenBits */ |
| 223 | 8, /* BlueBits */ |
| 224 | 8, /* AlphaBits */ |
| 225 | 0, /* LuminanceBits */ |
| 226 | 0, /* IntensityBits */ |
| 227 | 0, /* IndexBits */ |
| 228 | 0, /* DepthBits */ |
| 229 | 4, /* TexelBytes */ |
| 230 | fetch_1d_texel_rgba8888, /* FetchTexel1D */ |
| 231 | fetch_2d_texel_rgba8888, /* FetchTexel2D */ |
| 232 | fetch_3d_texel_rgba8888, /* FetchTexel3D */ |
| 233 | }; |
| 234 | |
| 235 | const struct gl_texture_format _mesa_texformat_argb8888 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 236 | MESA_FORMAT_ARGB8888, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 237 | GL_RGBA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 238 | 8, /* RedBits */ |
| 239 | 8, /* GreenBits */ |
| 240 | 8, /* BlueBits */ |
| 241 | 8, /* AlphaBits */ |
| 242 | 0, /* LuminanceBits */ |
| 243 | 0, /* IntensityBits */ |
| 244 | 0, /* IndexBits */ |
| 245 | 0, /* DepthBits */ |
| 246 | 4, /* TexelBytes */ |
| 247 | fetch_1d_texel_argb8888, /* FetchTexel1D */ |
| 248 | fetch_2d_texel_argb8888, /* FetchTexel2D */ |
| 249 | fetch_3d_texel_argb8888, /* FetchTexel3D */ |
| 250 | }; |
| 251 | |
| 252 | const struct gl_texture_format _mesa_texformat_rgb888 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 253 | MESA_FORMAT_RGB888, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 254 | GL_RGB, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 255 | 8, /* RedBits */ |
| 256 | 8, /* GreenBits */ |
| 257 | 8, /* BlueBits */ |
| 258 | 0, /* AlphaBits */ |
| 259 | 0, /* LuminanceBits */ |
| 260 | 0, /* IntensityBits */ |
| 261 | 0, /* IndexBits */ |
| 262 | 0, /* DepthBits */ |
| 263 | 3, /* TexelBytes */ |
| 264 | fetch_1d_texel_rgb888, /* FetchTexel1D */ |
| 265 | fetch_2d_texel_rgb888, /* FetchTexel2D */ |
| 266 | fetch_3d_texel_rgb888, /* FetchTexel3D */ |
| 267 | }; |
| 268 | |
| 269 | const struct gl_texture_format _mesa_texformat_rgb565 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 270 | MESA_FORMAT_RGB565, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 271 | GL_RGB, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 272 | 5, /* RedBits */ |
| 273 | 6, /* GreenBits */ |
| 274 | 5, /* BlueBits */ |
| 275 | 0, /* AlphaBits */ |
| 276 | 0, /* LuminanceBits */ |
| 277 | 0, /* IntensityBits */ |
| 278 | 0, /* IndexBits */ |
| 279 | 0, /* DepthBits */ |
| 280 | 2, /* TexelBytes */ |
| 281 | fetch_1d_texel_rgb565, /* FetchTexel1D */ |
| 282 | fetch_2d_texel_rgb565, /* FetchTexel2D */ |
| 283 | fetch_3d_texel_rgb565, /* FetchTexel3D */ |
| 284 | }; |
| 285 | |
| 286 | const struct gl_texture_format _mesa_texformat_argb4444 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 287 | MESA_FORMAT_ARGB4444, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 288 | GL_RGBA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 289 | 4, /* RedBits */ |
| 290 | 4, /* GreenBits */ |
| 291 | 4, /* BlueBits */ |
| 292 | 4, /* AlphaBits */ |
| 293 | 0, /* LuminanceBits */ |
| 294 | 0, /* IntensityBits */ |
| 295 | 0, /* IndexBits */ |
| 296 | 0, /* DepthBits */ |
| 297 | 2, /* TexelBytes */ |
| 298 | fetch_1d_texel_argb4444, /* FetchTexel1D */ |
| 299 | fetch_2d_texel_argb4444, /* FetchTexel2D */ |
| 300 | fetch_3d_texel_argb4444, /* FetchTexel3D */ |
| 301 | }; |
| 302 | |
| 303 | const struct gl_texture_format _mesa_texformat_argb1555 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 304 | MESA_FORMAT_ARGB1555, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 305 | GL_RGBA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 306 | 5, /* RedBits */ |
| 307 | 5, /* GreenBits */ |
| 308 | 5, /* BlueBits */ |
| 309 | 1, /* AlphaBits */ |
| 310 | 0, /* LuminanceBits */ |
| 311 | 0, /* IntensityBits */ |
| 312 | 0, /* IndexBits */ |
| 313 | 0, /* DepthBits */ |
| 314 | 2, /* TexelBytes */ |
| 315 | fetch_1d_texel_argb1555, /* FetchTexel1D */ |
| 316 | fetch_2d_texel_argb1555, /* FetchTexel2D */ |
| 317 | fetch_3d_texel_argb1555, /* FetchTexel3D */ |
| 318 | }; |
| 319 | |
| 320 | const struct gl_texture_format _mesa_texformat_al88 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 321 | MESA_FORMAT_AL88, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 322 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 323 | 0, /* RedBits */ |
| 324 | 0, /* GreenBits */ |
| 325 | 0, /* BlueBits */ |
| 326 | 8, /* AlphaBits */ |
| 327 | 8, /* LuminanceBits */ |
| 328 | 0, /* IntensityBits */ |
| 329 | 0, /* IndexBits */ |
| 330 | 0, /* DepthBits */ |
| 331 | 2, /* TexelBytes */ |
| 332 | fetch_1d_texel_al88, /* FetchTexel1D */ |
| 333 | fetch_2d_texel_al88, /* FetchTexel2D */ |
| 334 | fetch_3d_texel_al88, /* FetchTexel3D */ |
| 335 | }; |
| 336 | |
| 337 | const struct gl_texture_format _mesa_texformat_rgb332 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 338 | MESA_FORMAT_RGB332, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 339 | GL_RGB, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 340 | 3, /* RedBits */ |
| 341 | 3, /* GreenBits */ |
| 342 | 2, /* BlueBits */ |
| 343 | 0, /* AlphaBits */ |
| 344 | 0, /* LuminanceBits */ |
| 345 | 0, /* IntensityBits */ |
| 346 | 0, /* IndexBits */ |
| 347 | 0, /* DepthBits */ |
| 348 | 1, /* TexelBytes */ |
| 349 | fetch_1d_texel_rgb332, /* FetchTexel1D */ |
| 350 | fetch_2d_texel_rgb332, /* FetchTexel2D */ |
| 351 | fetch_3d_texel_rgb332, /* FetchTexel3D */ |
| 352 | }; |
| 353 | |
| 354 | const struct gl_texture_format _mesa_texformat_a8 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 355 | MESA_FORMAT_A8, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 356 | GL_ALPHA, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 357 | 0, /* RedBits */ |
| 358 | 0, /* GreenBits */ |
| 359 | 0, /* BlueBits */ |
| 360 | 8, /* AlphaBits */ |
| 361 | 0, /* LuminanceBits */ |
| 362 | 0, /* IntensityBits */ |
| 363 | 0, /* IndexBits */ |
| 364 | 0, /* DepthBits */ |
| 365 | 1, /* TexelBytes */ |
| 366 | fetch_1d_texel_a8, /* FetchTexel1D */ |
| 367 | fetch_2d_texel_a8, /* FetchTexel2D */ |
| 368 | fetch_3d_texel_a8, /* FetchTexel3D */ |
| 369 | }; |
| 370 | |
| 371 | const struct gl_texture_format _mesa_texformat_l8 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 372 | MESA_FORMAT_L8, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 373 | GL_LUMINANCE, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 374 | 0, /* RedBits */ |
| 375 | 0, /* GreenBits */ |
| 376 | 0, /* BlueBits */ |
| 377 | 0, /* AlphaBits */ |
| 378 | 8, /* LuminanceBits */ |
| 379 | 0, /* IntensityBits */ |
| 380 | 0, /* IndexBits */ |
| 381 | 0, /* DepthBits */ |
| 382 | 1, /* TexelBytes */ |
| 383 | fetch_1d_texel_l8, /* FetchTexel1D */ |
| 384 | fetch_2d_texel_l8, /* FetchTexel2D */ |
| 385 | fetch_3d_texel_l8, /* FetchTexel3D */ |
| 386 | }; |
| 387 | |
| 388 | const struct gl_texture_format _mesa_texformat_i8 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 389 | MESA_FORMAT_I8, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 390 | GL_INTENSITY, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 391 | 0, /* RedBits */ |
| 392 | 0, /* GreenBits */ |
| 393 | 0, /* BlueBits */ |
| 394 | 0, /* AlphaBits */ |
| 395 | 0, /* LuminanceBits */ |
| 396 | 8, /* IntensityBits */ |
| 397 | 0, /* IndexBits */ |
| 398 | 0, /* DepthBits */ |
| 399 | 1, /* TexelBytes */ |
| 400 | fetch_1d_texel_i8, /* FetchTexel1D */ |
| 401 | fetch_2d_texel_i8, /* FetchTexel2D */ |
| 402 | fetch_3d_texel_i8, /* FetchTexel3D */ |
| 403 | }; |
| 404 | |
| 405 | const struct gl_texture_format _mesa_texformat_ci8 = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 406 | MESA_FORMAT_CI8, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 407 | GL_COLOR_INDEX, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 408 | 0, /* RedBits */ |
| 409 | 0, /* GreenBits */ |
| 410 | 0, /* BlueBits */ |
| 411 | 0, /* AlphaBits */ |
| 412 | 0, /* LuminanceBits */ |
| 413 | 0, /* IntensityBits */ |
| 414 | 8, /* IndexBits */ |
| 415 | 0, /* DepthBits */ |
| 416 | 1, /* TexelBytes */ |
| 417 | fetch_1d_texel_ci8, /* FetchTexel1D */ |
| 418 | fetch_2d_texel_ci8, /* FetchTexel2D */ |
| 419 | fetch_3d_texel_ci8, /* FetchTexel3D */ |
| 420 | }; |
| 421 | |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 422 | const struct gl_texture_format _mesa_texformat_ycbcr = { |
| 423 | MESA_FORMAT_YCBCR, /* MesaFormat */ |
| 424 | GL_YCBCR_MESA, /* BaseFormat */ |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 425 | 0, /* RedBits */ |
| 426 | 0, /* GreenBits */ |
| 427 | 0, /* BlueBits */ |
| 428 | 0, /* AlphaBits */ |
| 429 | 0, /* LuminanceBits */ |
| 430 | 0, /* IntensityBits */ |
| 431 | 0, /* IndexBits */ |
| 432 | 0, /* DepthBits */ |
| 433 | 2, /* TexelBytes */ |
| 434 | fetch_1d_texel_ycbcr, /* FetchTexel1D */ |
| 435 | fetch_2d_texel_ycbcr, /* FetchTexel2D */ |
| 436 | fetch_3d_texel_ycbcr, /* FetchTexel3D */ |
| 437 | }; |
| 438 | |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 439 | const struct gl_texture_format _mesa_texformat_ycbcr_rev = { |
| 440 | MESA_FORMAT_YCBCR_REV, /* MesaFormat */ |
| 441 | GL_YCBCR_MESA, /* BaseFormat */ |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 442 | 0, /* RedBits */ |
| 443 | 0, /* GreenBits */ |
| 444 | 0, /* BlueBits */ |
| 445 | 0, /* AlphaBits */ |
| 446 | 0, /* LuminanceBits */ |
| 447 | 0, /* IntensityBits */ |
| 448 | 0, /* IndexBits */ |
| 449 | 0, /* DepthBits */ |
| 450 | 2, /* TexelBytes */ |
| 451 | fetch_1d_texel_ycbcr_rev, /* FetchTexel1D */ |
| 452 | fetch_2d_texel_ycbcr_rev, /* FetchTexel2D */ |
| 453 | fetch_3d_texel_ycbcr_rev, /* FetchTexel3D */ |
| 454 | }; |
| 455 | |
| Daniel Borca | 40bd9d0 | 2003-10-29 14:35:31 +0000 | [diff] [blame^] | 456 | const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { |
| 457 | MESA_FORMAT_RGB_FXT1, /* MesaFormat */ |
| 458 | GL_RGB, /* BaseFormat */ |
| 459 | 4, /*approx*/ /* RedBits */ |
| 460 | 4, /*approx*/ /* GreenBits */ |
| 461 | 4, /*approx*/ /* BlueBits */ |
| 462 | 0, /* AlphaBits */ |
| 463 | 0, /* LuminanceBits */ |
| 464 | 0, /* IntensityBits */ |
| 465 | 0, /* IndexBits */ |
| 466 | 0, /* DepthBits */ |
| 467 | 0, /* TexelBytes */ |
| 468 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 469 | fetch_2d_texel_rgb_fxt1, /* FetchTexel2D */ |
| 470 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 471 | }; |
| 472 | |
| 473 | const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { |
| 474 | MESA_FORMAT_RGBA_FXT1, /* MesaFormat */ |
| 475 | GL_RGBA, /* BaseFormat */ |
| 476 | 4, /*approx*/ /* RedBits */ |
| 477 | 4, /*approx*/ /* GreenBits */ |
| 478 | 4, /*approx*/ /* BlueBits */ |
| 479 | 1, /*approx*/ /* AlphaBits */ |
| 480 | 0, /* LuminanceBits */ |
| 481 | 0, /* IntensityBits */ |
| 482 | 0, /* IndexBits */ |
| 483 | 0, /* DepthBits */ |
| 484 | 0, /* TexelBytes */ |
| 485 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 486 | fetch_2d_texel_rgba_fxt1, /* FetchTexel2D */ |
| 487 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 488 | }; |
| 489 | |
| Brian Paul | 7823388 | 2003-04-03 20:57:49 +0000 | [diff] [blame] | 490 | const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { |
| 491 | MESA_FORMAT_RGB_DXT1, /* MesaFormat */ |
| 492 | GL_RGB, /* BaseFormat */ |
| 493 | 4, /*approx*/ /* RedBits */ |
| 494 | 4, /*approx*/ /* GreenBits */ |
| 495 | 4, /*approx*/ /* BlueBits */ |
| 496 | 0, /* AlphaBits */ |
| 497 | 0, /* LuminanceBits */ |
| 498 | 0, /* IntensityBits */ |
| 499 | 0, /* IndexBits */ |
| 500 | 0, /* DepthBits */ |
| 501 | 0, /* TexelBytes */ |
| 502 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 503 | fetch_2d_texel_rgb_dxt1, /* FetchTexel2D */ |
| 504 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 505 | }; |
| 506 | |
| 507 | const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { |
| 508 | MESA_FORMAT_RGBA_DXT1, /* MesaFormat */ |
| 509 | GL_RGBA, /* BaseFormat */ |
| 510 | 4, /*approx*/ /* RedBits */ |
| 511 | 4, /*approx*/ /* GreenBits */ |
| 512 | 4, /*approx*/ /* BlueBits */ |
| 513 | 1, /*approx*/ /* AlphaBits */ |
| 514 | 0, /* LuminanceBits */ |
| 515 | 0, /* IntensityBits */ |
| 516 | 0, /* IndexBits */ |
| 517 | 0, /* DepthBits */ |
| 518 | 0, /* TexelBytes */ |
| 519 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 520 | fetch_2d_texel_rgba_dxt1, /* FetchTexel2D */ |
| 521 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 522 | }; |
| 523 | |
| 524 | const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { |
| 525 | MESA_FORMAT_RGBA_DXT3, /* MesaFormat */ |
| 526 | GL_RGBA, /* BaseFormat */ |
| 527 | 4, /*approx*/ /* RedBits */ |
| 528 | 4, /*approx*/ /* GreenBits */ |
| 529 | 4, /*approx*/ /* BlueBits */ |
| 530 | 4, /*approx*/ /* AlphaBits */ |
| 531 | 0, /* LuminanceBits */ |
| 532 | 0, /* IntensityBits */ |
| 533 | 0, /* IndexBits */ |
| 534 | 0, /* DepthBits */ |
| 535 | 0, /* TexelBytes */ |
| 536 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 537 | fetch_2d_texel_rgba_dxt3, /* FetchTexel2D */ |
| 538 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 539 | }; |
| 540 | |
| 541 | const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { |
| 542 | MESA_FORMAT_RGBA_DXT5, /* MesaFormat */ |
| 543 | GL_RGBA, /* BaseFormat */ |
| 544 | 4,/*approx*/ /* RedBits */ |
| 545 | 4,/*approx*/ /* GreenBits */ |
| 546 | 4,/*approx*/ /* BlueBits */ |
| 547 | 4,/*approx*/ /* AlphaBits */ |
| 548 | 0, /* LuminanceBits */ |
| 549 | 0, /* IntensityBits */ |
| 550 | 0, /* IndexBits */ |
| 551 | 0, /* DepthBits */ |
| 552 | 0, /* TexelBytes */ |
| 553 | NULL, /*impossible*/ /* FetchTexel1D */ |
| 554 | fetch_2d_texel_rgba_dxt5, /* FetchTexel2D */ |
| 555 | NULL, /*impossible*/ /* FetchTexel3D */ |
| 556 | }; |
| 557 | |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 558 | |
| Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 559 | /* Big-endian */ |
| 560 | #if 0 |
| 561 | const struct gl_texture_format _mesa_texformat_abgr8888 = { |
| 562 | MESA_FORMAT_ABGR8888, /* MesaFormat */ |
| 563 | GL_RGBA, /* BaseFormat */ |
| 564 | GL_UNSIGNED_INT_8_8_8_8, /* Type */ |
| 565 | 8, /* RedBits */ |
| 566 | 8, /* GreenBits */ |
| 567 | 8, /* BlueBits */ |
| 568 | 8, /* AlphaBits */ |
| 569 | 0, /* LuminanceBits */ |
| 570 | 0, /* IntensityBits */ |
| 571 | 0, /* IndexBits */ |
| 572 | 0, /* DepthBits */ |
| 573 | 4, /* TexelBytes */ |
| 574 | fetch_1d_texel_abgr8888, /* FetchTexel1D */ |
| 575 | fetch_2d_texel_abgr8888, /* FetchTexel2D */ |
| 576 | fetch_3d_texel_abgr8888, /* FetchTexel3D */ |
| 577 | }; |
| 578 | |
| 579 | const struct gl_texture_format _mesa_texformat_bgra8888 = { |
| 580 | MESA_FORMAT_BGRA8888, /* MesaFormat */ |
| 581 | GL_RGBA, /* BaseFormat */ |
| 582 | GL_UNSIGNED_INT_8_8_8_8, /* Type */ |
| 583 | 8, /* RedBits */ |
| 584 | 8, /* GreenBits */ |
| 585 | 8, /* BlueBits */ |
| 586 | 8, /* AlphaBits */ |
| 587 | 0, /* LuminanceBits */ |
| 588 | 0, /* IntensityBits */ |
| 589 | 0, /* IndexBits */ |
| 590 | 0, /* DepthBits */ |
| 591 | 4, /* TexelBytes */ |
| 592 | fetch_1d_texel_bgra8888, /* FetchTexel1D */ |
| 593 | fetch_2d_texel_bgra8888, /* FetchTexel2D */ |
| 594 | fetch_3d_texel_bgra8888, /* FetchTexel3D */ |
| 595 | }; |
| 596 | |
| 597 | const struct gl_texture_format _mesa_texformat_bgr888 = { |
| 598 | MESA_FORMAT_BGR888, /* MesaFormat */ |
| 599 | GL_RGB, /* BaseFormat */ |
| 600 | GL_UNSIGNED_BYTE, /* Type */ |
| 601 | 8, /* RedBits */ |
| 602 | 8, /* GreenBits */ |
| 603 | 8, /* BlueBits */ |
| 604 | 0, /* AlphaBits */ |
| 605 | 0, /* LuminanceBits */ |
| 606 | 0, /* IntensityBits */ |
| 607 | 0, /* IndexBits */ |
| 608 | 0, /* DepthBits */ |
| 609 | 3, /* TexelBytes */ |
| 610 | fetch_1d_texel_bgr888, /* FetchTexel1D */ |
| 611 | fetch_2d_texel_bgr888, /* FetchTexel2D */ |
| 612 | fetch_3d_texel_bgr888, /* FetchTexel3D */ |
| 613 | }; |
| 614 | |
| 615 | const struct gl_texture_format _mesa_texformat_bgr565 = { |
| 616 | MESA_FORMAT_BGR565, /* MesaFormat */ |
| 617 | GL_RGB, /* BaseFormat */ |
| 618 | GL_UNSIGNED_SHORT_5_6_5, /* Type */ |
| 619 | 5, /* RedBits */ |
| 620 | 6, /* GreenBits */ |
| 621 | 5, /* BlueBits */ |
| 622 | 0, /* AlphaBits */ |
| 623 | 0, /* LuminanceBits */ |
| 624 | 0, /* IntensityBits */ |
| 625 | 0, /* IndexBits */ |
| 626 | 0, /* DepthBits */ |
| 627 | 2, /* TexelBytes */ |
| 628 | fetch_1d_texel_bgr565, /* FetchTexel1D */ |
| 629 | fetch_2d_texel_bgr565, /* FetchTexel2D */ |
| 630 | fetch_3d_texel_bgr565, /* FetchTexel3D */ |
| 631 | }; |
| 632 | |
| 633 | const struct gl_texture_format _mesa_texformat_bgra4444 = { |
| 634 | MESA_FORMAT_BGRA4444, /* MesaFormat */ |
| 635 | GL_RGBA, /* BaseFormat */ |
| 636 | GL_UNSIGNED_SHORT_4_4_4_4_REV, /* Type */ |
| 637 | 4, /* RedBits */ |
| 638 | 4, /* GreenBits */ |
| 639 | 4, /* BlueBits */ |
| 640 | 4, /* AlphaBits */ |
| 641 | 0, /* LuminanceBits */ |
| 642 | 0, /* IntensityBits */ |
| 643 | 0, /* IndexBits */ |
| 644 | 0, /* DepthBits */ |
| 645 | 2, /* TexelBytes */ |
| 646 | fetch_1d_texel_bgra4444, /* FetchTexel1D */ |
| 647 | fetch_2d_texel_bgra4444, /* FetchTexel2D */ |
| 648 | fetch_3d_texel_bgra4444, /* FetchTexel3D */ |
| 649 | }; |
| 650 | |
| 651 | const struct gl_texture_format _mesa_texformat_bgra5551 = { |
| 652 | MESA_FORMAT_BGRA5551, /* MesaFormat */ |
| 653 | GL_RGBA, /* BaseFormat */ |
| 654 | GL_UNSIGNED_SHORT_1_5_5_5_REV, /* Type */ |
| 655 | 5, /* RedBits */ |
| 656 | 5, /* GreenBits */ |
| 657 | 5, /* BlueBits */ |
| 658 | 1, /* AlphaBits */ |
| 659 | 0, /* LuminanceBits */ |
| 660 | 0, /* IntensityBits */ |
| 661 | 0, /* IndexBits */ |
| 662 | 0, /* DepthBits */ |
| 663 | 2, /* TexelBytes */ |
| 664 | fetch_1d_texel_bgra1555, /* FetchTexel1D */ |
| 665 | fetch_2d_texel_bgra1555, /* FetchTexel2D */ |
| 666 | fetch_3d_texel_bgra1555, /* FetchTexel3D */ |
| 667 | }; |
| 668 | |
| 669 | const struct gl_texture_format _mesa_texformat_la88 = { |
| 670 | MESA_FORMAT_LA88, /* MesaFormat */ |
| 671 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
| 672 | GL_UNSIGNED_BYTE, /* Type */ |
| 673 | 0, /* RedBits */ |
| 674 | 0, /* GreenBits */ |
| 675 | 0, /* BlueBits */ |
| 676 | 8, /* AlphaBits */ |
| 677 | 8, /* LuminanceBits */ |
| 678 | 0, /* IntensityBits */ |
| 679 | 0, /* IndexBits */ |
| 680 | 0, /* DepthBits */ |
| 681 | 2, /* TexelBytes */ |
| 682 | fetch_1d_texel_la88, /* FetchTexel1D */ |
| 683 | fetch_2d_texel_la88, /* FetchTexel2D */ |
| 684 | fetch_3d_texel_la88, /* FetchTexel3D */ |
| 685 | }; |
| 686 | |
| 687 | const struct gl_texture_format _mesa_texformat_bgr233 = { |
| 688 | MESA_FORMAT_BGR233, /* MesaFormat */ |
| 689 | GL_RGB, /* BaseFormat */ |
| 690 | GL_UNSIGNED_BYTE_3_3_2, /* Type */ |
| 691 | 3, /* RedBits */ |
| 692 | 3, /* GreenBits */ |
| 693 | 2, /* BlueBits */ |
| 694 | 0, /* AlphaBits */ |
| 695 | 0, /* LuminanceBits */ |
| 696 | 0, /* IntensityBits */ |
| 697 | 0, /* IndexBits */ |
| 698 | 0, /* DepthBits */ |
| 699 | 1, /* TexelBytes */ |
| 700 | fetch_1d_texel_bgr233, /* FetchTexel1D */ |
| 701 | fetch_2d_texel_bgr233, /* FetchTexel2D */ |
| 702 | fetch_3d_texel_bgr233, /* FetchTexel3D */ |
| 703 | }; |
| 704 | #endif |
| 705 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 706 | /*@}*/ |
| 707 | |
| 708 | |
| 709 | /***************************************************************/ |
| 710 | /** \name Null format (useful for proxy textures) */ |
| 711 | /*@{*/ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 712 | |
| 713 | const struct gl_texture_format _mesa_null_texformat = { |
| Gareth Hughes | 38f2866 | 2001-03-28 20:40:51 +0000 | [diff] [blame] | 714 | -1, /* MesaFormat */ |
| Brian Paul | 1c85aa3 | 2001-04-20 16:46:04 +0000 | [diff] [blame] | 715 | 0, /* BaseFormat */ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 716 | 0, /* RedBits */ |
| 717 | 0, /* GreenBits */ |
| 718 | 0, /* BlueBits */ |
| 719 | 0, /* AlphaBits */ |
| 720 | 0, /* LuminanceBits */ |
| 721 | 0, /* IntensityBits */ |
| 722 | 0, /* IndexBits */ |
| 723 | 0, /* DepthBits */ |
| 724 | 0, /* TexelBytes */ |
| 725 | fetch_null_texel, /* FetchTexel1D */ |
| 726 | fetch_null_texel, /* FetchTexel2D */ |
| 727 | fetch_null_texel, /* FetchTexel3D */ |
| 728 | }; |
| 729 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 730 | /*@}*/ |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 731 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 732 | |
| 733 | /** |
| 734 | * Determine whether a given texture format is a hardware texture |
| 735 | * format. |
| 736 | * |
| 737 | * \param format texture format. |
| 738 | * |
| 739 | * \return GL_TRUE if \p format is a hardware texture format, or GL_FALSE |
| 740 | * otherwise. |
| 741 | * |
| 742 | * \p format is a hardware texture format if gl_texture_format::MesaFormat is |
| 743 | * lower than _format::MESA_FORMAT_RGBA. |
| 744 | */ |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 745 | GLboolean |
| 746 | _mesa_is_hardware_tex_format( const struct gl_texture_format *format ) |
| 747 | { |
| 748 | return (format->MesaFormat < MESA_FORMAT_RGBA); |
| 749 | } |
| 750 | |
| 751 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 752 | /** |
| 753 | * Choose an appropriate texture format. |
| 754 | * |
| 755 | * \param ctx GL context. |
| 756 | * \param internalFormat internal texture format. |
| 757 | * \param format pixel format. |
| 758 | * \param type data type. |
| 759 | * |
| 760 | * \return a pointer to a gl_texture_format in which to store the texture on |
| 761 | * success, or NULL on failure. |
| 762 | * |
| 763 | * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers |
| 764 | * typically override this function with a specialized version. |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 765 | */ |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 766 | const struct gl_texture_format * |
| 767 | _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, |
| 768 | GLenum format, GLenum type ) |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 769 | { |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 770 | (void) format; |
| 771 | (void) type; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 772 | |
| 773 | switch ( internalFormat ) { |
| 774 | /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has |
| 775 | * got to be better than sticking them way down the end of this |
| 776 | * huge list. |
| 777 | */ |
| 778 | case 4: /* Quake3 uses this... */ |
| 779 | case GL_RGBA: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 780 | return &_mesa_texformat_rgba; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 781 | |
| 782 | case 3: /* ... and this. */ |
| 783 | case GL_RGB: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 784 | return &_mesa_texformat_rgb; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 785 | |
| 786 | /* GH: Okay, keep checking as normal. Still test for GL_RGB, |
| 787 | * GL_RGBA formats first. |
| 788 | */ |
| 789 | case GL_RGBA2: |
| 790 | case GL_RGBA4: |
| 791 | case GL_RGB5_A1: |
| 792 | case GL_RGBA8: |
| 793 | case GL_RGB10_A2: |
| 794 | case GL_RGBA12: |
| 795 | case GL_RGBA16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 796 | return &_mesa_texformat_rgba; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 797 | |
| 798 | case GL_R3_G3_B2: |
| 799 | case GL_RGB4: |
| 800 | case GL_RGB5: |
| 801 | case GL_RGB8: |
| 802 | case GL_RGB10: |
| 803 | case GL_RGB12: |
| 804 | case GL_RGB16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 805 | return &_mesa_texformat_rgb; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 806 | |
| 807 | case GL_ALPHA: |
| 808 | case GL_ALPHA4: |
| 809 | case GL_ALPHA8: |
| 810 | case GL_ALPHA12: |
| 811 | case GL_ALPHA16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 812 | return &_mesa_texformat_alpha; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 813 | |
| 814 | case 1: |
| 815 | case GL_LUMINANCE: |
| 816 | case GL_LUMINANCE4: |
| 817 | case GL_LUMINANCE8: |
| 818 | case GL_LUMINANCE12: |
| 819 | case GL_LUMINANCE16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 820 | return &_mesa_texformat_luminance; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 821 | |
| 822 | case 2: |
| 823 | case GL_LUMINANCE_ALPHA: |
| 824 | case GL_LUMINANCE4_ALPHA4: |
| 825 | case GL_LUMINANCE6_ALPHA2: |
| 826 | case GL_LUMINANCE8_ALPHA8: |
| 827 | case GL_LUMINANCE12_ALPHA4: |
| 828 | case GL_LUMINANCE12_ALPHA12: |
| 829 | case GL_LUMINANCE16_ALPHA16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 830 | return &_mesa_texformat_luminance_alpha; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 831 | |
| 832 | case GL_INTENSITY: |
| 833 | case GL_INTENSITY4: |
| 834 | case GL_INTENSITY8: |
| 835 | case GL_INTENSITY12: |
| 836 | case GL_INTENSITY16: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 837 | return &_mesa_texformat_intensity; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 838 | |
| 839 | case GL_COLOR_INDEX: |
| 840 | case GL_COLOR_INDEX1_EXT: |
| 841 | case GL_COLOR_INDEX2_EXT: |
| 842 | case GL_COLOR_INDEX4_EXT: |
| 843 | case GL_COLOR_INDEX8_EXT: |
| 844 | case GL_COLOR_INDEX12_EXT: |
| 845 | case GL_COLOR_INDEX16_EXT: |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 846 | return &_mesa_texformat_color_index; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 847 | |
| 848 | case GL_DEPTH_COMPONENT: |
| 849 | case GL_DEPTH_COMPONENT16_SGIX: |
| 850 | case GL_DEPTH_COMPONENT24_SGIX: |
| 851 | case GL_DEPTH_COMPONENT32_SGIX: |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 852 | if (!ctx->Extensions.SGIX_depth_texture) |
| 853 | _mesa_problem(ctx, "depth format without GL_SGIX_depth_texture"); |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 854 | return &_mesa_texformat_depth_component; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 855 | |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 856 | case GL_COMPRESSED_ALPHA_ARB: |
| 857 | if (!ctx->Extensions.ARB_texture_compression) |
| 858 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| 859 | return &_mesa_texformat_alpha; |
| 860 | case GL_COMPRESSED_LUMINANCE_ARB: |
| 861 | if (!ctx->Extensions.ARB_texture_compression) |
| 862 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| 863 | return &_mesa_texformat_luminance; |
| 864 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: |
| 865 | if (!ctx->Extensions.ARB_texture_compression) |
| 866 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| 867 | return &_mesa_texformat_luminance_alpha; |
| 868 | case GL_COMPRESSED_INTENSITY_ARB: |
| 869 | if (!ctx->Extensions.ARB_texture_compression) |
| 870 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| 871 | return &_mesa_texformat_intensity; |
| 872 | case GL_COMPRESSED_RGB_ARB: |
| 873 | if (!ctx->Extensions.ARB_texture_compression) |
| 874 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| Daniel Borca | 40bd9d0 | 2003-10-29 14:35:31 +0000 | [diff] [blame^] | 875 | if (ctx->Extensions.TDFX_texture_compression_FXT1) |
| 876 | return &_mesa_texformat_rgb_fxt1; |
| 877 | else if (ctx->Extensions.EXT_texture_compression_s3tc) |
| Brian Paul | 7823388 | 2003-04-03 20:57:49 +0000 | [diff] [blame] | 878 | return &_mesa_texformat_rgb_dxt1; |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 879 | return &_mesa_texformat_rgb; |
| 880 | case GL_COMPRESSED_RGBA_ARB: |
| 881 | if (!ctx->Extensions.ARB_texture_compression) |
| 882 | _mesa_problem(ctx, "texture compression extension not enabled"); |
| Daniel Borca | 40bd9d0 | 2003-10-29 14:35:31 +0000 | [diff] [blame^] | 883 | if (ctx->Extensions.TDFX_texture_compression_FXT1) |
| 884 | return &_mesa_texformat_rgba_fxt1; |
| 885 | else if (ctx->Extensions.EXT_texture_compression_s3tc) |
| Brian Paul | 7823388 | 2003-04-03 20:57:49 +0000 | [diff] [blame] | 886 | return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1! See the spec */ |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 887 | return &_mesa_texformat_rgba; |
| 888 | |
| Brian Paul | 89fb06f | 2002-09-27 02:45:37 +0000 | [diff] [blame] | 889 | /* GL_MESA_ycrcr_texture */ |
| Brian Paul | c5b9950 | 2002-09-21 16:51:25 +0000 | [diff] [blame] | 890 | case GL_YCBCR_MESA: |
| 891 | if (type == GL_UNSIGNED_SHORT_8_8_MESA) |
| 892 | return &_mesa_texformat_ycbcr; |
| 893 | else |
| 894 | return &_mesa_texformat_ycbcr_rev; |
| 895 | |
| Daniel Borca | 40bd9d0 | 2003-10-29 14:35:31 +0000 | [diff] [blame^] | 896 | /* GL_3DFX_texture_compression_FXT1 */ |
| 897 | case GL_COMPRESSED_RGB_FXT1_3DFX: |
| 898 | if (ctx->Extensions.TDFX_texture_compression_FXT1) |
| 899 | return &_mesa_texformat_rgb_fxt1; |
| 900 | else |
| 901 | return NULL; |
| 902 | case GL_COMPRESSED_RGBA_FXT1_3DFX: |
| 903 | if (ctx->Extensions.TDFX_texture_compression_FXT1) |
| 904 | return &_mesa_texformat_rgba_fxt1; |
| 905 | else |
| 906 | return NULL; |
| 907 | |
| Brian Paul | 7823388 | 2003-04-03 20:57:49 +0000 | [diff] [blame] | 908 | /* GL_EXT_texture_compression_s3tc */ |
| 909 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 910 | if (ctx->Extensions.EXT_texture_compression_s3tc) |
| 911 | return &_mesa_texformat_rgb_dxt1; |
| 912 | else |
| 913 | return NULL; |
| 914 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 915 | if (ctx->Extensions.EXT_texture_compression_s3tc) |
| 916 | return &_mesa_texformat_rgba_dxt1; |
| 917 | else |
| 918 | return NULL; |
| 919 | case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
| 920 | if (ctx->Extensions.EXT_texture_compression_s3tc) |
| 921 | return &_mesa_texformat_rgba_dxt3; |
| 922 | else |
| 923 | return NULL; |
| 924 | case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 925 | if (ctx->Extensions.EXT_texture_compression_s3tc) |
| 926 | return &_mesa_texformat_rgba_dxt5; |
| 927 | else |
| 928 | return NULL; |
| 929 | |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 930 | default: |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 931 | _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); |
| Brian Paul | 7d58f44 | 2001-04-04 21:54:20 +0000 | [diff] [blame] | 932 | return NULL; |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 933 | } |
| Gareth Hughes | 2c3d34c | 2001-03-18 08:53:49 +0000 | [diff] [blame] | 934 | } |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 935 | |
| 936 | |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 937 | /** |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 938 | * Return the base texture format for the given compressed format |
| Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 939 | * |
| 940 | * Called via dd_function_table::Driver.BaseCompressedTexFormat. |
| Brian Paul | e427666 | 2001-06-15 14:18:46 +0000 | [diff] [blame] | 941 | * This function is used by software rasterizers. Hardware drivers |
| 942 | * which support texture compression should not use this function but |
| 943 | * a specialized function instead. |
| 944 | */ |
| 945 | GLint |
| 946 | _mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat) |
| 947 | { |
| 948 | switch (intFormat) { |
| 949 | case GL_COMPRESSED_ALPHA_ARB: |
| 950 | return GL_ALPHA; |
| 951 | case GL_COMPRESSED_LUMINANCE_ARB: |
| 952 | return GL_LUMINANCE; |
| 953 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: |
| 954 | return GL_LUMINANCE_ALPHA; |
| 955 | case GL_COMPRESSED_INTENSITY_ARB: |
| 956 | return GL_INTENSITY; |
| 957 | case GL_COMPRESSED_RGB_ARB: |
| 958 | return GL_RGB; |
| 959 | case GL_COMPRESSED_RGBA_ARB: |
| 960 | return GL_RGBA; |
| 961 | default: |
| 962 | return -1; /* not a recognized compressed format */ |
| 963 | } |
| 964 | } |