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/texcompress_etc.h"
43 #include "main/teximage.h"
44 #include "s_context.h"
45 #include "s_texfetch.h"
46 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
47 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
51 * Convert an 8-bit sRGB value from non-linear space to a
52 * linear RGB value in [0, 1].
53 * Implemented with a 256-entry lookup table.
56 nonlinear_to_linear(GLubyte cs8
)
58 static GLfloat table
[256];
59 static GLboolean tableReady
= GL_FALSE
;
61 /* compute lookup table now */
63 for (i
= 0; i
< 256; i
++) {
64 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
66 table
[i
] = cs
/ 12.92f
;
69 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
79 /* Texel fetch routines for all supported formats
82 #include "s_texfetch_tmp.h"
85 #include "s_texfetch_tmp.h"
88 #include "s_texfetch_tmp.h"
91 * Null texel fetch function.
93 * Have to have this so the FetchTexel function pointer is never NULL.
95 static void fetch_null_texelf( const struct swrast_texture_image
*texImage
,
96 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
98 (void) texImage
; (void) i
; (void) j
; (void) k
;
103 _mesa_warning(NULL
, "fetch_null_texelf() called!");
106 static void store_null_texel(struct swrast_texture_image
*texImage
,
107 GLint i
, GLint j
, GLint k
, const void *texel
)
120 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
121 * XXX this is somewhat temporary.
125 FetchTexelFunc Fetch1D
;
126 FetchTexelFunc Fetch2D
;
127 FetchTexelFunc Fetch3D
;
128 StoreTexelFunc StoreTexel
;
130 texfetch_funcs
[MESA_FORMAT_COUNT
] =
141 MESA_FORMAT_RGBA8888
,
142 fetch_texel_1d_f_rgba8888
,
143 fetch_texel_2d_f_rgba8888
,
144 fetch_texel_3d_f_rgba8888
,
148 MESA_FORMAT_RGBA8888_REV
,
149 fetch_texel_1d_f_rgba8888_rev
,
150 fetch_texel_2d_f_rgba8888_rev
,
151 fetch_texel_3d_f_rgba8888_rev
,
152 store_texel_rgba8888_rev
155 MESA_FORMAT_ARGB8888
,
156 fetch_texel_1d_f_argb8888
,
157 fetch_texel_2d_f_argb8888
,
158 fetch_texel_3d_f_argb8888
,
162 MESA_FORMAT_ARGB8888_REV
,
163 fetch_texel_1d_f_argb8888_rev
,
164 fetch_texel_2d_f_argb8888_rev
,
165 fetch_texel_3d_f_argb8888_rev
,
166 store_texel_argb8888_rev
169 MESA_FORMAT_RGBX8888
,
170 fetch_texel_1d_f_rgbx8888
,
171 fetch_texel_2d_f_rgbx8888
,
172 fetch_texel_3d_f_rgbx8888
,
176 MESA_FORMAT_RGBX8888_REV
,
177 fetch_texel_1d_f_rgbx8888_rev
,
178 fetch_texel_2d_f_rgbx8888_rev
,
179 fetch_texel_3d_f_rgbx8888_rev
,
180 store_texel_rgbx8888_rev
,
183 MESA_FORMAT_XRGB8888
,
184 fetch_texel_1d_f_xrgb8888
,
185 fetch_texel_2d_f_xrgb8888
,
186 fetch_texel_3d_f_xrgb8888
,
190 MESA_FORMAT_XRGB8888_REV
,
191 fetch_texel_1d_f_xrgb8888_rev
,
192 fetch_texel_2d_f_xrgb8888_rev
,
193 fetch_texel_3d_f_xrgb8888_rev
,
194 store_texel_xrgb8888_rev
,
198 fetch_texel_1d_f_rgb888
,
199 fetch_texel_2d_f_rgb888
,
200 fetch_texel_3d_f_rgb888
,
205 fetch_texel_1d_f_bgr888
,
206 fetch_texel_2d_f_bgr888
,
207 fetch_texel_3d_f_bgr888
,
212 fetch_texel_1d_f_rgb565
,
213 fetch_texel_2d_f_rgb565
,
214 fetch_texel_3d_f_rgb565
,
218 MESA_FORMAT_RGB565_REV
,
219 fetch_texel_1d_f_rgb565_rev
,
220 fetch_texel_2d_f_rgb565_rev
,
221 fetch_texel_3d_f_rgb565_rev
,
222 store_texel_rgb565_rev
225 MESA_FORMAT_ARGB4444
,
226 fetch_texel_1d_f_argb4444
,
227 fetch_texel_2d_f_argb4444
,
228 fetch_texel_3d_f_argb4444
,
232 MESA_FORMAT_ARGB4444_REV
,
233 fetch_texel_1d_f_argb4444_rev
,
234 fetch_texel_2d_f_argb4444_rev
,
235 fetch_texel_3d_f_argb4444_rev
,
236 store_texel_argb4444_rev
239 MESA_FORMAT_RGBA5551
,
240 fetch_texel_1d_f_rgba5551
,
241 fetch_texel_2d_f_rgba5551
,
242 fetch_texel_3d_f_rgba5551
,
246 MESA_FORMAT_ARGB1555
,
247 fetch_texel_1d_f_argb1555
,
248 fetch_texel_2d_f_argb1555
,
249 fetch_texel_3d_f_argb1555
,
253 MESA_FORMAT_ARGB1555_REV
,
254 fetch_texel_1d_f_argb1555_rev
,
255 fetch_texel_2d_f_argb1555_rev
,
256 fetch_texel_3d_f_argb1555_rev
,
257 store_texel_argb1555_rev
261 fetch_texel_1d_f_al44
,
262 fetch_texel_2d_f_al44
,
263 fetch_texel_3d_f_al44
,
268 fetch_texel_1d_f_al88
,
269 fetch_texel_2d_f_al88
,
270 fetch_texel_3d_f_al88
,
274 MESA_FORMAT_AL88_REV
,
275 fetch_texel_1d_f_al88_rev
,
276 fetch_texel_2d_f_al88_rev
,
277 fetch_texel_3d_f_al88_rev
,
282 fetch_texel_1d_f_al1616
,
283 fetch_texel_2d_f_al1616
,
284 fetch_texel_3d_f_al1616
,
288 MESA_FORMAT_AL1616_REV
,
289 fetch_texel_1d_f_al1616_rev
,
290 fetch_texel_2d_f_al1616_rev
,
291 fetch_texel_3d_f_al1616_rev
,
292 store_texel_al1616_rev
296 fetch_texel_1d_f_rgb332
,
297 fetch_texel_2d_f_rgb332
,
298 fetch_texel_3d_f_rgb332
,
310 fetch_texel_1d_f_a16
,
311 fetch_texel_2d_f_a16
,
312 fetch_texel_3d_f_a16
,
324 fetch_texel_1d_f_l16
,
325 fetch_texel_2d_f_l16
,
326 fetch_texel_3d_f_l16
,
338 fetch_texel_1d_f_i16
,
339 fetch_texel_2d_f_i16
,
340 fetch_texel_3d_f_i16
,
345 fetch_texel_1d_f_ycbcr
,
346 fetch_texel_2d_f_ycbcr
,
347 fetch_texel_3d_f_ycbcr
,
351 MESA_FORMAT_YCBCR_REV
,
352 fetch_texel_1d_f_ycbcr_rev
,
353 fetch_texel_2d_f_ycbcr_rev
,
354 fetch_texel_3d_f_ycbcr_rev
,
355 store_texel_ycbcr_rev
366 fetch_texel_1d_f_gr88
,
367 fetch_texel_2d_f_gr88
,
368 fetch_texel_3d_f_gr88
,
373 fetch_texel_1d_f_rg88
,
374 fetch_texel_2d_f_rg88
,
375 fetch_texel_3d_f_rg88
,
380 fetch_texel_1d_f_r16
,
381 fetch_texel_2d_f_r16
,
382 fetch_texel_3d_f_r16
,
387 fetch_texel_1d_f_rg1616
,
388 fetch_texel_2d_f_rg1616
,
389 fetch_texel_3d_f_rg1616
,
393 MESA_FORMAT_RG1616_REV
,
394 fetch_texel_1d_f_rg1616_rev
,
395 fetch_texel_2d_f_rg1616_rev
,
396 fetch_texel_3d_f_rg1616_rev
,
397 store_texel_rg1616_rev
,
400 MESA_FORMAT_ARGB2101010
,
401 fetch_texel_1d_f_argb2101010
,
402 fetch_texel_2d_f_argb2101010
,
403 fetch_texel_3d_f_argb2101010
,
404 store_texel_argb2101010
408 fetch_texel_1d_f_z24_s8
,
409 fetch_texel_2d_f_z24_s8
,
410 fetch_texel_3d_f_z24_s8
,
415 fetch_texel_1d_f_s8_z24
,
416 fetch_texel_2d_f_s8_z24
,
417 fetch_texel_3d_f_s8_z24
,
422 fetch_texel_1d_f_z16
,
423 fetch_texel_2d_f_z16
,
424 fetch_texel_3d_f_z16
,
429 fetch_texel_1d_f_s8_z24
,
430 fetch_texel_2d_f_s8_z24
,
431 fetch_texel_3d_f_s8_z24
,
436 fetch_texel_1d_f_z24_s8
,
437 fetch_texel_2d_f_z24_s8
,
438 fetch_texel_3d_f_z24_s8
,
443 fetch_texel_1d_f_z32
,
444 fetch_texel_2d_f_z32
,
445 fetch_texel_3d_f_z32
,
457 fetch_texel_1d_srgb8
,
458 fetch_texel_2d_srgb8
,
459 fetch_texel_3d_srgb8
,
464 fetch_texel_1d_srgba8
,
465 fetch_texel_2d_srgba8
,
466 fetch_texel_3d_srgba8
,
471 fetch_texel_1d_sargb8
,
472 fetch_texel_2d_sargb8
,
473 fetch_texel_3d_sargb8
,
491 MESA_FORMAT_SRGB_DXT1
,
493 _mesa_fetch_texel_2d_f_srgb_dxt1
,
498 MESA_FORMAT_SRGBA_DXT1
,
500 _mesa_fetch_texel_2d_f_srgba_dxt1
,
505 MESA_FORMAT_SRGBA_DXT3
,
507 _mesa_fetch_texel_2d_f_srgba_dxt3
,
512 MESA_FORMAT_SRGBA_DXT5
,
514 _mesa_fetch_texel_2d_f_srgba_dxt5
,
520 MESA_FORMAT_RGB_FXT1
,
522 _mesa_fetch_texel_2d_f_rgb_fxt1
,
527 MESA_FORMAT_RGBA_FXT1
,
529 _mesa_fetch_texel_2d_f_rgba_fxt1
,
534 MESA_FORMAT_RGB_DXT1
,
536 _mesa_fetch_texel_2d_f_rgb_dxt1
,
541 MESA_FORMAT_RGBA_DXT1
,
543 _mesa_fetch_texel_2d_f_rgba_dxt1
,
548 MESA_FORMAT_RGBA_DXT3
,
550 _mesa_fetch_texel_2d_f_rgba_dxt3
,
555 MESA_FORMAT_RGBA_DXT5
,
557 _mesa_fetch_texel_2d_f_rgba_dxt5
,
562 MESA_FORMAT_RGBA_FLOAT32
,
563 fetch_texel_1d_f_rgba_f32
,
564 fetch_texel_2d_f_rgba_f32
,
565 fetch_texel_3d_f_rgba_f32
,
569 MESA_FORMAT_RGBA_FLOAT16
,
570 fetch_texel_1d_f_rgba_f16
,
571 fetch_texel_2d_f_rgba_f16
,
572 fetch_texel_3d_f_rgba_f16
,
576 MESA_FORMAT_RGB_FLOAT32
,
577 fetch_texel_1d_f_rgb_f32
,
578 fetch_texel_2d_f_rgb_f32
,
579 fetch_texel_3d_f_rgb_f32
,
583 MESA_FORMAT_RGB_FLOAT16
,
584 fetch_texel_1d_f_rgb_f16
,
585 fetch_texel_2d_f_rgb_f16
,
586 fetch_texel_3d_f_rgb_f16
,
590 MESA_FORMAT_ALPHA_FLOAT32
,
591 fetch_texel_1d_f_alpha_f32
,
592 fetch_texel_2d_f_alpha_f32
,
593 fetch_texel_3d_f_alpha_f32
,
594 store_texel_alpha_f32
597 MESA_FORMAT_ALPHA_FLOAT16
,
598 fetch_texel_1d_f_alpha_f16
,
599 fetch_texel_2d_f_alpha_f16
,
600 fetch_texel_3d_f_alpha_f16
,
601 store_texel_alpha_f16
604 MESA_FORMAT_LUMINANCE_FLOAT32
,
605 fetch_texel_1d_f_luminance_f32
,
606 fetch_texel_2d_f_luminance_f32
,
607 fetch_texel_3d_f_luminance_f32
,
608 store_texel_luminance_f32
611 MESA_FORMAT_LUMINANCE_FLOAT16
,
612 fetch_texel_1d_f_luminance_f16
,
613 fetch_texel_2d_f_luminance_f16
,
614 fetch_texel_3d_f_luminance_f16
,
615 store_texel_luminance_f16
618 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
619 fetch_texel_1d_f_luminance_alpha_f32
,
620 fetch_texel_2d_f_luminance_alpha_f32
,
621 fetch_texel_3d_f_luminance_alpha_f32
,
622 store_texel_luminance_alpha_f32
625 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
626 fetch_texel_1d_f_luminance_alpha_f16
,
627 fetch_texel_2d_f_luminance_alpha_f16
,
628 fetch_texel_3d_f_luminance_alpha_f16
,
629 store_texel_luminance_alpha_f16
632 MESA_FORMAT_INTENSITY_FLOAT32
,
633 fetch_texel_1d_f_intensity_f32
,
634 fetch_texel_2d_f_intensity_f32
,
635 fetch_texel_3d_f_intensity_f32
,
636 store_texel_intensity_f32
639 MESA_FORMAT_INTENSITY_FLOAT16
,
640 fetch_texel_1d_f_intensity_f16
,
641 fetch_texel_2d_f_intensity_f16
,
642 fetch_texel_3d_f_intensity_f16
,
643 store_texel_intensity_f16
646 MESA_FORMAT_R_FLOAT32
,
647 fetch_texel_1d_f_r_f32
,
648 fetch_texel_2d_f_r_f32
,
649 fetch_texel_3d_f_r_f32
,
653 MESA_FORMAT_R_FLOAT16
,
654 fetch_texel_1d_f_r_f16
,
655 fetch_texel_2d_f_r_f16
,
656 fetch_texel_3d_f_r_f16
,
660 MESA_FORMAT_RG_FLOAT32
,
661 fetch_texel_1d_f_rg_f32
,
662 fetch_texel_2d_f_rg_f32
,
663 fetch_texel_3d_f_rg_f32
,
667 MESA_FORMAT_RG_FLOAT16
,
668 fetch_texel_1d_f_rg_f16
,
669 fetch_texel_2d_f_rg_f16
,
670 fetch_texel_3d_f_rg_f16
,
675 MESA_FORMAT_ALPHA_UINT8
,
683 MESA_FORMAT_ALPHA_UINT16
,
691 MESA_FORMAT_ALPHA_UINT32
,
699 MESA_FORMAT_ALPHA_INT8
,
707 MESA_FORMAT_ALPHA_INT16
,
715 MESA_FORMAT_ALPHA_INT32
,
724 MESA_FORMAT_INTENSITY_UINT8
,
732 MESA_FORMAT_INTENSITY_UINT16
,
740 MESA_FORMAT_INTENSITY_UINT32
,
748 MESA_FORMAT_INTENSITY_INT8
,
756 MESA_FORMAT_INTENSITY_INT16
,
764 MESA_FORMAT_INTENSITY_INT32
,
773 MESA_FORMAT_LUMINANCE_UINT8
,
781 MESA_FORMAT_LUMINANCE_UINT16
,
789 MESA_FORMAT_LUMINANCE_UINT32
,
797 MESA_FORMAT_LUMINANCE_INT8
,
805 MESA_FORMAT_LUMINANCE_INT16
,
813 MESA_FORMAT_LUMINANCE_INT32
,
822 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
830 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
838 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
846 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
854 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
862 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
887 MESA_FORMAT_RGB_INT8
,
894 /* non-normalized, signed int */
896 MESA_FORMAT_RGBA_INT8
,
897 fetch_texel_1d_rgba_int8
,
898 fetch_texel_2d_rgba_int8
,
899 fetch_texel_3d_rgba_int8
,
900 store_texel_rgba_int8
910 MESA_FORMAT_RG_INT16
,
917 MESA_FORMAT_RGB_INT16
,
924 MESA_FORMAT_RGBA_INT16
,
925 fetch_texel_1d_rgba_int16
,
926 fetch_texel_2d_rgba_int16
,
927 fetch_texel_3d_rgba_int16
,
928 store_texel_rgba_int16
938 MESA_FORMAT_RG_INT32
,
945 MESA_FORMAT_RGB_INT32
,
952 MESA_FORMAT_RGBA_INT32
,
953 fetch_texel_1d_rgba_int32
,
954 fetch_texel_2d_rgba_int32
,
955 fetch_texel_3d_rgba_int32
,
956 store_texel_rgba_int32
959 /* non-normalized, unsigned int */
968 MESA_FORMAT_RG_UINT8
,
975 MESA_FORMAT_RGB_UINT8
,
982 MESA_FORMAT_RGBA_UINT8
,
983 fetch_texel_1d_rgba_uint8
,
984 fetch_texel_2d_rgba_uint8
,
985 fetch_texel_3d_rgba_uint8
,
986 store_texel_rgba_uint8
989 MESA_FORMAT_R_UINT16
,
996 MESA_FORMAT_RG_UINT16
,
1003 MESA_FORMAT_RGB_UINT16
,
1010 MESA_FORMAT_RGBA_UINT16
,
1011 fetch_texel_1d_rgba_uint16
,
1012 fetch_texel_2d_rgba_uint16
,
1013 fetch_texel_3d_rgba_uint16
,
1014 store_texel_rgba_uint16
1017 MESA_FORMAT_R_UINT32
,
1024 MESA_FORMAT_RG_UINT32
,
1031 MESA_FORMAT_RGB_UINT32
,
1038 MESA_FORMAT_RGBA_UINT32
,
1039 fetch_texel_1d_rgba_uint32
,
1040 fetch_texel_2d_rgba_uint32
,
1041 fetch_texel_3d_rgba_uint32
,
1042 store_texel_rgba_uint32
1048 fetch_texel_1d_dudv8
,
1049 fetch_texel_2d_dudv8
,
1050 fetch_texel_3d_dudv8
,
1054 /* signed, normalized */
1056 MESA_FORMAT_SIGNED_R8
,
1057 fetch_texel_1d_signed_r8
,
1058 fetch_texel_2d_signed_r8
,
1059 fetch_texel_3d_signed_r8
,
1060 store_texel_signed_r8
1063 MESA_FORMAT_SIGNED_RG88_REV
,
1064 fetch_texel_1d_signed_rg88_rev
,
1065 fetch_texel_2d_signed_rg88_rev
,
1066 fetch_texel_3d_signed_rg88_rev
,
1067 store_texel_signed_rg88_rev
1070 MESA_FORMAT_SIGNED_RGBX8888
,
1071 fetch_texel_1d_signed_rgbx8888
,
1072 fetch_texel_2d_signed_rgbx8888
,
1073 fetch_texel_3d_signed_rgbx8888
,
1074 store_texel_signed_rgbx8888
1077 MESA_FORMAT_SIGNED_RGBA8888
,
1078 fetch_texel_1d_signed_rgba8888
,
1079 fetch_texel_2d_signed_rgba8888
,
1080 fetch_texel_3d_signed_rgba8888
,
1081 store_texel_signed_rgba8888
1084 MESA_FORMAT_SIGNED_RGBA8888_REV
,
1085 fetch_texel_1d_signed_rgba8888_rev
,
1086 fetch_texel_2d_signed_rgba8888_rev
,
1087 fetch_texel_3d_signed_rgba8888_rev
,
1088 store_texel_signed_rgba8888_rev
1091 MESA_FORMAT_SIGNED_R16
,
1092 fetch_texel_1d_signed_r16
,
1093 fetch_texel_2d_signed_r16
,
1094 fetch_texel_3d_signed_r16
,
1095 store_texel_signed_r16
1098 MESA_FORMAT_SIGNED_GR1616
,
1099 fetch_texel_1d_signed_rg1616
,
1100 fetch_texel_2d_signed_rg1616
,
1101 fetch_texel_3d_signed_rg1616
,
1102 store_texel_signed_rg1616
1105 MESA_FORMAT_SIGNED_RGB_16
,
1106 fetch_texel_1d_signed_rgb_16
,
1107 fetch_texel_2d_signed_rgb_16
,
1108 fetch_texel_3d_signed_rgb_16
,
1109 store_texel_signed_rgb_16
1112 MESA_FORMAT_SIGNED_RGBA_16
,
1113 fetch_texel_1d_signed_rgba_16
,
1114 fetch_texel_2d_signed_rgba_16
,
1115 fetch_texel_3d_signed_rgba_16
,
1116 store_texel_signed_rgba_16
1119 MESA_FORMAT_RGBA_16
,
1120 fetch_texel_1d_rgba_16
,
1121 fetch_texel_2d_rgba_16
,
1122 fetch_texel_3d_rgba_16
,
1126 MESA_FORMAT_RED_RGTC1
,
1128 _mesa_fetch_texel_2d_f_red_rgtc1
,
1133 MESA_FORMAT_SIGNED_RED_RGTC1
,
1135 _mesa_fetch_texel_2d_f_signed_red_rgtc1
,
1140 MESA_FORMAT_RG_RGTC2
,
1142 _mesa_fetch_texel_2d_f_rg_rgtc2
,
1147 MESA_FORMAT_SIGNED_RG_RGTC2
,
1149 _mesa_fetch_texel_2d_f_signed_rg_rgtc2
,
1154 MESA_FORMAT_L_LATC1
,
1156 _mesa_fetch_texel_2d_f_l_latc1
,
1161 MESA_FORMAT_SIGNED_L_LATC1
,
1163 _mesa_fetch_texel_2d_f_signed_l_latc1
,
1168 MESA_FORMAT_LA_LATC2
,
1170 _mesa_fetch_texel_2d_f_la_latc2
,
1175 MESA_FORMAT_SIGNED_LA_LATC2
,
1177 _mesa_fetch_texel_2d_f_signed_la_latc2
,
1182 MESA_FORMAT_ETC1_RGB8
,
1184 _mesa_fetch_texel_2d_f_etc1_rgb8
,
1189 MESA_FORMAT_SIGNED_A8
,
1190 fetch_texel_1d_signed_a8
,
1191 fetch_texel_2d_signed_a8
,
1192 fetch_texel_3d_signed_a8
,
1193 store_texel_signed_a8
1196 MESA_FORMAT_SIGNED_L8
,
1197 fetch_texel_1d_signed_l8
,
1198 fetch_texel_2d_signed_l8
,
1199 fetch_texel_3d_signed_l8
,
1200 store_texel_signed_l8
1203 MESA_FORMAT_SIGNED_AL88
,
1204 fetch_texel_1d_signed_al88
,
1205 fetch_texel_2d_signed_al88
,
1206 fetch_texel_3d_signed_al88
,
1207 store_texel_signed_al88
1210 MESA_FORMAT_SIGNED_I8
,
1211 fetch_texel_1d_signed_i8
,
1212 fetch_texel_2d_signed_i8
,
1213 fetch_texel_3d_signed_i8
,
1214 store_texel_signed_i8
1217 MESA_FORMAT_SIGNED_A16
,
1218 fetch_texel_1d_signed_a16
,
1219 fetch_texel_2d_signed_a16
,
1220 fetch_texel_3d_signed_a16
,
1221 store_texel_signed_a16
1224 MESA_FORMAT_SIGNED_L16
,
1225 fetch_texel_1d_signed_l16
,
1226 fetch_texel_2d_signed_l16
,
1227 fetch_texel_3d_signed_l16
,
1228 store_texel_signed_l16
1231 MESA_FORMAT_SIGNED_AL1616
,
1232 fetch_texel_1d_signed_al1616
,
1233 fetch_texel_2d_signed_al1616
,
1234 fetch_texel_3d_signed_al1616
,
1235 store_texel_signed_al1616
1238 MESA_FORMAT_SIGNED_I16
,
1239 fetch_texel_1d_signed_i16
,
1240 fetch_texel_2d_signed_i16
,
1241 fetch_texel_3d_signed_i16
,
1242 store_texel_signed_i16
1245 MESA_FORMAT_RGB9_E5_FLOAT
,
1246 fetch_texel_1d_rgb9_e5
,
1247 fetch_texel_2d_rgb9_e5
,
1248 fetch_texel_3d_rgb9_e5
,
1252 MESA_FORMAT_R11_G11_B10_FLOAT
,
1253 fetch_texel_1d_r11_g11_b10f
,
1254 fetch_texel_2d_r11_g11_b10f
,
1255 fetch_texel_3d_r11_g11_b10f
,
1256 store_texel_r11_g11_b10f
1259 MESA_FORMAT_Z32_FLOAT
,
1260 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1261 fetch_texel_2d_f_r_f32
,
1262 fetch_texel_3d_f_r_f32
,
1266 MESA_FORMAT_Z32_FLOAT_X24S8
,
1267 fetch_texel_1d_z32f_x24s8
,
1268 fetch_texel_2d_z32f_x24s8
,
1269 fetch_texel_3d_z32f_x24s8
,
1270 store_texel_z32f_x24s8
1273 MESA_FORMAT_ARGB2101010_UINT
,
1283 _mesa_get_texel_fetch_func(gl_format format
, GLuint dims
)
1286 /* check that the table entries are sorted by format name */
1288 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1289 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1293 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1295 assert(format
< MESA_FORMAT_COUNT
);
1299 return texfetch_funcs
[format
].Fetch1D
;
1301 return texfetch_funcs
[format
].Fetch2D
;
1303 return texfetch_funcs
[format
].Fetch3D
;
1305 assert(0 && "bad dims in _mesa_get_texel_fetch_func");
1312 _mesa_get_texel_store_func(gl_format format
)
1314 assert(format
< MESA_FORMAT_COUNT
);
1315 return texfetch_funcs
[format
].StoreTexel
;
1320 * Initialize the texture image's FetchTexel methods.
1323 set_fetch_functions(struct swrast_texture_image
*texImage
, GLuint dims
)
1325 gl_format format
= texImage
->Base
.TexFormat
;
1327 ASSERT(dims
== 1 || dims
== 2 || dims
== 3);
1329 if (texImage
->Base
.TexObject
->Sampler
.sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1330 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1331 format
= _mesa_get_srgb_format_linear(format
);
1334 texImage
->FetchTexel
= _mesa_get_texel_fetch_func(format
, dims
);
1335 ASSERT(texImage
->FetchTexel
);
1339 _mesa_update_fetch_functions(struct gl_texture_object
*texObj
)
1344 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1346 for (face
= 0; face
< 6; face
++) {
1347 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1348 if (texObj
->Image
[face
][i
]) {
1349 set_fetch_functions(swrast_texture_image(texObj
->Image
[face
][i
]),