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!");
108 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
109 * XXX this is somewhat temporary.
113 FetchTexelFunc Fetch1D
;
114 FetchTexelFunc Fetch2D
;
115 FetchTexelFunc Fetch3D
;
117 texfetch_funcs
[MESA_FORMAT_COUNT
] =
127 MESA_FORMAT_RGBA8888
,
128 fetch_texel_1d_f_rgba8888
,
129 fetch_texel_2d_f_rgba8888
,
130 fetch_texel_3d_f_rgba8888
133 MESA_FORMAT_RGBA8888_REV
,
134 fetch_texel_1d_f_rgba8888_rev
,
135 fetch_texel_2d_f_rgba8888_rev
,
136 fetch_texel_3d_f_rgba8888_rev
139 MESA_FORMAT_ARGB8888
,
140 fetch_texel_1d_f_argb8888
,
141 fetch_texel_2d_f_argb8888
,
142 fetch_texel_3d_f_argb8888
145 MESA_FORMAT_ARGB8888_REV
,
146 fetch_texel_1d_f_argb8888_rev
,
147 fetch_texel_2d_f_argb8888_rev
,
148 fetch_texel_3d_f_argb8888_rev
151 MESA_FORMAT_RGBX8888
,
152 fetch_texel_1d_f_rgbx8888
,
153 fetch_texel_2d_f_rgbx8888
,
154 fetch_texel_3d_f_rgbx8888
157 MESA_FORMAT_RGBX8888_REV
,
158 fetch_texel_1d_f_rgbx8888_rev
,
159 fetch_texel_2d_f_rgbx8888_rev
,
160 fetch_texel_3d_f_rgbx8888_rev
163 MESA_FORMAT_XRGB8888
,
164 fetch_texel_1d_f_xrgb8888
,
165 fetch_texel_2d_f_xrgb8888
,
166 fetch_texel_3d_f_xrgb8888
169 MESA_FORMAT_XRGB8888_REV
,
170 fetch_texel_1d_f_xrgb8888_rev
,
171 fetch_texel_2d_f_xrgb8888_rev
,
172 fetch_texel_3d_f_xrgb8888_rev
176 fetch_texel_1d_f_rgb888
,
177 fetch_texel_2d_f_rgb888
,
178 fetch_texel_3d_f_rgb888
182 fetch_texel_1d_f_bgr888
,
183 fetch_texel_2d_f_bgr888
,
184 fetch_texel_3d_f_bgr888
188 fetch_texel_1d_f_rgb565
,
189 fetch_texel_2d_f_rgb565
,
190 fetch_texel_3d_f_rgb565
193 MESA_FORMAT_RGB565_REV
,
194 fetch_texel_1d_f_rgb565_rev
,
195 fetch_texel_2d_f_rgb565_rev
,
196 fetch_texel_3d_f_rgb565_rev
199 MESA_FORMAT_ARGB4444
,
200 fetch_texel_1d_f_argb4444
,
201 fetch_texel_2d_f_argb4444
,
202 fetch_texel_3d_f_argb4444
205 MESA_FORMAT_ARGB4444_REV
,
206 fetch_texel_1d_f_argb4444_rev
,
207 fetch_texel_2d_f_argb4444_rev
,
208 fetch_texel_3d_f_argb4444_rev
211 MESA_FORMAT_RGBA5551
,
212 fetch_texel_1d_f_rgba5551
,
213 fetch_texel_2d_f_rgba5551
,
214 fetch_texel_3d_f_rgba5551
217 MESA_FORMAT_ARGB1555
,
218 fetch_texel_1d_f_argb1555
,
219 fetch_texel_2d_f_argb1555
,
220 fetch_texel_3d_f_argb1555
223 MESA_FORMAT_ARGB1555_REV
,
224 fetch_texel_1d_f_argb1555_rev
,
225 fetch_texel_2d_f_argb1555_rev
,
226 fetch_texel_3d_f_argb1555_rev
230 fetch_texel_1d_f_al44
,
231 fetch_texel_2d_f_al44
,
232 fetch_texel_3d_f_al44
236 fetch_texel_1d_f_al88
,
237 fetch_texel_2d_f_al88
,
238 fetch_texel_3d_f_al88
241 MESA_FORMAT_AL88_REV
,
242 fetch_texel_1d_f_al88_rev
,
243 fetch_texel_2d_f_al88_rev
,
244 fetch_texel_3d_f_al88_rev
248 fetch_texel_1d_f_al1616
,
249 fetch_texel_2d_f_al1616
,
250 fetch_texel_3d_f_al1616
253 MESA_FORMAT_AL1616_REV
,
254 fetch_texel_1d_f_al1616_rev
,
255 fetch_texel_2d_f_al1616_rev
,
256 fetch_texel_3d_f_al1616_rev
260 fetch_texel_1d_f_rgb332
,
261 fetch_texel_2d_f_rgb332
,
262 fetch_texel_3d_f_rgb332
272 fetch_texel_1d_f_a16
,
273 fetch_texel_2d_f_a16
,
284 fetch_texel_1d_f_l16
,
285 fetch_texel_2d_f_l16
,
296 fetch_texel_1d_f_i16
,
297 fetch_texel_2d_f_i16
,
302 fetch_texel_1d_f_ycbcr
,
303 fetch_texel_2d_f_ycbcr
,
304 fetch_texel_3d_f_ycbcr
307 MESA_FORMAT_YCBCR_REV
,
308 fetch_texel_1d_f_ycbcr_rev
,
309 fetch_texel_2d_f_ycbcr_rev
,
310 fetch_texel_3d_f_ycbcr_rev
320 fetch_texel_1d_f_gr88
,
321 fetch_texel_2d_f_gr88
,
322 fetch_texel_3d_f_gr88
326 fetch_texel_1d_f_rg88
,
327 fetch_texel_2d_f_rg88
,
328 fetch_texel_3d_f_rg88
332 fetch_texel_1d_f_r16
,
333 fetch_texel_2d_f_r16
,
338 fetch_texel_1d_f_rg1616
,
339 fetch_texel_2d_f_rg1616
,
340 fetch_texel_3d_f_rg1616
343 MESA_FORMAT_RG1616_REV
,
344 fetch_texel_1d_f_rg1616_rev
,
345 fetch_texel_2d_f_rg1616_rev
,
346 fetch_texel_3d_f_rg1616_rev
349 MESA_FORMAT_ARGB2101010
,
350 fetch_texel_1d_f_argb2101010
,
351 fetch_texel_2d_f_argb2101010
,
352 fetch_texel_3d_f_argb2101010
356 fetch_texel_1d_f_z24_s8
,
357 fetch_texel_2d_f_z24_s8
,
358 fetch_texel_3d_f_z24_s8
362 fetch_texel_1d_f_s8_z24
,
363 fetch_texel_2d_f_s8_z24
,
364 fetch_texel_3d_f_s8_z24
368 fetch_texel_1d_f_z16
,
369 fetch_texel_2d_f_z16
,
374 fetch_texel_1d_f_s8_z24
,
375 fetch_texel_2d_f_s8_z24
,
376 fetch_texel_3d_f_s8_z24
380 fetch_texel_1d_f_z24_s8
,
381 fetch_texel_2d_f_z24_s8
,
382 fetch_texel_3d_f_z24_s8
386 fetch_texel_1d_f_z32
,
387 fetch_texel_2d_f_z32
,
398 fetch_texel_1d_srgb8
,
399 fetch_texel_2d_srgb8
,
404 fetch_texel_1d_srgba8
,
405 fetch_texel_2d_srgba8
,
406 fetch_texel_3d_srgba8
410 fetch_texel_1d_sargb8
,
411 fetch_texel_2d_sargb8
,
412 fetch_texel_3d_sargb8
427 MESA_FORMAT_SRGB_DXT1
,
429 _mesa_fetch_texel_2d_f_srgb_dxt1
,
433 MESA_FORMAT_SRGBA_DXT1
,
435 _mesa_fetch_texel_2d_f_srgba_dxt1
,
439 MESA_FORMAT_SRGBA_DXT3
,
441 _mesa_fetch_texel_2d_f_srgba_dxt3
,
445 MESA_FORMAT_SRGBA_DXT5
,
447 _mesa_fetch_texel_2d_f_srgba_dxt5
,
452 MESA_FORMAT_RGB_FXT1
,
454 _mesa_fetch_texel_2d_f_rgb_fxt1
,
458 MESA_FORMAT_RGBA_FXT1
,
460 _mesa_fetch_texel_2d_f_rgba_fxt1
,
464 MESA_FORMAT_RGB_DXT1
,
466 _mesa_fetch_texel_2d_f_rgb_dxt1
,
470 MESA_FORMAT_RGBA_DXT1
,
472 _mesa_fetch_texel_2d_f_rgba_dxt1
,
476 MESA_FORMAT_RGBA_DXT3
,
478 _mesa_fetch_texel_2d_f_rgba_dxt3
,
482 MESA_FORMAT_RGBA_DXT5
,
484 _mesa_fetch_texel_2d_f_rgba_dxt5
,
488 MESA_FORMAT_RGBA_FLOAT32
,
489 fetch_texel_1d_f_rgba_f32
,
490 fetch_texel_2d_f_rgba_f32
,
491 fetch_texel_3d_f_rgba_f32
494 MESA_FORMAT_RGBA_FLOAT16
,
495 fetch_texel_1d_f_rgba_f16
,
496 fetch_texel_2d_f_rgba_f16
,
497 fetch_texel_3d_f_rgba_f16
500 MESA_FORMAT_RGB_FLOAT32
,
501 fetch_texel_1d_f_rgb_f32
,
502 fetch_texel_2d_f_rgb_f32
,
503 fetch_texel_3d_f_rgb_f32
506 MESA_FORMAT_RGB_FLOAT16
,
507 fetch_texel_1d_f_rgb_f16
,
508 fetch_texel_2d_f_rgb_f16
,
509 fetch_texel_3d_f_rgb_f16
512 MESA_FORMAT_ALPHA_FLOAT32
,
513 fetch_texel_1d_f_alpha_f32
,
514 fetch_texel_2d_f_alpha_f32
,
515 fetch_texel_3d_f_alpha_f32
518 MESA_FORMAT_ALPHA_FLOAT16
,
519 fetch_texel_1d_f_alpha_f16
,
520 fetch_texel_2d_f_alpha_f16
,
521 fetch_texel_3d_f_alpha_f16
524 MESA_FORMAT_LUMINANCE_FLOAT32
,
525 fetch_texel_1d_f_luminance_f32
,
526 fetch_texel_2d_f_luminance_f32
,
527 fetch_texel_3d_f_luminance_f32
530 MESA_FORMAT_LUMINANCE_FLOAT16
,
531 fetch_texel_1d_f_luminance_f16
,
532 fetch_texel_2d_f_luminance_f16
,
533 fetch_texel_3d_f_luminance_f16
536 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
537 fetch_texel_1d_f_luminance_alpha_f32
,
538 fetch_texel_2d_f_luminance_alpha_f32
,
539 fetch_texel_3d_f_luminance_alpha_f32
542 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
543 fetch_texel_1d_f_luminance_alpha_f16
,
544 fetch_texel_2d_f_luminance_alpha_f16
,
545 fetch_texel_3d_f_luminance_alpha_f16
548 MESA_FORMAT_INTENSITY_FLOAT32
,
549 fetch_texel_1d_f_intensity_f32
,
550 fetch_texel_2d_f_intensity_f32
,
551 fetch_texel_3d_f_intensity_f32
554 MESA_FORMAT_INTENSITY_FLOAT16
,
555 fetch_texel_1d_f_intensity_f16
,
556 fetch_texel_2d_f_intensity_f16
,
557 fetch_texel_3d_f_intensity_f16
560 MESA_FORMAT_R_FLOAT32
,
561 fetch_texel_1d_f_r_f32
,
562 fetch_texel_2d_f_r_f32
,
563 fetch_texel_3d_f_r_f32
566 MESA_FORMAT_R_FLOAT16
,
567 fetch_texel_1d_f_r_f16
,
568 fetch_texel_2d_f_r_f16
,
569 fetch_texel_3d_f_r_f16
572 MESA_FORMAT_RG_FLOAT32
,
573 fetch_texel_1d_f_rg_f32
,
574 fetch_texel_2d_f_rg_f32
,
575 fetch_texel_3d_f_rg_f32
578 MESA_FORMAT_RG_FLOAT16
,
579 fetch_texel_1d_f_rg_f16
,
580 fetch_texel_2d_f_rg_f16
,
581 fetch_texel_3d_f_rg_f16
585 MESA_FORMAT_ALPHA_UINT8
,
592 MESA_FORMAT_ALPHA_UINT16
,
599 MESA_FORMAT_ALPHA_UINT32
,
606 MESA_FORMAT_ALPHA_INT8
,
613 MESA_FORMAT_ALPHA_INT16
,
620 MESA_FORMAT_ALPHA_INT32
,
628 MESA_FORMAT_INTENSITY_UINT8
,
635 MESA_FORMAT_INTENSITY_UINT16
,
642 MESA_FORMAT_INTENSITY_UINT32
,
649 MESA_FORMAT_INTENSITY_INT8
,
656 MESA_FORMAT_INTENSITY_INT16
,
663 MESA_FORMAT_INTENSITY_INT32
,
671 MESA_FORMAT_LUMINANCE_UINT8
,
678 MESA_FORMAT_LUMINANCE_UINT16
,
685 MESA_FORMAT_LUMINANCE_UINT32
,
692 MESA_FORMAT_LUMINANCE_INT8
,
699 MESA_FORMAT_LUMINANCE_INT16
,
706 MESA_FORMAT_LUMINANCE_INT32
,
714 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
721 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
728 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
735 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
742 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
749 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
771 MESA_FORMAT_RGB_INT8
,
777 /* non-normalized, signed int */
779 MESA_FORMAT_RGBA_INT8
,
780 fetch_texel_1d_rgba_int8
,
781 fetch_texel_2d_rgba_int8
,
782 fetch_texel_3d_rgba_int8
791 MESA_FORMAT_RG_INT16
,
797 MESA_FORMAT_RGB_INT16
,
803 MESA_FORMAT_RGBA_INT16
,
804 fetch_texel_1d_rgba_int16
,
805 fetch_texel_2d_rgba_int16
,
806 fetch_texel_3d_rgba_int16
815 MESA_FORMAT_RG_INT32
,
821 MESA_FORMAT_RGB_INT32
,
827 MESA_FORMAT_RGBA_INT32
,
828 fetch_texel_1d_rgba_int32
,
829 fetch_texel_2d_rgba_int32
,
830 fetch_texel_3d_rgba_int32
833 /* non-normalized, unsigned int */
841 MESA_FORMAT_RG_UINT8
,
847 MESA_FORMAT_RGB_UINT8
,
853 MESA_FORMAT_RGBA_UINT8
,
854 fetch_texel_1d_rgba_uint8
,
855 fetch_texel_2d_rgba_uint8
,
856 fetch_texel_3d_rgba_uint8
859 MESA_FORMAT_R_UINT16
,
865 MESA_FORMAT_RG_UINT16
,
871 MESA_FORMAT_RGB_UINT16
,
877 MESA_FORMAT_RGBA_UINT16
,
878 fetch_texel_1d_rgba_uint16
,
879 fetch_texel_2d_rgba_uint16
,
880 fetch_texel_3d_rgba_uint16
883 MESA_FORMAT_R_UINT32
,
889 MESA_FORMAT_RG_UINT32
,
895 MESA_FORMAT_RGB_UINT32
,
901 MESA_FORMAT_RGBA_UINT32
,
902 fetch_texel_1d_rgba_uint32
,
903 fetch_texel_2d_rgba_uint32
,
904 fetch_texel_3d_rgba_uint32
910 fetch_texel_1d_dudv8
,
911 fetch_texel_2d_dudv8
,
915 /* signed, normalized */
917 MESA_FORMAT_SIGNED_R8
,
918 fetch_texel_1d_signed_r8
,
919 fetch_texel_2d_signed_r8
,
920 fetch_texel_3d_signed_r8
923 MESA_FORMAT_SIGNED_RG88_REV
,
924 fetch_texel_1d_signed_rg88_rev
,
925 fetch_texel_2d_signed_rg88_rev
,
926 fetch_texel_3d_signed_rg88_rev
929 MESA_FORMAT_SIGNED_RGBX8888
,
930 fetch_texel_1d_signed_rgbx8888
,
931 fetch_texel_2d_signed_rgbx8888
,
932 fetch_texel_3d_signed_rgbx8888
935 MESA_FORMAT_SIGNED_RGBA8888
,
936 fetch_texel_1d_signed_rgba8888
,
937 fetch_texel_2d_signed_rgba8888
,
938 fetch_texel_3d_signed_rgba8888
941 MESA_FORMAT_SIGNED_RGBA8888_REV
,
942 fetch_texel_1d_signed_rgba8888_rev
,
943 fetch_texel_2d_signed_rgba8888_rev
,
944 fetch_texel_3d_signed_rgba8888_rev
947 MESA_FORMAT_SIGNED_R16
,
948 fetch_texel_1d_signed_r16
,
949 fetch_texel_2d_signed_r16
,
950 fetch_texel_3d_signed_r16
953 MESA_FORMAT_SIGNED_GR1616
,
954 fetch_texel_1d_signed_rg1616
,
955 fetch_texel_2d_signed_rg1616
,
956 fetch_texel_3d_signed_rg1616
959 MESA_FORMAT_SIGNED_RGB_16
,
960 fetch_texel_1d_signed_rgb_16
,
961 fetch_texel_2d_signed_rgb_16
,
962 fetch_texel_3d_signed_rgb_16
965 MESA_FORMAT_SIGNED_RGBA_16
,
966 fetch_texel_1d_signed_rgba_16
,
967 fetch_texel_2d_signed_rgba_16
,
968 fetch_texel_3d_signed_rgba_16
972 fetch_texel_1d_rgba_16
,
973 fetch_texel_2d_rgba_16
,
974 fetch_texel_3d_rgba_16
977 MESA_FORMAT_RED_RGTC1
,
979 _mesa_fetch_texel_2d_f_red_rgtc1
,
983 MESA_FORMAT_SIGNED_RED_RGTC1
,
985 _mesa_fetch_texel_2d_f_signed_red_rgtc1
,
989 MESA_FORMAT_RG_RGTC2
,
991 _mesa_fetch_texel_2d_f_rg_rgtc2
,
995 MESA_FORMAT_SIGNED_RG_RGTC2
,
997 _mesa_fetch_texel_2d_f_signed_rg_rgtc2
,
1001 MESA_FORMAT_L_LATC1
,
1003 _mesa_fetch_texel_2d_f_l_latc1
,
1007 MESA_FORMAT_SIGNED_L_LATC1
,
1009 _mesa_fetch_texel_2d_f_signed_l_latc1
,
1013 MESA_FORMAT_LA_LATC2
,
1015 _mesa_fetch_texel_2d_f_la_latc2
,
1019 MESA_FORMAT_SIGNED_LA_LATC2
,
1021 _mesa_fetch_texel_2d_f_signed_la_latc2
,
1025 MESA_FORMAT_ETC1_RGB8
,
1027 _mesa_fetch_texel_2d_f_etc1_rgb8
,
1031 MESA_FORMAT_SIGNED_A8
,
1032 fetch_texel_1d_signed_a8
,
1033 fetch_texel_2d_signed_a8
,
1034 fetch_texel_3d_signed_a8
1037 MESA_FORMAT_SIGNED_L8
,
1038 fetch_texel_1d_signed_l8
,
1039 fetch_texel_2d_signed_l8
,
1040 fetch_texel_3d_signed_l8
1043 MESA_FORMAT_SIGNED_AL88
,
1044 fetch_texel_1d_signed_al88
,
1045 fetch_texel_2d_signed_al88
,
1046 fetch_texel_3d_signed_al88
1049 MESA_FORMAT_SIGNED_I8
,
1050 fetch_texel_1d_signed_i8
,
1051 fetch_texel_2d_signed_i8
,
1052 fetch_texel_3d_signed_i8
1055 MESA_FORMAT_SIGNED_A16
,
1056 fetch_texel_1d_signed_a16
,
1057 fetch_texel_2d_signed_a16
,
1058 fetch_texel_3d_signed_a16
1061 MESA_FORMAT_SIGNED_L16
,
1062 fetch_texel_1d_signed_l16
,
1063 fetch_texel_2d_signed_l16
,
1064 fetch_texel_3d_signed_l16
1067 MESA_FORMAT_SIGNED_AL1616
,
1068 fetch_texel_1d_signed_al1616
,
1069 fetch_texel_2d_signed_al1616
,
1070 fetch_texel_3d_signed_al1616
1073 MESA_FORMAT_SIGNED_I16
,
1074 fetch_texel_1d_signed_i16
,
1075 fetch_texel_2d_signed_i16
,
1076 fetch_texel_3d_signed_i16
1079 MESA_FORMAT_RGB9_E5_FLOAT
,
1080 fetch_texel_1d_rgb9_e5
,
1081 fetch_texel_2d_rgb9_e5
,
1082 fetch_texel_3d_rgb9_e5
1085 MESA_FORMAT_R11_G11_B10_FLOAT
,
1086 fetch_texel_1d_r11_g11_b10f
,
1087 fetch_texel_2d_r11_g11_b10f
,
1088 fetch_texel_3d_r11_g11_b10f
1091 MESA_FORMAT_Z32_FLOAT
,
1092 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1093 fetch_texel_2d_f_r_f32
,
1094 fetch_texel_3d_f_r_f32
1097 MESA_FORMAT_Z32_FLOAT_X24S8
,
1098 fetch_texel_1d_z32f_x24s8
,
1099 fetch_texel_2d_z32f_x24s8
,
1100 fetch_texel_3d_z32f_x24s8
1103 MESA_FORMAT_ARGB2101010_UINT
,
1112 _mesa_get_texel_fetch_func(gl_format format
, GLuint dims
)
1115 /* check that the table entries are sorted by format name */
1117 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1118 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1122 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1124 assert(format
< MESA_FORMAT_COUNT
);
1128 return texfetch_funcs
[format
].Fetch1D
;
1130 return texfetch_funcs
[format
].Fetch2D
;
1132 return texfetch_funcs
[format
].Fetch3D
;
1134 assert(0 && "bad dims in _mesa_get_texel_fetch_func");
1141 * Initialize the texture image's FetchTexel methods.
1144 set_fetch_functions(struct swrast_texture_image
*texImage
, GLuint dims
)
1146 gl_format format
= texImage
->Base
.TexFormat
;
1148 ASSERT(dims
== 1 || dims
== 2 || dims
== 3);
1150 if (texImage
->Base
.TexObject
->Sampler
.sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1151 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1152 format
= _mesa_get_srgb_format_linear(format
);
1155 texImage
->FetchTexel
= _mesa_get_texel_fetch_func(format
, dims
);
1156 ASSERT(texImage
->FetchTexel
);
1160 _mesa_update_fetch_functions(struct gl_texture_object
*texObj
)
1165 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1167 for (face
= 0; face
< 6; face
++) {
1168 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1169 if (texObj
->Image
[face
][i
]) {
1170 set_fetch_functions(swrast_texture_image(texObj
->Image
[face
][i
]),