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"
47 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
48 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
50 #include "../main/u_format_rgb9e5.h"
51 #include "../main/u_format_r11g11b10f.h"
56 * Convert an 8-bit sRGB value from non-linear space to a
57 * linear RGB value in [0, 1].
58 * Implemented with a 256-entry lookup table.
61 nonlinear_to_linear(GLubyte cs8
)
63 static GLfloat table
[256];
64 static GLboolean tableReady
= GL_FALSE
;
66 /* compute lookup table now */
68 for (i
= 0; i
< 256; i
++) {
69 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
71 table
[i
] = cs
/ 12.92f
;
74 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
84 /* Texel fetch routines for all supported formats
87 #include "s_texfetch_tmp.h"
90 #include "s_texfetch_tmp.h"
93 #include "s_texfetch_tmp.h"
96 * Null texel fetch function.
98 * Have to have this so the FetchTexel function pointer is never NULL.
100 static void fetch_null_texelf( const struct swrast_texture_image
*texImage
,
101 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
103 (void) texImage
; (void) i
; (void) j
; (void) k
;
108 _mesa_warning(NULL
, "fetch_null_texelf() called!");
113 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
114 * XXX this is somewhat temporary.
118 FetchTexelFunc Fetch1D
;
119 FetchTexelFunc Fetch2D
;
120 FetchTexelFunc Fetch3D
;
122 texfetch_funcs
[MESA_FORMAT_COUNT
] =
132 MESA_FORMAT_RGBA8888
,
133 fetch_texel_1d_f_rgba8888
,
134 fetch_texel_2d_f_rgba8888
,
135 fetch_texel_3d_f_rgba8888
138 MESA_FORMAT_RGBA8888_REV
,
139 fetch_texel_1d_f_rgba8888_rev
,
140 fetch_texel_2d_f_rgba8888_rev
,
141 fetch_texel_3d_f_rgba8888_rev
144 MESA_FORMAT_ARGB8888
,
145 fetch_texel_1d_f_argb8888
,
146 fetch_texel_2d_f_argb8888
,
147 fetch_texel_3d_f_argb8888
150 MESA_FORMAT_ARGB8888_REV
,
151 fetch_texel_1d_f_argb8888_rev
,
152 fetch_texel_2d_f_argb8888_rev
,
153 fetch_texel_3d_f_argb8888_rev
156 MESA_FORMAT_RGBX8888
,
157 fetch_texel_1d_f_rgbx8888
,
158 fetch_texel_2d_f_rgbx8888
,
159 fetch_texel_3d_f_rgbx8888
162 MESA_FORMAT_RGBX8888_REV
,
163 fetch_texel_1d_f_rgbx8888_rev
,
164 fetch_texel_2d_f_rgbx8888_rev
,
165 fetch_texel_3d_f_rgbx8888_rev
168 MESA_FORMAT_XRGB8888
,
169 fetch_texel_1d_f_xrgb8888
,
170 fetch_texel_2d_f_xrgb8888
,
171 fetch_texel_3d_f_xrgb8888
174 MESA_FORMAT_XRGB8888_REV
,
175 fetch_texel_1d_f_xrgb8888_rev
,
176 fetch_texel_2d_f_xrgb8888_rev
,
177 fetch_texel_3d_f_xrgb8888_rev
181 fetch_texel_1d_f_rgb888
,
182 fetch_texel_2d_f_rgb888
,
183 fetch_texel_3d_f_rgb888
187 fetch_texel_1d_f_bgr888
,
188 fetch_texel_2d_f_bgr888
,
189 fetch_texel_3d_f_bgr888
193 fetch_texel_1d_f_rgb565
,
194 fetch_texel_2d_f_rgb565
,
195 fetch_texel_3d_f_rgb565
198 MESA_FORMAT_RGB565_REV
,
199 fetch_texel_1d_f_rgb565_rev
,
200 fetch_texel_2d_f_rgb565_rev
,
201 fetch_texel_3d_f_rgb565_rev
204 MESA_FORMAT_ARGB4444
,
205 fetch_texel_1d_f_argb4444
,
206 fetch_texel_2d_f_argb4444
,
207 fetch_texel_3d_f_argb4444
210 MESA_FORMAT_ARGB4444_REV
,
211 fetch_texel_1d_f_argb4444_rev
,
212 fetch_texel_2d_f_argb4444_rev
,
213 fetch_texel_3d_f_argb4444_rev
216 MESA_FORMAT_RGBA5551
,
217 fetch_texel_1d_f_rgba5551
,
218 fetch_texel_2d_f_rgba5551
,
219 fetch_texel_3d_f_rgba5551
222 MESA_FORMAT_ARGB1555
,
223 fetch_texel_1d_f_argb1555
,
224 fetch_texel_2d_f_argb1555
,
225 fetch_texel_3d_f_argb1555
228 MESA_FORMAT_ARGB1555_REV
,
229 fetch_texel_1d_f_argb1555_rev
,
230 fetch_texel_2d_f_argb1555_rev
,
231 fetch_texel_3d_f_argb1555_rev
235 fetch_texel_1d_f_al44
,
236 fetch_texel_2d_f_al44
,
237 fetch_texel_3d_f_al44
241 fetch_texel_1d_f_al88
,
242 fetch_texel_2d_f_al88
,
243 fetch_texel_3d_f_al88
246 MESA_FORMAT_AL88_REV
,
247 fetch_texel_1d_f_al88_rev
,
248 fetch_texel_2d_f_al88_rev
,
249 fetch_texel_3d_f_al88_rev
253 fetch_texel_1d_f_al1616
,
254 fetch_texel_2d_f_al1616
,
255 fetch_texel_3d_f_al1616
258 MESA_FORMAT_AL1616_REV
,
259 fetch_texel_1d_f_al1616_rev
,
260 fetch_texel_2d_f_al1616_rev
,
261 fetch_texel_3d_f_al1616_rev
265 fetch_texel_1d_f_rgb332
,
266 fetch_texel_2d_f_rgb332
,
267 fetch_texel_3d_f_rgb332
277 fetch_texel_1d_f_a16
,
278 fetch_texel_2d_f_a16
,
289 fetch_texel_1d_f_l16
,
290 fetch_texel_2d_f_l16
,
301 fetch_texel_1d_f_i16
,
302 fetch_texel_2d_f_i16
,
307 fetch_texel_1d_f_ycbcr
,
308 fetch_texel_2d_f_ycbcr
,
309 fetch_texel_3d_f_ycbcr
312 MESA_FORMAT_YCBCR_REV
,
313 fetch_texel_1d_f_ycbcr_rev
,
314 fetch_texel_2d_f_ycbcr_rev
,
315 fetch_texel_3d_f_ycbcr_rev
325 fetch_texel_1d_f_gr88
,
326 fetch_texel_2d_f_gr88
,
327 fetch_texel_3d_f_gr88
331 fetch_texel_1d_f_rg88
,
332 fetch_texel_2d_f_rg88
,
333 fetch_texel_3d_f_rg88
337 fetch_texel_1d_f_r16
,
338 fetch_texel_2d_f_r16
,
343 fetch_texel_1d_f_rg1616
,
344 fetch_texel_2d_f_rg1616
,
345 fetch_texel_3d_f_rg1616
348 MESA_FORMAT_RG1616_REV
,
349 fetch_texel_1d_f_rg1616_rev
,
350 fetch_texel_2d_f_rg1616_rev
,
351 fetch_texel_3d_f_rg1616_rev
354 MESA_FORMAT_ARGB2101010
,
355 fetch_texel_1d_f_argb2101010
,
356 fetch_texel_2d_f_argb2101010
,
357 fetch_texel_3d_f_argb2101010
361 fetch_texel_1d_f_z24_s8
,
362 fetch_texel_2d_f_z24_s8
,
363 fetch_texel_3d_f_z24_s8
367 fetch_texel_1d_f_s8_z24
,
368 fetch_texel_2d_f_s8_z24
,
369 fetch_texel_3d_f_s8_z24
373 fetch_texel_1d_f_z16
,
374 fetch_texel_2d_f_z16
,
379 fetch_texel_1d_f_s8_z24
,
380 fetch_texel_2d_f_s8_z24
,
381 fetch_texel_3d_f_s8_z24
385 fetch_texel_1d_f_z24_s8
,
386 fetch_texel_2d_f_z24_s8
,
387 fetch_texel_3d_f_z24_s8
391 fetch_texel_1d_f_z32
,
392 fetch_texel_2d_f_z32
,
403 fetch_texel_1d_srgb8
,
404 fetch_texel_2d_srgb8
,
409 fetch_texel_1d_srgba8
,
410 fetch_texel_2d_srgba8
,
411 fetch_texel_3d_srgba8
415 fetch_texel_1d_sargb8
,
416 fetch_texel_2d_sargb8
,
417 fetch_texel_3d_sargb8
432 MESA_FORMAT_SRGB_DXT1
,
434 _mesa_fetch_texel_2d_f_srgb_dxt1
,
438 MESA_FORMAT_SRGBA_DXT1
,
440 _mesa_fetch_texel_2d_f_srgba_dxt1
,
444 MESA_FORMAT_SRGBA_DXT3
,
446 _mesa_fetch_texel_2d_f_srgba_dxt3
,
450 MESA_FORMAT_SRGBA_DXT5
,
452 _mesa_fetch_texel_2d_f_srgba_dxt5
,
457 MESA_FORMAT_RGB_FXT1
,
459 _mesa_fetch_texel_2d_f_rgb_fxt1
,
463 MESA_FORMAT_RGBA_FXT1
,
465 _mesa_fetch_texel_2d_f_rgba_fxt1
,
469 MESA_FORMAT_RGB_DXT1
,
471 _mesa_fetch_texel_2d_f_rgb_dxt1
,
475 MESA_FORMAT_RGBA_DXT1
,
477 _mesa_fetch_texel_2d_f_rgba_dxt1
,
481 MESA_FORMAT_RGBA_DXT3
,
483 _mesa_fetch_texel_2d_f_rgba_dxt3
,
487 MESA_FORMAT_RGBA_DXT5
,
489 _mesa_fetch_texel_2d_f_rgba_dxt5
,
493 MESA_FORMAT_RGBA_FLOAT32
,
494 fetch_texel_1d_f_rgba_f32
,
495 fetch_texel_2d_f_rgba_f32
,
496 fetch_texel_3d_f_rgba_f32
499 MESA_FORMAT_RGBA_FLOAT16
,
500 fetch_texel_1d_f_rgba_f16
,
501 fetch_texel_2d_f_rgba_f16
,
502 fetch_texel_3d_f_rgba_f16
505 MESA_FORMAT_RGB_FLOAT32
,
506 fetch_texel_1d_f_rgb_f32
,
507 fetch_texel_2d_f_rgb_f32
,
508 fetch_texel_3d_f_rgb_f32
511 MESA_FORMAT_RGB_FLOAT16
,
512 fetch_texel_1d_f_rgb_f16
,
513 fetch_texel_2d_f_rgb_f16
,
514 fetch_texel_3d_f_rgb_f16
517 MESA_FORMAT_ALPHA_FLOAT32
,
518 fetch_texel_1d_f_alpha_f32
,
519 fetch_texel_2d_f_alpha_f32
,
520 fetch_texel_3d_f_alpha_f32
523 MESA_FORMAT_ALPHA_FLOAT16
,
524 fetch_texel_1d_f_alpha_f16
,
525 fetch_texel_2d_f_alpha_f16
,
526 fetch_texel_3d_f_alpha_f16
529 MESA_FORMAT_LUMINANCE_FLOAT32
,
530 fetch_texel_1d_f_luminance_f32
,
531 fetch_texel_2d_f_luminance_f32
,
532 fetch_texel_3d_f_luminance_f32
535 MESA_FORMAT_LUMINANCE_FLOAT16
,
536 fetch_texel_1d_f_luminance_f16
,
537 fetch_texel_2d_f_luminance_f16
,
538 fetch_texel_3d_f_luminance_f16
541 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
542 fetch_texel_1d_f_luminance_alpha_f32
,
543 fetch_texel_2d_f_luminance_alpha_f32
,
544 fetch_texel_3d_f_luminance_alpha_f32
547 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
548 fetch_texel_1d_f_luminance_alpha_f16
,
549 fetch_texel_2d_f_luminance_alpha_f16
,
550 fetch_texel_3d_f_luminance_alpha_f16
553 MESA_FORMAT_INTENSITY_FLOAT32
,
554 fetch_texel_1d_f_intensity_f32
,
555 fetch_texel_2d_f_intensity_f32
,
556 fetch_texel_3d_f_intensity_f32
559 MESA_FORMAT_INTENSITY_FLOAT16
,
560 fetch_texel_1d_f_intensity_f16
,
561 fetch_texel_2d_f_intensity_f16
,
562 fetch_texel_3d_f_intensity_f16
565 MESA_FORMAT_R_FLOAT32
,
566 fetch_texel_1d_f_r_f32
,
567 fetch_texel_2d_f_r_f32
,
568 fetch_texel_3d_f_r_f32
571 MESA_FORMAT_R_FLOAT16
,
572 fetch_texel_1d_f_r_f16
,
573 fetch_texel_2d_f_r_f16
,
574 fetch_texel_3d_f_r_f16
577 MESA_FORMAT_RG_FLOAT32
,
578 fetch_texel_1d_f_rg_f32
,
579 fetch_texel_2d_f_rg_f32
,
580 fetch_texel_3d_f_rg_f32
583 MESA_FORMAT_RG_FLOAT16
,
584 fetch_texel_1d_f_rg_f16
,
585 fetch_texel_2d_f_rg_f16
,
586 fetch_texel_3d_f_rg_f16
590 MESA_FORMAT_ALPHA_UINT8
,
597 MESA_FORMAT_ALPHA_UINT16
,
604 MESA_FORMAT_ALPHA_UINT32
,
611 MESA_FORMAT_ALPHA_INT8
,
618 MESA_FORMAT_ALPHA_INT16
,
625 MESA_FORMAT_ALPHA_INT32
,
633 MESA_FORMAT_INTENSITY_UINT8
,
640 MESA_FORMAT_INTENSITY_UINT16
,
647 MESA_FORMAT_INTENSITY_UINT32
,
654 MESA_FORMAT_INTENSITY_INT8
,
661 MESA_FORMAT_INTENSITY_INT16
,
668 MESA_FORMAT_INTENSITY_INT32
,
676 MESA_FORMAT_LUMINANCE_UINT8
,
683 MESA_FORMAT_LUMINANCE_UINT16
,
690 MESA_FORMAT_LUMINANCE_UINT32
,
697 MESA_FORMAT_LUMINANCE_INT8
,
704 MESA_FORMAT_LUMINANCE_INT16
,
711 MESA_FORMAT_LUMINANCE_INT32
,
719 MESA_FORMAT_LUMINANCE_ALPHA_UINT8
,
726 MESA_FORMAT_LUMINANCE_ALPHA_UINT16
,
733 MESA_FORMAT_LUMINANCE_ALPHA_UINT32
,
740 MESA_FORMAT_LUMINANCE_ALPHA_INT8
,
747 MESA_FORMAT_LUMINANCE_ALPHA_INT16
,
754 MESA_FORMAT_LUMINANCE_ALPHA_INT32
,
776 MESA_FORMAT_RGB_INT8
,
782 /* non-normalized, signed int */
784 MESA_FORMAT_RGBA_INT8
,
785 fetch_texel_1d_rgba_int8
,
786 fetch_texel_2d_rgba_int8
,
787 fetch_texel_3d_rgba_int8
796 MESA_FORMAT_RG_INT16
,
802 MESA_FORMAT_RGB_INT16
,
808 MESA_FORMAT_RGBA_INT16
,
809 fetch_texel_1d_rgba_int16
,
810 fetch_texel_2d_rgba_int16
,
811 fetch_texel_3d_rgba_int16
820 MESA_FORMAT_RG_INT32
,
826 MESA_FORMAT_RGB_INT32
,
832 MESA_FORMAT_RGBA_INT32
,
833 fetch_texel_1d_rgba_int32
,
834 fetch_texel_2d_rgba_int32
,
835 fetch_texel_3d_rgba_int32
838 /* non-normalized, unsigned int */
846 MESA_FORMAT_RG_UINT8
,
852 MESA_FORMAT_RGB_UINT8
,
858 MESA_FORMAT_RGBA_UINT8
,
859 fetch_texel_1d_rgba_uint8
,
860 fetch_texel_2d_rgba_uint8
,
861 fetch_texel_3d_rgba_uint8
864 MESA_FORMAT_R_UINT16
,
870 MESA_FORMAT_RG_UINT16
,
876 MESA_FORMAT_RGB_UINT16
,
882 MESA_FORMAT_RGBA_UINT16
,
883 fetch_texel_1d_rgba_uint16
,
884 fetch_texel_2d_rgba_uint16
,
885 fetch_texel_3d_rgba_uint16
888 MESA_FORMAT_R_UINT32
,
894 MESA_FORMAT_RG_UINT32
,
900 MESA_FORMAT_RGB_UINT32
,
906 MESA_FORMAT_RGBA_UINT32
,
907 fetch_texel_1d_rgba_uint32
,
908 fetch_texel_2d_rgba_uint32
,
909 fetch_texel_3d_rgba_uint32
915 fetch_texel_1d_dudv8
,
916 fetch_texel_2d_dudv8
,
920 /* signed, normalized */
922 MESA_FORMAT_SIGNED_R8
,
923 fetch_texel_1d_signed_r8
,
924 fetch_texel_2d_signed_r8
,
925 fetch_texel_3d_signed_r8
928 MESA_FORMAT_SIGNED_RG88_REV
,
929 fetch_texel_1d_signed_rg88_rev
,
930 fetch_texel_2d_signed_rg88_rev
,
931 fetch_texel_3d_signed_rg88_rev
934 MESA_FORMAT_SIGNED_RGBX8888
,
935 fetch_texel_1d_signed_rgbx8888
,
936 fetch_texel_2d_signed_rgbx8888
,
937 fetch_texel_3d_signed_rgbx8888
940 MESA_FORMAT_SIGNED_RGBA8888
,
941 fetch_texel_1d_signed_rgba8888
,
942 fetch_texel_2d_signed_rgba8888
,
943 fetch_texel_3d_signed_rgba8888
946 MESA_FORMAT_SIGNED_RGBA8888_REV
,
947 fetch_texel_1d_signed_rgba8888_rev
,
948 fetch_texel_2d_signed_rgba8888_rev
,
949 fetch_texel_3d_signed_rgba8888_rev
952 MESA_FORMAT_SIGNED_R16
,
953 fetch_texel_1d_signed_r16
,
954 fetch_texel_2d_signed_r16
,
955 fetch_texel_3d_signed_r16
958 MESA_FORMAT_SIGNED_GR1616
,
959 fetch_texel_1d_signed_rg1616
,
960 fetch_texel_2d_signed_rg1616
,
961 fetch_texel_3d_signed_rg1616
964 MESA_FORMAT_SIGNED_RGB_16
,
965 fetch_texel_1d_signed_rgb_16
,
966 fetch_texel_2d_signed_rgb_16
,
967 fetch_texel_3d_signed_rgb_16
970 MESA_FORMAT_SIGNED_RGBA_16
,
971 fetch_texel_1d_signed_rgba_16
,
972 fetch_texel_2d_signed_rgba_16
,
973 fetch_texel_3d_signed_rgba_16
977 fetch_texel_1d_rgba_16
,
978 fetch_texel_2d_rgba_16
,
979 fetch_texel_3d_rgba_16
982 MESA_FORMAT_RED_RGTC1
,
984 _mesa_fetch_texel_2d_f_red_rgtc1
,
988 MESA_FORMAT_SIGNED_RED_RGTC1
,
990 _mesa_fetch_texel_2d_f_signed_red_rgtc1
,
994 MESA_FORMAT_RG_RGTC2
,
996 _mesa_fetch_texel_2d_f_rg_rgtc2
,
1000 MESA_FORMAT_SIGNED_RG_RGTC2
,
1002 _mesa_fetch_texel_2d_f_signed_rg_rgtc2
,
1006 MESA_FORMAT_L_LATC1
,
1008 _mesa_fetch_texel_2d_f_l_latc1
,
1012 MESA_FORMAT_SIGNED_L_LATC1
,
1014 _mesa_fetch_texel_2d_f_signed_l_latc1
,
1018 MESA_FORMAT_LA_LATC2
,
1020 _mesa_fetch_texel_2d_f_la_latc2
,
1024 MESA_FORMAT_SIGNED_LA_LATC2
,
1026 _mesa_fetch_texel_2d_f_signed_la_latc2
,
1030 MESA_FORMAT_ETC1_RGB8
,
1032 _mesa_fetch_texel_2d_f_etc1_rgb8
,
1036 MESA_FORMAT_SIGNED_A8
,
1037 fetch_texel_1d_signed_a8
,
1038 fetch_texel_2d_signed_a8
,
1039 fetch_texel_3d_signed_a8
1042 MESA_FORMAT_SIGNED_L8
,
1043 fetch_texel_1d_signed_l8
,
1044 fetch_texel_2d_signed_l8
,
1045 fetch_texel_3d_signed_l8
1048 MESA_FORMAT_SIGNED_AL88
,
1049 fetch_texel_1d_signed_al88
,
1050 fetch_texel_2d_signed_al88
,
1051 fetch_texel_3d_signed_al88
1054 MESA_FORMAT_SIGNED_I8
,
1055 fetch_texel_1d_signed_i8
,
1056 fetch_texel_2d_signed_i8
,
1057 fetch_texel_3d_signed_i8
1060 MESA_FORMAT_SIGNED_A16
,
1061 fetch_texel_1d_signed_a16
,
1062 fetch_texel_2d_signed_a16
,
1063 fetch_texel_3d_signed_a16
1066 MESA_FORMAT_SIGNED_L16
,
1067 fetch_texel_1d_signed_l16
,
1068 fetch_texel_2d_signed_l16
,
1069 fetch_texel_3d_signed_l16
1072 MESA_FORMAT_SIGNED_AL1616
,
1073 fetch_texel_1d_signed_al1616
,
1074 fetch_texel_2d_signed_al1616
,
1075 fetch_texel_3d_signed_al1616
1078 MESA_FORMAT_SIGNED_I16
,
1079 fetch_texel_1d_signed_i16
,
1080 fetch_texel_2d_signed_i16
,
1081 fetch_texel_3d_signed_i16
1084 MESA_FORMAT_RGB9_E5_FLOAT
,
1085 fetch_texel_1d_rgb9_e5
,
1086 fetch_texel_2d_rgb9_e5
,
1087 fetch_texel_3d_rgb9_e5
1090 MESA_FORMAT_R11_G11_B10_FLOAT
,
1091 fetch_texel_1d_r11_g11_b10f
,
1092 fetch_texel_2d_r11_g11_b10f
,
1093 fetch_texel_3d_r11_g11_b10f
1096 MESA_FORMAT_Z32_FLOAT
,
1097 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
1098 fetch_texel_2d_f_r_f32
,
1099 fetch_texel_3d_f_r_f32
1102 MESA_FORMAT_Z32_FLOAT_X24S8
,
1103 fetch_texel_1d_z32f_x24s8
,
1104 fetch_texel_2d_z32f_x24s8
,
1105 fetch_texel_3d_z32f_x24s8
1108 MESA_FORMAT_ARGB2101010_UINT
,
1117 _mesa_get_texel_fetch_func(gl_format format
, GLuint dims
)
1120 /* check that the table entries are sorted by format name */
1122 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
1123 assert(texfetch_funcs
[fmt
].Name
== fmt
);
1127 STATIC_ASSERT(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
1129 assert(format
< MESA_FORMAT_COUNT
);
1133 return texfetch_funcs
[format
].Fetch1D
;
1135 return texfetch_funcs
[format
].Fetch2D
;
1137 return texfetch_funcs
[format
].Fetch3D
;
1139 assert(0 && "bad dims in _mesa_get_texel_fetch_func");
1146 * Initialize the texture image's FetchTexel methods.
1149 set_fetch_functions(struct swrast_texture_image
*texImage
, GLuint dims
)
1151 gl_format format
= texImage
->Base
.TexFormat
;
1153 ASSERT(dims
== 1 || dims
== 2 || dims
== 3);
1155 if (texImage
->Base
.TexObject
->Sampler
.sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1156 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1157 format
= _mesa_get_srgb_format_linear(format
);
1160 texImage
->FetchTexel
= _mesa_get_texel_fetch_func(format
, dims
);
1161 ASSERT(texImage
->FetchTexel
);
1165 _mesa_update_fetch_functions(struct gl_texture_object
*texObj
)
1170 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1172 for (face
= 0; face
< 6; face
++) {
1173 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1174 if (texObj
->Image
[face
][i
]) {
1175 set_fetch_functions(swrast_texture_image(texObj
->Image
[face
][i
]),