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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
31 * Texel fetch/store functions
33 * \author Gareth Hughes
37 #include "main/colormac.h"
38 #include "main/macros.h"
39 #include "main/texcompress.h"
40 #include "main/texcompress_fxt1.h"
41 #include "main/texcompress_s3tc.h"
42 #include "main/texcompress_rgtc.h"
43 #include "main/texcompress_etc.h"
44 #include "main/teximage.h"
45 #include "main/samplerobj.h"
46 #include "s_context.h"
47 #include "s_texfetch.h"
48 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
49 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
53 * Convert an 8-bit sRGB value from non-linear space to a
54 * linear RGB value in [0, 1].
55 * Implemented with a 256-entry lookup table.
58 nonlinear_to_linear(GLubyte cs8
)
60 static GLfloat table
[256];
61 static GLboolean tableReady
= GL_FALSE
;
63 /* compute lookup table now */
65 for (i
= 0; i
< 256; i
++) {
66 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
68 table
[i
] = cs
/ 12.92f
;
71 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
81 /* Texel fetch routines for all supported formats
84 #include "s_texfetch_tmp.h"
87 #include "s_texfetch_tmp.h"
90 #include "s_texfetch_tmp.h"
94 * All compressed texture texel fetching is done though this function.
95 * Basically just call a core-Mesa texel fetch function.
98 fetch_compressed(const struct swrast_texture_image
*swImage
,
99 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
101 /* The FetchCompressedTexel function takes an integer pixel rowstride,
102 * while the image's rowstride is bytes per row of blocks.
105 GLuint texelBytes
= _mesa_get_format_bytes(swImage
->Base
.TexFormat
);
106 _mesa_get_format_block_size(swImage
->Base
.TexFormat
, &bw
, &bh
);
107 assert(swImage
->RowStride
* bw
% texelBytes
== 0);
109 swImage
->FetchCompressedTexel(swImage
->ImageSlices
[k
],
110 swImage
->RowStride
* bw
/ texelBytes
,
117 * Null texel fetch function.
119 * Have to have this so the FetchTexel function pointer is never NULL.
121 static void fetch_null_texelf( const struct swrast_texture_image
*texImage
,
122 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
124 (void) texImage
; (void) i
; (void) j
; (void) k
;
129 _mesa_warning(NULL
, "fetch_null_texelf() called!");
134 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
135 * XXX this is somewhat temporary.
139 FetchTexelFunc Fetch1D
;
140 FetchTexelFunc Fetch2D
;
141 FetchTexelFunc Fetch3D
;
153 MESA_FORMAT_RGBA8888
,
154 fetch_texel_1d_f_rgba8888
,
155 fetch_texel_2d_f_rgba8888
,
156 fetch_texel_3d_f_rgba8888
159 MESA_FORMAT_RGBA8888_REV
,
160 fetch_texel_1d_f_rgba8888_rev
,
161 fetch_texel_2d_f_rgba8888_rev
,
162 fetch_texel_3d_f_rgba8888_rev
165 MESA_FORMAT_ARGB8888
,
166 fetch_texel_1d_f_argb8888
,
167 fetch_texel_2d_f_argb8888
,
168 fetch_texel_3d_f_argb8888
171 MESA_FORMAT_ARGB8888_REV
,
172 fetch_texel_1d_f_argb8888_rev
,
173 fetch_texel_2d_f_argb8888_rev
,
174 fetch_texel_3d_f_argb8888_rev
177 MESA_FORMAT_RGBX8888
,
178 fetch_texel_1d_f_rgbx8888
,
179 fetch_texel_2d_f_rgbx8888
,
180 fetch_texel_3d_f_rgbx8888
183 MESA_FORMAT_RGBX8888_REV
,
184 fetch_texel_1d_f_rgbx8888_rev
,
185 fetch_texel_2d_f_rgbx8888_rev
,
186 fetch_texel_3d_f_rgbx8888_rev
189 MESA_FORMAT_XRGB8888
,
190 fetch_texel_1d_f_xrgb8888
,
191 fetch_texel_2d_f_xrgb8888
,
192 fetch_texel_3d_f_xrgb8888
195 MESA_FORMAT_XRGB8888_REV
,
196 fetch_texel_1d_f_xrgb8888_rev
,
197 fetch_texel_2d_f_xrgb8888_rev
,
198 fetch_texel_3d_f_xrgb8888_rev
202 fetch_texel_1d_f_rgb888
,
203 fetch_texel_2d_f_rgb888
,
204 fetch_texel_3d_f_rgb888
208 fetch_texel_1d_f_bgr888
,
209 fetch_texel_2d_f_bgr888
,
210 fetch_texel_3d_f_bgr888
214 fetch_texel_1d_f_rgb565
,
215 fetch_texel_2d_f_rgb565
,
216 fetch_texel_3d_f_rgb565
219 MESA_FORMAT_RGB565_REV
,
220 fetch_texel_1d_f_rgb565_rev
,
221 fetch_texel_2d_f_rgb565_rev
,
222 fetch_texel_3d_f_rgb565_rev
225 MESA_FORMAT_ARGB4444
,
226 fetch_texel_1d_f_argb4444
,
227 fetch_texel_2d_f_argb4444
,
228 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
237 MESA_FORMAT_RGBA5551
,
238 fetch_texel_1d_f_rgba5551
,
239 fetch_texel_2d_f_rgba5551
,
240 fetch_texel_3d_f_rgba5551
243 MESA_FORMAT_ARGB1555
,
244 fetch_texel_1d_f_argb1555
,
245 fetch_texel_2d_f_argb1555
,
246 fetch_texel_3d_f_argb1555
249 MESA_FORMAT_ARGB1555_REV
,
250 fetch_texel_1d_f_argb1555_rev
,
251 fetch_texel_2d_f_argb1555_rev
,
252 fetch_texel_3d_f_argb1555_rev
256 fetch_texel_1d_f_al44
,
257 fetch_texel_2d_f_al44
,
258 fetch_texel_3d_f_al44
262 fetch_texel_1d_f_al88
,
263 fetch_texel_2d_f_al88
,
264 fetch_texel_3d_f_al88
267 MESA_FORMAT_AL88_REV
,
268 fetch_texel_1d_f_al88_rev
,
269 fetch_texel_2d_f_al88_rev
,
270 fetch_texel_3d_f_al88_rev
274 fetch_texel_1d_f_al1616
,
275 fetch_texel_2d_f_al1616
,
276 fetch_texel_3d_f_al1616
279 MESA_FORMAT_AL1616_REV
,
280 fetch_texel_1d_f_al1616_rev
,
281 fetch_texel_2d_f_al1616_rev
,
282 fetch_texel_3d_f_al1616_rev
286 fetch_texel_1d_f_rgb332
,
287 fetch_texel_2d_f_rgb332
,
288 fetch_texel_3d_f_rgb332
298 fetch_texel_1d_f_a16
,
299 fetch_texel_2d_f_a16
,
310 fetch_texel_1d_f_l16
,
311 fetch_texel_2d_f_l16
,
322 fetch_texel_1d_f_i16
,
323 fetch_texel_2d_f_i16
,
328 fetch_texel_1d_f_ycbcr
,
329 fetch_texel_2d_f_ycbcr
,
330 fetch_texel_3d_f_ycbcr
333 MESA_FORMAT_YCBCR_REV
,
334 fetch_texel_1d_f_ycbcr_rev
,
335 fetch_texel_2d_f_ycbcr_rev
,
336 fetch_texel_3d_f_ycbcr_rev
346 fetch_texel_1d_f_gr88
,
347 fetch_texel_2d_f_gr88
,
348 fetch_texel_3d_f_gr88
352 fetch_texel_1d_f_rg88
,
353 fetch_texel_2d_f_rg88
,
354 fetch_texel_3d_f_rg88
358 fetch_texel_1d_f_r16
,
359 fetch_texel_2d_f_r16
,
364 fetch_texel_1d_f_rg1616
,
365 fetch_texel_2d_f_rg1616
,
366 fetch_texel_3d_f_rg1616
370 fetch_texel_1d_f_rg1616_rev
,
371 fetch_texel_2d_f_rg1616_rev
,
372 fetch_texel_3d_f_rg1616_rev
375 MESA_FORMAT_ARGB2101010
,
376 fetch_texel_1d_f_argb2101010
,
377 fetch_texel_2d_f_argb2101010
,
378 fetch_texel_3d_f_argb2101010
382 fetch_texel_1d_f_z24_s8
,
383 fetch_texel_2d_f_z24_s8
,
384 fetch_texel_3d_f_z24_s8
388 fetch_texel_1d_f_s8_z24
,
389 fetch_texel_2d_f_s8_z24
,
390 fetch_texel_3d_f_s8_z24
394 fetch_texel_1d_f_z16
,
395 fetch_texel_2d_f_z16
,
400 fetch_texel_1d_f_s8_z24
,
401 fetch_texel_2d_f_s8_z24
,
402 fetch_texel_3d_f_s8_z24
406 fetch_texel_1d_f_z24_s8
,
407 fetch_texel_2d_f_z24_s8
,
408 fetch_texel_3d_f_z24_s8
412 fetch_texel_1d_f_z32
,
413 fetch_texel_2d_f_z32
,
424 fetch_texel_1d_srgb8
,
425 fetch_texel_2d_srgb8
,
430 fetch_texel_1d_srgba8
,
431 fetch_texel_2d_srgba8
,
432 fetch_texel_3d_srgba8
436 fetch_texel_1d_sargb8
,
437 fetch_texel_2d_sargb8
,
438 fetch_texel_3d_sargb8
453 MESA_FORMAT_SRGB_DXT1
,
459 MESA_FORMAT_SRGBA_DXT1
,
465 MESA_FORMAT_SRGBA_DXT3
,
471 MESA_FORMAT_SRGBA_DXT5
,
478 MESA_FORMAT_RGB_FXT1
,
484 MESA_FORMAT_RGBA_FXT1
,
490 MESA_FORMAT_RGB_DXT1
,
496 MESA_FORMAT_RGBA_DXT1
,
502 MESA_FORMAT_RGBA_DXT3
,
508 MESA_FORMAT_RGBA_DXT5
,
514 MESA_FORMAT_RGBA_FLOAT32
,
515 fetch_texel_1d_f_rgba_f32
,
516 fetch_texel_2d_f_rgba_f32
,
517 fetch_texel_3d_f_rgba_f32
520 MESA_FORMAT_RGBA_FLOAT16
,
521 fetch_texel_1d_f_rgba_f16
,
522 fetch_texel_2d_f_rgba_f16
,
523 fetch_texel_3d_f_rgba_f16
526 MESA_FORMAT_RGB_FLOAT32
,
527 fetch_texel_1d_f_rgb_f32
,
528 fetch_texel_2d_f_rgb_f32
,
529 fetch_texel_3d_f_rgb_f32
532 MESA_FORMAT_RGB_FLOAT16
,
533 fetch_texel_1d_f_rgb_f16
,
534 fetch_texel_2d_f_rgb_f16
,
535 fetch_texel_3d_f_rgb_f16
538 MESA_FORMAT_ALPHA_FLOAT32
,
539 fetch_texel_1d_f_alpha_f32
,
540 fetch_texel_2d_f_alpha_f32
,
541 fetch_texel_3d_f_alpha_f32
544 MESA_FORMAT_ALPHA_FLOAT16
,
545 fetch_texel_1d_f_alpha_f16
,
546 fetch_texel_2d_f_alpha_f16
,
547 fetch_texel_3d_f_alpha_f16
550 MESA_FORMAT_LUMINANCE_FLOAT32
,
551 fetch_texel_1d_f_luminance_f32
,
552 fetch_texel_2d_f_luminance_f32
,
553 fetch_texel_3d_f_luminance_f32
556 MESA_FORMAT_LUMINANCE_FLOAT16
,
557 fetch_texel_1d_f_luminance_f16
,
558 fetch_texel_2d_f_luminance_f16
,
559 fetch_texel_3d_f_luminance_f16
562 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
563 fetch_texel_1d_f_luminance_alpha_f32
,
564 fetch_texel_2d_f_luminance_alpha_f32
,
565 fetch_texel_3d_f_luminance_alpha_f32
568 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
569 fetch_texel_1d_f_luminance_alpha_f16
,
570 fetch_texel_2d_f_luminance_alpha_f16
,
571 fetch_texel_3d_f_luminance_alpha_f16
574 MESA_FORMAT_INTENSITY_FLOAT32
,
575 fetch_texel_1d_f_intensity_f32
,
576 fetch_texel_2d_f_intensity_f32
,
577 fetch_texel_3d_f_intensity_f32
580 MESA_FORMAT_INTENSITY_FLOAT16
,
581 fetch_texel_1d_f_intensity_f16
,
582 fetch_texel_2d_f_intensity_f16
,
583 fetch_texel_3d_f_intensity_f16
586 MESA_FORMAT_R_FLOAT32
,
587 fetch_texel_1d_f_r_f32
,
588 fetch_texel_2d_f_r_f32
,
589 fetch_texel_3d_f_r_f32
592 MESA_FORMAT_R_FLOAT16
,
593 fetch_texel_1d_f_r_f16
,
594 fetch_texel_2d_f_r_f16
,
595 fetch_texel_3d_f_r_f16
598 MESA_FORMAT_RG_FLOAT32
,
599 fetch_texel_1d_f_rg_f32
,
600 fetch_texel_2d_f_rg_f32
,
601 fetch_texel_3d_f_rg_f32
604 MESA_FORMAT_RG_FLOAT16
,
605 fetch_texel_1d_f_rg_f16
,
606 fetch_texel_2d_f_rg_f16
,
607 fetch_texel_3d_f_rg_f16
611 MESA_FORMAT_ALPHA_UINT8
,
618 MESA_FORMAT_ALPHA_UINT16
,
625 MESA_FORMAT_ALPHA_UINT32
,
632 MESA_FORMAT_ALPHA_INT8
,
639 MESA_FORMAT_ALPHA_INT16
,
646 MESA_FORMAT_ALPHA_INT32
,
654 MESA_FORMAT_INTENSITY_UINT8
,
661 MESA_FORMAT_INTENSITY_UINT16
,
668 MESA_FORMAT_INTENSITY_UINT32
,
675 MESA_FORMAT_INTENSITY_INT8
,
682 MESA_FORMAT_INTENSITY_INT16
,
689 MESA_FORMAT_INTENSITY_INT32
,
697 MESA_FORMAT_LUMINANCE_UINT8
,
704 MESA_FORMAT_LUMINANCE_UINT16
,
711 MESA_FORMAT_LUMINANCE_UINT32
,
718 MESA_FORMAT_LUMINANCE_INT8
,
725 MESA_FORMAT_LUMINANCE_INT16
,
732 MESA_FORMAT_LUMINANCE_INT32
,
740 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
747 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
754 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
761 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
768 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
775 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
797 MESA_FORMAT_RGB_INT8
,
803 /* non-normalized, signed int */
805 MESA_FORMAT_RGBA_INT8
,
806 fetch_texel_1d_rgba_int8
,
807 fetch_texel_2d_rgba_int8
,
808 fetch_texel_3d_rgba_int8
817 MESA_FORMAT_RG_INT16
,
823 MESA_FORMAT_RGB_INT16
,
829 MESA_FORMAT_RGBA_INT16
,
830 fetch_texel_1d_rgba_int16
,
831 fetch_texel_2d_rgba_int16
,
832 fetch_texel_3d_rgba_int16
841 MESA_FORMAT_RG_INT32
,
847 MESA_FORMAT_RGB_INT32
,
853 MESA_FORMAT_RGBA_INT32
,
854 fetch_texel_1d_rgba_int32
,
855 fetch_texel_2d_rgba_int32
,
856 fetch_texel_3d_rgba_int32
859 /* non-normalized, unsigned int */
867 MESA_FORMAT_RG_UINT8
,
873 MESA_FORMAT_RGB_UINT8
,
879 MESA_FORMAT_RGBA_UINT8
,
880 fetch_texel_1d_rgba_uint8
,
881 fetch_texel_2d_rgba_uint8
,
882 fetch_texel_3d_rgba_uint8
885 MESA_FORMAT_R_UINT16
,
891 MESA_FORMAT_RG_UINT16
,
897 MESA_FORMAT_RGB_UINT16
,
903 MESA_FORMAT_RGBA_UINT16
,
904 fetch_texel_1d_rgba_uint16
,
905 fetch_texel_2d_rgba_uint16
,
906 fetch_texel_3d_rgba_uint16
909 MESA_FORMAT_R_UINT32
,
915 MESA_FORMAT_RG_UINT32
,
921 MESA_FORMAT_RGB_UINT32
,
927 MESA_FORMAT_RGBA_UINT32
,
928 fetch_texel_1d_rgba_uint32
,
929 fetch_texel_2d_rgba_uint32
,
930 fetch_texel_3d_rgba_uint32
936 fetch_texel_1d_dudv8
,
937 fetch_texel_2d_dudv8
,
941 /* signed, normalized */
943 MESA_FORMAT_SIGNED_R8
,
944 fetch_texel_1d_signed_r8
,
945 fetch_texel_2d_signed_r8
,
946 fetch_texel_3d_signed_r8
949 MESA_FORMAT_SIGNED_RG88_REV
,
950 fetch_texel_1d_signed_rg88_rev
,
951 fetch_texel_2d_signed_rg88_rev
,
952 fetch_texel_3d_signed_rg88_rev
955 MESA_FORMAT_SIGNED_RGBX8888
,
956 fetch_texel_1d_signed_rgbx8888
,
957 fetch_texel_2d_signed_rgbx8888
,
958 fetch_texel_3d_signed_rgbx8888
961 MESA_FORMAT_SIGNED_RGBA8888
,
962 fetch_texel_1d_signed_rgba8888
,
963 fetch_texel_2d_signed_rgba8888
,
964 fetch_texel_3d_signed_rgba8888
967 MESA_FORMAT_SIGNED_RGBA8888_REV
,
968 fetch_texel_1d_signed_rgba8888_rev
,
969 fetch_texel_2d_signed_rgba8888_rev
,
970 fetch_texel_3d_signed_rgba8888_rev
973 MESA_FORMAT_SIGNED_R16
,
974 fetch_texel_1d_signed_r16
,
975 fetch_texel_2d_signed_r16
,
976 fetch_texel_3d_signed_r16
979 MESA_FORMAT_SIGNED_GR1616
,
980 fetch_texel_1d_signed_rg1616
,
981 fetch_texel_2d_signed_rg1616
,
982 fetch_texel_3d_signed_rg1616
985 MESA_FORMAT_SIGNED_RGB_16
,
986 fetch_texel_1d_signed_rgb_16
,
987 fetch_texel_2d_signed_rgb_16
,
988 fetch_texel_3d_signed_rgb_16
991 MESA_FORMAT_SIGNED_RGBA_16
,
992 fetch_texel_1d_signed_rgba_16
,
993 fetch_texel_2d_signed_rgba_16
,
994 fetch_texel_3d_signed_rgba_16
998 fetch_texel_1d_rgba_16
,
999 fetch_texel_2d_rgba_16
,
1000 fetch_texel_3d_rgba_16
1003 MESA_FORMAT_RED_RGTC1
,
1009 MESA_FORMAT_SIGNED_RED_RGTC1
,
1015 MESA_FORMAT_RG_RGTC2
,
1021 MESA_FORMAT_SIGNED_RG_RGTC2
,
1027 MESA_FORMAT_L_LATC1
,
1033 MESA_FORMAT_SIGNED_L_LATC1
,
1039 MESA_FORMAT_LA_LATC2
,
1045 MESA_FORMAT_SIGNED_LA_LATC2
,
1051 MESA_FORMAT_ETC1_RGB8
,
1057 MESA_FORMAT_ETC2_RGB8
,
1063 MESA_FORMAT_ETC2_SRGB8
,
1069 MESA_FORMAT_ETC2_RGBA8_EAC
,
1075 MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
,
1081 MESA_FORMAT_ETC2_R11_EAC
,
1087 MESA_FORMAT_ETC2_RG11_EAC
,
1093 MESA_FORMAT_ETC2_SIGNED_R11_EAC
,
1099 MESA_FORMAT_ETC2_SIGNED_RG11_EAC
,
1105 MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
,
1111 MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
,
1117 MESA_FORMAT_SIGNED_A8
,
1118 fetch_texel_1d_signed_a8
,
1119 fetch_texel_2d_signed_a8
,
1120 fetch_texel_3d_signed_a8
1123 MESA_FORMAT_SIGNED_L8
,
1124 fetch_texel_1d_signed_l8
,
1125 fetch_texel_2d_signed_l8
,
1126 fetch_texel_3d_signed_l8
1129 MESA_FORMAT_SIGNED_AL88
,
1130 fetch_texel_1d_signed_al88
,
1131 fetch_texel_2d_signed_al88
,
1132 fetch_texel_3d_signed_al88
1135 MESA_FORMAT_SIGNED_I8
,
1136 fetch_texel_1d_signed_i8
,
1137 fetch_texel_2d_signed_i8
,
1138 fetch_texel_3d_signed_i8
1141 MESA_FORMAT_SIGNED_A16
,
1142 fetch_texel_1d_signed_a16
,
1143 fetch_texel_2d_signed_a16
,
1144 fetch_texel_3d_signed_a16
1147 MESA_FORMAT_SIGNED_L16
,
1148 fetch_texel_1d_signed_l16
,
1149 fetch_texel_2d_signed_l16
,
1150 fetch_texel_3d_signed_l16
1153 MESA_FORMAT_SIGNED_AL1616
,
1154 fetch_texel_1d_signed_al1616
,
1155 fetch_texel_2d_signed_al1616
,
1156 fetch_texel_3d_signed_al1616
1159 MESA_FORMAT_SIGNED_I16
,
1160 fetch_texel_1d_signed_i16
,
1161 fetch_texel_2d_signed_i16
,
1162 fetch_texel_3d_signed_i16
1165 MESA_FORMAT_RGB9_E5_FLOAT
,
1166 fetch_texel_1d_rgb9_e5
,
1167 fetch_texel_2d_rgb9_e5
,
1168 fetch_texel_3d_rgb9_e5
1171 MESA_FORMAT_R11_G11_B10_FLOAT
,
1172 fetch_texel_1d_r11_g11_b10f
,
1173 fetch_texel_2d_r11_g11_b10f
,
1174 fetch_texel_3d_r11_g11_b10f
1177 MESA_FORMAT_Z32_FLOAT
,
1178 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1179 fetch_texel_2d_f_r_f32
,
1180 fetch_texel_3d_f_r_f32
1183 MESA_FORMAT_Z32_FLOAT_X24S8
,
1184 fetch_texel_1d_z32f_x24s8
,
1185 fetch_texel_2d_z32f_x24s8
,
1186 fetch_texel_3d_z32f_x24s8
1189 MESA_FORMAT_ARGB2101010_UINT
,
1195 MESA_FORMAT_ABGR2101010_UINT
,
1201 MESA_FORMAT_XRGB4444_UNORM
,
1207 MESA_FORMAT_XRGB1555_UNORM
,
1213 MESA_FORMAT_XBGR8888_SNORM
,
1219 MESA_FORMAT_XBGR8888_SRGB
,
1225 MESA_FORMAT_XBGR8888_UINT
,
1231 MESA_FORMAT_XBGR8888_SINT
,
1237 MESA_FORMAT_XRGB2101010_UNORM
,
1243 MESA_FORMAT_XBGR16161616_UNORM
,
1249 MESA_FORMAT_XBGR16161616_SNORM
,
1255 MESA_FORMAT_XBGR16161616_FLOAT
,
1261 MESA_FORMAT_XBGR16161616_UINT
,
1267 MESA_FORMAT_XBGR16161616_SINT
,
1273 MESA_FORMAT_XBGR32323232_FLOAT
,
1279 MESA_FORMAT_XBGR32323232_UINT
,
1285 MESA_FORMAT_XBGR32323232_SINT
,
1294 * Initialize the texture image's FetchTexel methods.
1297 set_fetch_functions(const struct gl_sampler_object
*samp
,
1298 struct swrast_texture_image
*texImage
, GLuint dims
)
1300 gl_format format
= texImage
->Base
.TexFormat
;
1303 /* check that the table entries are sorted by format name */
1305 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1306 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1310 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1312 if (samp
->sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1313 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1314 format
= _mesa_get_srgb_format_linear(format
);
1317 assert(format
< MESA_FORMAT_COUNT
);
1321 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch1D
;
1324 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch2D
;
1327 texImage
->FetchTexel
= texfetch_funcs
[format
].Fetch3D
;
1330 assert(!"Bad dims in set_fetch_functions()");
1333 texImage
->FetchCompressedTexel
= _mesa_get_compressed_fetch_func(format
);
1335 ASSERT(texImage
->FetchTexel
);
1339 _mesa_update_fetch_functions(struct gl_context
*ctx
, GLuint unit
)
1341 struct gl_texture_object
*texObj
= ctx
->Texture
.Unit
[unit
]._Current
;
1342 struct gl_sampler_object
*samp
;
1349 samp
= _mesa_get_samplerobj(ctx
, unit
);
1351 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1353 for (face
= 0; face
< 6; face
++) {
1354 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1355 if (texObj
->Image
[face
][i
]) {
1356 set_fetch_functions(samp
,
1357 swrast_texture_image(texObj
->Image
[face
][i
]),