Fix pow <small> and a very stypid bug with dummy srcs(0 equals to tmp0.x)</small...
[mesa.git] / src / mesa / main / texformat.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file texformat.c
28 * Texture formats.
29 *
30 * \author Gareth Hughes
31 */
32
33
34 #include "colormac.h"
35 #include "context.h"
36 #include "texformat.h"
37 #include "texstore.h"
38
39
40
41 /* Texel fetch routines for all supported formats
42 */
43 #define DIM 1
44 #include "texformat_tmp.h"
45
46 #define DIM 2
47 #include "texformat_tmp.h"
48
49 #define DIM 3
50 #include "texformat_tmp.h"
51
52 /**
53 * Null texel fetch function.
54 *
55 * Have to have this so the FetchTexel function pointer is never NULL.
56 */
57 static void fetch_null_texel( const struct gl_texture_image *texImage,
58 GLint i, GLint j, GLint k, GLchan *texel )
59 {
60 (void) texImage; (void) i; (void) j; (void) k;
61 texel[RCOMP] = 0;
62 texel[GCOMP] = 0;
63 texel[BCOMP] = 0;
64 texel[ACOMP] = 0;
65 _mesa_warning(NULL, "fetch_null_texel() called!");
66 }
67
68 static void fetch_null_texelf( const struct gl_texture_image *texImage,
69 GLint i, GLint j, GLint k, GLfloat *texel )
70 {
71 (void) texImage; (void) i; (void) j; (void) k;
72 texel[RCOMP] = 0.0;
73 texel[GCOMP] = 0.0;
74 texel[BCOMP] = 0.0;
75 texel[ACOMP] = 0.0;
76 _mesa_warning(NULL, "fetch_null_texelf() called!");
77 }
78
79 static void store_null_texel(struct gl_texture_image *texImage,
80 GLint i, GLint j, GLint k, const void *texel)
81 {
82 /* no-op */
83 }
84
85
86 /**
87 * Notes about the predefined gl_texture_formats:
88 *
89 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
90 * images, returning both GLchan values and GLfloat values. (six
91 * functions in total)
92 * You don't have to provide both the GLchan and GLfloat functions;
93 * just one or the other is OK. Mesa will use an "adaptor" to convert
94 * between GLchan/GLfloat when needed.
95 * Since the adaptors have small performance penalty, we provide both
96 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
97 */
98
99
100 /***************************************************************/
101 /** \name Default GLchan-based formats */
102 /*@{*/
103
104 const struct gl_texture_format _mesa_texformat_rgba = {
105 MESA_FORMAT_RGBA, /* MesaFormat */
106 GL_RGBA, /* BaseFormat */
107 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
108 CHAN_BITS, /* RedBits */
109 CHAN_BITS, /* GreenBits */
110 CHAN_BITS, /* BlueBits */
111 CHAN_BITS, /* AlphaBits */
112 0, /* LuminanceBits */
113 0, /* IntensityBits */
114 0, /* IndexBits */
115 0, /* DepthBits */
116 0, /* StencilBits */
117 4 * sizeof(GLchan), /* TexelBytes */
118 _mesa_texstore_rgba, /* StoreTexImageFunc */
119 fetch_texel_1d_rgba, /* FetchTexel1D */
120 fetch_texel_2d_rgba, /* FetchTexel2D */
121 fetch_texel_3d_rgba, /* FetchTexel3D */
122 fetch_texel_1d_f_rgba, /* FetchTexel1Df */
123 fetch_texel_2d_f_rgba, /* FetchTexel2Df */
124 fetch_texel_3d_f_rgba, /* FetchTexel3Df */
125 store_texel_rgba /* StoreTexel */
126 };
127
128 const struct gl_texture_format _mesa_texformat_rgb = {
129 MESA_FORMAT_RGB, /* MesaFormat */
130 GL_RGB, /* BaseFormat */
131 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
132 CHAN_BITS, /* RedBits */
133 CHAN_BITS, /* GreenBits */
134 CHAN_BITS, /* BlueBits */
135 0, /* AlphaBits */
136 0, /* LuminanceBits */
137 0, /* IntensityBits */
138 0, /* IndexBits */
139 0, /* DepthBits */
140 0, /* StencilBits */
141 3 * sizeof(GLchan), /* TexelBytes */
142 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
143 fetch_texel_1d_rgb, /* FetchTexel1D */
144 fetch_texel_2d_rgb, /* FetchTexel2D */
145 fetch_texel_3d_rgb, /* FetchTexel3D */
146 fetch_texel_1d_f_rgb, /* FetchTexel1Df */
147 fetch_texel_2d_f_rgb, /* FetchTexel2Df */
148 fetch_texel_3d_f_rgb, /* FetchTexel3Df */
149 store_texel_rgb /* StoreTexel */
150 };
151
152 const struct gl_texture_format _mesa_texformat_alpha = {
153 MESA_FORMAT_ALPHA, /* MesaFormat */
154 GL_ALPHA, /* BaseFormat */
155 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
156 0, /* RedBits */
157 0, /* GreenBits */
158 0, /* BlueBits */
159 CHAN_BITS, /* AlphaBits */
160 0, /* LuminanceBits */
161 0, /* IntensityBits */
162 0, /* IndexBits */
163 0, /* DepthBits */
164 0, /* StencilBits */
165 sizeof(GLchan), /* TexelBytes */
166 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
167 fetch_texel_1d_alpha, /* FetchTexel1D */
168 fetch_texel_2d_alpha, /* FetchTexel2D */
169 fetch_texel_3d_alpha, /* FetchTexel3D */
170 NULL, /* FetchTexel1Df */
171 NULL, /* FetchTexel2Df */
172 NULL, /* FetchTexel3Df */
173 store_texel_alpha /* StoreTexel */
174 };
175
176 const struct gl_texture_format _mesa_texformat_luminance = {
177 MESA_FORMAT_LUMINANCE, /* MesaFormat */
178 GL_LUMINANCE, /* BaseFormat */
179 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
180 0, /* RedBits */
181 0, /* GreenBits */
182 0, /* BlueBits */
183 0, /* AlphaBits */
184 CHAN_BITS, /* LuminanceBits */
185 0, /* IntensityBits */
186 0, /* IndexBits */
187 0, /* DepthBits */
188 0, /* StencilBits */
189 sizeof(GLchan), /* TexelBytes */
190 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
191 fetch_texel_1d_luminance, /* FetchTexel1D */
192 fetch_texel_2d_luminance, /* FetchTexel2D */
193 fetch_texel_3d_luminance, /* FetchTexel3D */
194 NULL, /* FetchTexel1Df */
195 NULL, /* FetchTexel2Df */
196 NULL, /* FetchTexel3Df */
197 store_texel_luminance /* StoreTexel */
198 };
199
200 const struct gl_texture_format _mesa_texformat_luminance_alpha = {
201 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
202 GL_LUMINANCE_ALPHA, /* BaseFormat */
203 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
204 0, /* RedBits */
205 0, /* GreenBits */
206 0, /* BlueBits */
207 CHAN_BITS, /* AlphaBits */
208 CHAN_BITS, /* LuminanceBits */
209 0, /* IntensityBits */
210 0, /* IndexBits */
211 0, /* DepthBits */
212 0, /* StencilBits */
213 2 * sizeof(GLchan), /* TexelBytes */
214 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
215 fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
216 fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
217 fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
218 NULL, /* FetchTexel1Df */
219 NULL, /* FetchTexel2Df */
220 NULL, /* FetchTexel3Df */
221 store_texel_luminance_alpha /* StoreTexel */
222 };
223
224 const struct gl_texture_format _mesa_texformat_intensity = {
225 MESA_FORMAT_INTENSITY, /* MesaFormat */
226 GL_INTENSITY, /* BaseFormat */
227 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
228 0, /* RedBits */
229 0, /* GreenBits */
230 0, /* BlueBits */
231 0, /* AlphaBits */
232 0, /* LuminanceBits */
233 CHAN_BITS, /* IntensityBits */
234 0, /* IndexBits */
235 0, /* DepthBits */
236 0, /* StencilBits */
237 sizeof(GLchan), /* TexelBytes */
238 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
239 fetch_texel_1d_intensity, /* FetchTexel1D */
240 fetch_texel_2d_intensity, /* FetchTexel2D */
241 fetch_texel_3d_intensity, /* FetchTexel3D */
242 NULL, /* FetchTexel1Df */
243 NULL, /* FetchTexel2Df */
244 NULL, /* FetchTexel3Df */
245 store_texel_intensity /* StoreTexel */
246 };
247
248 const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
249 MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
250 GL_DEPTH_COMPONENT, /* BaseFormat */
251 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
252 0, /* RedBits */
253 0, /* GreenBits */
254 0, /* BlueBits */
255 0, /* AlphaBits */
256 0, /* LuminanceBits */
257 0, /* IntensityBits */
258 0, /* IndexBits */
259 sizeof(GLfloat) * 8, /* DepthBits */
260 sizeof(GLfloat) * 8, /* StencilBits */
261 sizeof(GLfloat), /* TexelBytes */
262 _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
263 NULL, /* FetchTexel1D */
264 NULL, /* FetchTexel1D */
265 NULL, /* FetchTexel1D */
266 fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
267 fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
268 fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
269 store_texel_depth_component_f32 /* StoreTexel */
270 };
271
272 const struct gl_texture_format _mesa_texformat_depth_component16 = {
273 MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
274 GL_DEPTH_COMPONENT, /* BaseFormat */
275 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
276 0, /* RedBits */
277 0, /* GreenBits */
278 0, /* BlueBits */
279 0, /* AlphaBits */
280 0, /* LuminanceBits */
281 0, /* IntensityBits */
282 0, /* IndexBits */
283 sizeof(GLushort) * 8, /* DepthBits */
284 sizeof(GLushort) * 8, /* StencilBits */
285 sizeof(GLushort), /* TexelBytes */
286 _mesa_texstore_depth_component16, /* StoreTexImageFunc */
287 NULL, /* FetchTexel1D */
288 NULL, /* FetchTexel1D */
289 NULL, /* FetchTexel1D */
290 fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
291 fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
292 fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
293 store_texel_depth_component16 /* StoreTexel */
294 };
295
296 const struct gl_texture_format _mesa_texformat_rgba_float32 = {
297 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
298 GL_RGBA, /* BaseFormat */
299 GL_FLOAT, /* DataType */
300 8 * sizeof(GLfloat), /* RedBits */
301 8 * sizeof(GLfloat), /* GreenBits */
302 8 * sizeof(GLfloat), /* BlueBits */
303 8 * sizeof(GLfloat), /* AlphaBits */
304 0, /* LuminanceBits */
305 0, /* IntensityBits */
306 0, /* IndexBits */
307 0, /* DepthBits */
308 0, /* StencilBits */
309 4 * sizeof(GLfloat), /* TexelBytes */
310 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
311 NULL, /* FetchTexel1D */
312 NULL, /* FetchTexel1D */
313 NULL, /* FetchTexel1D */
314 fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
315 fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
316 fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
317 store_texel_rgba_f32 /* StoreTexel */
318 };
319
320 const struct gl_texture_format _mesa_texformat_rgba_float16 = {
321 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
322 GL_RGBA, /* BaseFormat */
323 GL_FLOAT, /* DataType */
324 8 * sizeof(GLhalfARB), /* RedBits */
325 8 * sizeof(GLhalfARB), /* GreenBits */
326 8 * sizeof(GLhalfARB), /* BlueBits */
327 8 * sizeof(GLhalfARB), /* AlphaBits */
328 0, /* LuminanceBits */
329 0, /* IntensityBits */
330 0, /* IndexBits */
331 0, /* DepthBits */
332 0, /* StencilBits */
333 4 * sizeof(GLhalfARB), /* TexelBytes */
334 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
335 NULL, /* FetchTexel1D */
336 NULL, /* FetchTexel1D */
337 NULL, /* FetchTexel1D */
338 fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
339 fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
340 fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
341 store_texel_rgba_f16 /* StoreTexel */
342 };
343
344 const struct gl_texture_format _mesa_texformat_rgb_float32 = {
345 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
346 GL_RGB, /* BaseFormat */
347 GL_FLOAT, /* DataType */
348 8 * sizeof(GLfloat), /* RedBits */
349 8 * sizeof(GLfloat), /* GreenBits */
350 8 * sizeof(GLfloat), /* BlueBits */
351 0, /* AlphaBits */
352 0, /* LuminanceBits */
353 0, /* IntensityBits */
354 0, /* IndexBits */
355 0, /* DepthBits */
356 0, /* StencilBits */
357 3 * sizeof(GLfloat), /* TexelBytes */
358 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
359 NULL, /* FetchTexel1D */
360 NULL, /* FetchTexel1D */
361 NULL, /* FetchTexel1D */
362 fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
363 fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
364 fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
365 store_texel_rgb_f32 /* StoreTexel */
366 };
367
368 const struct gl_texture_format _mesa_texformat_rgb_float16 = {
369 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
370 GL_RGB, /* BaseFormat */
371 GL_FLOAT, /* DataType */
372 8 * sizeof(GLhalfARB), /* RedBits */
373 8 * sizeof(GLhalfARB), /* GreenBits */
374 8 * sizeof(GLhalfARB), /* BlueBits */
375 0, /* AlphaBits */
376 0, /* LuminanceBits */
377 0, /* IntensityBits */
378 0, /* IndexBits */
379 0, /* DepthBits */
380 0, /* StencilBits */
381 3 * sizeof(GLhalfARB), /* TexelBytes */
382 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
383 NULL, /* FetchTexel1D */
384 NULL, /* FetchTexel1D */
385 NULL, /* FetchTexel1D */
386 fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
387 fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
388 fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
389 store_texel_rgb_f16 /* StoreTexel */
390 };
391
392 const struct gl_texture_format _mesa_texformat_alpha_float32 = {
393 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
394 GL_ALPHA, /* BaseFormat */
395 GL_FLOAT, /* DataType */
396 0, /* RedBits */
397 0, /* GreenBits */
398 0, /* BlueBits */
399 8 * sizeof(GLfloat), /* AlphaBits */
400 0, /* LuminanceBits */
401 0, /* IntensityBits */
402 0, /* IndexBits */
403 0, /* DepthBits */
404 0, /* StencilBits */
405 1 * sizeof(GLfloat), /* TexelBytes */
406 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
407 NULL, /* FetchTexel1D */
408 NULL, /* FetchTexel1D */
409 NULL, /* FetchTexel1D */
410 fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
411 fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
412 fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
413 store_texel_alpha_f32 /* StoreTexel */
414 };
415
416 const struct gl_texture_format _mesa_texformat_alpha_float16 = {
417 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
418 GL_ALPHA, /* BaseFormat */
419 GL_FLOAT, /* DataType */
420 0, /* RedBits */
421 0, /* GreenBits */
422 0, /* BlueBits */
423 8 * sizeof(GLhalfARB), /* AlphaBits */
424 0, /* LuminanceBits */
425 0, /* IntensityBits */
426 0, /* IndexBits */
427 0, /* DepthBits */
428 0, /* StencilBits */
429 1 * sizeof(GLhalfARB), /* TexelBytes */
430 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
431 NULL, /* FetchTexel1D */
432 NULL, /* FetchTexel1D */
433 NULL, /* FetchTexel1D */
434 fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
435 fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
436 fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
437 store_texel_alpha_f16 /* StoreTexel */
438 };
439
440 const struct gl_texture_format _mesa_texformat_luminance_float32 = {
441 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
442 GL_LUMINANCE, /* BaseFormat */
443 GL_FLOAT, /* DataType */
444 0, /* RedBits */
445 0, /* GreenBits */
446 0, /* BlueBits */
447 0, /* AlphaBits */
448 8 * sizeof(GLfloat), /* LuminanceBits */
449 0, /* IntensityBits */
450 0, /* IndexBits */
451 0, /* DepthBits */
452 0, /* StencilBits */
453 1 * sizeof(GLfloat), /* TexelBytes */
454 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
455 NULL, /* FetchTexel1D */
456 NULL, /* FetchTexel2D */
457 NULL, /* FetchTexel3D */
458 fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
459 fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
460 fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
461 store_texel_luminance_f32 /* StoreTexel */
462 };
463
464 const struct gl_texture_format _mesa_texformat_luminance_float16 = {
465 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
466 GL_LUMINANCE, /* BaseFormat */
467 GL_FLOAT, /* DataType */
468 0, /* RedBits */
469 0, /* GreenBits */
470 0, /* BlueBits */
471 0, /* AlphaBits */
472 8 * sizeof(GLhalfARB), /* LuminanceBits */
473 0, /* IntensityBits */
474 0, /* IndexBits */
475 0, /* DepthBits */
476 0, /* StencilBits */
477 1 * sizeof(GLhalfARB), /* TexelBytes */
478 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
479 NULL, /* FetchTexel1D */
480 NULL, /* FetchTexel2D */
481 NULL, /* FetchTexel3D */
482 fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
483 fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
484 fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
485 store_texel_luminance_f16 /* StoreTexel */
486 };
487
488 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
489 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
490 GL_LUMINANCE_ALPHA, /* BaseFormat */
491 GL_FLOAT, /* DataType */
492 0, /* RedBits */
493 0, /* GreenBits */
494 0, /* BlueBits */
495 8 * sizeof(GLfloat), /* AlphaBits */
496 8 * sizeof(GLfloat), /* LuminanceBits */
497 0, /* IntensityBits */
498 0, /* IndexBits */
499 0, /* DepthBits */
500 0, /* StencilBits */
501 2 * sizeof(GLfloat), /* TexelBytes */
502 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
503 NULL, /* FetchTexel1D */
504 NULL, /* FetchTexel2D */
505 NULL, /* FetchTexel3D */
506 fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
507 fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
508 fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
509 store_texel_luminance_alpha_f32 /* StoreTexel */
510 };
511
512 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
513 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
514 GL_LUMINANCE_ALPHA, /* BaseFormat */
515 GL_FLOAT, /* DataType */
516 0, /* RedBits */
517 0, /* GreenBits */
518 0, /* BlueBits */
519 8 * sizeof(GLhalfARB), /* AlphaBits */
520 8 * sizeof(GLhalfARB), /* LuminanceBits */
521 0, /* IntensityBits */
522 0, /* IndexBits */
523 0, /* DepthBits */
524 0, /* StencilBits */
525 2 * sizeof(GLhalfARB), /* TexelBytes */
526 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
527 NULL, /* FetchTexel1D */
528 NULL, /* FetchTexel2D */
529 NULL, /* FetchTexel3D */
530 fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
531 fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
532 fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
533 store_texel_luminance_alpha_f16 /* StoreTexel */
534 };
535
536 const struct gl_texture_format _mesa_texformat_intensity_float32 = {
537 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
538 GL_INTENSITY, /* BaseFormat */
539 GL_FLOAT, /* DataType */
540 0, /* RedBits */
541 0, /* GreenBits */
542 0, /* BlueBits */
543 0, /* AlphaBits */
544 0, /* LuminanceBits */
545 8 * sizeof(GLfloat), /* IntensityBits */
546 0, /* IndexBits */
547 0, /* DepthBits */
548 0, /* StencilBits */
549 1 * sizeof(GLfloat), /* TexelBytes */
550 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
551 NULL, /* FetchTexel1D */
552 NULL, /* FetchTexel2D */
553 NULL, /* FetchTexel3D */
554 fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
555 fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
556 fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
557 store_texel_intensity_f32 /* StoreTexel */
558 };
559
560 const struct gl_texture_format _mesa_texformat_intensity_float16 = {
561 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
562 GL_INTENSITY, /* BaseFormat */
563 GL_FLOAT, /* DataType */
564 0, /* RedBits */
565 0, /* GreenBits */
566 0, /* BlueBits */
567 0, /* AlphaBits */
568 0, /* LuminanceBits */
569 8 * sizeof(GLhalfARB), /* IntensityBits */
570 0, /* IndexBits */
571 0, /* DepthBits */
572 0, /* StencilBits */
573 1 * sizeof(GLhalfARB), /* TexelBytes */
574 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
575 NULL, /* FetchTexel1D */
576 NULL, /* FetchTexel2D */
577 NULL, /* FetchTexel3D */
578 fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
579 fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
580 fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
581 store_texel_intensity_f16 /* StoreTexel */
582 };
583
584
585 /*@}*/
586
587
588 /***************************************************************/
589 /** \name Hardware formats */
590 /*@{*/
591
592 const struct gl_texture_format _mesa_texformat_rgba8888 = {
593 MESA_FORMAT_RGBA8888, /* MesaFormat */
594 GL_RGBA, /* BaseFormat */
595 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
596 8, /* RedBits */
597 8, /* GreenBits */
598 8, /* BlueBits */
599 8, /* AlphaBits */
600 0, /* LuminanceBits */
601 0, /* IntensityBits */
602 0, /* IndexBits */
603 0, /* DepthBits */
604 0, /* StencilBits */
605 4, /* TexelBytes */
606 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
607 fetch_texel_1d_rgba8888, /* FetchTexel1D */
608 fetch_texel_2d_rgba8888, /* FetchTexel2D */
609 fetch_texel_3d_rgba8888, /* FetchTexel3D */
610 NULL, /* FetchTexel1Df */
611 NULL, /* FetchTexel2Df */
612 NULL, /* FetchTexel3Df */
613 store_texel_rgba8888 /* StoreTexel */
614 };
615
616 const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
617 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
618 GL_RGBA, /* BaseFormat */
619 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
620 8, /* RedBits */
621 8, /* GreenBits */
622 8, /* BlueBits */
623 8, /* AlphaBits */
624 0, /* LuminanceBits */
625 0, /* IntensityBits */
626 0, /* IndexBits */
627 0, /* DepthBits */
628 0, /* StencilBits */
629 4, /* TexelBytes */
630 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
631 fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
632 fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
633 fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
634 NULL, /* FetchTexel1Df */
635 NULL, /* FetchTexel2Df */
636 NULL, /* FetchTexel3Df */
637 store_texel_rgba8888_rev /* StoreTexel */
638 };
639
640 const struct gl_texture_format _mesa_texformat_argb8888 = {
641 MESA_FORMAT_ARGB8888, /* MesaFormat */
642 GL_RGBA, /* BaseFormat */
643 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
644 8, /* RedBits */
645 8, /* GreenBits */
646 8, /* BlueBits */
647 8, /* AlphaBits */
648 0, /* LuminanceBits */
649 0, /* IntensityBits */
650 0, /* IndexBits */
651 0, /* DepthBits */
652 0, /* StencilBits */
653 4, /* TexelBytes */
654 _mesa_texstore_argb8888, /* StoreTexImageFunc */
655 fetch_texel_1d_argb8888, /* FetchTexel1D */
656 fetch_texel_2d_argb8888, /* FetchTexel2D */
657 fetch_texel_3d_argb8888, /* FetchTexel3D */
658 NULL, /* FetchTexel1Df */
659 NULL, /* FetchTexel2Df */
660 NULL, /* FetchTexel3Df */
661 store_texel_argb8888 /* StoreTexel */
662 };
663
664 const struct gl_texture_format _mesa_texformat_argb8888_rev = {
665 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
666 GL_RGBA, /* BaseFormat */
667 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
668 8, /* RedBits */
669 8, /* GreenBits */
670 8, /* BlueBits */
671 8, /* AlphaBits */
672 0, /* LuminanceBits */
673 0, /* IntensityBits */
674 0, /* IndexBits */
675 0, /* DepthBits */
676 0, /* StencilBits */
677 4, /* TexelBytes */
678 _mesa_texstore_argb8888, /* StoreTexImageFunc */
679 fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
680 fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
681 fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
682 NULL, /* FetchTexel1Df */
683 NULL, /* FetchTexel2Df */
684 NULL, /* FetchTexel3Df */
685 store_texel_argb8888_rev /* StoreTexel */
686 };
687
688 const struct gl_texture_format _mesa_texformat_rgb888 = {
689 MESA_FORMAT_RGB888, /* MesaFormat */
690 GL_RGB, /* BaseFormat */
691 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
692 8, /* RedBits */
693 8, /* GreenBits */
694 8, /* BlueBits */
695 0, /* AlphaBits */
696 0, /* LuminanceBits */
697 0, /* IntensityBits */
698 0, /* IndexBits */
699 0, /* DepthBits */
700 0, /* StencilBits */
701 3, /* TexelBytes */
702 _mesa_texstore_rgb888, /* StoreTexImageFunc */
703 fetch_texel_1d_rgb888, /* FetchTexel1D */
704 fetch_texel_2d_rgb888, /* FetchTexel2D */
705 fetch_texel_3d_rgb888, /* FetchTexel3D */
706 NULL, /* FetchTexel1Df */
707 NULL, /* FetchTexel2Df */
708 NULL, /* FetchTexel3Df */
709 store_texel_rgb888 /* StoreTexel */
710 };
711
712 const struct gl_texture_format _mesa_texformat_bgr888 = {
713 MESA_FORMAT_BGR888, /* MesaFormat */
714 GL_RGB, /* BaseFormat */
715 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
716 8, /* RedBits */
717 8, /* GreenBits */
718 8, /* BlueBits */
719 0, /* AlphaBits */
720 0, /* LuminanceBits */
721 0, /* IntensityBits */
722 0, /* IndexBits */
723 0, /* DepthBits */
724 0, /* StencilBits */
725 3, /* TexelBytes */
726 _mesa_texstore_bgr888, /* StoreTexImageFunc */
727 fetch_texel_1d_bgr888, /* FetchTexel1D */
728 fetch_texel_2d_bgr888, /* FetchTexel2D */
729 fetch_texel_3d_bgr888, /* FetchTexel3D */
730 NULL, /* FetchTexel1Df */
731 NULL, /* FetchTexel2Df */
732 NULL, /* FetchTexel3Df */
733 store_texel_bgr888 /* StoreTexel */
734 };
735
736 const struct gl_texture_format _mesa_texformat_rgb565 = {
737 MESA_FORMAT_RGB565, /* MesaFormat */
738 GL_RGB, /* BaseFormat */
739 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
740 5, /* RedBits */
741 6, /* GreenBits */
742 5, /* BlueBits */
743 0, /* AlphaBits */
744 0, /* LuminanceBits */
745 0, /* IntensityBits */
746 0, /* IndexBits */
747 0, /* DepthBits */
748 0, /* StencilBits */
749 2, /* TexelBytes */
750 _mesa_texstore_rgb565, /* StoreTexImageFunc */
751 fetch_texel_1d_rgb565, /* FetchTexel1D */
752 fetch_texel_2d_rgb565, /* FetchTexel2D */
753 fetch_texel_3d_rgb565, /* FetchTexel3D */
754 NULL, /* FetchTexel1Df */
755 NULL, /* FetchTexel2Df */
756 NULL, /* FetchTexel3Df */
757 store_texel_rgb565 /* StoreTexel */
758 };
759
760 const struct gl_texture_format _mesa_texformat_rgb565_rev = {
761 MESA_FORMAT_RGB565_REV, /* MesaFormat */
762 GL_RGB, /* BaseFormat */
763 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
764 5, /* RedBits */
765 6, /* GreenBits */
766 5, /* BlueBits */
767 0, /* AlphaBits */
768 0, /* LuminanceBits */
769 0, /* IntensityBits */
770 0, /* IndexBits */
771 0, /* DepthBits */
772 0, /* StencilBits */
773 2, /* TexelBytes */
774 _mesa_texstore_rgb565, /* StoreTexImageFunc */
775 fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
776 fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
777 fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
778 NULL, /* FetchTexel1Df */
779 NULL, /* FetchTexel2Df */
780 NULL, /* FetchTexel3Df */
781 store_texel_rgb565_rev /* StoreTexel */
782 };
783
784 const struct gl_texture_format _mesa_texformat_argb4444 = {
785 MESA_FORMAT_ARGB4444, /* MesaFormat */
786 GL_RGBA, /* BaseFormat */
787 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
788 4, /* RedBits */
789 4, /* GreenBits */
790 4, /* BlueBits */
791 4, /* AlphaBits */
792 0, /* LuminanceBits */
793 0, /* IntensityBits */
794 0, /* IndexBits */
795 0, /* DepthBits */
796 0, /* StencilBits */
797 2, /* TexelBytes */
798 _mesa_texstore_argb4444, /* StoreTexImageFunc */
799 fetch_texel_1d_argb4444, /* FetchTexel1D */
800 fetch_texel_2d_argb4444, /* FetchTexel2D */
801 fetch_texel_3d_argb4444, /* FetchTexel3D */
802 NULL, /* FetchTexel1Df */
803 NULL, /* FetchTexel2Df */
804 NULL, /* FetchTexel3Df */
805 store_texel_argb4444 /* StoreTexel */
806 };
807
808 const struct gl_texture_format _mesa_texformat_argb4444_rev = {
809 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
810 GL_RGBA, /* BaseFormat */
811 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
812 4, /* RedBits */
813 4, /* GreenBits */
814 4, /* BlueBits */
815 4, /* AlphaBits */
816 0, /* LuminanceBits */
817 0, /* IntensityBits */
818 0, /* IndexBits */
819 0, /* DepthBits */
820 0, /* StencilBits */
821 2, /* TexelBytes */
822 _mesa_texstore_argb4444, /* StoreTexImageFunc */
823 fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
824 fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
825 fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
826 NULL, /* FetchTexel1Df */
827 NULL, /* FetchTexel2Df */
828 NULL, /* FetchTexel3Df */
829 store_texel_argb4444_rev /* StoreTexel */
830 };
831
832 const struct gl_texture_format _mesa_texformat_argb1555 = {
833 MESA_FORMAT_ARGB1555, /* MesaFormat */
834 GL_RGBA, /* BaseFormat */
835 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
836 5, /* RedBits */
837 5, /* GreenBits */
838 5, /* BlueBits */
839 1, /* AlphaBits */
840 0, /* LuminanceBits */
841 0, /* IntensityBits */
842 0, /* IndexBits */
843 0, /* DepthBits */
844 0, /* StencilBits */
845 2, /* TexelBytes */
846 _mesa_texstore_argb1555, /* StoreTexImageFunc */
847 fetch_texel_1d_argb1555, /* FetchTexel1D */
848 fetch_texel_2d_argb1555, /* FetchTexel2D */
849 fetch_texel_3d_argb1555, /* FetchTexel3D */
850 NULL, /* FetchTexel1Df */
851 NULL, /* FetchTexel2Df */
852 NULL, /* FetchTexel3Df */
853 store_texel_argb1555 /* StoreTexel */
854 };
855
856 const struct gl_texture_format _mesa_texformat_argb1555_rev = {
857 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
858 GL_RGBA, /* BaseFormat */
859 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
860 5, /* RedBits */
861 5, /* GreenBits */
862 5, /* BlueBits */
863 1, /* AlphaBits */
864 0, /* LuminanceBits */
865 0, /* IntensityBits */
866 0, /* IndexBits */
867 0, /* DepthBits */
868 0, /* StencilBits */
869 2, /* TexelBytes */
870 _mesa_texstore_argb1555, /* StoreTexImageFunc */
871 fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
872 fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
873 fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
874 NULL, /* FetchTexel1Df */
875 NULL, /* FetchTexel2Df */
876 NULL, /* FetchTexel3Df */
877 store_texel_argb1555_rev /* StoreTexel */
878 };
879
880 const struct gl_texture_format _mesa_texformat_al88 = {
881 MESA_FORMAT_AL88, /* MesaFormat */
882 GL_LUMINANCE_ALPHA, /* BaseFormat */
883 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
884 0, /* RedBits */
885 0, /* GreenBits */
886 0, /* BlueBits */
887 8, /* AlphaBits */
888 8, /* LuminanceBits */
889 0, /* IntensityBits */
890 0, /* IndexBits */
891 0, /* DepthBits */
892 0, /* StencilBits */
893 2, /* TexelBytes */
894 _mesa_texstore_al88, /* StoreTexImageFunc */
895 fetch_texel_1d_al88, /* FetchTexel1D */
896 fetch_texel_2d_al88, /* FetchTexel2D */
897 fetch_texel_3d_al88, /* FetchTexel3D */
898 NULL, /* FetchTexel1Df */
899 NULL, /* FetchTexel2Df */
900 NULL, /* FetchTexel3Df */
901 store_texel_al88 /* StoreTexel */
902 };
903
904 const struct gl_texture_format _mesa_texformat_al88_rev = {
905 MESA_FORMAT_AL88_REV, /* MesaFormat */
906 GL_LUMINANCE_ALPHA, /* BaseFormat */
907 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
908 0, /* RedBits */
909 0, /* GreenBits */
910 0, /* BlueBits */
911 8, /* AlphaBits */
912 8, /* LuminanceBits */
913 0, /* IntensityBits */
914 0, /* IndexBits */
915 0, /* DepthBits */
916 0, /* StencilBits */
917 2, /* TexelBytes */
918 _mesa_texstore_al88, /* StoreTexImageFunc */
919 fetch_texel_1d_al88_rev, /* FetchTexel1D */
920 fetch_texel_2d_al88_rev, /* FetchTexel2D */
921 fetch_texel_3d_al88_rev, /* FetchTexel3D */
922 NULL, /* FetchTexel1Df */
923 NULL, /* FetchTexel2Df */
924 NULL, /* FetchTexel3Df */
925 store_texel_al88_rev /* StoreTexel */
926 };
927
928 const struct gl_texture_format _mesa_texformat_rgb332 = {
929 MESA_FORMAT_RGB332, /* MesaFormat */
930 GL_RGB, /* BaseFormat */
931 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
932 3, /* RedBits */
933 3, /* GreenBits */
934 2, /* BlueBits */
935 0, /* AlphaBits */
936 0, /* LuminanceBits */
937 0, /* IntensityBits */
938 0, /* IndexBits */
939 0, /* DepthBits */
940 0, /* StencilBits */
941 1, /* TexelBytes */
942 _mesa_texstore_rgb332, /* StoreTexImageFunc */
943 fetch_texel_1d_rgb332, /* FetchTexel1D */
944 fetch_texel_2d_rgb332, /* FetchTexel2D */
945 fetch_texel_3d_rgb332, /* FetchTexel3D */
946 NULL, /* FetchTexel1Df */
947 NULL, /* FetchTexel2Df */
948 NULL, /* FetchTexel3Df */
949 store_texel_rgb332 /* StoreTexel */
950 };
951
952 const struct gl_texture_format _mesa_texformat_a8 = {
953 MESA_FORMAT_A8, /* MesaFormat */
954 GL_ALPHA, /* BaseFormat */
955 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
956 0, /* RedBits */
957 0, /* GreenBits */
958 0, /* BlueBits */
959 8, /* AlphaBits */
960 0, /* LuminanceBits */
961 0, /* IntensityBits */
962 0, /* IndexBits */
963 0, /* DepthBits */
964 0, /* StencilBits */
965 1, /* TexelBytes */
966 _mesa_texstore_a8, /* StoreTexImageFunc */
967 fetch_texel_1d_a8, /* FetchTexel1D */
968 fetch_texel_2d_a8, /* FetchTexel2D */
969 fetch_texel_3d_a8, /* FetchTexel3D */
970 NULL, /* FetchTexel1Df */
971 NULL, /* FetchTexel2Df */
972 NULL, /* FetchTexel3Df */
973 store_texel_a8 /* StoreTexel */
974 };
975
976 const struct gl_texture_format _mesa_texformat_l8 = {
977 MESA_FORMAT_L8, /* MesaFormat */
978 GL_LUMINANCE, /* BaseFormat */
979 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
980 0, /* RedBits */
981 0, /* GreenBits */
982 0, /* BlueBits */
983 0, /* AlphaBits */
984 8, /* LuminanceBits */
985 0, /* IntensityBits */
986 0, /* IndexBits */
987 0, /* DepthBits */
988 0, /* StencilBits */
989 1, /* TexelBytes */
990 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
991 fetch_texel_1d_l8, /* FetchTexel1D */
992 fetch_texel_2d_l8, /* FetchTexel2D */
993 fetch_texel_3d_l8, /* FetchTexel3D */
994 NULL, /* FetchTexel1Df */
995 NULL, /* FetchTexel2Df */
996 NULL, /* FetchTexel3Df */
997 store_texel_l8 /* StoreTexel */
998 };
999
1000 const struct gl_texture_format _mesa_texformat_i8 = {
1001 MESA_FORMAT_I8, /* MesaFormat */
1002 GL_INTENSITY, /* BaseFormat */
1003 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1004 0, /* RedBits */
1005 0, /* GreenBits */
1006 0, /* BlueBits */
1007 0, /* AlphaBits */
1008 0, /* LuminanceBits */
1009 8, /* IntensityBits */
1010 0, /* IndexBits */
1011 0, /* DepthBits */
1012 0, /* StencilBits */
1013 1, /* TexelBytes */
1014 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
1015 fetch_texel_1d_i8, /* FetchTexel1D */
1016 fetch_texel_2d_i8, /* FetchTexel2D */
1017 fetch_texel_3d_i8, /* FetchTexel3D */
1018 NULL, /* FetchTexel1Df */
1019 NULL, /* FetchTexel2Df */
1020 NULL, /* FetchTexel3Df */
1021 store_texel_i8 /* StoreTexel */
1022 };
1023
1024 const struct gl_texture_format _mesa_texformat_ci8 = {
1025 MESA_FORMAT_CI8, /* MesaFormat */
1026 GL_COLOR_INDEX, /* BaseFormat */
1027 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1028 0, /* RedBits */
1029 0, /* GreenBits */
1030 0, /* BlueBits */
1031 0, /* AlphaBits */
1032 0, /* LuminanceBits */
1033 0, /* IntensityBits */
1034 8, /* IndexBits */
1035 0, /* DepthBits */
1036 0, /* StencilBits */
1037 1, /* TexelBytes */
1038 _mesa_texstore_ci8, /* StoreTexImageFunc */
1039 fetch_texel_1d_ci8, /* FetchTexel1D */
1040 fetch_texel_2d_ci8, /* FetchTexel2D */
1041 fetch_texel_3d_ci8, /* FetchTexel3D */
1042 NULL, /* FetchTexel1Df */
1043 NULL, /* FetchTexel2Df */
1044 NULL, /* FetchTexel3Df */
1045 store_texel_ci8 /* StoreTexel */
1046 };
1047
1048 const struct gl_texture_format _mesa_texformat_ycbcr = {
1049 MESA_FORMAT_YCBCR, /* MesaFormat */
1050 GL_YCBCR_MESA, /* BaseFormat */
1051 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1052 0, /* RedBits */
1053 0, /* GreenBits */
1054 0, /* BlueBits */
1055 0, /* AlphaBits */
1056 0, /* LuminanceBits */
1057 0, /* IntensityBits */
1058 0, /* IndexBits */
1059 0, /* DepthBits */
1060 0, /* StencilBits */
1061 2, /* TexelBytes */
1062 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1063 fetch_texel_1d_ycbcr, /* FetchTexel1D */
1064 fetch_texel_2d_ycbcr, /* FetchTexel2D */
1065 fetch_texel_3d_ycbcr, /* FetchTexel3D */
1066 NULL, /* FetchTexel1Df */
1067 NULL, /* FetchTexel2Df */
1068 NULL, /* FetchTexel3Df */
1069 store_texel_ycbcr /* StoreTexel */
1070 };
1071
1072 const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1073 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1074 GL_YCBCR_MESA, /* BaseFormat */
1075 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1076 0, /* RedBits */
1077 0, /* GreenBits */
1078 0, /* BlueBits */
1079 0, /* AlphaBits */
1080 0, /* LuminanceBits */
1081 0, /* IntensityBits */
1082 0, /* IndexBits */
1083 0, /* DepthBits */
1084 0, /* StencilBits */
1085 2, /* TexelBytes */
1086 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1087 fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
1088 fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
1089 fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
1090 NULL, /* FetchTexel1Df */
1091 NULL, /* FetchTexel2Df */
1092 NULL, /* FetchTexel3Df */
1093 store_texel_ycbcr_rev /* StoreTexel */
1094 };
1095
1096 const struct gl_texture_format _mesa_texformat_z24_s8 = {
1097 MESA_FORMAT_Z24_S8, /* MesaFormat */
1098 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1099 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1100 0, /* RedBits */
1101 0, /* GreenBits */
1102 0, /* BlueBits */
1103 0, /* AlphaBits */
1104 0, /* LuminanceBits */
1105 0, /* IntensityBits */
1106 0, /* IndexBits */
1107 24, /* DepthBits */
1108 8, /* StencilBits */
1109 4, /* TexelBytes */
1110 _mesa_texstore_z24_s8, /* StoreTexImageFunc */
1111 NULL, /* FetchTexel1D */
1112 NULL, /* FetchTexel2D */
1113 NULL, /* FetchTexel3D */
1114 fetch_texel_1d_f_z24_s8, /* FetchTexel1Df */
1115 fetch_texel_2d_f_z24_s8, /* FetchTexel2Df */
1116 fetch_texel_3d_f_z24_s8, /* FetchTexel3Df */
1117 store_texel_z24_s8 /* StoreTexel */
1118 };
1119
1120 /*@}*/
1121
1122
1123 /***************************************************************/
1124 /** \name Null format (useful for proxy textures) */
1125 /*@{*/
1126
1127 const struct gl_texture_format _mesa_null_texformat = {
1128 -1, /* MesaFormat */
1129 0, /* BaseFormat */
1130 GL_NONE, /* DataType */
1131 0, /* RedBits */
1132 0, /* GreenBits */
1133 0, /* BlueBits */
1134 0, /* AlphaBits */
1135 0, /* LuminanceBits */
1136 0, /* IntensityBits */
1137 0, /* IndexBits */
1138 0, /* DepthBits */
1139 0, /* StencilBits */
1140 0, /* TexelBytes */
1141 NULL, /* StoreTexImageFunc */
1142 fetch_null_texel, /* FetchTexel1D */
1143 fetch_null_texel, /* FetchTexel2D */
1144 fetch_null_texel, /* FetchTexel3D */
1145 fetch_null_texelf, /* FetchTexel1Df */
1146 fetch_null_texelf, /* FetchTexel2Df */
1147 fetch_null_texelf, /* FetchTexel3Df */
1148 store_null_texel /* StoreTexel */
1149 };
1150
1151 /*@}*/
1152
1153
1154 /**
1155 * Choose an appropriate texture format given the format, type and
1156 * internalFormat parameters passed to glTexImage().
1157 *
1158 * \param ctx the GL context.
1159 * \param internalFormat user's prefered internal texture format.
1160 * \param format incoming image pixel format.
1161 * \param type incoming image data type.
1162 *
1163 * \return a pointer to a gl_texture_format object which describes the
1164 * choosen texture format, or NULL on failure.
1165 *
1166 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1167 * will typically override this function with a specialized version.
1168 */
1169 const struct gl_texture_format *
1170 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1171 GLenum format, GLenum type )
1172 {
1173 (void) format;
1174 (void) type;
1175
1176 switch (internalFormat) {
1177 /* RGBA formats */
1178 case 4:
1179 case GL_RGBA:
1180 case GL_RGB10_A2:
1181 case GL_RGBA12:
1182 case GL_RGBA16:
1183 return &_mesa_texformat_rgba;
1184 case GL_RGBA8:
1185 return &_mesa_texformat_rgba8888;
1186 case GL_RGB5_A1:
1187 return &_mesa_texformat_argb1555;
1188 case GL_RGBA2:
1189 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
1190 case GL_RGBA4:
1191 return &_mesa_texformat_argb4444;
1192
1193 /* RGB formats */
1194 case 3:
1195 case GL_RGB:
1196 case GL_RGB10:
1197 case GL_RGB12:
1198 case GL_RGB16:
1199 return &_mesa_texformat_rgb;
1200 case GL_RGB8:
1201 return &_mesa_texformat_rgb888;
1202 case GL_R3_G3_B2:
1203 return &_mesa_texformat_rgb332;
1204 case GL_RGB4:
1205 return &_mesa_texformat_rgb565_rev; /* just to test another format */
1206 case GL_RGB5:
1207 return &_mesa_texformat_rgb565;
1208
1209 /* Alpha formats */
1210 case GL_ALPHA:
1211 case GL_ALPHA4:
1212 case GL_ALPHA12:
1213 case GL_ALPHA16:
1214 return &_mesa_texformat_alpha;
1215 case GL_ALPHA8:
1216 return &_mesa_texformat_a8;
1217
1218 /* Luminance formats */
1219 case 1:
1220 case GL_LUMINANCE:
1221 case GL_LUMINANCE4:
1222 case GL_LUMINANCE12:
1223 case GL_LUMINANCE16:
1224 return &_mesa_texformat_luminance;
1225 case GL_LUMINANCE8:
1226 return &_mesa_texformat_l8;
1227
1228 /* Luminance/Alpha formats */
1229 case 2:
1230 case GL_LUMINANCE_ALPHA:
1231 case GL_LUMINANCE4_ALPHA4:
1232 case GL_LUMINANCE6_ALPHA2:
1233 case GL_LUMINANCE12_ALPHA4:
1234 case GL_LUMINANCE12_ALPHA12:
1235 case GL_LUMINANCE16_ALPHA16:
1236 return &_mesa_texformat_luminance_alpha;
1237 case GL_LUMINANCE8_ALPHA8:
1238 return &_mesa_texformat_al88;
1239
1240 case GL_INTENSITY:
1241 case GL_INTENSITY4:
1242 case GL_INTENSITY12:
1243 case GL_INTENSITY16:
1244 return &_mesa_texformat_intensity;
1245 case GL_INTENSITY8:
1246 return &_mesa_texformat_i8;
1247
1248 case GL_COLOR_INDEX:
1249 case GL_COLOR_INDEX1_EXT:
1250 case GL_COLOR_INDEX2_EXT:
1251 case GL_COLOR_INDEX4_EXT:
1252 case GL_COLOR_INDEX12_EXT:
1253 case GL_COLOR_INDEX16_EXT:
1254 case GL_COLOR_INDEX8_EXT:
1255 return &_mesa_texformat_ci8;
1256
1257 default:
1258 ; /* fallthrough */
1259 }
1260
1261 if (ctx->Extensions.SGIX_depth_texture ||
1262 ctx->Extensions.ARB_depth_texture) {
1263 switch (internalFormat) {
1264 case GL_DEPTH_COMPONENT:
1265 case GL_DEPTH_COMPONENT24_SGIX:
1266 case GL_DEPTH_COMPONENT32_SGIX:
1267 return &_mesa_texformat_depth_component_float32;
1268 case GL_DEPTH_COMPONENT16_SGIX:
1269 return &_mesa_texformat_depth_component16;
1270 default:
1271 ; /* fallthrough */
1272 }
1273 }
1274
1275 if (ctx->Extensions.ARB_texture_compression) {
1276 switch (internalFormat) {
1277 case GL_COMPRESSED_ALPHA_ARB:
1278 return &_mesa_texformat_alpha;
1279 case GL_COMPRESSED_LUMINANCE_ARB:
1280 return &_mesa_texformat_luminance;
1281 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1282 return &_mesa_texformat_luminance_alpha;
1283 case GL_COMPRESSED_INTENSITY_ARB:
1284 return &_mesa_texformat_intensity;
1285 case GL_COMPRESSED_RGB_ARB:
1286 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1287 return &_mesa_texformat_rgb_fxt1;
1288 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1289 ctx->Extensions.S3_s3tc)
1290 return &_mesa_texformat_rgb_dxt1;
1291 else
1292 return &_mesa_texformat_rgb;
1293 case GL_COMPRESSED_RGBA_ARB:
1294 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1295 return &_mesa_texformat_rgba_fxt1;
1296 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1297 ctx->Extensions.S3_s3tc)
1298 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1299 else
1300 return &_mesa_texformat_rgba;
1301 default:
1302 ; /* fallthrough */
1303 }
1304 }
1305
1306 if (ctx->Extensions.MESA_ycbcr_texture) {
1307 if (internalFormat == GL_YCBCR_MESA) {
1308 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1309 return &_mesa_texformat_ycbcr;
1310 else
1311 return &_mesa_texformat_ycbcr_rev;
1312 }
1313 }
1314
1315 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1316 switch (internalFormat) {
1317 case GL_COMPRESSED_RGB_FXT1_3DFX:
1318 return &_mesa_texformat_rgb_fxt1;
1319 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1320 return &_mesa_texformat_rgba_fxt1;
1321 default:
1322 ; /* fallthrough */
1323 }
1324 }
1325
1326 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1327 switch (internalFormat) {
1328 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1329 return &_mesa_texformat_rgb_dxt1;
1330 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1331 return &_mesa_texformat_rgba_dxt1;
1332 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1333 return &_mesa_texformat_rgba_dxt3;
1334 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1335 return &_mesa_texformat_rgba_dxt5;
1336 default:
1337 ; /* fallthrough */
1338 }
1339 }
1340
1341 if (ctx->Extensions.S3_s3tc) {
1342 switch (internalFormat) {
1343 case GL_RGB_S3TC:
1344 case GL_RGB4_S3TC:
1345 return &_mesa_texformat_rgb_dxt1;
1346 case GL_RGBA_S3TC:
1347 case GL_RGBA4_S3TC:
1348 return &_mesa_texformat_rgba_dxt3;
1349 default:
1350 ; /* fallthrough */
1351 }
1352 }
1353
1354 if (ctx->Extensions.ARB_texture_float) {
1355 switch (internalFormat) {
1356 case GL_ALPHA16F_ARB:
1357 return &_mesa_texformat_alpha_float16;
1358 case GL_ALPHA32F_ARB:
1359 return &_mesa_texformat_alpha_float32;
1360 case GL_LUMINANCE16F_ARB:
1361 return &_mesa_texformat_luminance_float16;
1362 case GL_LUMINANCE32F_ARB:
1363 return &_mesa_texformat_luminance_float32;
1364 case GL_LUMINANCE_ALPHA16F_ARB:
1365 return &_mesa_texformat_luminance_alpha_float16;
1366 case GL_LUMINANCE_ALPHA32F_ARB:
1367 return &_mesa_texformat_luminance_alpha_float32;
1368 case GL_INTENSITY16F_ARB:
1369 return &_mesa_texformat_intensity_float16;
1370 case GL_INTENSITY32F_ARB:
1371 return &_mesa_texformat_intensity_float32;
1372 case GL_RGB16F_ARB:
1373 return &_mesa_texformat_rgb_float16;
1374 case GL_RGB32F_ARB:
1375 return &_mesa_texformat_rgb_float32;
1376 case GL_RGBA16F_ARB:
1377 return &_mesa_texformat_rgba_float16;
1378 case GL_RGBA32F_ARB:
1379 return &_mesa_texformat_rgba_float32;
1380 default:
1381 ; /* fallthrough */
1382 }
1383 }
1384
1385 if (ctx->Extensions.EXT_packed_depth_stencil) {
1386 switch (internalFormat) {
1387 case GL_DEPTH_STENCIL_EXT:
1388 case GL_DEPTH24_STENCIL8_EXT:
1389 return &_mesa_texformat_z24_s8;
1390 default:
1391 ; /* fallthrough */
1392 }
1393 }
1394
1395 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1396 return NULL;
1397 }