dbed3dba99b4a574333eb770caef7440b4e92ed6
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008-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.
28 * \file texfetch_tmp.h
29 * Texel fetch functions template.
31 * This template file is used by texfetch.c to generate texel fetch functions
32 * for 1-D, 2-D and 3-D texture images.
34 * It should be expanded by defining \p DIM as the number texture dimensions
35 * (1, 2 or 3). According to the value of \p DIM a series of macros is defined
36 * for the texel lookup in the gl_texture_image::Data.
38 * \author Gareth Hughes
45 #define TEXEL_ADDR( type, image, i, j, k, size ) \
46 ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
48 #define FETCH(x) fetch_texel_1d_##x
52 #define TEXEL_ADDR( type, image, i, j, k, size ) \
54 ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
56 #define FETCH(x) fetch_texel_2d_##x
60 #define TEXEL_ADDR( type, image, i, j, k, size ) \
61 ((type *)(image)->Data + ((image)->ImageOffsets[k] \
62 + (image)->RowStride * (j) + (i)) * (size))
64 #define FETCH(x) fetch_texel_3d_##x
67 #error illegal number of texture dimensions
71 /* MESA_FORMAT_Z32 ***********************************************************/
73 /* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
74 * returning 1 GLfloat.
75 * Note: no GLchan version of this function.
77 static void FETCH(f_z32
)( const struct gl_texture_image
*texImage
,
78 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
80 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
81 texel
[0] = src
[0] * (1.0F
/ 0xffffffff);
85 static void store_texel_z32(struct gl_texture_image
*texImage
,
86 GLint i
, GLint j
, GLint k
, const void *texel
)
88 const GLuint
*depth
= (const GLuint
*) texel
;
89 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
95 /* MESA_FORMAT_Z16 ***********************************************************/
97 /* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
98 * returning 1 GLfloat.
99 * Note: no GLchan version of this function.
101 static void FETCH(f_z16
)(const struct gl_texture_image
*texImage
,
102 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
104 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
105 texel
[0] = src
[0] * (1.0F
/ 65535.0F
);
109 static void store_texel_z16(struct gl_texture_image
*texImage
,
110 GLint i
, GLint j
, GLint k
, const void *texel
)
112 const GLushort
*depth
= (const GLushort
*) texel
;
113 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
119 /* MESA_FORMAT_RGBA_F32 ******************************************************/
121 /* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
123 static void FETCH(f_rgba_f32
)( const struct gl_texture_image
*texImage
,
124 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
126 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 4);
127 texel
[RCOMP
] = src
[0];
128 texel
[GCOMP
] = src
[1];
129 texel
[BCOMP
] = src
[2];
130 texel
[ACOMP
] = src
[3];
134 static void store_texel_rgba_f32(struct gl_texture_image
*texImage
,
135 GLint i
, GLint j
, GLint k
, const void *texel
)
137 const GLfloat
*depth
= (const GLfloat
*) texel
;
138 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 4);
139 dst
[0] = depth
[RCOMP
];
140 dst
[1] = depth
[GCOMP
];
141 dst
[2] = depth
[BCOMP
];
142 dst
[3] = depth
[ACOMP
];
147 /* MESA_FORMAT_RGBA_F16 ******************************************************/
149 /* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
150 * returning 4 GLfloats.
152 static void FETCH(f_rgba_f16
)( const struct gl_texture_image
*texImage
,
153 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
155 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 4);
156 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
157 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
158 texel
[BCOMP
] = _mesa_half_to_float(src
[2]);
159 texel
[ACOMP
] = _mesa_half_to_float(src
[3]);
163 static void store_texel_rgba_f16(struct gl_texture_image
*texImage
,
164 GLint i
, GLint j
, GLint k
, const void *texel
)
166 const GLfloat
*src
= (const GLfloat
*) texel
;
167 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 4);
168 dst
[0] = _mesa_float_to_half(src
[RCOMP
]);
169 dst
[1] = _mesa_float_to_half(src
[GCOMP
]);
170 dst
[2] = _mesa_float_to_half(src
[BCOMP
]);
171 dst
[3] = _mesa_float_to_half(src
[ACOMP
]);
175 /* MESA_FORMAT_RGB_F32 *******************************************************/
177 /* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
178 * returning 4 GLfloats.
180 static void FETCH(f_rgb_f32
)( const struct gl_texture_image
*texImage
,
181 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
183 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 3);
184 texel
[RCOMP
] = src
[0];
185 texel
[GCOMP
] = src
[1];
186 texel
[BCOMP
] = src
[2];
191 static void store_texel_rgb_f32(struct gl_texture_image
*texImage
,
192 GLint i
, GLint j
, GLint k
, const void *texel
)
194 const GLfloat
*src
= (const GLfloat
*) texel
;
195 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 3);
203 /* MESA_FORMAT_RGB_F16 *******************************************************/
205 /* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
206 * returning 4 GLfloats.
208 static void FETCH(f_rgb_f16
)( const struct gl_texture_image
*texImage
,
209 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
211 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 3);
212 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
213 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
214 texel
[BCOMP
] = _mesa_half_to_float(src
[2]);
219 static void store_texel_rgb_f16(struct gl_texture_image
*texImage
,
220 GLint i
, GLint j
, GLint k
, const void *texel
)
222 const GLfloat
*src
= (const GLfloat
*) texel
;
223 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 3);
224 dst
[0] = _mesa_float_to_half(src
[RCOMP
]);
225 dst
[1] = _mesa_float_to_half(src
[GCOMP
]);
226 dst
[2] = _mesa_float_to_half(src
[BCOMP
]);
231 /* MESA_FORMAT_ALPHA_F32 *****************************************************/
233 /* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
234 * returning 4 GLfloats.
236 static void FETCH(f_alpha_f32
)( const struct gl_texture_image
*texImage
,
237 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
239 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
243 texel
[ACOMP
] = src
[0];
247 static void store_texel_alpha_f32(struct gl_texture_image
*texImage
,
248 GLint i
, GLint j
, GLint k
, const void *texel
)
250 const GLfloat
*rgba
= (const GLfloat
*) texel
;
251 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
252 dst
[0] = rgba
[ACOMP
];
257 /* MESA_FORMAT_ALPHA_F32 *****************************************************/
259 /* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
260 * returning 4 GLfloats.
262 static void FETCH(f_alpha_f16
)( const struct gl_texture_image
*texImage
,
263 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
265 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
269 texel
[ACOMP
] = _mesa_half_to_float(src
[0]);
273 static void store_texel_alpha_f16(struct gl_texture_image
*texImage
,
274 GLint i
, GLint j
, GLint k
, const void *texel
)
276 const GLfloat
*rgba
= (const GLfloat
*) texel
;
277 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
278 dst
[0] = _mesa_float_to_half(rgba
[ACOMP
]);
283 /* MESA_FORMAT_LUMINANCE_F32 *************************************************/
285 /* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
286 * returning 4 GLfloats.
288 static void FETCH(f_luminance_f32
)( const struct gl_texture_image
*texImage
,
289 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
291 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
294 texel
[BCOMP
] = src
[0];
299 static void store_texel_luminance_f32(struct gl_texture_image
*texImage
,
300 GLint i
, GLint j
, GLint k
, const void *texel
)
302 const GLfloat
*rgba
= (const GLfloat
*) texel
;
303 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
304 dst
[0] = rgba
[RCOMP
];
309 /* MESA_FORMAT_LUMINANCE_F16 *************************************************/
311 /* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
312 * returning 4 GLfloats.
314 static void FETCH(f_luminance_f16
)( const struct gl_texture_image
*texImage
,
315 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
317 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
320 texel
[BCOMP
] = _mesa_half_to_float(src
[0]);
325 static void store_texel_luminance_f16(struct gl_texture_image
*texImage
,
326 GLint i
, GLint j
, GLint k
, const void *texel
)
328 const GLfloat
*rgba
= (const GLfloat
*) texel
;
329 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
330 dst
[0] = _mesa_float_to_half(rgba
[RCOMP
]);
335 /* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
337 /* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
338 * returning 4 GLfloats.
340 static void FETCH(f_luminance_alpha_f32
)( const struct gl_texture_image
*texImage
,
341 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
343 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
346 texel
[BCOMP
] = src
[0];
347 texel
[ACOMP
] = src
[1];
351 static void store_texel_luminance_alpha_f32(struct gl_texture_image
*texImage
,
352 GLint i
, GLint j
, GLint k
, const void *texel
)
354 const GLfloat
*rgba
= (const GLfloat
*) texel
;
355 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
356 dst
[0] = rgba
[RCOMP
];
357 dst
[1] = rgba
[ACOMP
];
362 /* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
364 /* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
365 * returning 4 GLfloats.
367 static void FETCH(f_luminance_alpha_f16
)( const struct gl_texture_image
*texImage
,
368 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
370 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
373 texel
[BCOMP
] = _mesa_half_to_float(src
[0]);
374 texel
[ACOMP
] = _mesa_half_to_float(src
[1]);
378 static void store_texel_luminance_alpha_f16(struct gl_texture_image
*texImage
,
379 GLint i
, GLint j
, GLint k
, const void *texel
)
381 const GLfloat
*rgba
= (const GLfloat
*) texel
;
382 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
383 dst
[0] = _mesa_float_to_half(rgba
[RCOMP
]);
384 dst
[1] = _mesa_float_to_half(rgba
[ACOMP
]);
389 /* MESA_FORMAT_INTENSITY_F32 *************************************************/
391 /* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
392 * returning 4 GLfloats.
394 static void FETCH(f_intensity_f32
)( const struct gl_texture_image
*texImage
,
395 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
397 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
401 texel
[ACOMP
] = src
[0];
405 static void store_texel_intensity_f32(struct gl_texture_image
*texImage
,
406 GLint i
, GLint j
, GLint k
, const void *texel
)
408 const GLfloat
*rgba
= (const GLfloat
*) texel
;
409 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
410 dst
[0] = rgba
[RCOMP
];
415 /* MESA_FORMAT_INTENSITY_F16 *************************************************/
417 /* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
418 * returning 4 GLfloats.
420 static void FETCH(f_intensity_f16
)( const struct gl_texture_image
*texImage
,
421 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
423 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
427 texel
[ACOMP
] = _mesa_half_to_float(src
[0]);
431 static void store_texel_intensity_f16(struct gl_texture_image
*texImage
,
432 GLint i
, GLint j
, GLint k
, const void *texel
)
434 const GLfloat
*rgba
= (const GLfloat
*) texel
;
435 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
436 dst
[0] = _mesa_float_to_half(rgba
[RCOMP
]);
441 /* MESA_FORMAT_R_FLOAT32 *****************************************************/
443 /* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
444 * returning 4 GLfloats.
446 static void FETCH(f_r_f32
)( const struct gl_texture_image
*texImage
,
447 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
449 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
450 texel
[RCOMP
] = src
[0];
457 static void store_texel_r_f32(struct gl_texture_image
*texImage
,
458 GLint i
, GLint j
, GLint k
, const void *texel
)
460 const GLfloat
*rgba
= (const GLfloat
*) texel
;
461 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
462 dst
[0] = rgba
[RCOMP
];
467 /* MESA_FORMAT_R_FLOAT16 *****************************************************/
469 /* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
470 * returning 4 GLfloats.
472 static void FETCH(f_r_f16
)( const struct gl_texture_image
*texImage
,
473 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
475 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
476 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
483 static void store_texel_r_f16(struct gl_texture_image
*texImage
,
484 GLint i
, GLint j
, GLint k
, const void *texel
)
486 const GLfloat
*rgba
= (const GLfloat
*) texel
;
487 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
488 dst
[0] = _mesa_float_to_half(rgba
[RCOMP
]);
493 /* MESA_FORMAT_RG_FLOAT32 ****************************************************/
495 /* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
496 * returning 4 GLfloats.
498 static void FETCH(f_rg_f32
)( const struct gl_texture_image
*texImage
,
499 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
501 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
502 texel
[RCOMP
] = src
[0];
503 texel
[GCOMP
] = src
[1];
509 static void store_texel_rg_f32(struct gl_texture_image
*texImage
,
510 GLint i
, GLint j
, GLint k
, const void *texel
)
512 const GLfloat
*rgba
= (const GLfloat
*) texel
;
513 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
514 dst
[0] = rgba
[RCOMP
];
515 dst
[1] = rgba
[GCOMP
];
520 /* MESA_FORMAT_RG_FLOAT16 ****************************************************/
522 /* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
523 * returning 4 GLfloats.
525 static void FETCH(f_rg_f16
)( const struct gl_texture_image
*texImage
,
526 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
528 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
529 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
530 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
536 static void store_texel_rg_f16(struct gl_texture_image
*texImage
,
537 GLint i
, GLint j
, GLint k
, const void *texel
)
539 const GLfloat
*rgba
= (const GLfloat
*) texel
;
540 GLhalfARB
*dst
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
541 dst
[0] = _mesa_float_to_half(rgba
[RCOMP
]);
542 dst
[1] = _mesa_float_to_half(rgba
[GCOMP
]);
548 * Begin Hardware formats
551 /* MESA_FORMAT_RGBA8888 ******************************************************/
553 /* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
554 static void FETCH(f_rgba8888
)( const struct gl_texture_image
*texImage
,
555 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
557 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
558 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
559 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
560 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
561 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
567 static void store_texel_rgba8888(struct gl_texture_image
*texImage
,
568 GLint i
, GLint j
, GLint k
, const void *texel
)
570 const GLubyte
*rgba
= (const GLubyte
*) texel
;
571 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
572 *dst
= PACK_COLOR_8888(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
577 /* MESA_FORMAT_RGBA888_REV ***************************************************/
579 /* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
580 static void FETCH(f_rgba8888_rev
)( const struct gl_texture_image
*texImage
,
581 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
583 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
584 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
585 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
586 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
587 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
591 static void store_texel_rgba8888_rev(struct gl_texture_image
*texImage
,
592 GLint i
, GLint j
, GLint k
, const void *texel
)
594 const GLubyte
*rgba
= (const GLubyte
*) texel
;
595 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
596 *dst
= PACK_COLOR_8888_REV(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
601 /* MESA_FORMAT_ARGB8888 ******************************************************/
603 /* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
604 static void FETCH(f_argb8888
)( const struct gl_texture_image
*texImage
,
605 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
607 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
608 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
609 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
610 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
611 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
615 static void store_texel_argb8888(struct gl_texture_image
*texImage
,
616 GLint i
, GLint j
, GLint k
, const void *texel
)
618 const GLubyte
*rgba
= (const GLubyte
*) texel
;
619 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
620 *dst
= PACK_COLOR_8888(rgba
[ACOMP
], rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
625 /* MESA_FORMAT_ARGB8888_REV **************************************************/
627 /* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
628 static void FETCH(f_argb8888_rev
)( const struct gl_texture_image
*texImage
,
629 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
631 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
632 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
633 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
634 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
635 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
639 static void store_texel_argb8888_rev(struct gl_texture_image
*texImage
,
640 GLint i
, GLint j
, GLint k
, const void *texel
)
642 const GLubyte
*rgba
= (const GLubyte
*) texel
;
643 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
644 *dst
= PACK_COLOR_8888(rgba
[BCOMP
], rgba
[GCOMP
], rgba
[RCOMP
], rgba
[ACOMP
]);
649 /* MESA_FORMAT_XRGB8888 ******************************************************/
651 /* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
652 static void FETCH(f_xrgb8888
)( const struct gl_texture_image
*texImage
,
653 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
655 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
656 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
657 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
658 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
663 static void store_texel_xrgb8888(struct gl_texture_image
*texImage
,
664 GLint i
, GLint j
, GLint k
, const void *texel
)
666 const GLubyte
*rgba
= (const GLubyte
*) texel
;
667 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
668 *dst
= PACK_COLOR_8888(0xff, rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
673 /* MESA_FORMAT_XRGB8888_REV **************************************************/
675 /* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
676 static void FETCH(f_xrgb8888_rev
)( const struct gl_texture_image
*texImage
,
677 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
679 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
680 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
681 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
682 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
687 static void store_texel_xrgb8888_rev(struct gl_texture_image
*texImage
,
688 GLint i
, GLint j
, GLint k
, const void *texel
)
690 const GLubyte
*rgba
= (const GLubyte
*) texel
;
691 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
692 *dst
= PACK_COLOR_8888(rgba
[BCOMP
], rgba
[GCOMP
], rgba
[RCOMP
], 0xff);
697 /* MESA_FORMAT_RGB888 ********************************************************/
699 /* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
700 static void FETCH(f_rgb888
)( const struct gl_texture_image
*texImage
,
701 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
703 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
704 texel
[RCOMP
] = UBYTE_TO_FLOAT( src
[2] );
705 texel
[GCOMP
] = UBYTE_TO_FLOAT( src
[1] );
706 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[0] );
711 static void store_texel_rgb888(struct gl_texture_image
*texImage
,
712 GLint i
, GLint j
, GLint k
, const void *texel
)
714 const GLubyte
*rgba
= (const GLubyte
*) texel
;
715 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
716 dst
[0] = rgba
[BCOMP
];
717 dst
[1] = rgba
[GCOMP
];
718 dst
[2] = rgba
[RCOMP
];
723 /* MESA_FORMAT_BGR888 ********************************************************/
725 /* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
726 static void FETCH(f_bgr888
)( const struct gl_texture_image
*texImage
,
727 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
729 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
730 texel
[RCOMP
] = UBYTE_TO_FLOAT( src
[0] );
731 texel
[GCOMP
] = UBYTE_TO_FLOAT( src
[1] );
732 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[2] );
737 static void store_texel_bgr888(struct gl_texture_image
*texImage
,
738 GLint i
, GLint j
, GLint k
, const void *texel
)
740 const GLubyte
*rgba
= (const GLubyte
*) texel
;
741 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
742 dst
[0] = rgba
[RCOMP
];
743 dst
[1] = rgba
[GCOMP
];
744 dst
[2] = rgba
[BCOMP
];
749 /* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
750 instead of slow (g << 2) * 255 / 252 (always rounds down) */
752 /* MESA_FORMAT_RGB565 ********************************************************/
754 /* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
755 static void FETCH(f_rgb565
)( const struct gl_texture_image
*texImage
,
756 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
758 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
759 const GLushort s
= *src
;
760 texel
[RCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
761 texel
[GCOMP
] = ((s
>> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
762 texel
[BCOMP
] = ((s
) & 0x1f) * (1.0F
/ 31.0F
);
767 static void store_texel_rgb565(struct gl_texture_image
*texImage
,
768 GLint i
, GLint j
, GLint k
, const void *texel
)
770 const GLubyte
*rgba
= (const GLubyte
*) texel
;
771 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
772 *dst
= PACK_COLOR_565(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
777 /* MESA_FORMAT_RGB565_REV ****************************************************/
779 /* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
780 static void FETCH(f_rgb565_rev
)( const struct gl_texture_image
*texImage
,
781 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
783 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
784 const GLushort s
= (*src
>> 8) | (*src
<< 8); /* byte swap */
785 texel
[RCOMP
] = UBYTE_TO_FLOAT( ((s
>> 8) & 0xf8) | ((s
>> 13) & 0x7) );
786 texel
[GCOMP
] = UBYTE_TO_FLOAT( ((s
>> 3) & 0xfc) | ((s
>> 9) & 0x3) );
787 texel
[BCOMP
] = UBYTE_TO_FLOAT( ((s
<< 3) & 0xf8) | ((s
>> 2) & 0x7) );
792 static void store_texel_rgb565_rev(struct gl_texture_image
*texImage
,
793 GLint i
, GLint j
, GLint k
, const void *texel
)
795 const GLchan
*rgba
= (const GLchan
*) texel
;
796 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
797 GLushort p
= PACK_COLOR_565(CHAN_TO_UBYTE(rgba
[RCOMP
]),
798 CHAN_TO_UBYTE(rgba
[GCOMP
]),
799 CHAN_TO_UBYTE(rgba
[BCOMP
]));
800 *dst
= (p
>> 8) | (p
<< 8); /* byte swap */
805 /* MESA_FORMAT_ARGB4444 ******************************************************/
807 /* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
808 static void FETCH(f_argb4444
)( const struct gl_texture_image
*texImage
,
809 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
811 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
812 const GLushort s
= *src
;
813 texel
[RCOMP
] = ((s
>> 8) & 0xf) * (1.0F
/ 15.0F
);
814 texel
[GCOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
815 texel
[BCOMP
] = ((s
) & 0xf) * (1.0F
/ 15.0F
);
816 texel
[ACOMP
] = ((s
>> 12) & 0xf) * (1.0F
/ 15.0F
);
820 static void store_texel_argb4444(struct gl_texture_image
*texImage
,
821 GLint i
, GLint j
, GLint k
, const void *texel
)
823 const GLchan
*rgba
= (const GLchan
*) texel
;
824 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
825 *dst
= PACK_COLOR_4444(CHAN_TO_UBYTE(rgba
[ACOMP
]),
826 CHAN_TO_UBYTE(rgba
[RCOMP
]),
827 CHAN_TO_UBYTE(rgba
[GCOMP
]),
828 CHAN_TO_UBYTE(rgba
[BCOMP
]));
833 /* MESA_FORMAT_ARGB4444_REV **************************************************/
835 /* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
836 static void FETCH(f_argb4444_rev
)( const struct gl_texture_image
*texImage
,
837 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
839 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
840 texel
[RCOMP
] = ((s
) & 0xf) * (1.0F
/ 15.0F
);
841 texel
[GCOMP
] = ((s
>> 12) & 0xf) * (1.0F
/ 15.0F
);
842 texel
[BCOMP
] = ((s
>> 8) & 0xf) * (1.0F
/ 15.0F
);
843 texel
[ACOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
847 static void store_texel_argb4444_rev(struct gl_texture_image
*texImage
,
848 GLint i
, GLint j
, GLint k
, const void *texel
)
850 const GLchan
*rgba
= (const GLchan
*) texel
;
851 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
852 *dst
= PACK_COLOR_4444(CHAN_TO_UBYTE(rgba
[GCOMP
]),
853 CHAN_TO_UBYTE(rgba
[BCOMP
]),
854 CHAN_TO_UBYTE(rgba
[ACOMP
]),
855 CHAN_TO_UBYTE(rgba
[RCOMP
]));
859 /* MESA_FORMAT_RGBA5551 ******************************************************/
861 /* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
862 static void FETCH(f_rgba5551
)( const struct gl_texture_image
*texImage
,
863 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
865 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
866 const GLushort s
= *src
;
867 texel
[RCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
868 texel
[GCOMP
] = ((s
>> 6) & 0x1f) * (1.0F
/ 31.0F
);
869 texel
[BCOMP
] = ((s
>> 1) & 0x1f) * (1.0F
/ 31.0F
);
870 texel
[ACOMP
] = ((s
) & 0x01) * 1.0F
;
874 static void store_texel_rgba5551(struct gl_texture_image
*texImage
,
875 GLint i
, GLint j
, GLint k
, const void *texel
)
877 const GLubyte
*rgba
= (const GLubyte
*) texel
;
878 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
879 *dst
= PACK_COLOR_5551(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
883 /* MESA_FORMAT_ARGB1555 ******************************************************/
885 /* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
886 static void FETCH(f_argb1555
)( const struct gl_texture_image
*texImage
,
887 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
889 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
890 const GLushort s
= *src
;
891 texel
[RCOMP
] = ((s
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
892 texel
[GCOMP
] = ((s
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
893 texel
[BCOMP
] = ((s
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
894 texel
[ACOMP
] = ((s
>> 15) & 0x01) * 1.0F
;
898 static void store_texel_argb1555(struct gl_texture_image
*texImage
,
899 GLint i
, GLint j
, GLint k
, const void *texel
)
901 const GLubyte
*rgba
= (const GLubyte
*) texel
;
902 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
903 *dst
= PACK_COLOR_1555(rgba
[ACOMP
], rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
908 /* MESA_FORMAT_ARGB1555_REV **************************************************/
910 /* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
911 static void FETCH(f_argb1555_rev
)( const struct gl_texture_image
*texImage
,
912 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
914 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
915 const GLushort s
= (*src
<< 8) | (*src
>> 8); /* byteswap */
916 texel
[RCOMP
] = UBYTE_TO_FLOAT( ((s
>> 7) & 0xf8) | ((s
>> 12) & 0x7) );
917 texel
[GCOMP
] = UBYTE_TO_FLOAT( ((s
>> 2) & 0xf8) | ((s
>> 7) & 0x7) );
918 texel
[BCOMP
] = UBYTE_TO_FLOAT( ((s
<< 3) & 0xf8) | ((s
>> 2) & 0x7) );
919 texel
[ACOMP
] = UBYTE_TO_FLOAT( ((s
>> 15) & 0x01) * 255 );
923 static void store_texel_argb1555_rev(struct gl_texture_image
*texImage
,
924 GLint i
, GLint j
, GLint k
, const void *texel
)
926 const GLubyte
*rgba
= (const GLubyte
*) texel
;
927 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
928 *dst
= PACK_COLOR_1555_REV(rgba
[ACOMP
], rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
933 /* MESA_FORMAT_ARGB2101010 ***************************************************/
935 /* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */
936 static void FETCH(f_argb2101010
)( const struct gl_texture_image
*texImage
,
937 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
939 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
940 const GLuint s
= *src
;
941 texel
[RCOMP
] = ((s
>> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
942 texel
[GCOMP
] = ((s
>> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
943 texel
[BCOMP
] = ((s
>> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
944 texel
[ACOMP
] = ((s
>> 30) & 0x03) * (1.0F
/ 3.0F
);
948 static void store_texel_argb2101010(struct gl_texture_image
*texImage
,
949 GLint i
, GLint j
, GLint k
, const void *texel
)
951 const GLchan
*rgba
= (const GLchan
*) texel
;
952 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
953 GLushort r
= CHAN_TO_USHORT(rgba
[RCOMP
]);
954 GLushort g
= CHAN_TO_USHORT(rgba
[GCOMP
]);
955 GLushort b
= CHAN_TO_USHORT(rgba
[BCOMP
]);
956 GLushort a
= CHAN_TO_USHORT(rgba
[ACOMP
]);
957 *dst
= PACK_COLOR_2101010_US(a
, r
, g
, b
);
962 /* MESA_FORMAT_RG88 **********************************************************/
964 /* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
965 static void FETCH(f_rg88
)( const struct gl_texture_image
*texImage
,
966 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
968 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
969 texel
[RCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
970 texel
[GCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
976 static void store_texel_rg88(struct gl_texture_image
*texImage
,
977 GLint i
, GLint j
, GLint k
, const void *texel
)
979 const GLchan
*rgba
= (const GLubyte
*) texel
;
980 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
981 GLubyte r
= CHAN_TO_UBYTE(rgba
[RCOMP
]);
982 GLubyte g
= CHAN_TO_UBYTE(rgba
[GCOMP
]);
983 *dst
= PACK_COLOR_88(g
, r
);
988 /* MESA_FORMAT_RG88_REV ******************************************************/
990 /* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */
991 static void FETCH(f_rg88_rev
)( const struct gl_texture_image
*texImage
,
992 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
994 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
995 texel
[RCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
996 texel
[GCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
1002 static void store_texel_rg88_rev(struct gl_texture_image
*texImage
,
1003 GLint i
, GLint j
, GLint k
, const void *texel
)
1005 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1006 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1007 *dst
= PACK_COLOR_88(rgba
[GCOMP
], rgba
[RCOMP
]);
1012 /* MESA_FORMAT_AL44 **********************************************************/
1014 /* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */
1015 static void FETCH(f_al44
)( const struct gl_texture_image
*texImage
,
1016 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1018 const GLubyte s
= *TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1021 texel
[BCOMP
] = (s
& 0xf) * (1.0F
/ 15.0F
);
1022 texel
[ACOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
1026 static void store_texel_al44(struct gl_texture_image
*texImage
,
1027 GLint i
, GLint j
, GLint k
, const void *texel
)
1029 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1030 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1031 *dst
= PACK_COLOR_44(rgba
[ACOMP
], rgba
[RCOMP
]);
1036 /* MESA_FORMAT_AL88 **********************************************************/
1038 /* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
1039 static void FETCH(f_al88
)( const struct gl_texture_image
*texImage
,
1040 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1042 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1045 texel
[BCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
1046 texel
[ACOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
1050 static void store_texel_al88(struct gl_texture_image
*texImage
,
1051 GLint i
, GLint j
, GLint k
, const void *texel
)
1053 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1054 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1055 *dst
= PACK_COLOR_88(rgba
[ACOMP
], rgba
[RCOMP
]);
1060 /* MESA_FORMAT_R8 ************************************************************/
1062 /* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
1063 static void FETCH(f_r8
)(const struct gl_texture_image
*texImage
,
1064 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1066 const GLubyte s
= *TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1067 texel
[RCOMP
] = UBYTE_TO_FLOAT(s
);
1074 static void store_texel_r8(struct gl_texture_image
*texImage
,
1075 GLint i
, GLint j
, GLint k
, const void *texel
)
1077 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1078 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1084 /* MESA_FORMAT_R16 ***********************************************************/
1086 /* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */
1087 static void FETCH(f_r16
)(const struct gl_texture_image
*texImage
,
1088 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1090 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1091 texel
[RCOMP
] = USHORT_TO_FLOAT(s
);
1098 static void store_texel_r16(struct gl_texture_image
*texImage
,
1099 GLint i
, GLint j
, GLint k
, const void *texel
)
1101 const GLchan
*rgba
= (const GLchan
*) texel
;
1102 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1103 *dst
= CHAN_TO_USHORT(rgba
[RCOMP
]);
1108 /* MESA_FORMAT_AL88_REV ******************************************************/
1110 /* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
1111 static void FETCH(f_al88_rev
)( const struct gl_texture_image
*texImage
,
1112 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1114 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1117 texel
[BCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
1118 texel
[ACOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
1122 static void store_texel_al88_rev(struct gl_texture_image
*texImage
,
1123 GLint i
, GLint j
, GLint k
, const void *texel
)
1125 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1126 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1127 *dst
= PACK_COLOR_88(rgba
[RCOMP
], rgba
[ACOMP
]);
1132 /* MESA_FORMAT_RG1616 ********************************************************/
1134 /* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */
1135 static void FETCH(f_rg1616
)( const struct gl_texture_image
*texImage
,
1136 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1138 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1139 texel
[RCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
1140 texel
[GCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
1146 static void store_texel_rg1616(struct gl_texture_image
*texImage
,
1147 GLint i
, GLint j
, GLint k
, const void *texel
)
1149 const GLchan
*rgba
= (const GLchan
*) texel
;
1150 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1151 GLushort r
= CHAN_TO_USHORT(rgba
[RCOMP
]);
1152 GLushort g
= CHAN_TO_USHORT(rgba
[GCOMP
]);
1153 *dst
= PACK_COLOR_1616(g
, r
);
1158 /* MESA_FORMAT_RG1616_REV ****************************************************/
1160 /* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */
1161 static void FETCH(f_rg1616_rev
)( const struct gl_texture_image
*texImage
,
1162 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1164 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1165 texel
[RCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
1166 texel
[GCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
1172 static void store_texel_rg1616_rev(struct gl_texture_image
*texImage
,
1173 GLint i
, GLint j
, GLint k
, const void *texel
)
1175 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1176 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1177 *dst
= PACK_COLOR_1616(rgba
[GCOMP
], rgba
[RCOMP
]);
1182 /* MESA_FORMAT_AL1616 ********************************************************/
1184 /* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
1185 static void FETCH(f_al1616
)( const struct gl_texture_image
*texImage
,
1186 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1188 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1191 texel
[BCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
1192 texel
[ACOMP
] = USHORT_TO_FLOAT( s
>> 16 );
1196 static void store_texel_al1616(struct gl_texture_image
*texImage
,
1197 GLint i
, GLint j
, GLint k
, const void *texel
)
1199 const GLchan
*rgba
= (const GLchan
*) texel
;
1200 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1201 GLushort l
= CHAN_TO_USHORT(rgba
[RCOMP
]);
1202 GLushort a
= CHAN_TO_USHORT(rgba
[ACOMP
]);
1203 *dst
= PACK_COLOR_1616(a
, l
);
1208 /* MESA_FORMAT_AL1616_REV ****************************************************/
1210 /* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
1211 static void FETCH(f_al1616_rev
)( const struct gl_texture_image
*texImage
,
1212 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1214 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1217 texel
[BCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
1218 texel
[ACOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
1222 static void store_texel_al1616_rev(struct gl_texture_image
*texImage
,
1223 GLint i
, GLint j
, GLint k
, const void *texel
)
1225 const GLushort
*rgba
= (const GLushort
*) texel
;
1226 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1227 *dst
= PACK_COLOR_1616(rgba
[RCOMP
], rgba
[ACOMP
]);
1232 /* MESA_FORMAT_RGB332 ********************************************************/
1234 /* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
1235 static void FETCH(f_rgb332
)( const struct gl_texture_image
*texImage
,
1236 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1238 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1239 const GLubyte s
= *src
;
1240 texel
[RCOMP
] = ((s
>> 5) & 0x7) * (1.0F
/ 7.0F
);
1241 texel
[GCOMP
] = ((s
>> 2) & 0x7) * (1.0F
/ 7.0F
);
1242 texel
[BCOMP
] = ((s
) & 0x3) * (1.0F
/ 3.0F
);
1243 texel
[ACOMP
] = 1.0F
;
1247 static void store_texel_rgb332(struct gl_texture_image
*texImage
,
1248 GLint i
, GLint j
, GLint k
, const void *texel
)
1250 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1251 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1252 *dst
= PACK_COLOR_332(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
1257 /* MESA_FORMAT_A8 ************************************************************/
1259 /* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
1260 static void FETCH(f_a8
)( const struct gl_texture_image
*texImage
,
1261 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1263 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1266 texel
[BCOMP
] = 0.0F
;
1267 texel
[ACOMP
] = UBYTE_TO_FLOAT( src
[0] );
1271 static void store_texel_a8(struct gl_texture_image
*texImage
,
1272 GLint i
, GLint j
, GLint k
, const void *texel
)
1274 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1275 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1281 /* MESA_FORMAT_A16 ************************************************************/
1283 /* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
1284 static void FETCH(f_a16
)( const struct gl_texture_image
*texImage
,
1285 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1287 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1290 texel
[BCOMP
] = 0.0F
;
1291 texel
[ACOMP
] = USHORT_TO_FLOAT( src
[0] );
1295 static void store_texel_a16(struct gl_texture_image
*texImage
,
1296 GLint i
, GLint j
, GLint k
, const void *texel
)
1298 const GLchan
*rgba
= (const GLchan
*) texel
;
1299 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1300 *dst
= CHAN_TO_USHORT(rgba
[ACOMP
]);
1305 /* MESA_FORMAT_L8 ************************************************************/
1307 /* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
1308 static void FETCH(f_l8
)( const struct gl_texture_image
*texImage
,
1309 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1311 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1314 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[0] );
1315 texel
[ACOMP
] = 1.0F
;
1319 static void store_texel_l8(struct gl_texture_image
*texImage
,
1320 GLint i
, GLint j
, GLint k
, const void *texel
)
1322 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1323 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1329 /* MESA_FORMAT_L16 ***********************************************************/
1331 /* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */
1332 static void FETCH(f_l16
)( const struct gl_texture_image
*texImage
,
1333 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1335 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1338 texel
[BCOMP
] = USHORT_TO_FLOAT( src
[0] );
1339 texel
[ACOMP
] = 1.0F
;
1343 static void store_texel_l16(struct gl_texture_image
*texImage
,
1344 GLint i
, GLint j
, GLint k
, const void *texel
)
1346 const GLushort
*rgba
= (const GLushort
*) texel
;
1347 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1353 /* MESA_FORMAT_I8 ************************************************************/
1355 /* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
1356 static void FETCH(f_i8
)( const struct gl_texture_image
*texImage
,
1357 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1359 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1363 texel
[ACOMP
] = UBYTE_TO_FLOAT( src
[0] );
1367 static void store_texel_i8(struct gl_texture_image
*texImage
,
1368 GLint i
, GLint j
, GLint k
, const void *texel
)
1370 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1371 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1377 /* MESA_FORMAT_I16 ***********************************************************/
1379 /* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
1380 static void FETCH(f_i16
)( const struct gl_texture_image
*texImage
,
1381 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1383 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1387 texel
[ACOMP
] = USHORT_TO_FLOAT( src
[0] );
1391 static void store_texel_i16(struct gl_texture_image
*texImage
,
1392 GLint i
, GLint j
, GLint k
, const void *texel
)
1394 const GLushort
*rgba
= (const GLushort
*) texel
;
1395 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1401 /* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
1402 /* Note: component order is same as for MESA_FORMAT_RGB888 */
1403 static void FETCH(srgb8
)(const struct gl_texture_image
*texImage
,
1404 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1406 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
1407 texel
[RCOMP
] = nonlinear_to_linear(src
[2]);
1408 texel
[GCOMP
] = nonlinear_to_linear(src
[1]);
1409 texel
[BCOMP
] = nonlinear_to_linear(src
[0]);
1410 texel
[ACOMP
] = 1.0F
;
1414 static void store_texel_srgb8(struct gl_texture_image
*texImage
,
1415 GLint i
, GLint j
, GLint k
, const void *texel
)
1417 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1418 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
1419 dst
[0] = rgba
[BCOMP
]; /* no conversion */
1420 dst
[1] = rgba
[GCOMP
];
1421 dst
[2] = rgba
[RCOMP
];
1425 /* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
1426 static void FETCH(srgba8
)(const struct gl_texture_image
*texImage
,
1427 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1429 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1430 texel
[RCOMP
] = nonlinear_to_linear( (s
>> 24) );
1431 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 16) & 0xff );
1432 texel
[BCOMP
] = nonlinear_to_linear( (s
>> 8) & 0xff );
1433 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff ); /* linear! */
1437 static void store_texel_srgba8(struct gl_texture_image
*texImage
,
1438 GLint i
, GLint j
, GLint k
, const void *texel
)
1440 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1441 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1442 *dst
= PACK_COLOR_8888(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
1446 /* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
1447 static void FETCH(sargb8
)(const struct gl_texture_image
*texImage
,
1448 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1450 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1451 texel
[RCOMP
] = nonlinear_to_linear( (s
>> 16) & 0xff );
1452 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 8) & 0xff );
1453 texel
[BCOMP
] = nonlinear_to_linear( (s
) & 0xff );
1454 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) ); /* linear! */
1458 static void store_texel_sargb8(struct gl_texture_image
*texImage
,
1459 GLint i
, GLint j
, GLint k
, const void *texel
)
1461 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1462 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1463 *dst
= PACK_COLOR_8888(rgba
[ACOMP
], rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
]);
1467 /* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
1468 static void FETCH(sl8
)(const struct gl_texture_image
*texImage
,
1469 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1471 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1474 texel
[BCOMP
] = nonlinear_to_linear(src
[0]);
1475 texel
[ACOMP
] = 1.0F
;
1479 static void store_texel_sl8(struct gl_texture_image
*texImage
,
1480 GLint i
, GLint j
, GLint k
, const void *texel
)
1482 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1483 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
1484 dst
[0] = rgba
[RCOMP
];
1488 /* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
1489 static void FETCH(sla8
)(const struct gl_texture_image
*texImage
,
1490 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1492 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 2);
1495 texel
[BCOMP
] = nonlinear_to_linear(src
[0]);
1496 texel
[ACOMP
] = UBYTE_TO_FLOAT(src
[1]); /* linear */
1500 static void store_texel_sla8(struct gl_texture_image
*texImage
,
1501 GLint i
, GLint j
, GLint k
, const void *texel
)
1503 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1504 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 2);
1505 dst
[0] = rgba
[RCOMP
];
1506 dst
[1] = rgba
[ACOMP
];
1511 /* MESA_FORMAT_RGBA_INT8 **************************************************/
1514 FETCH(rgba_int8
)(const struct gl_texture_image
*texImage
,
1515 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1517 const GLbyte
*src
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 4);
1518 texel
[RCOMP
] = (GLfloat
) src
[0];
1519 texel
[GCOMP
] = (GLfloat
) src
[1];
1520 texel
[BCOMP
] = (GLfloat
) src
[2];
1521 texel
[ACOMP
] = (GLfloat
) src
[3];
1526 store_texel_rgba_int8(struct gl_texture_image
*texImage
,
1527 GLint i
, GLint j
, GLint k
, const void *texel
)
1529 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1530 GLbyte
*dst
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 4);
1531 dst
[0] = rgba
[RCOMP
];
1532 dst
[1] = rgba
[GCOMP
];
1533 dst
[2] = rgba
[BCOMP
];
1534 dst
[3] = rgba
[ACOMP
];
1539 /* MESA_FORMAT_RGBA_INT16 **************************************************/
1542 FETCH(rgba_int16
)(const struct gl_texture_image
*texImage
,
1543 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1545 const GLshort
*src
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
1546 texel
[RCOMP
] = (GLfloat
) src
[0];
1547 texel
[GCOMP
] = (GLfloat
) src
[1];
1548 texel
[BCOMP
] = (GLfloat
) src
[2];
1549 texel
[ACOMP
] = (GLfloat
) src
[3];
1554 store_texel_rgba_int16(struct gl_texture_image
*texImage
,
1555 GLint i
, GLint j
, GLint k
, const void *texel
)
1557 const GLshort
*rgba
= (const GLshort
*) texel
;
1558 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
1559 dst
[0] = rgba
[RCOMP
];
1560 dst
[1] = rgba
[GCOMP
];
1561 dst
[2] = rgba
[BCOMP
];
1562 dst
[3] = rgba
[ACOMP
];
1567 /* MESA_FORMAT_RGBA_INT32 **************************************************/
1570 FETCH(rgba_int32
)(const struct gl_texture_image
*texImage
,
1571 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1573 const GLint
*src
= TEXEL_ADDR(GLint
, texImage
, i
, j
, k
, 4);
1574 texel
[RCOMP
] = (GLfloat
) src
[0];
1575 texel
[GCOMP
] = (GLfloat
) src
[1];
1576 texel
[BCOMP
] = (GLfloat
) src
[2];
1577 texel
[ACOMP
] = (GLfloat
) src
[3];
1582 store_texel_rgba_int32(struct gl_texture_image
*texImage
,
1583 GLint i
, GLint j
, GLint k
, const void *texel
)
1585 const GLint
*rgba
= (const GLint
*) texel
;
1586 GLint
*dst
= TEXEL_ADDR(GLint
, texImage
, i
, j
, k
, 4);
1587 dst
[0] = rgba
[RCOMP
];
1588 dst
[1] = rgba
[GCOMP
];
1589 dst
[2] = rgba
[BCOMP
];
1590 dst
[3] = rgba
[ACOMP
];
1595 /* MESA_FORMAT_RGBA_UINT8 **************************************************/
1598 FETCH(rgba_uint8
)(const struct gl_texture_image
*texImage
,
1599 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1601 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 4);
1602 texel
[RCOMP
] = (GLfloat
) src
[0];
1603 texel
[GCOMP
] = (GLfloat
) src
[1];
1604 texel
[BCOMP
] = (GLfloat
) src
[2];
1605 texel
[ACOMP
] = (GLfloat
) src
[3];
1610 store_texel_rgba_uint8(struct gl_texture_image
*texImage
,
1611 GLint i
, GLint j
, GLint k
, const void *texel
)
1613 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1614 GLubyte
*dst
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 4);
1615 dst
[0] = rgba
[RCOMP
];
1616 dst
[1] = rgba
[GCOMP
];
1617 dst
[2] = rgba
[BCOMP
];
1618 dst
[3] = rgba
[ACOMP
];
1623 /* MESA_FORMAT_RGBA_UINT16 **************************************************/
1626 FETCH(rgba_uint16
)(const struct gl_texture_image
*texImage
,
1627 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1629 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1630 texel
[RCOMP
] = (GLfloat
) src
[0];
1631 texel
[GCOMP
] = (GLfloat
) src
[1];
1632 texel
[BCOMP
] = (GLfloat
) src
[2];
1633 texel
[ACOMP
] = (GLfloat
) src
[3];
1638 store_texel_rgba_uint16(struct gl_texture_image
*texImage
,
1639 GLint i
, GLint j
, GLint k
, const void *texel
)
1641 const GLushort
*rgba
= (const GLushort
*) texel
;
1642 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1643 dst
[0] = rgba
[RCOMP
];
1644 dst
[1] = rgba
[GCOMP
];
1645 dst
[2] = rgba
[BCOMP
];
1646 dst
[3] = rgba
[ACOMP
];
1651 /* MESA_FORMAT_RGBA_UINT32 **************************************************/
1654 FETCH(rgba_uint32
)(const struct gl_texture_image
*texImage
,
1655 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1657 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 4);
1658 texel
[RCOMP
] = (GLfloat
) src
[0];
1659 texel
[GCOMP
] = (GLfloat
) src
[1];
1660 texel
[BCOMP
] = (GLfloat
) src
[2];
1661 texel
[ACOMP
] = (GLfloat
) src
[3];
1666 store_texel_rgba_uint32(struct gl_texture_image
*texImage
,
1667 GLint i
, GLint j
, GLint k
, const void *texel
)
1669 const GLuint
*rgba
= (const GLuint
*) texel
;
1670 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 4);
1671 dst
[0] = rgba
[RCOMP
];
1672 dst
[1] = rgba
[GCOMP
];
1673 dst
[2] = rgba
[BCOMP
];
1674 dst
[3] = rgba
[ACOMP
];
1679 /* MESA_FORMAT_DUDV8 ********************************************************/
1681 /* this format by definition produces 0,0,0,1 as rgba values,
1682 however we'll return the dudv values as rg and fix up elsewhere */
1683 static void FETCH(dudv8
)(const struct gl_texture_image
*texImage
,
1684 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1686 const GLbyte
*src
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 2);
1687 texel
[RCOMP
] = BYTE_TO_FLOAT(src
[0]);
1688 texel
[GCOMP
] = BYTE_TO_FLOAT(src
[1]);
1694 /* MESA_FORMAT_SIGNED_R8 ***********************************************/
1696 static void FETCH(signed_r8
)( const struct gl_texture_image
*texImage
,
1697 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1699 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1700 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( s
);
1701 texel
[GCOMP
] = 0.0F
;
1702 texel
[BCOMP
] = 0.0F
;
1703 texel
[ACOMP
] = 1.0F
;
1707 static void store_texel_signed_r8(struct gl_texture_image
*texImage
,
1708 GLint i
, GLint j
, GLint k
, const void *texel
)
1710 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1711 GLbyte
*dst
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1717 /* MESA_FORMAT_SIGNED_A8 ***********************************************/
1719 static void FETCH(signed_a8
)( const struct gl_texture_image
*texImage
,
1720 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1722 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1723 texel
[RCOMP
] = 0.0F
;
1724 texel
[GCOMP
] = 0.0F
;
1725 texel
[BCOMP
] = 0.0F
;
1726 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
1730 static void store_texel_signed_a8(struct gl_texture_image
*texImage
,
1731 GLint i
, GLint j
, GLint k
, const void *texel
)
1733 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1734 GLbyte
*dst
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1740 /* MESA_FORMAT_SIGNED_L8 ***********************************************/
1742 static void FETCH(signed_l8
)( const struct gl_texture_image
*texImage
,
1743 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1745 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1748 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( s
);
1749 texel
[ACOMP
] = 1.0F
;
1753 static void store_texel_signed_l8(struct gl_texture_image
*texImage
,
1754 GLint i
, GLint j
, GLint k
, const void *texel
)
1756 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1757 GLbyte
*dst
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1763 /* MESA_FORMAT_SIGNED_I8 ***********************************************/
1765 static void FETCH(signed_i8
)( const struct gl_texture_image
*texImage
,
1766 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1768 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1772 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
1776 static void store_texel_signed_i8(struct gl_texture_image
*texImage
,
1777 GLint i
, GLint j
, GLint k
, const void *texel
)
1779 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1780 GLbyte
*dst
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
1786 /* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
1788 static void FETCH(signed_rg88_rev
)( const struct gl_texture_image
*texImage
,
1789 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1791 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1792 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
1793 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1794 texel
[BCOMP
] = 0.0F
;
1795 texel
[ACOMP
] = 1.0F
;
1799 static void store_texel_signed_rg88_rev(struct gl_texture_image
*texImage
,
1800 GLint i
, GLint j
, GLint k
, const void *texel
)
1802 const GLbyte
*rg
= (const GLbyte
*) texel
;
1803 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1804 dst
[0] = PACK_COLOR_88(rg
[GCOMP
], rg
[RCOMP
]);
1809 /* MESA_FORMAT_SIGNED_AL88 ***********************************************/
1811 static void FETCH(signed_al88
)( const struct gl_texture_image
*texImage
,
1812 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1814 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1817 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
1818 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1822 static void store_texel_signed_al88(struct gl_texture_image
*texImage
,
1823 GLint i
, GLint j
, GLint k
, const void *texel
)
1825 const GLbyte
*rg
= (const GLbyte
*) texel
;
1826 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
1827 dst
[0] = PACK_COLOR_88(rg
[ACOMP
], rg
[RCOMP
]);
1832 /* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
1834 static void FETCH(signed_rgbx8888
)( const struct gl_texture_image
*texImage
,
1835 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1837 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1838 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1839 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1840 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1841 texel
[ACOMP
] = 1.0f
;
1845 static void store_texel_signed_rgbx8888(struct gl_texture_image
*texImage
,
1846 GLint i
, GLint j
, GLint k
, const void *texel
)
1848 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1849 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1850 *dst
= PACK_COLOR_8888(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], 255);
1855 /* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
1857 static void FETCH(signed_rgba8888
)( const struct gl_texture_image
*texImage
,
1858 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1860 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1861 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1862 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1863 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1864 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1868 static void store_texel_signed_rgba8888(struct gl_texture_image
*texImage
,
1869 GLint i
, GLint j
, GLint k
, const void *texel
)
1871 const GLbyte
*rgba
= (const GLbyte
*) texel
;
1872 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1873 *dst
= PACK_COLOR_8888(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
1877 static void FETCH(signed_rgba8888_rev
)( const struct gl_texture_image
*texImage
,
1878 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1880 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1881 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1882 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1883 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1884 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1888 static void store_texel_signed_rgba8888_rev(struct gl_texture_image
*texImage
,
1889 GLint i
, GLint j
, GLint k
, const void *texel
)
1891 const GLubyte
*rgba
= (const GLubyte
*) texel
;
1892 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1893 *dst
= PACK_COLOR_8888_REV(rgba
[RCOMP
], rgba
[GCOMP
], rgba
[BCOMP
], rgba
[ACOMP
]);
1899 /* MESA_FORMAT_SIGNED_R16 ***********************************************/
1902 FETCH(signed_r16
)(const struct gl_texture_image
*texImage
,
1903 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1905 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1906 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1907 texel
[GCOMP
] = 0.0F
;
1908 texel
[BCOMP
] = 0.0F
;
1909 texel
[ACOMP
] = 1.0F
;
1914 store_texel_signed_r16(struct gl_texture_image
*texImage
,
1915 GLint i
, GLint j
, GLint k
, const void *texel
)
1917 const GLshort
*rgba
= (const GLshort
*) texel
;
1918 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1924 /* MESA_FORMAT_SIGNED_A16 ***********************************************/
1927 FETCH(signed_a16
)(const struct gl_texture_image
*texImage
,
1928 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1930 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1931 texel
[RCOMP
] = 0.0F
;
1932 texel
[GCOMP
] = 0.0F
;
1933 texel
[BCOMP
] = 0.0F
;
1934 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1939 store_texel_signed_a16(struct gl_texture_image
*texImage
,
1940 GLint i
, GLint j
, GLint k
, const void *texel
)
1942 const GLshort
*rgba
= (const GLshort
*) texel
;
1943 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1949 /* MESA_FORMAT_SIGNED_L16 ***********************************************/
1952 FETCH(signed_l16
)(const struct gl_texture_image
*texImage
,
1953 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1955 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1958 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1959 texel
[ACOMP
] = 1.0F
;
1964 store_texel_signed_l16(struct gl_texture_image
*texImage
,
1965 GLint i
, GLint j
, GLint k
, const void *texel
)
1967 const GLshort
*rgba
= (const GLshort
*) texel
;
1968 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1974 /* MESA_FORMAT_SIGNED_I16 ***********************************************/
1977 FETCH(signed_i16
)(const struct gl_texture_image
*texImage
,
1978 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1980 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1984 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1989 store_texel_signed_i16(struct gl_texture_image
*texImage
,
1990 GLint i
, GLint j
, GLint k
, const void *texel
)
1992 const GLshort
*rgba
= (const GLshort
*) texel
;
1993 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1999 /* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
2002 FETCH(signed_rg1616
)(const struct gl_texture_image
*texImage
,
2003 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2005 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
2006 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
2007 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
2008 texel
[BCOMP
] = 0.0F
;
2009 texel
[ACOMP
] = 1.0F
;
2014 store_texel_signed_rg1616(struct gl_texture_image
*texImage
,
2015 GLint i
, GLint j
, GLint k
, const void *texel
)
2017 const GLchan
*rgba
= (const GLchan
*) texel
;
2018 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
2019 dst
[0] = CHAN_TO_SHORT(rgba
[RCOMP
]);
2020 dst
[1] = CHAN_TO_SHORT(rgba
[GCOMP
]);
2025 /* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
2028 FETCH(signed_al1616
)(const struct gl_texture_image
*texImage
,
2029 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2031 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
2034 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
2035 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
2040 store_texel_signed_al1616(struct gl_texture_image
*texImage
,
2041 GLint i
, GLint j
, GLint k
, const void *texel
)
2043 const GLchan
*rgba
= (const GLchan
*) texel
;
2044 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
2045 dst
[0] = CHAN_TO_SHORT(rgba
[RCOMP
]);
2046 dst
[1] = CHAN_TO_SHORT(rgba
[ACOMP
]);
2051 /* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
2054 FETCH(signed_rgb_16
)(const struct gl_texture_image
*texImage
,
2055 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2057 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 3);
2058 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
2059 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
2060 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
2061 texel
[ACOMP
] = 1.0F
;
2066 store_texel_signed_rgb_16(struct gl_texture_image
*texImage
,
2067 GLint i
, GLint j
, GLint k
, const void *texel
)
2069 const GLchan
*rgba
= (const GLchan
*) texel
;
2070 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 3);
2071 dst
[0] = CHAN_TO_SHORT(rgba
[RCOMP
]);
2072 dst
[1] = CHAN_TO_SHORT(rgba
[GCOMP
]);
2073 dst
[2] = CHAN_TO_SHORT(rgba
[BCOMP
]);
2078 /* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
2081 FETCH(signed_rgba_16
)(const struct gl_texture_image
*texImage
,
2082 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2084 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
2085 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
2086 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
2087 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
2088 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[3] );
2093 store_texel_signed_rgba_16(struct gl_texture_image
*texImage
,
2094 GLint i
, GLint j
, GLint k
, const void *texel
)
2096 const GLchan
*rgba
= (const GLchan
*) texel
;
2097 GLshort
*dst
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
2098 dst
[0] = CHAN_TO_SHORT(rgba
[RCOMP
]);
2099 dst
[1] = CHAN_TO_SHORT(rgba
[GCOMP
]);
2100 dst
[2] = CHAN_TO_SHORT(rgba
[BCOMP
]);
2101 dst
[3] = CHAN_TO_SHORT(rgba
[ACOMP
]);
2107 /* MESA_FORMAT_RGBA_16 ***********************************************/
2110 FETCH(rgba_16
)(const struct gl_texture_image
*texImage
,
2111 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2113 const GLushort
*s
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
2114 texel
[RCOMP
] = USHORT_TO_FLOAT( s
[0] );
2115 texel
[GCOMP
] = USHORT_TO_FLOAT( s
[1] );
2116 texel
[BCOMP
] = USHORT_TO_FLOAT( s
[2] );
2117 texel
[ACOMP
] = USHORT_TO_FLOAT( s
[3] );
2122 store_texel_rgba_16(struct gl_texture_image
*texImage
,
2123 GLint i
, GLint j
, GLint k
, const void *texel
)
2125 const GLchan
*rgba
= (const GLchan
*) texel
;
2126 GLushort
*dst
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
2127 dst
[0] = CHAN_TO_USHORT(rgba
[RCOMP
]);
2128 dst
[1] = CHAN_TO_USHORT(rgba
[GCOMP
]);
2129 dst
[2] = CHAN_TO_USHORT(rgba
[BCOMP
]);
2130 dst
[3] = CHAN_TO_USHORT(rgba
[ACOMP
]);
2136 /* MESA_FORMAT_YCBCR *********************************************************/
2138 /* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.
2139 * We convert YCbCr to RGB here.
2141 static void FETCH(f_ycbcr
)( const struct gl_texture_image
*texImage
,
2142 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2144 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
2145 const GLushort
*src1
= src0
+ 1; /* odd */
2146 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
2147 const GLubyte cb
= *src0
& 0xff; /* chroma U */
2148 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
2149 const GLubyte cr
= *src1
& 0xff; /* chroma V */
2150 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
2151 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
2152 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
2153 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
2154 r
*= (1.0F
/ 255.0F
);
2155 g
*= (1.0F
/ 255.0F
);
2156 b
*= (1.0F
/ 255.0F
);
2157 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
2158 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
2159 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
2160 texel
[ACOMP
] = 1.0F
;
2164 static void store_texel_ycbcr(struct gl_texture_image
*texImage
,
2165 GLint i
, GLint j
, GLint k
, const void *texel
)
2177 /* MESA_FORMAT_YCBCR_REV *****************************************************/
2179 /* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
2180 * We convert YCbCr to RGB here.
2182 static void FETCH(f_ycbcr_rev
)( const struct gl_texture_image
*texImage
,
2183 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2185 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
2186 const GLushort
*src1
= src0
+ 1; /* odd */
2187 const GLubyte y0
= *src0
& 0xff; /* luminance */
2188 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
2189 const GLubyte y1
= *src1
& 0xff; /* luminance */
2190 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
2191 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
2192 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
2193 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
2194 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
2195 r
*= (1.0F
/ 255.0F
);
2196 g
*= (1.0F
/ 255.0F
);
2197 b
*= (1.0F
/ 255.0F
);
2198 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
2199 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
2200 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
2201 texel
[ACOMP
] = 1.0F
;
2205 static void store_texel_ycbcr_rev(struct gl_texture_image
*texImage
,
2206 GLint i
, GLint j
, GLint k
, const void *texel
)
2218 /* MESA_TEXFORMAT_Z24_S8 ***************************************************/
2220 static void FETCH(f_z24_s8
)( const struct gl_texture_image
*texImage
,
2221 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2223 /* only return Z, not stencil data */
2224 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2225 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
2226 texel
[0] = ((*src
) >> 8) * scale
;
2227 ASSERT(texImage
->TexFormat
== MESA_FORMAT_Z24_S8
||
2228 texImage
->TexFormat
== MESA_FORMAT_Z24_X8
);
2229 ASSERT(texel
[0] >= 0.0F
);
2230 ASSERT(texel
[0] <= 1.0F
);
2234 static void store_texel_z24_s8(struct gl_texture_image
*texImage
,
2235 GLint i
, GLint j
, GLint k
, const void *texel
)
2237 /* only store Z, not stencil */
2238 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2239 GLfloat depth
= *((GLfloat
*) texel
);
2240 GLuint zi
= ((GLuint
) (depth
* 0xffffff)) << 8;
2241 *dst
= zi
| (*dst
& 0xff);
2246 /* MESA_TEXFORMAT_S8_Z24 ***************************************************/
2248 static void FETCH(f_s8_z24
)( const struct gl_texture_image
*texImage
,
2249 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2251 /* only return Z, not stencil data */
2252 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2253 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
2254 texel
[0] = ((*src
) & 0x00ffffff) * scale
;
2255 ASSERT(texImage
->TexFormat
== MESA_FORMAT_S8_Z24
||
2256 texImage
->TexFormat
== MESA_FORMAT_X8_Z24
);
2257 ASSERT(texel
[0] >= 0.0F
);
2258 ASSERT(texel
[0] <= 1.0F
);
2262 static void store_texel_s8_z24(struct gl_texture_image
*texImage
,
2263 GLint i
, GLint j
, GLint k
, const void *texel
)
2265 /* only store Z, not stencil */
2266 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2267 GLfloat depth
= *((GLfloat
*) texel
);
2268 GLuint zi
= (GLuint
) (depth
* 0xffffff);
2269 *dst
= zi
| (*dst
& 0xff000000);
2274 /* MESA_FORMAT_RGB9_E5 ******************************************************/
2276 static void FETCH(rgb9_e5
)( const struct gl_texture_image
*texImage
,
2277 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2279 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2280 rgb9e5_to_float3(*src
, texel
);
2281 texel
[ACOMP
] = 1.0F
;
2285 static void store_texel_rgb9_e5(struct gl_texture_image
*texImage
,
2286 GLint i
, GLint j
, GLint k
, const void *texel
)
2288 const GLfloat
*src
= (const GLfloat
*) texel
;
2289 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2290 *dst
= float3_to_rgb9e5(src
);
2295 /* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
2297 static void FETCH(r11_g11_b10f
)( const struct gl_texture_image
*texImage
,
2298 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2300 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2301 r11g11b10f_to_float3(*src
, texel
);
2302 texel
[ACOMP
] = 1.0F
;
2306 static void store_texel_r11_g11_b10f(struct gl_texture_image
*texImage
,
2307 GLint i
, GLint j
, GLint k
, const void *texel
)
2309 const GLfloat
*src
= (const GLfloat
*) texel
;
2310 GLuint
*dst
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
2311 *dst
= float3_to_r11g11b10f(src
);
2316 /* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
2318 static void FETCH(z32f_x24s8
)(const struct gl_texture_image
*texImage
,
2319 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
2321 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
2322 texel
[RCOMP
] = src
[0];
2323 texel
[GCOMP
] = 0.0F
;
2324 texel
[BCOMP
] = 0.0F
;
2325 texel
[ACOMP
] = 1.0F
;
2329 static void store_texel_z32f_x24s8(struct gl_texture_image
*texImage
,
2330 GLint i
, GLint j
, GLint k
, const void *texel
)
2332 const GLfloat
*src
= (const GLfloat
*) texel
;
2333 GLfloat
*dst
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);