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 "main/samplerobj.h"
45 #include "s_context.h"
46 #include "s_texfetch.h"
47 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
48 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
52 * Convert an 8-bit sRGB value from non-linear space to a
53 * linear RGB value in [0, 1].
54 * Implemented with a 256-entry lookup table.
57 nonlinear_to_linear(GLubyte cs8
)
59 static GLfloat table
[256];
60 static GLboolean tableReady
= GL_FALSE
;
62 /* compute lookup table now */
64 for (i
= 0; i
< 256; i
++) {
65 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
67 table
[i
] = cs
/ 12.92f
;
70 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
80 /* Texel fetch routines for all supported formats
83 #include "s_texfetch_tmp.h"
86 #include "s_texfetch_tmp.h"
89 #include "s_texfetch_tmp.h"
93 * All compressed texture texel fetching is done though this function.
94 * Basically just call a core-Mesa texel fetch function.
97 fetch_compressed(const struct swrast_texture_image
*swImage
,
98 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
100 swImage
->FetchCompressedTexel(swImage
->Map
,
101 swImage
->ImageOffsets
,
109 * Null texel fetch function.
111 * Have to have this so the FetchTexel function pointer is never NULL.
113 static void fetch_null_texelf( const struct swrast_texture_image
*texImage
,
114 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
116 (void) texImage
; (void) i
; (void) j
; (void) k
;
121 _mesa_warning(NULL
, "fetch_null_texelf() called!");
126 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
127 * XXX this is somewhat temporary.
131 FetchTexelFunc Fetch1D
;
132 FetchTexelFunc Fetch2D
;
133 FetchTexelFunc Fetch3D
;
145 MESA_FORMAT_RGBA8888
,
146 fetch_texel_1d_f_rgba8888
,
147 fetch_texel_2d_f_rgba8888
,
148 fetch_texel_3d_f_rgba8888
151 MESA_FORMAT_RGBA8888_REV
,
152 fetch_texel_1d_f_rgba8888_rev
,
153 fetch_texel_2d_f_rgba8888_rev
,
154 fetch_texel_3d_f_rgba8888_rev
157 MESA_FORMAT_ARGB8888
,
158 fetch_texel_1d_f_argb8888
,
159 fetch_texel_2d_f_argb8888
,
160 fetch_texel_3d_f_argb8888
163 MESA_FORMAT_ARGB8888_REV
,
164 fetch_texel_1d_f_argb8888_rev
,
165 fetch_texel_2d_f_argb8888_rev
,
166 fetch_texel_3d_f_argb8888_rev
169 MESA_FORMAT_RGBX8888
,
170 fetch_texel_1d_f_rgbx8888
,
171 fetch_texel_2d_f_rgbx8888
,
172 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
181 MESA_FORMAT_XRGB8888
,
182 fetch_texel_1d_f_xrgb8888
,
183 fetch_texel_2d_f_xrgb8888
,
184 fetch_texel_3d_f_xrgb8888
187 MESA_FORMAT_XRGB8888_REV
,
188 fetch_texel_1d_f_xrgb8888_rev
,
189 fetch_texel_2d_f_xrgb8888_rev
,
190 fetch_texel_3d_f_xrgb8888_rev
194 fetch_texel_1d_f_rgb888
,
195 fetch_texel_2d_f_rgb888
,
196 fetch_texel_3d_f_rgb888
200 fetch_texel_1d_f_bgr888
,
201 fetch_texel_2d_f_bgr888
,
202 fetch_texel_3d_f_bgr888
206 fetch_texel_1d_f_rgb565
,
207 fetch_texel_2d_f_rgb565
,
208 fetch_texel_3d_f_rgb565
211 MESA_FORMAT_RGB565_REV
,
212 fetch_texel_1d_f_rgb565_rev
,
213 fetch_texel_2d_f_rgb565_rev
,
214 fetch_texel_3d_f_rgb565_rev
217 MESA_FORMAT_ARGB4444
,
218 fetch_texel_1d_f_argb4444
,
219 fetch_texel_2d_f_argb4444
,
220 fetch_texel_3d_f_argb4444
223 MESA_FORMAT_ARGB4444_REV
,
224 fetch_texel_1d_f_argb4444_rev
,
225 fetch_texel_2d_f_argb4444_rev
,
226 fetch_texel_3d_f_argb4444_rev
229 MESA_FORMAT_RGBA5551
,
230 fetch_texel_1d_f_rgba5551
,
231 fetch_texel_2d_f_rgba5551
,
232 fetch_texel_3d_f_rgba5551
235 MESA_FORMAT_ARGB1555
,
236 fetch_texel_1d_f_argb1555
,
237 fetch_texel_2d_f_argb1555
,
238 fetch_texel_3d_f_argb1555
241 MESA_FORMAT_ARGB1555_REV
,
242 fetch_texel_1d_f_argb1555_rev
,
243 fetch_texel_2d_f_argb1555_rev
,
244 fetch_texel_3d_f_argb1555_rev
248 fetch_texel_1d_f_al44
,
249 fetch_texel_2d_f_al44
,
250 fetch_texel_3d_f_al44
254 fetch_texel_1d_f_al88
,
255 fetch_texel_2d_f_al88
,
256 fetch_texel_3d_f_al88
259 MESA_FORMAT_AL88_REV
,
260 fetch_texel_1d_f_al88_rev
,
261 fetch_texel_2d_f_al88_rev
,
262 fetch_texel_3d_f_al88_rev
266 fetch_texel_1d_f_al1616
,
267 fetch_texel_2d_f_al1616
,
268 fetch_texel_3d_f_al1616
271 MESA_FORMAT_AL1616_REV
,
272 fetch_texel_1d_f_al1616_rev
,
273 fetch_texel_2d_f_al1616_rev
,
274 fetch_texel_3d_f_al1616_rev
278 fetch_texel_1d_f_rgb332
,
279 fetch_texel_2d_f_rgb332
,
280 fetch_texel_3d_f_rgb332
290 fetch_texel_1d_f_a16
,
291 fetch_texel_2d_f_a16
,
302 fetch_texel_1d_f_l16
,
303 fetch_texel_2d_f_l16
,
314 fetch_texel_1d_f_i16
,
315 fetch_texel_2d_f_i16
,
320 fetch_texel_1d_f_ycbcr
,
321 fetch_texel_2d_f_ycbcr
,
322 fetch_texel_3d_f_ycbcr
325 MESA_FORMAT_YCBCR_REV
,
326 fetch_texel_1d_f_ycbcr_rev
,
327 fetch_texel_2d_f_ycbcr_rev
,
328 fetch_texel_3d_f_ycbcr_rev
338 fetch_texel_1d_f_gr88
,
339 fetch_texel_2d_f_gr88
,
340 fetch_texel_3d_f_gr88
344 fetch_texel_1d_f_rg88
,
345 fetch_texel_2d_f_rg88
,
346 fetch_texel_3d_f_rg88
350 fetch_texel_1d_f_r16
,
351 fetch_texel_2d_f_r16
,
356 fetch_texel_1d_f_rg1616
,
357 fetch_texel_2d_f_rg1616
,
358 fetch_texel_3d_f_rg1616
362 fetch_texel_1d_f_rg1616_rev
,
363 fetch_texel_2d_f_rg1616_rev
,
364 fetch_texel_3d_f_rg1616_rev
367 MESA_FORMAT_ARGB2101010
,
368 fetch_texel_1d_f_argb2101010
,
369 fetch_texel_2d_f_argb2101010
,
370 fetch_texel_3d_f_argb2101010
374 fetch_texel_1d_f_z24_s8
,
375 fetch_texel_2d_f_z24_s8
,
376 fetch_texel_3d_f_z24_s8
380 fetch_texel_1d_f_s8_z24
,
381 fetch_texel_2d_f_s8_z24
,
382 fetch_texel_3d_f_s8_z24
386 fetch_texel_1d_f_z16
,
387 fetch_texel_2d_f_z16
,
392 fetch_texel_1d_f_s8_z24
,
393 fetch_texel_2d_f_s8_z24
,
394 fetch_texel_3d_f_s8_z24
398 fetch_texel_1d_f_z24_s8
,
399 fetch_texel_2d_f_z24_s8
,
400 fetch_texel_3d_f_z24_s8
404 fetch_texel_1d_f_z32
,
405 fetch_texel_2d_f_z32
,
416 fetch_texel_1d_srgb8
,
417 fetch_texel_2d_srgb8
,
422 fetch_texel_1d_srgba8
,
423 fetch_texel_2d_srgba8
,
424 fetch_texel_3d_srgba8
428 fetch_texel_1d_sargb8
,
429 fetch_texel_2d_sargb8
,
430 fetch_texel_3d_sargb8
445 MESA_FORMAT_SRGB_DXT1
,
451 MESA_FORMAT_SRGBA_DXT1
,
457 MESA_FORMAT_SRGBA_DXT3
,
463 MESA_FORMAT_SRGBA_DXT5
,
470 MESA_FORMAT_RGB_FXT1
,
476 MESA_FORMAT_RGBA_FXT1
,
482 MESA_FORMAT_RGB_DXT1
,
488 MESA_FORMAT_RGBA_DXT1
,
494 MESA_FORMAT_RGBA_DXT3
,
500 MESA_FORMAT_RGBA_DXT5
,
506 MESA_FORMAT_RGBA_FLOAT32
,
507 fetch_texel_1d_f_rgba_f32
,
508 fetch_texel_2d_f_rgba_f32
,
509 fetch_texel_3d_f_rgba_f32
512 MESA_FORMAT_RGBA_FLOAT16
,
513 fetch_texel_1d_f_rgba_f16
,
514 fetch_texel_2d_f_rgba_f16
,
515 fetch_texel_3d_f_rgba_f16
518 MESA_FORMAT_RGB_FLOAT32
,
519 fetch_texel_1d_f_rgb_f32
,
520 fetch_texel_2d_f_rgb_f32
,
521 fetch_texel_3d_f_rgb_f32
524 MESA_FORMAT_RGB_FLOAT16
,
525 fetch_texel_1d_f_rgb_f16
,
526 fetch_texel_2d_f_rgb_f16
,
527 fetch_texel_3d_f_rgb_f16
530 MESA_FORMAT_ALPHA_FLOAT32
,
531 fetch_texel_1d_f_alpha_f32
,
532 fetch_texel_2d_f_alpha_f32
,
533 fetch_texel_3d_f_alpha_f32
536 MESA_FORMAT_ALPHA_FLOAT16
,
537 fetch_texel_1d_f_alpha_f16
,
538 fetch_texel_2d_f_alpha_f16
,
539 fetch_texel_3d_f_alpha_f16
542 MESA_FORMAT_LUMINANCE_FLOAT32
,
543 fetch_texel_1d_f_luminance_f32
,
544 fetch_texel_2d_f_luminance_f32
,
545 fetch_texel_3d_f_luminance_f32
548 MESA_FORMAT_LUMINANCE_FLOAT16
,
549 fetch_texel_1d_f_luminance_f16
,
550 fetch_texel_2d_f_luminance_f16
,
551 fetch_texel_3d_f_luminance_f16
554 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
555 fetch_texel_1d_f_luminance_alpha_f32
,
556 fetch_texel_2d_f_luminance_alpha_f32
,
557 fetch_texel_3d_f_luminance_alpha_f32
560 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
561 fetch_texel_1d_f_luminance_alpha_f16
,
562 fetch_texel_2d_f_luminance_alpha_f16
,
563 fetch_texel_3d_f_luminance_alpha_f16
566 MESA_FORMAT_INTENSITY_FLOAT32
,
567 fetch_texel_1d_f_intensity_f32
,
568 fetch_texel_2d_f_intensity_f32
,
569 fetch_texel_3d_f_intensity_f32
572 MESA_FORMAT_INTENSITY_FLOAT16
,
573 fetch_texel_1d_f_intensity_f16
,
574 fetch_texel_2d_f_intensity_f16
,
575 fetch_texel_3d_f_intensity_f16
578 MESA_FORMAT_R_FLOAT32
,
579 fetch_texel_1d_f_r_f32
,
580 fetch_texel_2d_f_r_f32
,
581 fetch_texel_3d_f_r_f32
584 MESA_FORMAT_R_FLOAT16
,
585 fetch_texel_1d_f_r_f16
,
586 fetch_texel_2d_f_r_f16
,
587 fetch_texel_3d_f_r_f16
590 MESA_FORMAT_RG_FLOAT32
,
591 fetch_texel_1d_f_rg_f32
,
592 fetch_texel_2d_f_rg_f32
,
593 fetch_texel_3d_f_rg_f32
596 MESA_FORMAT_RG_FLOAT16
,
597 fetch_texel_1d_f_rg_f16
,
598 fetch_texel_2d_f_rg_f16
,
599 fetch_texel_3d_f_rg_f16
603 MESA_FORMAT_ALPHA_UINT8
,
610 MESA_FORMAT_ALPHA_UINT16
,
617 MESA_FORMAT_ALPHA_UINT32
,
624 MESA_FORMAT_ALPHA_INT8
,
631 MESA_FORMAT_ALPHA_INT16
,
638 MESA_FORMAT_ALPHA_INT32
,
646 MESA_FORMAT_INTENSITY_UINT8
,
653 MESA_FORMAT_INTENSITY_UINT16
,
660 MESA_FORMAT_INTENSITY_UINT32
,
667 MESA_FORMAT_INTENSITY_INT8
,
674 MESA_FORMAT_INTENSITY_INT16
,
681 MESA_FORMAT_INTENSITY_INT32
,
689 MESA_FORMAT_LUMINANCE_UINT8
,
696 MESA_FORMAT_LUMINANCE_UINT16
,
703 MESA_FORMAT_LUMINANCE_UINT32
,
710 MESA_FORMAT_LUMINANCE_INT8
,
717 MESA_FORMAT_LUMINANCE_INT16
,
724 MESA_FORMAT_LUMINANCE_INT32
,
732 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
739 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
746 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
753 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
760 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
767 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
789 MESA_FORMAT_RGB_INT8
,
795 /* non-normalized, signed int */
797 MESA_FORMAT_RGBA_INT8
,
798 fetch_texel_1d_rgba_int8
,
799 fetch_texel_2d_rgba_int8
,
800 fetch_texel_3d_rgba_int8
809 MESA_FORMAT_RG_INT16
,
815 MESA_FORMAT_RGB_INT16
,
821 MESA_FORMAT_RGBA_INT16
,
822 fetch_texel_1d_rgba_int16
,
823 fetch_texel_2d_rgba_int16
,
824 fetch_texel_3d_rgba_int16
833 MESA_FORMAT_RG_INT32
,
839 MESA_FORMAT_RGB_INT32
,
845 MESA_FORMAT_RGBA_INT32
,
846 fetch_texel_1d_rgba_int32
,
847 fetch_texel_2d_rgba_int32
,
848 fetch_texel_3d_rgba_int32
851 /* non-normalized, unsigned int */
859 MESA_FORMAT_RG_UINT8
,
865 MESA_FORMAT_RGB_UINT8
,
871 MESA_FORMAT_RGBA_UINT8
,
872 fetch_texel_1d_rgba_uint8
,
873 fetch_texel_2d_rgba_uint8
,
874 fetch_texel_3d_rgba_uint8
877 MESA_FORMAT_R_UINT16
,
883 MESA_FORMAT_RG_UINT16
,
889 MESA_FORMAT_RGB_UINT16
,
895 MESA_FORMAT_RGBA_UINT16
,
896 fetch_texel_1d_rgba_uint16
,
897 fetch_texel_2d_rgba_uint16
,
898 fetch_texel_3d_rgba_uint16
901 MESA_FORMAT_R_UINT32
,
907 MESA_FORMAT_RG_UINT32
,
913 MESA_FORMAT_RGB_UINT32
,
919 MESA_FORMAT_RGBA_UINT32
,
920 fetch_texel_1d_rgba_uint32
,
921 fetch_texel_2d_rgba_uint32
,
922 fetch_texel_3d_rgba_uint32
928 fetch_texel_1d_dudv8
,
929 fetch_texel_2d_dudv8
,
933 /* signed, normalized */
935 MESA_FORMAT_SIGNED_R8
,
936 fetch_texel_1d_signed_r8
,
937 fetch_texel_2d_signed_r8
,
938 fetch_texel_3d_signed_r8
941 MESA_FORMAT_SIGNED_RG88_REV
,
942 fetch_texel_1d_signed_rg88_rev
,
943 fetch_texel_2d_signed_rg88_rev
,
944 fetch_texel_3d_signed_rg88_rev
947 MESA_FORMAT_SIGNED_RGBX8888
,
948 fetch_texel_1d_signed_rgbx8888
,
949 fetch_texel_2d_signed_rgbx8888
,
950 fetch_texel_3d_signed_rgbx8888
953 MESA_FORMAT_SIGNED_RGBA8888
,
954 fetch_texel_1d_signed_rgba8888
,
955 fetch_texel_2d_signed_rgba8888
,
956 fetch_texel_3d_signed_rgba8888
959 MESA_FORMAT_SIGNED_RGBA8888_REV
,
960 fetch_texel_1d_signed_rgba8888_rev
,
961 fetch_texel_2d_signed_rgba8888_rev
,
962 fetch_texel_3d_signed_rgba8888_rev
965 MESA_FORMAT_SIGNED_R16
,
966 fetch_texel_1d_signed_r16
,
967 fetch_texel_2d_signed_r16
,
968 fetch_texel_3d_signed_r16
971 MESA_FORMAT_SIGNED_GR1616
,
972 fetch_texel_1d_signed_rg1616
,
973 fetch_texel_2d_signed_rg1616
,
974 fetch_texel_3d_signed_rg1616
977 MESA_FORMAT_SIGNED_RGB_16
,
978 fetch_texel_1d_signed_rgb_16
,
979 fetch_texel_2d_signed_rgb_16
,
980 fetch_texel_3d_signed_rgb_16
983 MESA_FORMAT_SIGNED_RGBA_16
,
984 fetch_texel_1d_signed_rgba_16
,
985 fetch_texel_2d_signed_rgba_16
,
986 fetch_texel_3d_signed_rgba_16
990 fetch_texel_1d_rgba_16
,
991 fetch_texel_2d_rgba_16
,
992 fetch_texel_3d_rgba_16
995 MESA_FORMAT_RED_RGTC1
,
1001 MESA_FORMAT_SIGNED_RED_RGTC1
,
1007 MESA_FORMAT_RG_RGTC2
,
1013 MESA_FORMAT_SIGNED_RG_RGTC2
,
1019 MESA_FORMAT_L_LATC1
,
1025 MESA_FORMAT_SIGNED_L_LATC1
,
1031 MESA_FORMAT_LA_LATC2
,
1037 MESA_FORMAT_SIGNED_LA_LATC2
,
1043 MESA_FORMAT_ETC1_RGB8
,
1049 MESA_FORMAT_ETC2_RGB8
,
1055 MESA_FORMAT_ETC2_SRGB8
,
1061 MESA_FORMAT_ETC2_RGBA8_EAC
,
1067 MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
,
1073 MESA_FORMAT_ETC2_R11_EAC
,
1079 MESA_FORMAT_ETC2_RG11_EAC
,
1085 MESA_FORMAT_ETC2_SIGNED_R11_EAC
,
1091 MESA_FORMAT_ETC2_SIGNED_RG11_EAC
,
1097 MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
,
1103 MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
,
1109 MESA_FORMAT_SIGNED_A8
,
1110 fetch_texel_1d_signed_a8
,
1111 fetch_texel_2d_signed_a8
,
1112 fetch_texel_3d_signed_a8
1115 MESA_FORMAT_SIGNED_L8
,
1116 fetch_texel_1d_signed_l8
,
1117 fetch_texel_2d_signed_l8
,
1118 fetch_texel_3d_signed_l8
1121 MESA_FORMAT_SIGNED_AL88
,
1122 fetch_texel_1d_signed_al88
,
1123 fetch_texel_2d_signed_al88
,
1124 fetch_texel_3d_signed_al88
1127 MESA_FORMAT_SIGNED_I8
,
1128 fetch_texel_1d_signed_i8
,
1129 fetch_texel_2d_signed_i8
,
1130 fetch_texel_3d_signed_i8
1133 MESA_FORMAT_SIGNED_A16
,
1134 fetch_texel_1d_signed_a16
,
1135 fetch_texel_2d_signed_a16
,
1136 fetch_texel_3d_signed_a16
1139 MESA_FORMAT_SIGNED_L16
,
1140 fetch_texel_1d_signed_l16
,
1141 fetch_texel_2d_signed_l16
,
1142 fetch_texel_3d_signed_l16
1145 MESA_FORMAT_SIGNED_AL1616
,
1146 fetch_texel_1d_signed_al1616
,
1147 fetch_texel_2d_signed_al1616
,
1148 fetch_texel_3d_signed_al1616
1151 MESA_FORMAT_SIGNED_I16
,
1152 fetch_texel_1d_signed_i16
,
1153 fetch_texel_2d_signed_i16
,
1154 fetch_texel_3d_signed_i16
1157 MESA_FORMAT_RGB9_E5_FLOAT
,
1158 fetch_texel_1d_rgb9_e5
,
1159 fetch_texel_2d_rgb9_e5
,
1160 fetch_texel_3d_rgb9_e5
1163 MESA_FORMAT_R11_G11_B10_FLOAT
,
1164 fetch_texel_1d_r11_g11_b10f
,
1165 fetch_texel_2d_r11_g11_b10f
,
1166 fetch_texel_3d_r11_g11_b10f
1169 MESA_FORMAT_Z32_FLOAT
,
1170 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1171 fetch_texel_2d_f_r_f32
,
1172 fetch_texel_3d_f_r_f32
1175 MESA_FORMAT_Z32_FLOAT_X24S8
,
1176 fetch_texel_1d_z32f_x24s8
,
1177 fetch_texel_2d_z32f_x24s8
,
1178 fetch_texel_3d_z32f_x24s8
1181 MESA_FORMAT_ARGB2101010_UINT
,
1187 MESA_FORMAT_ABGR2101010_UINT
,
1193 MESA_FORMAT_XRGB4444_UNORM
,
1199 MESA_FORMAT_XRGB1555_UNORM
,
1205 MESA_FORMAT_XBGR8888_SNORM
,
1211 MESA_FORMAT_XBGR8888_SRGB
,
1217 MESA_FORMAT_XBGR8888_UINT
,
1223 MESA_FORMAT_XBGR8888_SINT
,
1229 MESA_FORMAT_XRGB2101010_UNORM
,
1235 MESA_FORMAT_XBGR16161616_UNORM
,
1241 MESA_FORMAT_XBGR16161616_SNORM
,
1247 MESA_FORMAT_XBGR16161616_FLOAT
,
1253 MESA_FORMAT_XBGR16161616_UINT
,
1259 MESA_FORMAT_XBGR16161616_SINT
,
1265 MESA_FORMAT_XBGR32323232_FLOAT
,
1271 MESA_FORMAT_XBGR32323232_UINT
,
1277 MESA_FORMAT_XBGR32323232_SINT
,
1286 * Initialize the texture image's FetchTexel methods.
1289 set_fetch_functions(const struct gl_sampler_object
*samp
,
1290 struct swrast_texture_image
*texImage
, GLuint dims
)
1292 gl_format format
= texImage
->Base
.TexFormat
;
1295 /* check that the table entries are sorted by format name */
1297 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1298 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1302 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1304 if (samp
->sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1305 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1306 format
= _mesa_get_srgb_format_linear(format
);
1309 assert(format
< MESA_FORMAT_COUNT
);
1313 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch1D
;
1316 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch2D
;
1319 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch3D
;
1322 assert(!"Bad dims in set_fetch_functions()");
1325 texImage
->FetchCompressedTexel
= _mesa_get_compressed_fetch_func(format
);
1327 ASSERT(texImage
->FetchTexel
);
1331 _mesa_update_fetch_functions(struct gl_context
*ctx
, GLuint unit
)
1333 struct gl_texture_object
*texObj
= ctx
->Texture
.Unit
[unit
]._Current
;
1334 struct gl_sampler_object
*samp
;
1341 samp
= _mesa_get_samplerobj(ctx
, unit
);
1343 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1345 for (face
= 0; face
< 6; face
++) {
1346 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1347 if (texObj
->Image
[face
][i
]) {
1348 set_fetch_functions(samp
,
1349 swrast_texture_image(texObj
->Image
[face
][i
]),