- use new program option values from arbprogram.syn
[mesa.git] / src / mesa / main / texformat.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 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 "glheader.h"
35 #include "colormac.h"
36 #include "context.h"
37 #include "image.h"
38 #include "imports.h"
39 #include "mtypes.h"
40 #include "texformat.h"
41 #include "teximage.h"
42 #include "texstate.h"
43 #include "texstore.h"
44
45
46
47 /* Texel fetch routines for all supported formats
48 */
49 #define DIM 1
50 #include "texformat_tmp.h"
51
52 #define DIM 2
53 #include "texformat_tmp.h"
54
55 #define DIM 3
56 #include "texformat_tmp.h"
57
58 /**
59 * Null texel fetch function.
60 *
61 * Have to have this so the FetchTexel function pointer is never NULL.
62 */
63 static void fetch_null_texel( const struct gl_texture_image *texImage,
64 GLint i, GLint j, GLint k, GLchan *texel )
65 {
66 (void) texImage; (void) i; (void) j; (void) k;
67 texel[RCOMP] = 0;
68 texel[GCOMP] = 0;
69 texel[BCOMP] = 0;
70 texel[ACOMP] = 0;
71 _mesa_warning(NULL, "fetch_null_texel() called!");
72 }
73
74 static void fetch_null_texelf( const struct gl_texture_image *texImage,
75 GLint i, GLint j, GLint k, GLfloat *texel )
76 {
77 (void) texImage; (void) i; (void) j; (void) k;
78 texel[RCOMP] = 0.0;
79 texel[GCOMP] = 0.0;
80 texel[BCOMP] = 0.0;
81 texel[ACOMP] = 0.0;
82 _mesa_warning(NULL, "fetch_null_texelf() called!");
83 }
84
85
86 /***************************************************************/
87 /** \name Default GLchan-based formats */
88 /*@{*/
89
90 const struct gl_texture_format _mesa_texformat_rgba = {
91 MESA_FORMAT_RGBA, /* MesaFormat */
92 GL_RGBA, /* BaseFormat */
93 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
94 CHAN_BITS, /* RedBits */
95 CHAN_BITS, /* GreenBits */
96 CHAN_BITS, /* BlueBits */
97 CHAN_BITS, /* AlphaBits */
98 0, /* LuminanceBits */
99 0, /* IntensityBits */
100 0, /* IndexBits */
101 0, /* DepthBits */
102 4 * sizeof(GLchan), /* TexelBytes */
103 _mesa_texstore_rgba, /* StoreTexImageFunc */
104 fetch_texel_1d_rgba, /* FetchTexel1D */
105 fetch_texel_2d_rgba, /* FetchTexel2D */
106 fetch_texel_3d_rgba, /* FetchTexel3D */
107 fetch_texel_1d_f_rgba, /* FetchTexel1Df */
108 fetch_texel_2d_f_rgba, /* FetchTexel2Df */
109 fetch_texel_3d_f_rgba, /* FetchTexel3Df */
110 };
111
112 const struct gl_texture_format _mesa_texformat_rgb = {
113 MESA_FORMAT_RGB, /* MesaFormat */
114 GL_RGB, /* BaseFormat */
115 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
116 CHAN_BITS, /* RedBits */
117 CHAN_BITS, /* GreenBits */
118 CHAN_BITS, /* BlueBits */
119 0, /* AlphaBits */
120 0, /* LuminanceBits */
121 0, /* IntensityBits */
122 0, /* IndexBits */
123 0, /* DepthBits */
124 3 * sizeof(GLchan), /* TexelBytes */
125 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
126 fetch_texel_1d_rgb, /* FetchTexel1D */
127 fetch_texel_2d_rgb, /* FetchTexel2D */
128 fetch_texel_3d_rgb, /* FetchTexel3D */
129 fetch_texel_1d_f_rgb, /* FetchTexel1Df */
130 fetch_texel_2d_f_rgb, /* FetchTexel2Df */
131 fetch_texel_3d_f_rgb, /* FetchTexel3Df */
132 };
133
134 const struct gl_texture_format _mesa_texformat_alpha = {
135 MESA_FORMAT_ALPHA, /* MesaFormat */
136 GL_ALPHA, /* BaseFormat */
137 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
138 0, /* RedBits */
139 0, /* GreenBits */
140 0, /* BlueBits */
141 CHAN_BITS, /* AlphaBits */
142 0, /* LuminanceBits */
143 0, /* IntensityBits */
144 0, /* IndexBits */
145 0, /* DepthBits */
146 sizeof(GLchan), /* TexelBytes */
147 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
148 fetch_texel_1d_alpha, /* FetchTexel1D */
149 fetch_texel_2d_alpha, /* FetchTexel2D */
150 fetch_texel_3d_alpha, /* FetchTexel3D */
151 fetch_texel_1d_f_alpha, /* FetchTexel1Df */
152 fetch_texel_2d_f_alpha, /* FetchTexel2Df */
153 fetch_texel_3d_f_alpha, /* FetchTexel3Df */
154 };
155
156 const struct gl_texture_format _mesa_texformat_luminance = {
157 MESA_FORMAT_LUMINANCE, /* MesaFormat */
158 GL_LUMINANCE, /* BaseFormat */
159 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
160 0, /* RedBits */
161 0, /* GreenBits */
162 0, /* BlueBits */
163 0, /* AlphaBits */
164 CHAN_BITS, /* LuminanceBits */
165 0, /* IntensityBits */
166 0, /* IndexBits */
167 0, /* DepthBits */
168 sizeof(GLchan), /* TexelBytes */
169 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
170 fetch_texel_1d_luminance, /* FetchTexel1D */
171 fetch_texel_2d_luminance, /* FetchTexel2D */
172 fetch_texel_3d_luminance, /* FetchTexel3D */
173 fetch_texel_1d_f_luminance, /* FetchTexel1Df */
174 fetch_texel_2d_f_luminance, /* FetchTexel2Df */
175 fetch_texel_3d_f_luminance, /* FetchTexel3Df */
176 };
177
178 const struct gl_texture_format _mesa_texformat_luminance_alpha = {
179 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
180 GL_LUMINANCE_ALPHA, /* BaseFormat */
181 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
182 0, /* RedBits */
183 0, /* GreenBits */
184 0, /* BlueBits */
185 CHAN_BITS, /* AlphaBits */
186 CHAN_BITS, /* LuminanceBits */
187 0, /* IntensityBits */
188 0, /* IndexBits */
189 0, /* DepthBits */
190 2 * sizeof(GLchan), /* TexelBytes */
191 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
192 fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
193 fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
194 fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
195 fetch_texel_1d_f_luminance_alpha, /* FetchTexel1Df */
196 fetch_texel_2d_f_luminance_alpha, /* FetchTexel2Df */
197 fetch_texel_3d_f_luminance_alpha, /* FetchTexel3Df */
198 };
199
200 const struct gl_texture_format _mesa_texformat_intensity = {
201 MESA_FORMAT_INTENSITY, /* MesaFormat */
202 GL_INTENSITY, /* BaseFormat */
203 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
204 0, /* RedBits */
205 0, /* GreenBits */
206 0, /* BlueBits */
207 0, /* AlphaBits */
208 0, /* LuminanceBits */
209 CHAN_BITS, /* IntensityBits */
210 0, /* IndexBits */
211 0, /* DepthBits */
212 sizeof(GLchan), /* TexelBytes */
213 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
214 fetch_texel_1d_intensity, /* FetchTexel1D */
215 fetch_texel_2d_intensity, /* FetchTexel2D */
216 fetch_texel_3d_intensity, /* FetchTexel3D */
217 fetch_texel_1d_f_intensity, /* FetchTexel1Df */
218 fetch_texel_2d_f_intensity, /* FetchTexel2Df */
219 fetch_texel_3d_f_intensity, /* FetchTexel3Df */
220 };
221
222 const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
223 MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
224 GL_DEPTH_COMPONENT, /* BaseFormat */
225 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
226 0, /* RedBits */
227 0, /* GreenBits */
228 0, /* BlueBits */
229 0, /* AlphaBits */
230 0, /* LuminanceBits */
231 0, /* IntensityBits */
232 0, /* IndexBits */
233 sizeof(GLfloat) * 8, /* DepthBits */
234 sizeof(GLfloat), /* TexelBytes */
235 _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
236 fetch_null_texel, /* FetchTexel1D */
237 fetch_null_texel, /* FetchTexel1D */
238 fetch_null_texel, /* FetchTexel1D */
239 fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
240 fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
241 fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
242 };
243
244 const struct gl_texture_format _mesa_texformat_depth_component16 = {
245 MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
246 GL_DEPTH_COMPONENT, /* BaseFormat */
247 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
248 0, /* RedBits */
249 0, /* GreenBits */
250 0, /* BlueBits */
251 0, /* AlphaBits */
252 0, /* LuminanceBits */
253 0, /* IntensityBits */
254 0, /* IndexBits */
255 sizeof(GLushort) * 8, /* DepthBits */
256 sizeof(GLushort), /* TexelBytes */
257 _mesa_texstore_depth_component16, /* StoreTexImageFunc */
258 fetch_null_texel, /* FetchTexel1D */
259 fetch_null_texel, /* FetchTexel1D */
260 fetch_null_texel, /* FetchTexel1D */
261 fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
262 fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
263 fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
264 };
265
266 const struct gl_texture_format _mesa_texformat_rgba_float32 = {
267 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
268 GL_RGBA, /* BaseFormat */
269 GL_FLOAT, /* DataType */
270 8 * sizeof(GLfloat), /* RedBits */
271 8 * sizeof(GLfloat), /* GreenBits */
272 8 * sizeof(GLfloat), /* BlueBits */
273 8 * sizeof(GLfloat), /* AlphaBits */
274 0, /* LuminanceBits */
275 0, /* IntensityBits */
276 0, /* IndexBits */
277 0, /* DepthBits */
278 4 * sizeof(GLfloat), /* TexelBytes */
279 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
280 fetch_texel_1d_rgba_f32, /* FetchTexel1D */
281 fetch_texel_2d_rgba_f32, /* FetchTexel1D */
282 fetch_texel_3d_rgba_f32, /* FetchTexel1D */
283 fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
284 fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
285 fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
286 };
287
288 const struct gl_texture_format _mesa_texformat_rgba_float16 = {
289 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
290 GL_RGBA, /* BaseFormat */
291 GL_FLOAT, /* DataType */
292 8 * sizeof(GLhalfARB), /* RedBits */
293 8 * sizeof(GLhalfARB), /* GreenBits */
294 8 * sizeof(GLhalfARB), /* BlueBits */
295 8 * sizeof(GLhalfARB), /* AlphaBits */
296 0, /* LuminanceBits */
297 0, /* IntensityBits */
298 0, /* IndexBits */
299 0, /* DepthBits */
300 4 * sizeof(GLhalfARB), /* TexelBytes */
301 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
302 fetch_texel_1d_rgba_f16, /* FetchTexel1D */
303 fetch_texel_2d_rgba_f16, /* FetchTexel1D */
304 fetch_texel_3d_rgba_f16, /* FetchTexel1D */
305 fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
306 fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
307 fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
308 };
309
310 const struct gl_texture_format _mesa_texformat_rgb_float32 = {
311 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
312 GL_RGB, /* BaseFormat */
313 GL_FLOAT, /* DataType */
314 8 * sizeof(GLfloat), /* RedBits */
315 8 * sizeof(GLfloat), /* GreenBits */
316 8 * sizeof(GLfloat), /* BlueBits */
317 0, /* AlphaBits */
318 0, /* LuminanceBits */
319 0, /* IntensityBits */
320 0, /* IndexBits */
321 0, /* DepthBits */
322 3 * sizeof(GLfloat), /* TexelBytes */
323 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
324 fetch_texel_1d_rgb_f32, /* FetchTexel1D */
325 fetch_texel_2d_rgb_f32, /* FetchTexel1D */
326 fetch_texel_3d_rgb_f32, /* FetchTexel1D */
327 fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
328 fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
329 fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
330 };
331
332 const struct gl_texture_format _mesa_texformat_rgb_float16 = {
333 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
334 GL_RGB, /* BaseFormat */
335 GL_FLOAT, /* DataType */
336 8 * sizeof(GLhalfARB), /* RedBits */
337 8 * sizeof(GLhalfARB), /* GreenBits */
338 8 * sizeof(GLhalfARB), /* BlueBits */
339 0, /* AlphaBits */
340 0, /* LuminanceBits */
341 0, /* IntensityBits */
342 0, /* IndexBits */
343 0, /* DepthBits */
344 3 * sizeof(GLhalfARB), /* TexelBytes */
345 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
346 fetch_texel_1d_rgb_f16, /* FetchTexel1D */
347 fetch_texel_2d_rgb_f16, /* FetchTexel1D */
348 fetch_texel_3d_rgb_f16, /* FetchTexel1D */
349 fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
350 fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
351 fetch_texel_3d_f_rgb_f16 /* FetchTexel3Df */
352 };
353
354 const struct gl_texture_format _mesa_texformat_alpha_float32 = {
355 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
356 GL_ALPHA, /* BaseFormat */
357 GL_FLOAT, /* DataType */
358 0, /* RedBits */
359 0, /* GreenBits */
360 0, /* BlueBits */
361 8 * sizeof(GLfloat), /* AlphaBits */
362 0, /* LuminanceBits */
363 0, /* IntensityBits */
364 0, /* IndexBits */
365 0, /* DepthBits */
366 1 * sizeof(GLfloat), /* TexelBytes */
367 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
368 fetch_texel_1d_alpha_f32, /* FetchTexel1D */
369 fetch_texel_2d_alpha_f32, /* FetchTexel1D */
370 fetch_texel_3d_alpha_f32, /* FetchTexel1D */
371 fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
372 fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
373 fetch_texel_3d_f_alpha_f32 /* FetchTexel3Df */
374 };
375
376 const struct gl_texture_format _mesa_texformat_alpha_float16 = {
377 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
378 GL_ALPHA, /* BaseFormat */
379 GL_FLOAT, /* DataType */
380 0, /* RedBits */
381 0, /* GreenBits */
382 0, /* BlueBits */
383 8 * sizeof(GLhalfARB), /* AlphaBits */
384 0, /* LuminanceBits */
385 0, /* IntensityBits */
386 0, /* IndexBits */
387 0, /* DepthBits */
388 1 * sizeof(GLhalfARB), /* TexelBytes */
389 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
390 fetch_texel_1d_alpha_f16, /* FetchTexel1D */
391 fetch_texel_2d_alpha_f16, /* FetchTexel1D */
392 fetch_texel_3d_alpha_f16, /* FetchTexel1D */
393 fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
394 fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
395 fetch_texel_3d_f_alpha_f16 /* FetchTexel3Df */
396 };
397
398 const struct gl_texture_format _mesa_texformat_luminance_float32 = {
399 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
400 GL_LUMINANCE, /* BaseFormat */
401 GL_FLOAT, /* DataType */
402 0, /* RedBits */
403 0, /* GreenBits */
404 0, /* BlueBits */
405 0, /* AlphaBits */
406 8 * sizeof(GLfloat), /* LuminanceBits */
407 0, /* IntensityBits */
408 0, /* IndexBits */
409 0, /* DepthBits */
410 1 * sizeof(GLfloat), /* TexelBytes */
411 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
412 fetch_texel_1d_luminance_f32, /* FetchTexel1D */
413 fetch_texel_2d_luminance_f32, /* FetchTexel2D */
414 fetch_texel_3d_luminance_f32, /* FetchTexel3D */
415 fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
416 fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
417 fetch_texel_3d_f_luminance_f32 /* FetchTexel3Df */
418 };
419
420 const struct gl_texture_format _mesa_texformat_luminance_float16 = {
421 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
422 GL_LUMINANCE, /* BaseFormat */
423 GL_FLOAT, /* DataType */
424 0, /* RedBits */
425 0, /* GreenBits */
426 0, /* BlueBits */
427 0, /* AlphaBits */
428 8 * sizeof(GLhalfARB), /* LuminanceBits */
429 0, /* IntensityBits */
430 0, /* IndexBits */
431 0, /* DepthBits */
432 1 * sizeof(GLhalfARB), /* TexelBytes */
433 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
434 fetch_texel_1d_luminance_f16, /* FetchTexel1D */
435 fetch_texel_2d_luminance_f16, /* FetchTexel2D */
436 fetch_texel_3d_luminance_f16, /* FetchTexel3D */
437 fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
438 fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
439 fetch_texel_3d_f_luminance_f16 /* FetchTexel3Df */
440 };
441
442 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
443 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
444 GL_LUMINANCE_ALPHA, /* BaseFormat */
445 GL_FLOAT, /* DataType */
446 0, /* RedBits */
447 0, /* GreenBits */
448 0, /* BlueBits */
449 8 * sizeof(GLfloat), /* AlphaBits */
450 8 * sizeof(GLfloat), /* LuminanceBits */
451 0, /* IntensityBits */
452 0, /* IndexBits */
453 0, /* DepthBits */
454 2 * sizeof(GLfloat), /* TexelBytes */
455 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
456 fetch_texel_1d_luminance_alpha_f32, /* FetchTexel1D */
457 fetch_texel_2d_luminance_alpha_f32, /* FetchTexel2D */
458 fetch_texel_3d_luminance_alpha_f32, /* FetchTexel3D */
459 fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
460 fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
461 fetch_texel_3d_f_luminance_alpha_f32 /* FetchTexel3Df */
462 };
463
464 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
465 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
466 GL_LUMINANCE_ALPHA, /* BaseFormat */
467 GL_FLOAT, /* DataType */
468 0, /* RedBits */
469 0, /* GreenBits */
470 0, /* BlueBits */
471 8 * sizeof(GLhalfARB), /* AlphaBits */
472 8 * sizeof(GLhalfARB), /* LuminanceBits */
473 0, /* IntensityBits */
474 0, /* IndexBits */
475 0, /* DepthBits */
476 2 * sizeof(GLhalfARB), /* TexelBytes */
477 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
478 fetch_texel_1d_luminance_alpha_f16, /* FetchTexel1D */
479 fetch_texel_2d_luminance_alpha_f16, /* FetchTexel2D */
480 fetch_texel_3d_luminance_alpha_f16, /* FetchTexel3D */
481 fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
482 fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
483 fetch_texel_3d_f_luminance_alpha_f16 /* FetchTexel3Df */
484 };
485
486 const struct gl_texture_format _mesa_texformat_intensity_float32 = {
487 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
488 GL_INTENSITY, /* BaseFormat */
489 GL_FLOAT, /* DataType */
490 0, /* RedBits */
491 0, /* GreenBits */
492 0, /* BlueBits */
493 0, /* AlphaBits */
494 0, /* LuminanceBits */
495 8 * sizeof(GLfloat), /* IntensityBits */
496 0, /* IndexBits */
497 0, /* DepthBits */
498 1 * sizeof(GLfloat), /* TexelBytes */
499 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
500 fetch_texel_1d_intensity_f32, /* FetchTexel1D */
501 fetch_texel_2d_intensity_f32, /* FetchTexel2D */
502 fetch_texel_3d_intensity_f32, /* FetchTexel3D */
503 fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
504 fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
505 fetch_texel_3d_f_intensity_f32 /* FetchTexel3Df */
506 };
507
508 const struct gl_texture_format _mesa_texformat_intensity_float16 = {
509 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
510 GL_INTENSITY, /* BaseFormat */
511 GL_FLOAT, /* DataType */
512 0, /* RedBits */
513 0, /* GreenBits */
514 0, /* BlueBits */
515 0, /* AlphaBits */
516 0, /* LuminanceBits */
517 8 * sizeof(GLhalfARB), /* IntensityBits */
518 0, /* IndexBits */
519 0, /* DepthBits */
520 1 * sizeof(GLhalfARB), /* TexelBytes */
521 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
522 fetch_texel_1d_intensity_f16, /* FetchTexel1D */
523 fetch_texel_2d_intensity_f16, /* FetchTexel2D */
524 fetch_texel_3d_intensity_f16, /* FetchTexel3D */
525 fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
526 fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
527 fetch_texel_3d_f_intensity_f16 /* FetchTexel3Df */
528 };
529
530
531 /*@}*/
532
533
534 /***************************************************************/
535 /** \name Hardware formats */
536 /*@{*/
537
538 const struct gl_texture_format _mesa_texformat_rgba8888 = {
539 MESA_FORMAT_RGBA8888, /* MesaFormat */
540 GL_RGBA, /* BaseFormat */
541 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
542 8, /* RedBits */
543 8, /* GreenBits */
544 8, /* BlueBits */
545 8, /* AlphaBits */
546 0, /* LuminanceBits */
547 0, /* IntensityBits */
548 0, /* IndexBits */
549 0, /* DepthBits */
550 4, /* TexelBytes */
551 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
552 fetch_texel_1d_rgba8888, /* FetchTexel1D */
553 fetch_texel_2d_rgba8888, /* FetchTexel2D */
554 fetch_texel_3d_rgba8888, /* FetchTexel3D */
555 fetch_texel_1d_f_rgba8888, /* FetchTexel1Df */
556 fetch_texel_2d_f_rgba8888, /* FetchTexel2Df */
557 fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */
558 };
559
560 const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
561 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
562 GL_RGBA, /* BaseFormat */
563 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
564 8, /* RedBits */
565 8, /* GreenBits */
566 8, /* BlueBits */
567 8, /* AlphaBits */
568 0, /* LuminanceBits */
569 0, /* IntensityBits */
570 0, /* IndexBits */
571 0, /* DepthBits */
572 4, /* TexelBytes */
573 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
574 fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
575 fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
576 fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
577 fetch_texel_1d_f_rgba8888_rev, /* FetchTexel1Df */
578 fetch_texel_2d_f_rgba8888_rev, /* FetchTexel2Df */
579 fetch_texel_3d_f_rgba8888_rev, /* FetchTexel3Df */
580 };
581
582 const struct gl_texture_format _mesa_texformat_argb8888 = {
583 MESA_FORMAT_ARGB8888, /* MesaFormat */
584 GL_RGBA, /* BaseFormat */
585 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
586 8, /* RedBits */
587 8, /* GreenBits */
588 8, /* BlueBits */
589 8, /* AlphaBits */
590 0, /* LuminanceBits */
591 0, /* IntensityBits */
592 0, /* IndexBits */
593 0, /* DepthBits */
594 4, /* TexelBytes */
595 _mesa_texstore_argb8888, /* StoreTexImageFunc */
596 fetch_texel_1d_argb8888, /* FetchTexel1D */
597 fetch_texel_2d_argb8888, /* FetchTexel2D */
598 fetch_texel_3d_argb8888, /* FetchTexel3D */
599 fetch_texel_1d_f_argb8888, /* FetchTexel1Df */
600 fetch_texel_2d_f_argb8888, /* FetchTexel2Df */
601 fetch_texel_3d_f_argb8888, /* FetchTexel3Df */
602 };
603
604 const struct gl_texture_format _mesa_texformat_argb8888_rev = {
605 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
606 GL_RGBA, /* BaseFormat */
607 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
608 8, /* RedBits */
609 8, /* GreenBits */
610 8, /* BlueBits */
611 8, /* AlphaBits */
612 0, /* LuminanceBits */
613 0, /* IntensityBits */
614 0, /* IndexBits */
615 0, /* DepthBits */
616 4, /* TexelBytes */
617 _mesa_texstore_argb8888, /* StoreTexImageFunc */
618 fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
619 fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
620 fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
621 fetch_texel_1d_f_argb8888_rev, /* FetchTexel1Df */
622 fetch_texel_2d_f_argb8888_rev, /* FetchTexel2Df */
623 fetch_texel_3d_f_argb8888_rev, /* FetchTexel3Df */
624 };
625
626 const struct gl_texture_format _mesa_texformat_rgb888 = {
627 MESA_FORMAT_RGB888, /* MesaFormat */
628 GL_RGB, /* BaseFormat */
629 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
630 8, /* RedBits */
631 8, /* GreenBits */
632 8, /* BlueBits */
633 0, /* AlphaBits */
634 0, /* LuminanceBits */
635 0, /* IntensityBits */
636 0, /* IndexBits */
637 0, /* DepthBits */
638 3, /* TexelBytes */
639 _mesa_texstore_rgb888, /* StoreTexImageFunc */
640 fetch_texel_1d_rgb888, /* FetchTexel1D */
641 fetch_texel_2d_rgb888, /* FetchTexel2D */
642 fetch_texel_3d_rgb888, /* FetchTexel3D */
643 fetch_texel_1d_f_rgb888, /* FetchTexel1Df */
644 fetch_texel_2d_f_rgb888, /* FetchTexel2Df */
645 fetch_texel_3d_f_rgb888, /* FetchTexel3Df */
646 };
647
648 const struct gl_texture_format _mesa_texformat_bgr888 = {
649 MESA_FORMAT_BGR888, /* MesaFormat */
650 GL_RGB, /* BaseFormat */
651 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
652 8, /* RedBits */
653 8, /* GreenBits */
654 8, /* BlueBits */
655 0, /* AlphaBits */
656 0, /* LuminanceBits */
657 0, /* IntensityBits */
658 0, /* IndexBits */
659 0, /* DepthBits */
660 3, /* TexelBytes */
661 _mesa_texstore_bgr888, /* StoreTexImageFunc */
662 fetch_texel_1d_bgr888, /* FetchTexel1D */
663 fetch_texel_2d_bgr888, /* FetchTexel2D */
664 fetch_texel_3d_bgr888, /* FetchTexel3D */
665 fetch_texel_1d_f_bgr888, /* FetchTexel1Df */
666 fetch_texel_2d_f_bgr888, /* FetchTexel2Df */
667 fetch_texel_3d_f_bgr888, /* FetchTexel3Df */
668 };
669
670 const struct gl_texture_format _mesa_texformat_rgb565 = {
671 MESA_FORMAT_RGB565, /* MesaFormat */
672 GL_RGB, /* BaseFormat */
673 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
674 5, /* RedBits */
675 6, /* GreenBits */
676 5, /* BlueBits */
677 0, /* AlphaBits */
678 0, /* LuminanceBits */
679 0, /* IntensityBits */
680 0, /* IndexBits */
681 0, /* DepthBits */
682 2, /* TexelBytes */
683 _mesa_texstore_rgb565, /* StoreTexImageFunc */
684 fetch_texel_1d_rgb565, /* FetchTexel1D */
685 fetch_texel_2d_rgb565, /* FetchTexel2D */
686 fetch_texel_3d_rgb565, /* FetchTexel3D */
687 fetch_texel_1d_f_rgb565, /* FetchTexel1Df */
688 fetch_texel_2d_f_rgb565, /* FetchTexel2Df */
689 fetch_texel_3d_f_rgb565, /* FetchTexel3Df */
690 };
691
692 const struct gl_texture_format _mesa_texformat_rgb565_rev = {
693 MESA_FORMAT_RGB565_REV, /* MesaFormat */
694 GL_RGB, /* BaseFormat */
695 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
696 5, /* RedBits */
697 6, /* GreenBits */
698 5, /* BlueBits */
699 0, /* AlphaBits */
700 0, /* LuminanceBits */
701 0, /* IntensityBits */
702 0, /* IndexBits */
703 0, /* DepthBits */
704 2, /* TexelBytes */
705 _mesa_texstore_rgb565, /* StoreTexImageFunc */
706 fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
707 fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
708 fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
709 fetch_texel_1d_f_rgb565_rev, /* FetchTexel1Df */
710 fetch_texel_2d_f_rgb565_rev, /* FetchTexel2Df */
711 fetch_texel_3d_f_rgb565_rev, /* FetchTexel3Df */
712 };
713
714 const struct gl_texture_format _mesa_texformat_argb4444 = {
715 MESA_FORMAT_ARGB4444, /* MesaFormat */
716 GL_RGBA, /* BaseFormat */
717 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
718 4, /* RedBits */
719 4, /* GreenBits */
720 4, /* BlueBits */
721 4, /* AlphaBits */
722 0, /* LuminanceBits */
723 0, /* IntensityBits */
724 0, /* IndexBits */
725 0, /* DepthBits */
726 2, /* TexelBytes */
727 _mesa_texstore_argb4444, /* StoreTexImageFunc */
728 fetch_texel_1d_argb4444, /* FetchTexel1D */
729 fetch_texel_2d_argb4444, /* FetchTexel2D */
730 fetch_texel_3d_argb4444, /* FetchTexel3D */
731 fetch_texel_1d_f_argb4444, /* FetchTexel1Df */
732 fetch_texel_2d_f_argb4444, /* FetchTexel2Df */
733 fetch_texel_3d_f_argb4444, /* FetchTexel3Df */
734 };
735
736 const struct gl_texture_format _mesa_texformat_argb4444_rev = {
737 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
738 GL_RGBA, /* BaseFormat */
739 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
740 4, /* RedBits */
741 4, /* GreenBits */
742 4, /* BlueBits */
743 4, /* AlphaBits */
744 0, /* LuminanceBits */
745 0, /* IntensityBits */
746 0, /* IndexBits */
747 0, /* DepthBits */
748 2, /* TexelBytes */
749 _mesa_texstore_argb4444, /* StoreTexImageFunc */
750 fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
751 fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
752 fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
753 fetch_texel_1d_f_argb4444_rev, /* FetchTexel1Df */
754 fetch_texel_2d_f_argb4444_rev, /* FetchTexel2Df */
755 fetch_texel_3d_f_argb4444_rev, /* FetchTexel3Df */
756 };
757
758 const struct gl_texture_format _mesa_texformat_argb1555 = {
759 MESA_FORMAT_ARGB1555, /* MesaFormat */
760 GL_RGBA, /* BaseFormat */
761 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
762 5, /* RedBits */
763 5, /* GreenBits */
764 5, /* BlueBits */
765 1, /* AlphaBits */
766 0, /* LuminanceBits */
767 0, /* IntensityBits */
768 0, /* IndexBits */
769 0, /* DepthBits */
770 2, /* TexelBytes */
771 _mesa_texstore_argb1555, /* StoreTexImageFunc */
772 fetch_texel_1d_argb1555, /* FetchTexel1D */
773 fetch_texel_2d_argb1555, /* FetchTexel2D */
774 fetch_texel_3d_argb1555, /* FetchTexel3D */
775 fetch_texel_1d_f_argb1555, /* FetchTexel1Df */
776 fetch_texel_2d_f_argb1555, /* FetchTexel2Df */
777 fetch_texel_3d_f_argb1555, /* FetchTexel3Df */
778 };
779
780 const struct gl_texture_format _mesa_texformat_argb1555_rev = {
781 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
782 GL_RGBA, /* BaseFormat */
783 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
784 5, /* RedBits */
785 5, /* GreenBits */
786 5, /* BlueBits */
787 1, /* AlphaBits */
788 0, /* LuminanceBits */
789 0, /* IntensityBits */
790 0, /* IndexBits */
791 0, /* DepthBits */
792 2, /* TexelBytes */
793 _mesa_texstore_argb1555, /* StoreTexImageFunc */
794 fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
795 fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
796 fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
797 fetch_texel_1d_f_argb1555_rev, /* FetchTexel1Df */
798 fetch_texel_2d_f_argb1555_rev, /* FetchTexel2Df */
799 fetch_texel_3d_f_argb1555_rev, /* FetchTexel3Df */
800 };
801
802 const struct gl_texture_format _mesa_texformat_al88 = {
803 MESA_FORMAT_AL88, /* MesaFormat */
804 GL_LUMINANCE_ALPHA, /* BaseFormat */
805 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
806 0, /* RedBits */
807 0, /* GreenBits */
808 0, /* BlueBits */
809 8, /* AlphaBits */
810 8, /* LuminanceBits */
811 0, /* IntensityBits */
812 0, /* IndexBits */
813 0, /* DepthBits */
814 2, /* TexelBytes */
815 _mesa_texstore_al88, /* StoreTexImageFunc */
816 fetch_texel_1d_al88, /* FetchTexel1D */
817 fetch_texel_2d_al88, /* FetchTexel2D */
818 fetch_texel_3d_al88, /* FetchTexel3D */
819 fetch_texel_1d_f_al88, /* FetchTexel1Df */
820 fetch_texel_2d_f_al88, /* FetchTexel2Df */
821 fetch_texel_3d_f_al88, /* FetchTexel3Df */
822 };
823
824 const struct gl_texture_format _mesa_texformat_al88_rev = {
825 MESA_FORMAT_AL88_REV, /* MesaFormat */
826 GL_LUMINANCE_ALPHA, /* BaseFormat */
827 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
828 0, /* RedBits */
829 0, /* GreenBits */
830 0, /* BlueBits */
831 8, /* AlphaBits */
832 8, /* LuminanceBits */
833 0, /* IntensityBits */
834 0, /* IndexBits */
835 0, /* DepthBits */
836 2, /* TexelBytes */
837 _mesa_texstore_al88, /* StoreTexImageFunc */
838 fetch_texel_1d_al88_rev, /* FetchTexel1D */
839 fetch_texel_2d_al88_rev, /* FetchTexel2D */
840 fetch_texel_3d_al88_rev, /* FetchTexel3D */
841 fetch_texel_1d_f_al88_rev, /* FetchTexel1Df */
842 fetch_texel_2d_f_al88_rev, /* FetchTexel2Df */
843 fetch_texel_3d_f_al88_rev, /* FetchTexel3Df */
844 };
845
846 const struct gl_texture_format _mesa_texformat_rgb332 = {
847 MESA_FORMAT_RGB332, /* MesaFormat */
848 GL_RGB, /* BaseFormat */
849 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
850 3, /* RedBits */
851 3, /* GreenBits */
852 2, /* BlueBits */
853 0, /* AlphaBits */
854 0, /* LuminanceBits */
855 0, /* IntensityBits */
856 0, /* IndexBits */
857 0, /* DepthBits */
858 1, /* TexelBytes */
859 _mesa_texstore_rgb332, /* StoreTexImageFunc */
860 fetch_texel_1d_rgb332, /* FetchTexel1D */
861 fetch_texel_2d_rgb332, /* FetchTexel2D */
862 fetch_texel_3d_rgb332, /* FetchTexel3D */
863 fetch_texel_1d_f_rgb332, /* FetchTexel1Df */
864 fetch_texel_2d_f_rgb332, /* FetchTexel2Df */
865 fetch_texel_3d_f_rgb332, /* FetchTexel3Df */
866 };
867
868 const struct gl_texture_format _mesa_texformat_a8 = {
869 MESA_FORMAT_A8, /* MesaFormat */
870 GL_ALPHA, /* BaseFormat */
871 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
872 0, /* RedBits */
873 0, /* GreenBits */
874 0, /* BlueBits */
875 8, /* AlphaBits */
876 0, /* LuminanceBits */
877 0, /* IntensityBits */
878 0, /* IndexBits */
879 0, /* DepthBits */
880 1, /* TexelBytes */
881 _mesa_texstore_a8, /* StoreTexImageFunc */
882 fetch_texel_1d_a8, /* FetchTexel1D */
883 fetch_texel_2d_a8, /* FetchTexel2D */
884 fetch_texel_3d_a8, /* FetchTexel3D */
885 fetch_texel_1d_f_a8, /* FetchTexel1Df */
886 fetch_texel_2d_f_a8, /* FetchTexel2Df */
887 fetch_texel_3d_f_a8, /* FetchTexel3Df */
888 };
889
890 const struct gl_texture_format _mesa_texformat_l8 = {
891 MESA_FORMAT_L8, /* MesaFormat */
892 GL_LUMINANCE, /* BaseFormat */
893 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
894 0, /* RedBits */
895 0, /* GreenBits */
896 0, /* BlueBits */
897 0, /* AlphaBits */
898 8, /* LuminanceBits */
899 0, /* IntensityBits */
900 0, /* IndexBits */
901 0, /* DepthBits */
902 1, /* TexelBytes */
903 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
904 fetch_texel_1d_l8, /* FetchTexel1D */
905 fetch_texel_2d_l8, /* FetchTexel2D */
906 fetch_texel_3d_l8, /* FetchTexel3D */
907 fetch_texel_1d_f_l8, /* FetchTexel1Df */
908 fetch_texel_2d_f_l8, /* FetchTexel2Df */
909 fetch_texel_3d_f_l8, /* FetchTexel3Df */
910 };
911
912 const struct gl_texture_format _mesa_texformat_i8 = {
913 MESA_FORMAT_I8, /* MesaFormat */
914 GL_INTENSITY, /* BaseFormat */
915 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
916 0, /* RedBits */
917 0, /* GreenBits */
918 0, /* BlueBits */
919 0, /* AlphaBits */
920 0, /* LuminanceBits */
921 8, /* IntensityBits */
922 0, /* IndexBits */
923 0, /* DepthBits */
924 1, /* TexelBytes */
925 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
926 fetch_texel_1d_i8, /* FetchTexel1D */
927 fetch_texel_2d_i8, /* FetchTexel2D */
928 fetch_texel_3d_i8, /* FetchTexel3D */
929 fetch_texel_1d_f_i8, /* FetchTexel1Df */
930 fetch_texel_2d_f_i8, /* FetchTexel2Df */
931 fetch_texel_3d_f_i8, /* FetchTexel3Df */
932 };
933
934 const struct gl_texture_format _mesa_texformat_ci8 = {
935 MESA_FORMAT_CI8, /* MesaFormat */
936 GL_COLOR_INDEX, /* BaseFormat */
937 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
938 0, /* RedBits */
939 0, /* GreenBits */
940 0, /* BlueBits */
941 0, /* AlphaBits */
942 0, /* LuminanceBits */
943 0, /* IntensityBits */
944 8, /* IndexBits */
945 0, /* DepthBits */
946 1, /* TexelBytes */
947 _mesa_texstore_ci8, /* StoreTexImageFunc */
948 fetch_texel_1d_ci8, /* FetchTexel1D */
949 fetch_texel_2d_ci8, /* FetchTexel2D */
950 fetch_texel_3d_ci8, /* FetchTexel3D */
951 fetch_texel_1d_f_ci8, /* FetchTexel1Df */
952 fetch_texel_2d_f_ci8, /* FetchTexel2Df */
953 fetch_texel_3d_f_ci8, /* FetchTexel3Df */
954 };
955
956 const struct gl_texture_format _mesa_texformat_ycbcr = {
957 MESA_FORMAT_YCBCR, /* MesaFormat */
958 GL_YCBCR_MESA, /* BaseFormat */
959 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
960 0, /* RedBits */
961 0, /* GreenBits */
962 0, /* BlueBits */
963 0, /* AlphaBits */
964 0, /* LuminanceBits */
965 0, /* IntensityBits */
966 0, /* IndexBits */
967 0, /* DepthBits */
968 2, /* TexelBytes */
969 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
970 fetch_texel_1d_ycbcr, /* FetchTexel1D */
971 fetch_texel_2d_ycbcr, /* FetchTexel2D */
972 fetch_texel_3d_ycbcr, /* FetchTexel3D */
973 fetch_texel_1d_f_ycbcr, /* FetchTexel1Df */
974 fetch_texel_2d_f_ycbcr, /* FetchTexel2Df */
975 fetch_texel_3d_f_ycbcr, /* FetchTexel3Df */
976 };
977
978 const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
979 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
980 GL_YCBCR_MESA, /* BaseFormat */
981 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
982 0, /* RedBits */
983 0, /* GreenBits */
984 0, /* BlueBits */
985 0, /* AlphaBits */
986 0, /* LuminanceBits */
987 0, /* IntensityBits */
988 0, /* IndexBits */
989 0, /* DepthBits */
990 2, /* TexelBytes */
991 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
992 fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
993 fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
994 fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
995 fetch_texel_1d_f_ycbcr_rev, /* FetchTexel1Df */
996 fetch_texel_2d_f_ycbcr_rev, /* FetchTexel2Df */
997 fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */
998 };
999
1000 /*@}*/
1001
1002
1003 /***************************************************************/
1004 /** \name Null format (useful for proxy textures) */
1005 /*@{*/
1006
1007 const struct gl_texture_format _mesa_null_texformat = {
1008 -1, /* MesaFormat */
1009 0, /* BaseFormat */
1010 GL_NONE, /* DataType */
1011 0, /* RedBits */
1012 0, /* GreenBits */
1013 0, /* BlueBits */
1014 0, /* AlphaBits */
1015 0, /* LuminanceBits */
1016 0, /* IntensityBits */
1017 0, /* IndexBits */
1018 0, /* DepthBits */
1019 0, /* TexelBytes */
1020 NULL, /* StoreTexImageFunc */
1021 fetch_null_texel, /* FetchTexel1D */
1022 fetch_null_texel, /* FetchTexel2D */
1023 fetch_null_texel, /* FetchTexel3D */
1024 fetch_null_texelf, /* FetchTexel1Df */
1025 fetch_null_texelf, /* FetchTexel2Df */
1026 fetch_null_texelf, /* FetchTexel3Df */
1027 };
1028
1029 /*@}*/
1030
1031
1032 /**
1033 * Choose an appropriate texture format given the format, type and
1034 * internalFormat parameters passed to glTexImage().
1035 *
1036 * \param ctx the GL context.
1037 * \param internalFormat user's prefered internal texture format.
1038 * \param format incoming image pixel format.
1039 * \param type incoming image data type.
1040 *
1041 * \return a pointer to a gl_texture_format object which describes the
1042 * choosen texture format, or NULL on failure.
1043 *
1044 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1045 * will typically override this function with a specialized version.
1046 */
1047 const struct gl_texture_format *
1048 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1049 GLenum format, GLenum type )
1050 {
1051 (void) format;
1052 (void) type;
1053
1054 switch (internalFormat) {
1055 /* RGBA formats */
1056 case 4:
1057 case GL_RGBA:
1058 case GL_RGB10_A2:
1059 case GL_RGBA12:
1060 case GL_RGBA16:
1061 return &_mesa_texformat_rgba;
1062 case GL_RGBA8:
1063 return &_mesa_texformat_rgba8888;
1064 case GL_RGB5_A1:
1065 return &_mesa_texformat_argb1555;
1066 case GL_RGBA2:
1067 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
1068 case GL_RGBA4:
1069 return &_mesa_texformat_argb4444;
1070
1071 /* RGB formats */
1072 case 3:
1073 case GL_RGB:
1074 case GL_RGB10:
1075 case GL_RGB12:
1076 case GL_RGB16:
1077 return &_mesa_texformat_rgb;
1078 case GL_RGB8:
1079 return &_mesa_texformat_rgb888;
1080 case GL_R3_G3_B2:
1081 return &_mesa_texformat_rgb332;
1082 case GL_RGB4:
1083 return &_mesa_texformat_rgb565_rev; /* just to test another format */
1084 case GL_RGB5:
1085 return &_mesa_texformat_rgb565;
1086
1087 /* Alpha formats */
1088 case GL_ALPHA:
1089 case GL_ALPHA4:
1090 case GL_ALPHA12:
1091 case GL_ALPHA16:
1092 return &_mesa_texformat_alpha;
1093 case GL_ALPHA8:
1094 return &_mesa_texformat_a8;
1095
1096 /* Luminance formats */
1097 case 1:
1098 case GL_LUMINANCE:
1099 case GL_LUMINANCE4:
1100 case GL_LUMINANCE12:
1101 case GL_LUMINANCE16:
1102 return &_mesa_texformat_luminance;
1103 case GL_LUMINANCE8:
1104 return &_mesa_texformat_l8;
1105
1106 /* Luminance/Alpha formats */
1107 case 2:
1108 case GL_LUMINANCE_ALPHA:
1109 case GL_LUMINANCE4_ALPHA4:
1110 case GL_LUMINANCE6_ALPHA2:
1111 case GL_LUMINANCE12_ALPHA4:
1112 case GL_LUMINANCE12_ALPHA12:
1113 case GL_LUMINANCE16_ALPHA16:
1114 return &_mesa_texformat_luminance_alpha;
1115 case GL_LUMINANCE8_ALPHA8:
1116 return &_mesa_texformat_al88;
1117
1118 case GL_INTENSITY:
1119 case GL_INTENSITY4:
1120 case GL_INTENSITY12:
1121 case GL_INTENSITY16:
1122 return &_mesa_texformat_intensity;
1123 case GL_INTENSITY8:
1124 return &_mesa_texformat_i8;
1125
1126 case GL_COLOR_INDEX:
1127 case GL_COLOR_INDEX1_EXT:
1128 case GL_COLOR_INDEX2_EXT:
1129 case GL_COLOR_INDEX4_EXT:
1130 case GL_COLOR_INDEX12_EXT:
1131 case GL_COLOR_INDEX16_EXT:
1132 case GL_COLOR_INDEX8_EXT:
1133 return &_mesa_texformat_ci8;
1134
1135 default:
1136 ; /* fallthrough */
1137 }
1138
1139 if (ctx->Extensions.SGIX_depth_texture) {
1140 switch (internalFormat) {
1141 case GL_DEPTH_COMPONENT:
1142 case GL_DEPTH_COMPONENT24_SGIX:
1143 case GL_DEPTH_COMPONENT32_SGIX:
1144 return &_mesa_texformat_depth_component_float32;
1145 case GL_DEPTH_COMPONENT16_SGIX:
1146 return &_mesa_texformat_depth_component16;
1147 default:
1148 ; /* fallthrough */
1149 }
1150 }
1151
1152 if (ctx->Extensions.ARB_texture_compression) {
1153 switch (internalFormat) {
1154 case GL_COMPRESSED_ALPHA_ARB:
1155 return &_mesa_texformat_alpha;
1156 case GL_COMPRESSED_LUMINANCE_ARB:
1157 return &_mesa_texformat_luminance;
1158 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1159 return &_mesa_texformat_luminance_alpha;
1160 case GL_COMPRESSED_INTENSITY_ARB:
1161 return &_mesa_texformat_intensity;
1162 case GL_COMPRESSED_RGB_ARB:
1163 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1164 return &_mesa_texformat_rgb_fxt1;
1165 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1166 ctx->Extensions.S3_s3tc)
1167 return &_mesa_texformat_rgb_dxt1;
1168 else
1169 return &_mesa_texformat_rgb;
1170 case GL_COMPRESSED_RGBA_ARB:
1171 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1172 return &_mesa_texformat_rgba_fxt1;
1173 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1174 ctx->Extensions.S3_s3tc)
1175 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1176 else
1177 return &_mesa_texformat_rgba;
1178 default:
1179 ; /* fallthrough */
1180 }
1181 }
1182
1183 if (ctx->Extensions.MESA_ycbcr_texture) {
1184 if (internalFormat == GL_YCBCR_MESA) {
1185 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1186 return &_mesa_texformat_ycbcr;
1187 else
1188 return &_mesa_texformat_ycbcr_rev;
1189 }
1190 }
1191
1192 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1193 switch (internalFormat) {
1194 case GL_COMPRESSED_RGB_FXT1_3DFX:
1195 return &_mesa_texformat_rgb_fxt1;
1196 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1197 return &_mesa_texformat_rgba_fxt1;
1198 default:
1199 ; /* fallthrough */
1200 }
1201 }
1202
1203 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1204 switch (internalFormat) {
1205 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1206 return &_mesa_texformat_rgb_dxt1;
1207 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1208 return &_mesa_texformat_rgba_dxt1;
1209 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1210 return &_mesa_texformat_rgba_dxt3;
1211 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1212 return &_mesa_texformat_rgba_dxt5;
1213 default:
1214 ; /* fallthrough */
1215 }
1216 }
1217
1218 if (ctx->Extensions.S3_s3tc) {
1219 switch (internalFormat) {
1220 case GL_RGB_S3TC:
1221 case GL_RGB4_S3TC:
1222 return &_mesa_texformat_rgb_dxt1;
1223 case GL_RGBA_S3TC:
1224 case GL_RGBA4_S3TC:
1225 return &_mesa_texformat_rgba_dxt3;
1226 default:
1227 ; /* fallthrough */
1228 }
1229 }
1230
1231 if (ctx->Extensions.ARB_texture_float) {
1232 switch (internalFormat) {
1233 case GL_ALPHA16F_ARB:
1234 return &_mesa_texformat_alpha_float16;
1235 case GL_ALPHA32F_ARB:
1236 return &_mesa_texformat_alpha_float32;
1237 case GL_LUMINANCE16F_ARB:
1238 return &_mesa_texformat_luminance_float16;
1239 case GL_LUMINANCE32F_ARB:
1240 return &_mesa_texformat_luminance_float32;
1241 case GL_LUMINANCE_ALPHA16F_ARB:
1242 return &_mesa_texformat_luminance_alpha_float16;
1243 case GL_LUMINANCE_ALPHA32F_ARB:
1244 return &_mesa_texformat_luminance_alpha_float32;
1245 case GL_INTENSITY16F_ARB:
1246 return &_mesa_texformat_intensity_float16;
1247 case GL_INTENSITY32F_ARB:
1248 return &_mesa_texformat_intensity_float32;
1249 case GL_RGB16F_ARB:
1250 return &_mesa_texformat_rgb_float16;
1251 case GL_RGB32F_ARB:
1252 return &_mesa_texformat_rgb_float32;
1253 case GL_RGBA16F_ARB:
1254 return &_mesa_texformat_rgba_float16;
1255 case GL_RGBA32F_ARB:
1256 return &_mesa_texformat_rgba_float32;
1257 default:
1258 ; /* fallthrough */
1259 }
1260 }
1261
1262 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1263 return NULL;
1264 }