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
38 #include "texcompress.h"
39 #include "texcompress_fxt1.h"
40 #include "texcompress_s3tc.h"
41 #include "texcompress_rgtc.h"
44 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
45 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
49 * Convert an 8-bit sRGB value from non-linear space to a
50 * linear RGB value in [0, 1].
51 * Implemented with a 256-entry lookup table.
54 nonlinear_to_linear(GLubyte cs8
)
56 static GLfloat table
[256];
57 static GLboolean tableReady
= GL_FALSE
;
59 /* compute lookup table now */
61 for (i
= 0; i
< 256; i
++) {
62 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
64 table
[i
] = cs
/ 12.92f
;
67 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
77 /* Texel fetch routines for all supported formats
80 #include "texfetch_tmp.h"
83 #include "texfetch_tmp.h"
86 #include "texfetch_tmp.h"
89 * Null texel fetch function.
91 * Have to have this so the FetchTexel function pointer is never NULL.
93 static void fetch_null_texelf( const struct gl_texture_image
*texImage
,
94 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
96 (void) texImage
; (void) i
; (void) j
; (void) k
;
101 _mesa_warning(NULL
, "fetch_null_texelf() called!");
104 static void store_null_texel(struct gl_texture_image
*texImage
,
105 GLint i
, GLint j
, GLint k
, const void *texel
)
118 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
119 * XXX this is somewhat temporary.
123 FetchTexelFuncF Fetch1D
;
124 FetchTexelFuncF Fetch2D
;
125 FetchTexelFuncF Fetch3D
;
126 StoreTexelFunc StoreTexel
;
128 texfetch_funcs
[MESA_FORMAT_COUNT
] =
139 MESA_FORMAT_RGBA8888
,
140 fetch_texel_1d_f_rgba8888
,
141 fetch_texel_2d_f_rgba8888
,
142 fetch_texel_3d_f_rgba8888
,
146 MESA_FORMAT_RGBA8888_REV
,
147 fetch_texel_1d_f_rgba8888_rev
,
148 fetch_texel_2d_f_rgba8888_rev
,
149 fetch_texel_3d_f_rgba8888_rev
,
150 store_texel_rgba8888_rev
153 MESA_FORMAT_ARGB8888
,
154 fetch_texel_1d_f_argb8888
,
155 fetch_texel_2d_f_argb8888
,
156 fetch_texel_3d_f_argb8888
,
160 MESA_FORMAT_ARGB8888_REV
,
161 fetch_texel_1d_f_argb8888_rev
,
162 fetch_texel_2d_f_argb8888_rev
,
163 fetch_texel_3d_f_argb8888_rev
,
164 store_texel_argb8888_rev
167 MESA_FORMAT_XRGB8888
,
168 fetch_texel_1d_f_xrgb8888
,
169 fetch_texel_2d_f_xrgb8888
,
170 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
,
178 store_texel_xrgb8888_rev
,
182 fetch_texel_1d_f_rgb888
,
183 fetch_texel_2d_f_rgb888
,
184 fetch_texel_3d_f_rgb888
,
189 fetch_texel_1d_f_bgr888
,
190 fetch_texel_2d_f_bgr888
,
191 fetch_texel_3d_f_bgr888
,
196 fetch_texel_1d_f_rgb565
,
197 fetch_texel_2d_f_rgb565
,
198 fetch_texel_3d_f_rgb565
,
202 MESA_FORMAT_RGB565_REV
,
203 fetch_texel_1d_f_rgb565_rev
,
204 fetch_texel_2d_f_rgb565_rev
,
205 fetch_texel_3d_f_rgb565_rev
,
206 store_texel_rgb565_rev
209 MESA_FORMAT_ARGB4444
,
210 fetch_texel_1d_f_argb4444
,
211 fetch_texel_2d_f_argb4444
,
212 fetch_texel_3d_f_argb4444
,
216 MESA_FORMAT_ARGB4444_REV
,
217 fetch_texel_1d_f_argb4444_rev
,
218 fetch_texel_2d_f_argb4444_rev
,
219 fetch_texel_3d_f_argb4444_rev
,
220 store_texel_argb4444_rev
223 MESA_FORMAT_RGBA5551
,
224 fetch_texel_1d_f_rgba5551
,
225 fetch_texel_2d_f_rgba5551
,
226 fetch_texel_3d_f_rgba5551
,
230 MESA_FORMAT_ARGB1555
,
231 fetch_texel_1d_f_argb1555
,
232 fetch_texel_2d_f_argb1555
,
233 fetch_texel_3d_f_argb1555
,
237 MESA_FORMAT_ARGB1555_REV
,
238 fetch_texel_1d_f_argb1555_rev
,
239 fetch_texel_2d_f_argb1555_rev
,
240 fetch_texel_3d_f_argb1555_rev
,
241 store_texel_argb1555_rev
245 fetch_texel_1d_f_al44
,
246 fetch_texel_2d_f_al44
,
247 fetch_texel_3d_f_al44
,
252 fetch_texel_1d_f_al88
,
253 fetch_texel_2d_f_al88
,
254 fetch_texel_3d_f_al88
,
258 MESA_FORMAT_AL88_REV
,
259 fetch_texel_1d_f_al88_rev
,
260 fetch_texel_2d_f_al88_rev
,
261 fetch_texel_3d_f_al88_rev
,
266 fetch_texel_1d_f_al1616
,
267 fetch_texel_2d_f_al1616
,
268 fetch_texel_3d_f_al1616
,
272 MESA_FORMAT_AL1616_REV
,
273 fetch_texel_1d_f_al1616_rev
,
274 fetch_texel_2d_f_al1616_rev
,
275 fetch_texel_3d_f_al1616_rev
,
276 store_texel_al1616_rev
280 fetch_texel_1d_f_rgb332
,
281 fetch_texel_2d_f_rgb332
,
282 fetch_texel_3d_f_rgb332
,
294 fetch_texel_1d_f_a16
,
295 fetch_texel_2d_f_a16
,
296 fetch_texel_3d_f_a16
,
308 fetch_texel_1d_f_l16
,
309 fetch_texel_2d_f_l16
,
310 fetch_texel_3d_f_l16
,
322 fetch_texel_1d_f_i16
,
323 fetch_texel_2d_f_i16
,
324 fetch_texel_3d_f_i16
,
329 fetch_texel_1d_f_ci8
,
330 fetch_texel_2d_f_ci8
,
331 fetch_texel_3d_f_ci8
,
336 fetch_texel_1d_f_ycbcr
,
337 fetch_texel_2d_f_ycbcr
,
338 fetch_texel_3d_f_ycbcr
,
342 MESA_FORMAT_YCBCR_REV
,
343 fetch_texel_1d_f_ycbcr_rev
,
344 fetch_texel_2d_f_ycbcr_rev
,
345 fetch_texel_3d_f_ycbcr_rev
,
346 store_texel_ycbcr_rev
357 fetch_texel_1d_f_rg88
,
358 fetch_texel_2d_f_rg88
,
359 fetch_texel_3d_f_rg88
,
363 MESA_FORMAT_RG88_REV
,
364 fetch_texel_1d_f_rg88_rev
,
365 fetch_texel_2d_f_rg88_rev
,
366 fetch_texel_3d_f_rg88_rev
,
367 store_texel_rg88_rev
,
371 fetch_texel_1d_f_r16
,
372 fetch_texel_2d_f_r16
,
373 fetch_texel_3d_f_r16
,
378 fetch_texel_1d_f_rg1616
,
379 fetch_texel_2d_f_rg1616
,
380 fetch_texel_3d_f_rg1616
,
384 MESA_FORMAT_RG1616_REV
,
385 fetch_texel_1d_f_rg1616_rev
,
386 fetch_texel_2d_f_rg1616_rev
,
387 fetch_texel_3d_f_rg1616_rev
,
388 store_texel_rg1616_rev
,
391 MESA_FORMAT_ARGB2101010
,
392 fetch_texel_1d_f_argb2101010
,
393 fetch_texel_2d_f_argb2101010
,
394 fetch_texel_3d_f_argb2101010
,
395 store_texel_argb2101010
399 fetch_texel_1d_f_z24_s8
,
400 fetch_texel_2d_f_z24_s8
,
401 fetch_texel_3d_f_z24_s8
,
406 fetch_texel_1d_f_s8_z24
,
407 fetch_texel_2d_f_s8_z24
,
408 fetch_texel_3d_f_s8_z24
,
413 fetch_texel_1d_f_z16
,
414 fetch_texel_2d_f_z16
,
415 fetch_texel_3d_f_z16
,
420 fetch_texel_1d_f_s8_z24
,
421 fetch_texel_2d_f_s8_z24
,
422 fetch_texel_3d_f_s8_z24
,
427 fetch_texel_1d_f_z24_s8
,
428 fetch_texel_2d_f_z24_s8
,
429 fetch_texel_3d_f_z24_s8
,
434 fetch_texel_1d_f_z32
,
435 fetch_texel_2d_f_z32
,
436 fetch_texel_3d_f_z32
,
448 fetch_texel_1d_srgb8
,
449 fetch_texel_2d_srgb8
,
450 fetch_texel_3d_srgb8
,
455 fetch_texel_1d_srgba8
,
456 fetch_texel_2d_srgba8
,
457 fetch_texel_3d_srgba8
,
462 fetch_texel_1d_sargb8
,
463 fetch_texel_2d_sargb8
,
464 fetch_texel_3d_sargb8
,
482 MESA_FORMAT_SRGB_DXT1
,
484 _mesa_fetch_texel_2d_f_srgb_dxt1
,
489 MESA_FORMAT_SRGBA_DXT1
,
491 _mesa_fetch_texel_2d_f_srgba_dxt1
,
496 MESA_FORMAT_SRGBA_DXT3
,
498 _mesa_fetch_texel_2d_f_srgba_dxt3
,
503 MESA_FORMAT_SRGBA_DXT5
,
505 _mesa_fetch_texel_2d_f_srgba_dxt5
,
511 MESA_FORMAT_RGB_FXT1
,
513 _mesa_fetch_texel_2d_f_rgb_fxt1
,
518 MESA_FORMAT_RGBA_FXT1
,
520 _mesa_fetch_texel_2d_f_rgba_fxt1
,
525 MESA_FORMAT_RGB_DXT1
,
527 _mesa_fetch_texel_2d_f_rgb_dxt1
,
532 MESA_FORMAT_RGBA_DXT1
,
534 _mesa_fetch_texel_2d_f_rgba_dxt1
,
539 MESA_FORMAT_RGBA_DXT3
,
541 _mesa_fetch_texel_2d_f_rgba_dxt3
,
546 MESA_FORMAT_RGBA_DXT5
,
548 _mesa_fetch_texel_2d_f_rgba_dxt5
,
553 MESA_FORMAT_RGBA_FLOAT32
,
554 fetch_texel_1d_f_rgba_f32
,
555 fetch_texel_2d_f_rgba_f32
,
556 fetch_texel_3d_f_rgba_f32
,
560 MESA_FORMAT_RGBA_FLOAT16
,
561 fetch_texel_1d_f_rgba_f16
,
562 fetch_texel_2d_f_rgba_f16
,
563 fetch_texel_3d_f_rgba_f16
,
567 MESA_FORMAT_RGB_FLOAT32
,
568 fetch_texel_1d_f_rgb_f32
,
569 fetch_texel_2d_f_rgb_f32
,
570 fetch_texel_3d_f_rgb_f32
,
574 MESA_FORMAT_RGB_FLOAT16
,
575 fetch_texel_1d_f_rgb_f16
,
576 fetch_texel_2d_f_rgb_f16
,
577 fetch_texel_3d_f_rgb_f16
,
581 MESA_FORMAT_ALPHA_FLOAT32
,
582 fetch_texel_1d_f_alpha_f32
,
583 fetch_texel_2d_f_alpha_f32
,
584 fetch_texel_3d_f_alpha_f32
,
585 store_texel_alpha_f32
588 MESA_FORMAT_ALPHA_FLOAT16
,
589 fetch_texel_1d_f_alpha_f16
,
590 fetch_texel_2d_f_alpha_f16
,
591 fetch_texel_3d_f_alpha_f16
,
592 store_texel_alpha_f16
595 MESA_FORMAT_LUMINANCE_FLOAT32
,
596 fetch_texel_1d_f_luminance_f32
,
597 fetch_texel_2d_f_luminance_f32
,
598 fetch_texel_3d_f_luminance_f32
,
599 store_texel_luminance_f32
602 MESA_FORMAT_LUMINANCE_FLOAT16
,
603 fetch_texel_1d_f_luminance_f16
,
604 fetch_texel_2d_f_luminance_f16
,
605 fetch_texel_3d_f_luminance_f16
,
606 store_texel_luminance_f16
609 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
610 fetch_texel_1d_f_luminance_alpha_f32
,
611 fetch_texel_2d_f_luminance_alpha_f32
,
612 fetch_texel_3d_f_luminance_alpha_f32
,
613 store_texel_luminance_alpha_f32
616 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
617 fetch_texel_1d_f_luminance_alpha_f16
,
618 fetch_texel_2d_f_luminance_alpha_f16
,
619 fetch_texel_3d_f_luminance_alpha_f16
,
620 store_texel_luminance_alpha_f16
623 MESA_FORMAT_INTENSITY_FLOAT32
,
624 fetch_texel_1d_f_intensity_f32
,
625 fetch_texel_2d_f_intensity_f32
,
626 fetch_texel_3d_f_intensity_f32
,
627 store_texel_intensity_f32
630 MESA_FORMAT_INTENSITY_FLOAT16
,
631 fetch_texel_1d_f_intensity_f16
,
632 fetch_texel_2d_f_intensity_f16
,
633 fetch_texel_3d_f_intensity_f16
,
634 store_texel_intensity_f16
637 MESA_FORMAT_R_FLOAT32
,
638 fetch_texel_1d_f_r_f32
,
639 fetch_texel_2d_f_r_f32
,
640 fetch_texel_3d_f_r_f32
,
644 MESA_FORMAT_R_FLOAT16
,
645 fetch_texel_1d_f_r_f16
,
646 fetch_texel_2d_f_r_f16
,
647 fetch_texel_3d_f_r_f16
,
651 MESA_FORMAT_RG_FLOAT32
,
652 fetch_texel_1d_f_rg_f32
,
653 fetch_texel_2d_f_rg_f32
,
654 fetch_texel_3d_f_rg_f32
,
658 MESA_FORMAT_RG_FLOAT16
,
659 fetch_texel_1d_f_rg_f16
,
660 fetch_texel_2d_f_rg_f16
,
661 fetch_texel_3d_f_rg_f16
,
665 /* non-normalized, signed int */
667 MESA_FORMAT_RGBA_INT8
,
668 fetch_texel_1d_rgba_int8
,
669 fetch_texel_2d_rgba_int8
,
670 fetch_texel_3d_rgba_int8
,
671 store_texel_rgba_int8
674 MESA_FORMAT_RGBA_INT16
,
675 fetch_texel_1d_rgba_int16
,
676 fetch_texel_2d_rgba_int16
,
677 fetch_texel_3d_rgba_int16
,
678 store_texel_rgba_int16
681 MESA_FORMAT_RGBA_INT32
,
682 fetch_texel_1d_rgba_int32
,
683 fetch_texel_2d_rgba_int32
,
684 fetch_texel_3d_rgba_int32
,
685 store_texel_rgba_int32
688 /* non-normalized, unsigned int */
690 MESA_FORMAT_RGBA_UINT8
,
691 fetch_texel_1d_rgba_uint8
,
692 fetch_texel_2d_rgba_uint8
,
693 fetch_texel_3d_rgba_uint8
,
694 store_texel_rgba_uint8
697 MESA_FORMAT_RGBA_UINT16
,
698 fetch_texel_1d_rgba_uint16
,
699 fetch_texel_2d_rgba_uint16
,
700 fetch_texel_3d_rgba_uint16
,
701 store_texel_rgba_uint16
704 MESA_FORMAT_RGBA_UINT32
,
705 fetch_texel_1d_rgba_uint32
,
706 fetch_texel_2d_rgba_uint32
,
707 fetch_texel_3d_rgba_uint32
,
708 store_texel_rgba_uint32
714 fetch_texel_1d_dudv8
,
715 fetch_texel_2d_dudv8
,
716 fetch_texel_3d_dudv8
,
720 /* signed, normalized */
722 MESA_FORMAT_SIGNED_R8
,
723 fetch_texel_1d_signed_r8
,
724 fetch_texel_2d_signed_r8
,
725 fetch_texel_3d_signed_r8
,
726 store_texel_signed_r8
729 MESA_FORMAT_SIGNED_RG88_REV
,
730 fetch_texel_1d_signed_rg88_rev
,
731 fetch_texel_2d_signed_rg88_rev
,
732 fetch_texel_3d_signed_rg88_rev
,
733 store_texel_signed_rg88_rev
736 MESA_FORMAT_SIGNED_RGBX8888
,
737 fetch_texel_1d_signed_rgbx8888
,
738 fetch_texel_2d_signed_rgbx8888
,
739 fetch_texel_3d_signed_rgbx8888
,
740 store_texel_signed_rgbx8888
743 MESA_FORMAT_SIGNED_RGBA8888
,
744 fetch_texel_1d_signed_rgba8888
,
745 fetch_texel_2d_signed_rgba8888
,
746 fetch_texel_3d_signed_rgba8888
,
747 store_texel_signed_rgba8888
750 MESA_FORMAT_SIGNED_RGBA8888_REV
,
751 fetch_texel_1d_signed_rgba8888_rev
,
752 fetch_texel_2d_signed_rgba8888_rev
,
753 fetch_texel_3d_signed_rgba8888_rev
,
754 store_texel_signed_rgba8888_rev
757 MESA_FORMAT_SIGNED_R16
,
758 fetch_texel_1d_signed_r16
,
759 fetch_texel_2d_signed_r16
,
760 fetch_texel_3d_signed_r16
,
761 store_texel_signed_r16
764 MESA_FORMAT_SIGNED_GR1616
,
765 fetch_texel_1d_signed_rg1616
,
766 fetch_texel_2d_signed_rg1616
,
767 fetch_texel_3d_signed_rg1616
,
768 store_texel_signed_rg1616
771 MESA_FORMAT_SIGNED_RGB_16
,
772 fetch_texel_1d_signed_rgb_16
,
773 fetch_texel_2d_signed_rgb_16
,
774 fetch_texel_3d_signed_rgb_16
,
775 store_texel_signed_rgb_16
778 MESA_FORMAT_SIGNED_RGBA_16
,
779 fetch_texel_1d_signed_rgba_16
,
780 fetch_texel_2d_signed_rgba_16
,
781 fetch_texel_3d_signed_rgba_16
,
782 store_texel_signed_rgba_16
786 fetch_texel_1d_rgba_16
,
787 fetch_texel_2d_rgba_16
,
788 fetch_texel_3d_rgba_16
,
792 MESA_FORMAT_RED_RGTC1
,
794 _mesa_fetch_texel_2d_f_red_rgtc1
,
799 MESA_FORMAT_SIGNED_RED_RGTC1
,
801 _mesa_fetch_texel_2d_f_signed_red_rgtc1
,
806 MESA_FORMAT_RG_RGTC2
,
808 _mesa_fetch_texel_2d_f_rg_rgtc2
,
813 MESA_FORMAT_SIGNED_RG_RGTC2
,
815 _mesa_fetch_texel_2d_f_signed_rg_rgtc2
,
822 _mesa_fetch_texel_2d_f_l_latc1
,
827 MESA_FORMAT_SIGNED_L_LATC1
,
829 _mesa_fetch_texel_2d_f_signed_l_latc1
,
834 MESA_FORMAT_LA_LATC2
,
836 _mesa_fetch_texel_2d_f_la_latc2
,
841 MESA_FORMAT_SIGNED_LA_LATC2
,
843 _mesa_fetch_texel_2d_f_signed_la_latc2
,
848 MESA_FORMAT_SIGNED_A8
,
849 fetch_texel_1d_signed_a8
,
850 fetch_texel_2d_signed_a8
,
851 fetch_texel_3d_signed_a8
,
852 store_texel_signed_a8
855 MESA_FORMAT_SIGNED_L8
,
856 fetch_texel_1d_signed_l8
,
857 fetch_texel_2d_signed_l8
,
858 fetch_texel_3d_signed_l8
,
859 store_texel_signed_l8
862 MESA_FORMAT_SIGNED_AL88
,
863 fetch_texel_1d_signed_al88
,
864 fetch_texel_2d_signed_al88
,
865 fetch_texel_3d_signed_al88
,
866 store_texel_signed_al88
869 MESA_FORMAT_SIGNED_I8
,
870 fetch_texel_1d_signed_i8
,
871 fetch_texel_2d_signed_i8
,
872 fetch_texel_3d_signed_i8
,
873 store_texel_signed_i8
876 MESA_FORMAT_SIGNED_A16
,
877 fetch_texel_1d_signed_a16
,
878 fetch_texel_2d_signed_a16
,
879 fetch_texel_3d_signed_a16
,
880 store_texel_signed_a16
883 MESA_FORMAT_SIGNED_L16
,
884 fetch_texel_1d_signed_l16
,
885 fetch_texel_2d_signed_l16
,
886 fetch_texel_3d_signed_l16
,
887 store_texel_signed_l16
890 MESA_FORMAT_SIGNED_AL1616
,
891 fetch_texel_1d_signed_al1616
,
892 fetch_texel_2d_signed_al1616
,
893 fetch_texel_3d_signed_al1616
,
894 store_texel_signed_al1616
897 MESA_FORMAT_SIGNED_I16
,
898 fetch_texel_1d_signed_i16
,
899 fetch_texel_2d_signed_i16
,
900 fetch_texel_3d_signed_i16
,
901 store_texel_signed_i16
904 MESA_FORMAT_RGB9_E5_FLOAT
,
905 fetch_texel_1d_rgb9_e5
,
906 fetch_texel_2d_rgb9_e5
,
907 fetch_texel_3d_rgb9_e5
,
911 MESA_FORMAT_R11_G11_B10_FLOAT
,
912 fetch_texel_1d_r11_g11_b10f
,
913 fetch_texel_2d_r11_g11_b10f
,
914 fetch_texel_3d_r11_g11_b10f
,
915 store_texel_r11_g11_b10f
918 MESA_FORMAT_Z32_FLOAT
,
919 fetch_texel_1d_f_r_f32
, /* Reuse the R32F functions. */
920 fetch_texel_2d_f_r_f32
,
921 fetch_texel_3d_f_r_f32
,
925 MESA_FORMAT_Z32_FLOAT_X24S8
,
926 fetch_texel_1d_z32f_x24s8
,
927 fetch_texel_2d_z32f_x24s8
,
928 fetch_texel_3d_z32f_x24s8
,
929 store_texel_z32f_x24s8
935 _mesa_get_texel_fetch_func(gl_format format
, GLuint dims
)
938 /* check that the table entries are sorted by format name */
940 for (fmt
= 0; fmt
< MESA_FORMAT_COUNT
; fmt
++) {
941 assert(texfetch_funcs
[fmt
].Name
== fmt
);
945 assert(Elements(texfetch_funcs
) == MESA_FORMAT_COUNT
);
946 assert(format
< MESA_FORMAT_COUNT
);
950 return texfetch_funcs
[format
].Fetch1D
;
952 return texfetch_funcs
[format
].Fetch2D
;
954 return texfetch_funcs
[format
].Fetch3D
;
956 assert(0 && "bad dims in _mesa_get_texel_fetch_func");
963 _mesa_get_texel_store_func(gl_format format
)
965 assert(format
< MESA_FORMAT_COUNT
);
966 return texfetch_funcs
[format
].StoreTexel
;
971 * Adaptor for fetching a GLchan texel from a float-valued texture.
974 fetch_texel_float_to_chan(const struct gl_texture_image
*texImage
,
975 GLint i
, GLint j
, GLint k
, GLchan
*texelOut
)
978 GLenum baseFormat
= _mesa_get_format_base_format(texImage
->TexFormat
);
980 ASSERT(texImage
->FetchTexelf
);
981 texImage
->FetchTexelf(texImage
, i
, j
, k
, temp
);
982 if (baseFormat
== GL_DEPTH_COMPONENT
||
983 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
984 /* just one channel */
985 UNCLAMPED_FLOAT_TO_CHAN(texelOut
[0], temp
[0]);
989 UNCLAMPED_FLOAT_TO_CHAN(texelOut
[0], temp
[0]);
990 UNCLAMPED_FLOAT_TO_CHAN(texelOut
[1], temp
[1]);
991 UNCLAMPED_FLOAT_TO_CHAN(texelOut
[2], temp
[2]);
992 UNCLAMPED_FLOAT_TO_CHAN(texelOut
[3], temp
[3]);
999 * Adaptor for fetching a float texel from a GLchan-valued texture.
1002 fetch_texel_chan_to_float(const struct gl_texture_image
*texImage
,
1003 GLint i
, GLint j
, GLint k
, GLfloat
*texelOut
)
1006 GLenum baseFormat
= _mesa_get_format_base_format(texImage
->TexFormat
);
1008 ASSERT(texImage
->FetchTexelc
);
1009 texImage
->FetchTexelc(texImage
, i
, j
, k
, temp
);
1010 if (baseFormat
== GL_DEPTH_COMPONENT
||
1011 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
1012 /* just one channel */
1013 texelOut
[0] = CHAN_TO_FLOAT(temp
[0]);
1017 texelOut
[0] = CHAN_TO_FLOAT(temp
[0]);
1018 texelOut
[1] = CHAN_TO_FLOAT(temp
[1]);
1019 texelOut
[2] = CHAN_TO_FLOAT(temp
[2]);
1020 texelOut
[3] = CHAN_TO_FLOAT(temp
[3]);
1027 * Initialize the texture image's FetchTexelc and FetchTexelf methods.
1030 _mesa_set_fetch_functions(struct gl_texture_image
*texImage
, GLuint dims
)
1032 gl_format format
= texImage
->TexFormat
;
1034 ASSERT(dims
== 1 || dims
== 2 || dims
== 3);
1036 if (texImage
->TexObject
->Sampler
.sRGBDecode
== GL_SKIP_DECODE_EXT
&&
1037 _mesa_get_format_color_encoding(format
) == GL_SRGB
) {
1038 format
= _mesa_get_srgb_format_linear(format
);
1041 texImage
->FetchTexelf
= _mesa_get_texel_fetch_func(format
, dims
);
1043 texImage
->FetchTexelc
= fetch_texel_float_to_chan
;
1045 ASSERT(texImage
->FetchTexelc
);
1046 ASSERT(texImage
->FetchTexelf
);
1050 _mesa_update_fetch_functions(struct gl_texture_object
*texObj
)
1055 dims
= _mesa_get_texture_dimensions(texObj
->Target
);
1057 for (face
= 0; face
< 6; face
++) {
1058 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
1059 if (texObj
->Image
[face
][i
]) {
1060 _mesa_set_fetch_functions(texObj
->Image
[face
][i
], dims
);