2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (c) 2009 VMware, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 * Texel fetch/store functions
32 * \author Gareth Hughes
36 #include "main/colormac.h"
37 #include "main/macros.h"
38 #include "main/texcompress.h"
39 #include "main/texcompress_fxt1.h"
40 #include "main/texcompress_s3tc.h"
41 #include "main/texcompress_rgtc.h"
42 #include "main/teximage.h"
43 #include "s_context.h"
44 #include "s_texfetch.h"
45 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
46 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
50 * Convert an 8-bit sRGB value from non-linear space to a
51 * linear RGB value in [0, 1].
52 * Implemented with a 256-entry lookup table.
55 nonlinear_to_linear(GLubyte cs8
)
57 static GLfloat table
[256];
58 static GLboolean tableReady
= GL_FALSE
;
60 /* compute lookup table now */
62 for (i
= 0; i
< 256; i
++) {
63 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
65 table
[i
] = cs
/ 12.92f
;
68 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
78 /* Texel fetch routines for all supported formats
81 #include "s_texfetch_tmp.h"
84 #include "s_texfetch_tmp.h"
87 #include "s_texfetch_tmp.h"
90 * Null texel fetch function.
92 * Have to have this so the FetchTexel function pointer is never NULL.
94 static void fetch_null_texelf( const struct swrast_texture_image
*texImage
,
95 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
97 (void) texImage
; (void) i
; (void) j
; (void) k
;
102 _mesa_warning(NULL
, "fetch_null_texelf() called!");
105 static void store_null_texel(struct swrast_texture_image
*texImage
,
106 GLint i
, GLint j
, GLint k
, const void *texel
)
119 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
120 * XXX this is somewhat temporary.
124 FetchTexelFunc Fetch1D
;
125 FetchTexelFunc Fetch2D
;
126 FetchTexelFunc Fetch3D
;
127 StoreTexelFunc StoreTexel
;
129 texfetch_funcs
[MESA_FORMAT_COUNT
] =
140 MESA_FORMAT_RGBA8888
,
141 fetch_texel_1d_f_rgba8888
,
142 fetch_texel_2d_f_rgba8888
,
143 fetch_texel_3d_f_rgba8888
,
147 MESA_FORMAT_RGBA8888_REV
,
148 fetch_texel_1d_f_rgba8888_rev
,
149 fetch_texel_2d_f_rgba8888_rev
,
150 fetch_texel_3d_f_rgba8888_rev
,
151 store_texel_rgba8888_rev
154 MESA_FORMAT_ARGB8888
,
155 fetch_texel_1d_f_argb8888
,
156 fetch_texel_2d_f_argb8888
,
157 fetch_texel_3d_f_argb8888
,
161 MESA_FORMAT_ARGB8888_REV
,
162 fetch_texel_1d_f_argb8888_rev
,
163 fetch_texel_2d_f_argb8888_rev
,
164 fetch_texel_3d_f_argb8888_rev
,
165 store_texel_argb8888_rev
168 MESA_FORMAT_RGBX8888
,
169 fetch_texel_1d_f_rgbx8888
,
170 fetch_texel_2d_f_rgbx8888
,
171 fetch_texel_3d_f_rgbx8888
,
175 MESA_FORMAT_RGBX8888_REV
,
176 fetch_texel_1d_f_rgbx8888_rev
,
177 fetch_texel_2d_f_rgbx8888_rev
,
178 fetch_texel_3d_f_rgbx8888_rev
,
179 store_texel_rgbx8888_rev
,
182 MESA_FORMAT_XRGB8888
,
183 fetch_texel_1d_f_xrgb8888
,
184 fetch_texel_2d_f_xrgb8888
,
185 fetch_texel_3d_f_xrgb8888
,
189 MESA_FORMAT_XRGB8888_REV
,
190 fetch_texel_1d_f_xrgb8888_rev
,
191 fetch_texel_2d_f_xrgb8888_rev
,
192 fetch_texel_3d_f_xrgb8888_rev
,
193 store_texel_xrgb8888_rev
,
197 fetch_texel_1d_f_rgb888
,
198 fetch_texel_2d_f_rgb888
,
199 fetch_texel_3d_f_rgb888
,
204 fetch_texel_1d_f_bgr888
,
205 fetch_texel_2d_f_bgr888
,
206 fetch_texel_3d_f_bgr888
,
211 fetch_texel_1d_f_rgb565
,
212 fetch_texel_2d_f_rgb565
,
213 fetch_texel_3d_f_rgb565
,
217 MESA_FORMAT_RGB565_REV
,
218 fetch_texel_1d_f_rgb565_rev
,
219 fetch_texel_2d_f_rgb565_rev
,
220 fetch_texel_3d_f_rgb565_rev
,
221 store_texel_rgb565_rev
224 MESA_FORMAT_ARGB4444
,
225 fetch_texel_1d_f_argb4444
,
226 fetch_texel_2d_f_argb4444
,
227 fetch_texel_3d_f_argb4444
,
231 MESA_FORMAT_ARGB4444_REV
,
232 fetch_texel_1d_f_argb4444_rev
,
233 fetch_texel_2d_f_argb4444_rev
,
234 fetch_texel_3d_f_argb4444_rev
,
235 store_texel_argb4444_rev
238 MESA_FORMAT_RGBA5551
,
239 fetch_texel_1d_f_rgba5551
,
240 fetch_texel_2d_f_rgba5551
,
241 fetch_texel_3d_f_rgba5551
,
245 MESA_FORMAT_ARGB1555
,
246 fetch_texel_1d_f_argb1555
,
247 fetch_texel_2d_f_argb1555
,
248 fetch_texel_3d_f_argb1555
,
252 MESA_FORMAT_ARGB1555_REV
,
253 fetch_texel_1d_f_argb1555_rev
,
254 fetch_texel_2d_f_argb1555_rev
,
255 fetch_texel_3d_f_argb1555_rev
,
256 store_texel_argb1555_rev
260 fetch_texel_1d_f_al44
,
261 fetch_texel_2d_f_al44
,
262 fetch_texel_3d_f_al44
,
267 fetch_texel_1d_f_al88
,
268 fetch_texel_2d_f_al88
,
269 fetch_texel_3d_f_al88
,
273 MESA_FORMAT_AL88_REV
,
274 fetch_texel_1d_f_al88_rev
,
275 fetch_texel_2d_f_al88_rev
,
276 fetch_texel_3d_f_al88_rev
,
281 fetch_texel_1d_f_al1616
,
282 fetch_texel_2d_f_al1616
,
283 fetch_texel_3d_f_al1616
,
287 MESA_FORMAT_AL1616_REV
,
288 fetch_texel_1d_f_al1616_rev
,
289 fetch_texel_2d_f_al1616_rev
,
290 fetch_texel_3d_f_al1616_rev
,
291 store_texel_al1616_rev
295 fetch_texel_1d_f_rgb332
,
296 fetch_texel_2d_f_rgb332
,
297 fetch_texel_3d_f_rgb332
,
309 fetch_texel_1d_f_a16
,
310 fetch_texel_2d_f_a16
,
311 fetch_texel_3d_f_a16
,
323 fetch_texel_1d_f_l16
,
324 fetch_texel_2d_f_l16
,
325 fetch_texel_3d_f_l16
,
337 fetch_texel_1d_f_i16
,
338 fetch_texel_2d_f_i16
,
339 fetch_texel_3d_f_i16
,
344 fetch_texel_1d_f_ycbcr
,
345 fetch_texel_2d_f_ycbcr
,
346 fetch_texel_3d_f_ycbcr
,
350 MESA_FORMAT_YCBCR_REV
,
351 fetch_texel_1d_f_ycbcr_rev
,
352 fetch_texel_2d_f_ycbcr_rev
,
353 fetch_texel_3d_f_ycbcr_rev
,
354 store_texel_ycbcr_rev
365 fetch_texel_1d_f_rg88
,
366 fetch_texel_2d_f_rg88
,
367 fetch_texel_3d_f_rg88
,
371 MESA_FORMAT_RG88_REV
,
372 fetch_texel_1d_f_rg88_rev
,
373 fetch_texel_2d_f_rg88_rev
,
374 fetch_texel_3d_f_rg88_rev
,
375 store_texel_rg88_rev
,
379 fetch_texel_1d_f_r16
,
380 fetch_texel_2d_f_r16
,
381 fetch_texel_3d_f_r16
,
386 fetch_texel_1d_f_rg1616
,
387 fetch_texel_2d_f_rg1616
,
388 fetch_texel_3d_f_rg1616
,
392 MESA_FORMAT_RG1616_REV
,
393 fetch_texel_1d_f_rg1616_rev
,
394 fetch_texel_2d_f_rg1616_rev
,
395 fetch_texel_3d_f_rg1616_rev
,
396 store_texel_rg1616_rev
,
399 MESA_FORMAT_ARGB2101010
,
400 fetch_texel_1d_f_argb2101010
,
401 fetch_texel_2d_f_argb2101010
,
402 fetch_texel_3d_f_argb2101010
,
403 store_texel_argb2101010
407 fetch_texel_1d_f_z24_s8
,
408 fetch_texel_2d_f_z24_s8
,
409 fetch_texel_3d_f_z24_s8
,
414 fetch_texel_1d_f_s8_z24
,
415 fetch_texel_2d_f_s8_z24
,
416 fetch_texel_3d_f_s8_z24
,
421 fetch_texel_1d_f_z16
,
422 fetch_texel_2d_f_z16
,
423 fetch_texel_3d_f_z16
,
428 fetch_texel_1d_f_s8_z24
,
429 fetch_texel_2d_f_s8_z24
,
430 fetch_texel_3d_f_s8_z24
,
435 fetch_texel_1d_f_z24_s8
,
436 fetch_texel_2d_f_z24_s8
,
437 fetch_texel_3d_f_z24_s8
,
442 fetch_texel_1d_f_z32
,
443 fetch_texel_2d_f_z32
,
444 fetch_texel_3d_f_z32
,
456 fetch_texel_1d_srgb8
,
457 fetch_texel_2d_srgb8
,
458 fetch_texel_3d_srgb8
,
463 fetch_texel_1d_srgba8
,
464 fetch_texel_2d_srgba8
,
465 fetch_texel_3d_srgba8
,
470 fetch_texel_1d_sargb8
,
471 fetch_texel_2d_sargb8
,
472 fetch_texel_3d_sargb8
,
490 MESA_FORMAT_SRGB_DXT1
,
492 _mesa_fetch_texel_2d_f_srgb_dxt1
,
497 MESA_FORMAT_SRGBA_DXT1
,
499 _mesa_fetch_texel_2d_f_srgba_dxt1
,
504 MESA_FORMAT_SRGBA_DXT3
,
506 _mesa_fetch_texel_2d_f_srgba_dxt3
,
511 MESA_FORMAT_SRGBA_DXT5
,
513 _mesa_fetch_texel_2d_f_srgba_dxt5
,
519 MESA_FORMAT_RGB_FXT1
,
521 _mesa_fetch_texel_2d_f_rgb_fxt1
,
526 MESA_FORMAT_RGBA_FXT1
,
528 _mesa_fetch_texel_2d_f_rgba_fxt1
,
533 MESA_FORMAT_RGB_DXT1
,
535 _mesa_fetch_texel_2d_f_rgb_dxt1
,
540 MESA_FORMAT_RGBA_DXT1
,
542 _mesa_fetch_texel_2d_f_rgba_dxt1
,
547 MESA_FORMAT_RGBA_DXT3
,
549 _mesa_fetch_texel_2d_f_rgba_dxt3
,
554 MESA_FORMAT_RGBA_DXT5
,
556 _mesa_fetch_texel_2d_f_rgba_dxt5
,
561 MESA_FORMAT_RGBA_FLOAT32
,
562 fetch_texel_1d_f_rgba_f32
,
563 fetch_texel_2d_f_rgba_f32
,
564 fetch_texel_3d_f_rgba_f32
,
568 MESA_FORMAT_RGBA_FLOAT16
,
569 fetch_texel_1d_f_rgba_f16
,
570 fetch_texel_2d_f_rgba_f16
,
571 fetch_texel_3d_f_rgba_f16
,
575 MESA_FORMAT_RGB_FLOAT32
,
576 fetch_texel_1d_f_rgb_f32
,
577 fetch_texel_2d_f_rgb_f32
,
578 fetch_texel_3d_f_rgb_f32
,
582 MESA_FORMAT_RGB_FLOAT16
,
583 fetch_texel_1d_f_rgb_f16
,
584 fetch_texel_2d_f_rgb_f16
,
585 fetch_texel_3d_f_rgb_f16
,
589 MESA_FORMAT_ALPHA_FLOAT32
,
590 fetch_texel_1d_f_alpha_f32
,
591 fetch_texel_2d_f_alpha_f32
,
592 fetch_texel_3d_f_alpha_f32
,
593 store_texel_alpha_f32
596 MESA_FORMAT_ALPHA_FLOAT16
,
597 fetch_texel_1d_f_alpha_f16
,
598 fetch_texel_2d_f_alpha_f16
,
599 fetch_texel_3d_f_alpha_f16
,
600 store_texel_alpha_f16
603 MESA_FORMAT_LUMINANCE_FLOAT32
,
604 fetch_texel_1d_f_luminance_f32
,
605 fetch_texel_2d_f_luminance_f32
,
606 fetch_texel_3d_f_luminance_f32
,
607 store_texel_luminance_f32
610 MESA_FORMAT_LUMINANCE_FLOAT16
,
611 fetch_texel_1d_f_luminance_f16
,
612 fetch_texel_2d_f_luminance_f16
,
613 fetch_texel_3d_f_luminance_f16
,
614 store_texel_luminance_f16
617 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
618 fetch_texel_1d_f_luminance_alpha_f32
,
619 fetch_texel_2d_f_luminance_alpha_f32
,
620 fetch_texel_3d_f_luminance_alpha_f32
,
621 store_texel_luminance_alpha_f32
624 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
625 fetch_texel_1d_f_luminance_alpha_f16
,
626 fetch_texel_2d_f_luminance_alpha_f16
,
627 fetch_texel_3d_f_luminance_alpha_f16
,
628 store_texel_luminance_alpha_f16
631 MESA_FORMAT_INTENSITY_FLOAT32
,
632 fetch_texel_1d_f_intensity_f32
,
633 fetch_texel_2d_f_intensity_f32
,
634 fetch_texel_3d_f_intensity_f32
,
635 store_texel_intensity_f32
638 MESA_FORMAT_INTENSITY_FLOAT16
,
639 fetch_texel_1d_f_intensity_f16
,
640 fetch_texel_2d_f_intensity_f16
,
641 fetch_texel_3d_f_intensity_f16
,
642 store_texel_intensity_f16
645 MESA_FORMAT_R_FLOAT32
,
646 fetch_texel_1d_f_r_f32
,
647 fetch_texel_2d_f_r_f32
,
648 fetch_texel_3d_f_r_f32
,
652 MESA_FORMAT_R_FLOAT16
,
653 fetch_texel_1d_f_r_f16
,
654 fetch_texel_2d_f_r_f16
,
655 fetch_texel_3d_f_r_f16
,
659 MESA_FORMAT_RG_FLOAT32
,
660 fetch_texel_1d_f_rg_f32
,
661 fetch_texel_2d_f_rg_f32
,
662 fetch_texel_3d_f_rg_f32
,
666 MESA_FORMAT_RG_FLOAT16
,
667 fetch_texel_1d_f_rg_f16
,
668 fetch_texel_2d_f_rg_f16
,
669 fetch_texel_3d_f_rg_f16
,
674 MESA_FORMAT_ALPHA_UINT8
,
682 MESA_FORMAT_ALPHA_UINT16
,
690 MESA_FORMAT_ALPHA_UINT32
,
698 MESA_FORMAT_ALPHA_INT8
,
706 MESA_FORMAT_ALPHA_INT16
,
714 MESA_FORMAT_ALPHA_INT32
,
723 MESA_FORMAT_INTENSITY_UINT8
,
731 MESA_FORMAT_INTENSITY_UINT16
,
739 MESA_FORMAT_INTENSITY_UINT32
,
747 MESA_FORMAT_INTENSITY_INT8
,
755 MESA_FORMAT_INTENSITY_INT16
,
763 MESA_FORMAT_INTENSITY_INT32
,
772 MESA_FORMAT_LUMINANCE_UINT8
,
780 MESA_FORMAT_LUMINANCE_UINT16
,
788 MESA_FORMAT_LUMINANCE_UINT32
,
796 MESA_FORMAT_LUMINANCE_INT8
,
804 MESA_FORMAT_LUMINANCE_INT16
,
812 MESA_FORMAT_LUMINANCE_INT32
,
821 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
829 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
837 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
845 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
853 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
861 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
886 MESA_FORMAT_RGB_INT8
,
893 /* non-normalized, signed int */
895 MESA_FORMAT_RGBA_INT8
,
896 fetch_texel_1d_rgba_int8
,
897 fetch_texel_2d_rgba_int8
,
898 fetch_texel_3d_rgba_int8
,
899 store_texel_rgba_int8
909 MESA_FORMAT_RG_INT16
,
916 MESA_FORMAT_RGB_INT16
,
923 MESA_FORMAT_RGBA_INT16
,
924 fetch_texel_1d_rgba_int16
,
925 fetch_texel_2d_rgba_int16
,
926 fetch_texel_3d_rgba_int16
,
927 store_texel_rgba_int16
937 MESA_FORMAT_RG_INT32
,
944 MESA_FORMAT_RGB_INT32
,
951 MESA_FORMAT_RGBA_INT32
,
952 fetch_texel_1d_rgba_int32
,
953 fetch_texel_2d_rgba_int32
,
954 fetch_texel_3d_rgba_int32
,
955 store_texel_rgba_int32
958 /* non-normalized, unsigned int */
967 MESA_FORMAT_RG_UINT8
,
974 MESA_FORMAT_RGB_UINT8
,
981 MESA_FORMAT_RGBA_UINT8
,
982 fetch_texel_1d_rgba_uint8
,
983 fetch_texel_2d_rgba_uint8
,
984 fetch_texel_3d_rgba_uint8
,
985 store_texel_rgba_uint8
988 MESA_FORMAT_R_UINT16
,
995 MESA_FORMAT_RG_UINT16
,
1002 MESA_FORMAT_RGB_UINT16
,
1009 MESA_FORMAT_RGBA_UINT16
,
1010 fetch_texel_1d_rgba_uint16
,
1011 fetch_texel_2d_rgba_uint16
,
1012 fetch_texel_3d_rgba_uint16
,
1013 store_texel_rgba_uint16
1016 MESA_FORMAT_R_UINT32
,
1023 MESA_FORMAT_RG_UINT32
,
1030 MESA_FORMAT_RGB_UINT32
,
1037 MESA_FORMAT_RGBA_UINT32
,
1038 fetch_texel_1d_rgba_uint32
,
1039 fetch_texel_2d_rgba_uint32
,
1040 fetch_texel_3d_rgba_uint32
,
1041 store_texel_rgba_uint32
1047 fetch_texel_1d_dudv8
,
1048 fetch_texel_2d_dudv8
,
1049 fetch_texel_3d_dudv8
,
1053 /* signed, normalized */
1055 MESA_FORMAT_SIGNED_R8
,
1056 fetch_texel_1d_signed_r8
,
1057 fetch_texel_2d_signed_r8
,
1058 fetch_texel_3d_signed_r8
,
1059 store_texel_signed_r8
1062 MESA_FORMAT_SIGNED_RG88_REV
,
1063 fetch_texel_1d_signed_rg88_rev
,
1064 fetch_texel_2d_signed_rg88_rev
,
1065 fetch_texel_3d_signed_rg88_rev
,
1066 store_texel_signed_rg88_rev
1069 MESA_FORMAT_SIGNED_RGBX8888
,
1070 fetch_texel_1d_signed_rgbx8888
,
1071 fetch_texel_2d_signed_rgbx8888
,
1072 fetch_texel_3d_signed_rgbx8888
,
1073 store_texel_signed_rgbx8888
1076 MESA_FORMAT_SIGNED_RGBA8888
,
1077 fetch_texel_1d_signed_rgba8888
,
1078 fetch_texel_2d_signed_rgba8888
,
1079 fetch_texel_3d_signed_rgba8888
,
1080 store_texel_signed_rgba8888
1083 MESA_FORMAT_SIGNED_RGBA8888_REV
,
1084 fetch_texel_1d_signed_rgba8888_rev
,
1085 fetch_texel_2d_signed_rgba8888_rev
,
1086 fetch_texel_3d_signed_rgba8888_rev
,
1087 store_texel_signed_rgba8888_rev
1090 MESA_FORMAT_SIGNED_R16
,
1091 fetch_texel_1d_signed_r16
,
1092 fetch_texel_2d_signed_r16
,
1093 fetch_texel_3d_signed_r16
,
1094 store_texel_signed_r16
1097 MESA_FORMAT_SIGNED_GR1616
,
1098 fetch_texel_1d_signed_rg1616
,
1099 fetch_texel_2d_signed_rg1616
,
1100 fetch_texel_3d_signed_rg1616
,
1101 store_texel_signed_rg1616
1104 MESA_FORMAT_SIGNED_RGB_16
,
1105 fetch_texel_1d_signed_rgb_16
,
1106 fetch_texel_2d_signed_rgb_16
,
1107 fetch_texel_3d_signed_rgb_16
,
1108 store_texel_signed_rgb_16
1111 MESA_FORMAT_SIGNED_RGBA_16
,
1112 fetch_texel_1d_signed_rgba_16
,
1113 fetch_texel_2d_signed_rgba_16
,
1114 fetch_texel_3d_signed_rgba_16
,
1115 store_texel_signed_rgba_16
1118 MESA_FORMAT_RGBA_16
,
1119 fetch_texel_1d_rgba_16
,
1120 fetch_texel_2d_rgba_16
,
1121 fetch_texel_3d_rgba_16
,
1125 MESA_FORMAT_RED_RGTC1
,
1127 _mesa_fetch_texel_2d_f_red_rgtc1
,
1132 MESA_FORMAT_SIGNED_RED_RGTC1
,
1134 _mesa_fetch_texel_2d_f_signed_red_rgtc1
,
1139 MESA_FORMAT_RG_RGTC2
,
1141 _mesa_fetch_texel_2d_f_rg_rgtc2
,
1146 MESA_FORMAT_SIGNED_RG_RGTC2
,
1148 _mesa_fetch_texel_2d_f_signed_rg_rgtc2
,
1153 MESA_FORMAT_L_LATC1
,
1155 _mesa_fetch_texel_2d_f_l_latc1
,
1160 MESA_FORMAT_SIGNED_L_LATC1
,
1162 _mesa_fetch_texel_2d_f_signed_l_latc1
,
1167 MESA_FORMAT_LA_LATC2
,
1169 _mesa_fetch_texel_2d_f_la_latc2
,
1174 MESA_FORMAT_SIGNED_LA_LATC2
,
1176 _mesa_fetch_texel_2d_f_signed_la_latc2
,
1181 MESA_FORMAT_SIGNED_A8
,
1182 fetch_texel_1d_signed_a8
,
1183 fetch_texel_2d_signed_a8
,
1184 fetch_texel_3d_signed_a8
,
1185 store_texel_signed_a8
1188 MESA_FORMAT_SIGNED_L8
,
1189 fetch_texel_1d_signed_l8
,
1190 fetch_texel_2d_signed_l8
,
1191 fetch_texel_3d_signed_l8
,
1192 store_texel_signed_l8
1195 MESA_FORMAT_SIGNED_AL88
,
1196 fetch_texel_1d_signed_al88
,
1197 fetch_texel_2d_signed_al88
,
1198 fetch_texel_3d_signed_al88
,
1199 store_texel_signed_al88
1202 MESA_FORMAT_SIGNED_I8
,
1203 fetch_texel_1d_signed_i8
,
1204 fetch_texel_2d_signed_i8
,
1205 fetch_texel_3d_signed_i8
,
1206 store_texel_signed_i8
1209 MESA_FORMAT_SIGNED_A16
,
1210 fetch_texel_1d_signed_a16
,
1211 fetch_texel_2d_signed_a16
,
1212 fetch_texel_3d_signed_a16
,
1213 store_texel_signed_a16
1216 MESA_FORMAT_SIGNED_L16
,
1217 fetch_texel_1d_signed_l16
,
1218 fetch_texel_2d_signed_l16
,
1219 fetch_texel_3d_signed_l16
,
1220 store_texel_signed_l16
1223 MESA_FORMAT_SIGNED_AL1616
,
1224 fetch_texel_1d_signed_al1616
,
1225 fetch_texel_2d_signed_al1616
,
1226 fetch_texel_3d_signed_al1616
,
1227 store_texel_signed_al1616
1230 MESA_FORMAT_SIGNED_I16
,
1231 fetch_texel_1d_signed_i16
,
1232 fetch_texel_2d_signed_i16
,
1233 fetch_texel_3d_signed_i16
,
1234 store_texel_signed_i16
1237 MESA_FORMAT_RGB9_E5_FLOAT
,
1238 fetch_texel_1d_rgb9_e5
,
1239 fetch_texel_2d_rgb9_e5
,
1240 fetch_texel_3d_rgb9_e5
,
1244 MESA_FORMAT_R11_G11_B10_FLOAT
,
1245 fetch_texel_1d_r11_g11_b10f
,
1246 fetch_texel_2d_r11_g11_b10f
,
1247 fetch_texel_3d_r11_g11_b10f
,
1248 store_texel_r11_g11_b10f
1251 MESA_FORMAT_Z32_FLOAT
,
1252 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1253 fetch_texel_2d_f_r_f32
,
1254 fetch_texel_3d_f_r_f32
,
1258 MESA_FORMAT_Z32_FLOAT_X24S8
,
1259 fetch_texel_1d_z32f_x24s8
,
1260 fetch_texel_2d_z32f_x24s8
,
1261 fetch_texel_3d_z32f_x24s8
,
1262 store_texel_z32f_x24s8
1265 MESA_FORMAT_ARGB2101010_UINT
,
1275 _mesa_get_texel_fetch_func(gl_format format
, GLuint dims
)
1278 /* check that the table entries are sorted by format name */
1280 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1281 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1285 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1287 assert(format
< MESA_FORMAT_COUNT
);
1291 return texfetch_funcs
[format
].Fetch1D
;
1293 return texfetch_funcs
[format
].Fetch2D
;
1295 return texfetch_funcs
[format
].Fetch3D
;
1297 assert(0 && "bad dims in _mesa_get_texel_fetch_func");
1304 _mesa_get_texel_store_func(gl_format format
)
1306 assert(format
< MESA_FORMAT_COUNT
);
1307 return texfetch_funcs
[format
].StoreTexel
;
1312 * Initialize the texture image's FetchTexel methods.
1315 set_fetch_functions(struct swrast_texture_image
*texImage
, GLuint dims
)
1317 gl_format format
= texImage
->Base
.TexFormat
;
1319 ASSERT(dims
== 1 || dims
== 2 || dims
== 3);
1321 if (texImage
->Base
.TexObject
->Sampler
.sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1322 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1323 format
= _mesa_get_srgb_format_linear(format
);
1326 texImage
->FetchTexel
= _mesa_get_texel_fetch_func(format
, dims
);
1327 ASSERT(texImage
->FetchTexel
);
1331 _mesa_update_fetch_functions(struct gl_texture_object
*texObj
)
1336 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1338 for (face
= 0; face
< 6; face
++) {
1339 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1340 if (texObj
->Image
[face
][i
]) {
1341 set_fetch_functions(swrast_texture_image(texObj
->Image
[face
][i
]),