2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (c) 2008-2009 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * 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)->ImageSlices[0] + (i) * (size)))
48 #define FETCH(x) fetch_texel_1d_##x
52 #define TEXEL_ADDR( type, image, i, j, k, size ) \
54 ((type *)((GLubyte *) (image)->ImageSlices[0] + (image)->RowStride * (j)) + \
57 #define FETCH(x) fetch_texel_2d_##x
61 #define TEXEL_ADDR( type, image, i, j, k, size ) \
62 ((type *)((GLubyte *) (image)->ImageSlices[k] + \
63 (image)->RowStride * (j)) + (i) * (size))
65 #define FETCH(x) fetch_texel_3d_##x
68 #error illegal number of texture dimensions
73 FETCH(Z_UNORM32
)(const struct swrast_texture_image
*texImage
,
74 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
76 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
77 texel
[0] = src
[0] * (1.0F
/ 0xffffffff);
82 FETCH(Z_UNORM16
)(const struct swrast_texture_image
*texImage
,
83 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
85 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
86 texel
[0] = src
[0] * (1.0F
/ 65535.0F
);
91 FETCH(RGBA_FLOAT32
)(const struct swrast_texture_image
*texImage
,
92 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
94 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 4);
95 texel
[RCOMP
] = src
[0];
96 texel
[GCOMP
] = src
[1];
97 texel
[BCOMP
] = src
[2];
98 texel
[ACOMP
] = src
[3];
103 FETCH(RGBA_FLOAT16
)(const struct swrast_texture_image
*texImage
,
104 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
106 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 4);
107 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
108 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
109 texel
[BCOMP
] = _mesa_half_to_float(src
[2]);
110 texel
[ACOMP
] = _mesa_half_to_float(src
[3]);
115 FETCH(RGB_FLOAT32
)(const struct swrast_texture_image
*texImage
,
116 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
118 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 3);
119 texel
[RCOMP
] = src
[0];
120 texel
[GCOMP
] = src
[1];
121 texel
[BCOMP
] = src
[2];
127 FETCH(RGB_FLOAT16
)(const struct swrast_texture_image
*texImage
,
128 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
130 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 3);
131 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
132 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
133 texel
[BCOMP
] = _mesa_half_to_float(src
[2]);
139 FETCH(A_FLOAT32
)(const struct swrast_texture_image
*texImage
,
140 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
142 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
146 texel
[ACOMP
] = src
[0];
151 FETCH(A_FLOAT16
)(const struct swrast_texture_image
*texImage
,
152 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
154 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
158 texel
[ACOMP
] = _mesa_half_to_float(src
[0]);
163 FETCH(L_FLOAT32
)(const struct swrast_texture_image
*texImage
,
164 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
166 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
169 texel
[BCOMP
] = src
[0];
175 FETCH(L_FLOAT16
)(const struct swrast_texture_image
*texImage
,
176 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
178 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
181 texel
[BCOMP
] = _mesa_half_to_float(src
[0]);
187 FETCH(LA_FLOAT32
)(const struct swrast_texture_image
*texImage
,
188 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
190 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
193 texel
[BCOMP
] = src
[0];
194 texel
[ACOMP
] = src
[1];
199 FETCH(LA_FLOAT16
)(const struct swrast_texture_image
*texImage
,
200 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
202 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
205 texel
[BCOMP
] = _mesa_half_to_float(src
[0]);
206 texel
[ACOMP
] = _mesa_half_to_float(src
[1]);
211 FETCH(I_FLOAT32
)(const struct swrast_texture_image
*texImage
,
212 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
214 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
218 texel
[ACOMP
] = src
[0];
223 FETCH(I_FLOAT16
)(const struct swrast_texture_image
*texImage
,
224 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
226 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
230 texel
[ACOMP
] = _mesa_half_to_float(src
[0]);
235 FETCH(R_FLOAT32
)(const struct swrast_texture_image
*texImage
,
236 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
238 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 1);
239 texel
[RCOMP
] = src
[0];
247 FETCH(R_FLOAT16
)(const struct swrast_texture_image
*texImage
,
248 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
250 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 1);
251 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
259 FETCH(RG_FLOAT32
)(const struct swrast_texture_image
*texImage
,
260 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
262 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
263 texel
[RCOMP
] = src
[0];
264 texel
[GCOMP
] = src
[1];
271 FETCH(RG_FLOAT16
)(const struct swrast_texture_image
*texImage
,
272 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
274 const GLhalfARB
*src
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 2);
275 texel
[RCOMP
] = _mesa_half_to_float(src
[0]);
276 texel
[GCOMP
] = _mesa_half_to_float(src
[1]);
283 FETCH(A8B8G8R8_UNORM
)(const struct swrast_texture_image
*texImage
,
284 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
286 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
287 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
288 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
289 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
290 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
295 FETCH(R8G8B8A8_UNORM
)(const struct swrast_texture_image
*texImage
,
296 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
298 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
299 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
300 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
301 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
302 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
307 FETCH(B8G8R8A8_UNORM
)(const struct swrast_texture_image
*texImage
,
308 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
310 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
311 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
312 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
313 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
314 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
319 FETCH(A8R8G8B8_UNORM
)(const struct swrast_texture_image
*texImage
,
320 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
322 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
323 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
324 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
325 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
326 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
331 FETCH(X8B8G8R8_UNORM
)(const struct swrast_texture_image
*texImage
,
332 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
334 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
335 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
336 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
337 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
343 FETCH(R8G8B8X8_UNORM
)(const struct swrast_texture_image
*texImage
,
344 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
346 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
347 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
348 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
349 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
355 FETCH(B8G8R8X8_UNORM
)(const struct swrast_texture_image
*texImage
,
356 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
358 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
359 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
360 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
361 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff );
367 FETCH(X8R8G8B8_UNORM
)(const struct swrast_texture_image
*texImage
,
368 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
370 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
371 texel
[RCOMP
] = UBYTE_TO_FLOAT( (s
>> 8) & 0xff );
372 texel
[GCOMP
] = UBYTE_TO_FLOAT( (s
>> 16) & 0xff );
373 texel
[BCOMP
] = UBYTE_TO_FLOAT( (s
>> 24) );
379 FETCH(BGR_UNORM8
)(const struct swrast_texture_image
*texImage
,
380 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
382 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
383 texel
[RCOMP
] = UBYTE_TO_FLOAT( src
[2] );
384 texel
[GCOMP
] = UBYTE_TO_FLOAT( src
[1] );
385 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[0] );
391 FETCH(RGB_UNORM8
)(const struct swrast_texture_image
*texImage
,
392 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
394 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
395 texel
[RCOMP
] = UBYTE_TO_FLOAT( src
[0] );
396 texel
[GCOMP
] = UBYTE_TO_FLOAT( src
[1] );
397 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[2] );
403 FETCH(B5G6R5_UNORM
)(const struct swrast_texture_image
*texImage
,
404 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
406 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
407 const GLushort s
= *src
;
408 texel
[RCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
409 texel
[GCOMP
] = ((s
>> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
410 texel
[BCOMP
] = ((s
) & 0x1f) * (1.0F
/ 31.0F
);
416 FETCH(R5G6B5_UNORM
)(const struct swrast_texture_image
*texImage
,
417 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
419 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
420 const GLushort s
= *src
;
421 texel
[RCOMP
] = ((s
) & 0x1f) * (1.0F
/ 31.0F
);
422 texel
[GCOMP
] = ((s
>> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
423 texel
[BCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
429 FETCH(B4G4R4A4_UNORM
)(const struct swrast_texture_image
*texImage
,
430 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
432 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
433 const GLushort s
= *src
;
434 texel
[RCOMP
] = ((s
>> 8) & 0xf) * (1.0F
/ 15.0F
);
435 texel
[GCOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
436 texel
[BCOMP
] = ((s
) & 0xf) * (1.0F
/ 15.0F
);
437 texel
[ACOMP
] = ((s
>> 12) & 0xf) * (1.0F
/ 15.0F
);
442 FETCH(A4R4G4B4_UNORM
)(const struct swrast_texture_image
*texImage
,
443 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
445 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
446 texel
[RCOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
447 texel
[GCOMP
] = ((s
>> 8) & 0xf) * (1.0F
/ 15.0F
);
448 texel
[BCOMP
] = ((s
>> 12) & 0xf) * (1.0F
/ 15.0F
);
449 texel
[ACOMP
] = ((s
) & 0xf) * (1.0F
/ 15.0F
);
454 FETCH(A1B5G5R5_UNORM
)(const struct swrast_texture_image
*texImage
,
455 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
457 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
458 const GLushort s
= *src
;
459 texel
[RCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
460 texel
[GCOMP
] = ((s
>> 6) & 0x1f) * (1.0F
/ 31.0F
);
461 texel
[BCOMP
] = ((s
>> 1) & 0x1f) * (1.0F
/ 31.0F
);
462 texel
[ACOMP
] = ((s
) & 0x01) * 1.0F
;
467 FETCH(B5G5R5A1_UNORM
)(const struct swrast_texture_image
*texImage
,
468 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
470 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
471 const GLushort s
= *src
;
472 texel
[RCOMP
] = ((s
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
473 texel
[GCOMP
] = ((s
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
474 texel
[BCOMP
] = ((s
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
475 texel
[ACOMP
] = ((s
>> 15) & 0x01) * 1.0F
;
480 FETCH(A1R5G5B5_UNORM
)(const struct swrast_texture_image
*texImage
,
481 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
483 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
484 const GLushort s
= (*src
<< 8) | (*src
>> 8); /* byteswap */
485 texel
[RCOMP
] = ((s
>> 1) & 0x1f) * (1.0F
/ 31.0F
);
486 texel
[GCOMP
] = ((s
>> 6) & 0x1f) * (1.0F
/ 31.0F
);
487 texel
[BCOMP
] = ((s
>> 11) & 0x1f) * (1.0F
/ 31.0F
);
488 texel
[ACOMP
] = ((s
) & 0x01) * 1.0F
;
493 FETCH(B10G10R10A2_UNORM
)(const struct swrast_texture_image
*texImage
,
494 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
496 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
497 const GLuint s
= *src
;
498 texel
[RCOMP
] = ((s
>> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
499 texel
[GCOMP
] = ((s
>> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
500 texel
[BCOMP
] = ((s
>> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
501 texel
[ACOMP
] = ((s
>> 30) & 0x03) * (1.0F
/ 3.0F
);
506 FETCH(R10G10B10A2_UNORM
)(const struct swrast_texture_image
*texImage
,
507 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
509 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
510 const GLuint s
= *src
;
511 texel
[RCOMP
] = ((s
>> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
512 texel
[GCOMP
] = ((s
>> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
513 texel
[BCOMP
] = ((s
>> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
514 texel
[ACOMP
] = ((s
>> 30) & 0x03) * (1.0F
/ 3.0F
);
519 FETCH(R8G8_UNORM
)(const struct swrast_texture_image
*texImage
,
520 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
522 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
523 texel
[RCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
524 texel
[GCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
531 FETCH(G8R8_UNORM
)(const struct swrast_texture_image
*texImage
,
532 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
534 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
535 texel
[RCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
536 texel
[GCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
543 FETCH(L4A4_UNORM
)(const struct swrast_texture_image
*texImage
,
544 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
546 const GLubyte s
= *TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
549 texel
[BCOMP
] = (s
& 0xf) * (1.0F
/ 15.0F
);
550 texel
[ACOMP
] = ((s
>> 4) & 0xf) * (1.0F
/ 15.0F
);
555 FETCH(L8A8_UNORM
)(const struct swrast_texture_image
*texImage
,
556 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
558 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
561 texel
[BCOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
562 texel
[ACOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
567 FETCH(R_UNORM8
)(const struct swrast_texture_image
*texImage
,
568 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
570 const GLubyte s
= *TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
571 texel
[RCOMP
] = UBYTE_TO_FLOAT(s
);
579 FETCH(R_UNORM16
)(const struct swrast_texture_image
*texImage
,
580 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
582 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
583 texel
[RCOMP
] = USHORT_TO_FLOAT(s
);
591 FETCH(A8L8_UNORM
)(const struct swrast_texture_image
*texImage
,
592 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
594 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
597 texel
[BCOMP
] = UBYTE_TO_FLOAT( s
>> 8 );
598 texel
[ACOMP
] = UBYTE_TO_FLOAT( s
& 0xff );
603 FETCH(R16G16_UNORM
)(const struct swrast_texture_image
*texImage
,
604 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
606 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
607 texel
[RCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
608 texel
[GCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
615 FETCH(G16R16_UNORM
)(const struct swrast_texture_image
*texImage
,
616 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
618 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
619 texel
[RCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
620 texel
[GCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
627 FETCH(L16A16_UNORM
)(const struct swrast_texture_image
*texImage
,
628 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
630 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
633 texel
[BCOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
634 texel
[ACOMP
] = USHORT_TO_FLOAT( s
>> 16 );
639 FETCH(A16L16_UNORM
)(const struct swrast_texture_image
*texImage
,
640 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
642 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
645 texel
[BCOMP
] = USHORT_TO_FLOAT( s
>> 16 );
646 texel
[ACOMP
] = USHORT_TO_FLOAT( s
& 0xffff );
651 FETCH(B2G3R3_UNORM
)(const struct swrast_texture_image
*texImage
,
652 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
654 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
655 const GLubyte s
= *src
;
656 texel
[RCOMP
] = ((s
>> 5) & 0x7) * (1.0F
/ 7.0F
);
657 texel
[GCOMP
] = ((s
>> 2) & 0x7) * (1.0F
/ 7.0F
);
658 texel
[BCOMP
] = ((s
) & 0x3) * (1.0F
/ 3.0F
);
664 FETCH(A_UNORM8
)(const struct swrast_texture_image
*texImage
,
665 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
667 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
671 texel
[ACOMP
] = UBYTE_TO_FLOAT( src
[0] );
676 FETCH(A_UNORM16
)(const struct swrast_texture_image
*texImage
,
677 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
679 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
683 texel
[ACOMP
] = USHORT_TO_FLOAT( src
[0] );
688 FETCH(L_UNORM8
)(const struct swrast_texture_image
*texImage
,
689 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
691 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
694 texel
[BCOMP
] = UBYTE_TO_FLOAT( src
[0] );
700 FETCH(L_UNORM16
)(const struct swrast_texture_image
*texImage
,
701 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
703 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
706 texel
[BCOMP
] = USHORT_TO_FLOAT( src
[0] );
712 FETCH(I_UNORM8
)(const struct swrast_texture_image
*texImage
,
713 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
715 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
719 texel
[ACOMP
] = UBYTE_TO_FLOAT( src
[0] );
724 FETCH(I_UNORM16
)(const struct swrast_texture_image
*texImage
,
725 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
727 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
731 texel
[ACOMP
] = USHORT_TO_FLOAT( src
[0] );
736 FETCH(BGR_SRGB8
)(const struct swrast_texture_image
*texImage
,
737 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
739 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 3);
740 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float(src
[2]);
741 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float(src
[1]);
742 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float(src
[0]);
748 FETCH(A8B8G8R8_SRGB
)(const struct swrast_texture_image
*texImage
,
749 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
751 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
752 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 24) );
753 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
754 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
755 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
) & 0xff ); /* linear! */
760 FETCH(B8G8R8A8_SRGB
)(const struct swrast_texture_image
*texImage
,
761 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
763 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
764 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
765 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
766 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
) & 0xff );
767 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) ); /* linear! */
772 FETCH(A8R8G8B8_SRGB
)(const struct swrast_texture_image
*texImage
,
773 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
775 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
776 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
777 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
778 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 24) );
779 texel
[ACOMP
] = UBYTE_TO_FLOAT( s
& 0xff ); /* linear! */
784 FETCH(R8G8B8A8_SRGB
)(const struct swrast_texture_image
*texImage
,
785 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
787 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
788 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
) & 0xff );
789 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
790 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
791 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) ); /* linear! */
796 FETCH(R8G8B8X8_SRGB
)(const struct swrast_texture_image
*texImage
,
797 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
799 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
800 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
) & 0xff );
801 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
802 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
808 FETCH(X8B8G8R8_SRGB
)(const struct swrast_texture_image
*texImage
,
809 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
811 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
812 texel
[RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 24) );
813 texel
[GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 16) & 0xff );
814 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
>> 8) & 0xff );
820 FETCH(L_SRGB8
)(const struct swrast_texture_image
*texImage
,
821 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
823 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
826 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float(src
[0]);
832 FETCH(L8A8_SRGB
)(const struct swrast_texture_image
*texImage
,
833 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
835 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 1);
838 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
& 0xff);
839 texel
[ACOMP
] = UBYTE_TO_FLOAT(s
>> 8); /* linear */
844 FETCH(A8L8_SRGB
)(const struct swrast_texture_image
*texImage
,
845 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
847 const GLushort s
= *TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 2);
850 texel
[BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
>> 8);
851 texel
[ACOMP
] = UBYTE_TO_FLOAT(s
& 0xff); /* linear */
856 FETCH(RGBA_SINT8
)(const struct swrast_texture_image
*texImage
,
857 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
859 const GLbyte
*src
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 4);
860 texel
[RCOMP
] = (GLfloat
) src
[0];
861 texel
[GCOMP
] = (GLfloat
) src
[1];
862 texel
[BCOMP
] = (GLfloat
) src
[2];
863 texel
[ACOMP
] = (GLfloat
) src
[3];
868 FETCH(RGBA_SINT16
)(const struct swrast_texture_image
*texImage
,
869 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
871 const GLshort
*src
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
872 texel
[RCOMP
] = (GLfloat
) src
[0];
873 texel
[GCOMP
] = (GLfloat
) src
[1];
874 texel
[BCOMP
] = (GLfloat
) src
[2];
875 texel
[ACOMP
] = (GLfloat
) src
[3];
880 FETCH(RGBA_SINT32
)(const struct swrast_texture_image
*texImage
,
881 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
883 const GLint
*src
= TEXEL_ADDR(GLint
, texImage
, i
, j
, k
, 4);
884 texel
[RCOMP
] = (GLfloat
) src
[0];
885 texel
[GCOMP
] = (GLfloat
) src
[1];
886 texel
[BCOMP
] = (GLfloat
) src
[2];
887 texel
[ACOMP
] = (GLfloat
) src
[3];
892 FETCH(RGBA_UINT8
)(const struct swrast_texture_image
*texImage
,
893 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
895 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 4);
896 texel
[RCOMP
] = (GLfloat
) src
[0];
897 texel
[GCOMP
] = (GLfloat
) src
[1];
898 texel
[BCOMP
] = (GLfloat
) src
[2];
899 texel
[ACOMP
] = (GLfloat
) src
[3];
904 FETCH(RGBA_UINT16
)(const struct swrast_texture_image
*texImage
,
905 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
907 const GLushort
*src
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
908 texel
[RCOMP
] = (GLfloat
) src
[0];
909 texel
[GCOMP
] = (GLfloat
) src
[1];
910 texel
[BCOMP
] = (GLfloat
) src
[2];
911 texel
[ACOMP
] = (GLfloat
) src
[3];
916 FETCH(RGBA_UINT32
)(const struct swrast_texture_image
*texImage
,
917 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
919 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 4);
920 texel
[RCOMP
] = (GLfloat
) src
[0];
921 texel
[GCOMP
] = (GLfloat
) src
[1];
922 texel
[BCOMP
] = (GLfloat
) src
[2];
923 texel
[ACOMP
] = (GLfloat
) src
[3];
928 FETCH(R_SNORM8
)(const struct swrast_texture_image
*texImage
,
929 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
931 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
932 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( s
);
940 FETCH(A_SNORM8
)(const struct swrast_texture_image
*texImage
,
941 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
943 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
947 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
952 FETCH(L_SNORM8
)(const struct swrast_texture_image
*texImage
,
953 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
955 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
958 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( s
);
964 FETCH(I_SNORM8
)(const struct swrast_texture_image
*texImage
,
965 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
967 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
971 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
976 FETCH(R8G8_SNORM
)(const struct swrast_texture_image
*texImage
,
977 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
979 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
980 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
981 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
988 FETCH(L8A8_SNORM
)(const struct swrast_texture_image
*texImage
,
989 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
991 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
994 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
995 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1000 FETCH(A8L8_SNORM
)(const struct swrast_texture_image
*texImage
,
1001 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1003 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1006 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1007 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
1012 FETCH(X8B8G8R8_SNORM
)(const struct swrast_texture_image
*texImage
,
1013 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1015 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1016 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1017 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1018 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1019 texel
[ACOMP
] = 1.0f
;
1024 FETCH(A8B8G8R8_SNORM
)(const struct swrast_texture_image
*texImage
,
1025 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1027 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1028 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1029 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1030 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1031 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1036 FETCH(R8G8B8A8_SNORM
)(const struct swrast_texture_image
*texImage
,
1037 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1039 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1040 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1041 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1042 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1043 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1048 FETCH(R_SNORM16
)(const struct swrast_texture_image
*texImage
,
1049 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1051 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1052 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1053 texel
[GCOMP
] = 0.0F
;
1054 texel
[BCOMP
] = 0.0F
;
1055 texel
[ACOMP
] = 1.0F
;
1060 FETCH(A_SNORM16
)(const struct swrast_texture_image
*texImage
,
1061 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1063 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1064 texel
[RCOMP
] = 0.0F
;
1065 texel
[GCOMP
] = 0.0F
;
1066 texel
[BCOMP
] = 0.0F
;
1067 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1072 FETCH(L_SNORM16
)(const struct swrast_texture_image
*texImage
,
1073 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1075 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1078 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1079 texel
[ACOMP
] = 1.0F
;
1084 FETCH(I_SNORM16
)(const struct swrast_texture_image
*texImage
,
1085 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1087 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1091 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1096 FETCH(R16G16_SNORM
)(const struct swrast_texture_image
*texImage
,
1097 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1099 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
1100 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1101 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1102 texel
[BCOMP
] = 0.0F
;
1103 texel
[ACOMP
] = 1.0F
;
1108 FETCH(LA_SNORM16
)(const struct swrast_texture_image
*texImage
,
1109 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1111 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
1114 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1115 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1121 FETCH(RGB_SNORM16
)(const struct swrast_texture_image
*texImage
,
1122 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1124 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 3);
1125 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1126 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1127 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
1128 texel
[ACOMP
] = 1.0F
;
1133 FETCH(RGBA_SNORM16
)(const struct swrast_texture_image
*texImage
,
1134 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1136 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
1137 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1138 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1139 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
1140 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[3] );
1145 FETCH(RGBA_UNORM16
)(const struct swrast_texture_image
*texImage
,
1146 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1148 const GLushort
*s
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1149 texel
[RCOMP
] = USHORT_TO_FLOAT( s
[0] );
1150 texel
[GCOMP
] = USHORT_TO_FLOAT( s
[1] );
1151 texel
[BCOMP
] = USHORT_TO_FLOAT( s
[2] );
1152 texel
[ACOMP
] = USHORT_TO_FLOAT( s
[3] );
1157 FETCH(RGBX_UNORM16
)(const struct swrast_texture_image
*texImage
,
1158 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1160 const GLushort
*s
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1161 texel
[RCOMP
] = USHORT_TO_FLOAT(s
[0]);
1162 texel
[GCOMP
] = USHORT_TO_FLOAT(s
[1]);
1163 texel
[BCOMP
] = USHORT_TO_FLOAT(s
[2]);
1164 texel
[ACOMP
] = 1.0f
;
1169 FETCH(RGBX_FLOAT16
)(const struct swrast_texture_image
*texImage
,
1170 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1172 const GLhalfARB
*s
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 4);
1173 texel
[RCOMP
] = _mesa_half_to_float(s
[0]);
1174 texel
[GCOMP
] = _mesa_half_to_float(s
[1]);
1175 texel
[BCOMP
] = _mesa_half_to_float(s
[2]);
1176 texel
[ACOMP
] = 1.0f
;
1181 FETCH(RGBX_FLOAT32
)(const struct swrast_texture_image
*texImage
,
1182 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1184 const GLfloat
*s
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 4);
1185 texel
[RCOMP
] = s
[0];
1186 texel
[GCOMP
] = s
[1];
1187 texel
[BCOMP
] = s
[2];
1188 texel
[ACOMP
] = 1.0f
;
1193 * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
1196 FETCH(YCBCR
)(const struct swrast_texture_image
*texImage
,
1197 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1199 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
1200 const GLushort
*src1
= src0
+ 1; /* odd */
1201 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
1202 const GLubyte cb
= *src0
& 0xff; /* chroma U */
1203 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
1204 const GLubyte cr
= *src1
& 0xff; /* chroma V */
1205 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
1206 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
1207 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
1208 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
1209 r
*= (1.0F
/ 255.0F
);
1210 g
*= (1.0F
/ 255.0F
);
1211 b
*= (1.0F
/ 255.0F
);
1212 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
1213 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
1214 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
1215 texel
[ACOMP
] = 1.0F
;
1220 * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
1223 FETCH(YCBCR_REV
)(const struct swrast_texture_image
*texImage
,
1224 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1226 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
1227 const GLushort
*src1
= src0
+ 1; /* odd */
1228 const GLubyte y0
= *src0
& 0xff; /* luminance */
1229 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
1230 const GLubyte y1
= *src1
& 0xff; /* luminance */
1231 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
1232 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
1233 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
1234 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
1235 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
1236 r
*= (1.0F
/ 255.0F
);
1237 g
*= (1.0F
/ 255.0F
);
1238 b
*= (1.0F
/ 255.0F
);
1239 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
1240 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
1241 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
1242 texel
[ACOMP
] = 1.0F
;
1247 FETCH(S8_UINT_Z24_UNORM
)(const struct swrast_texture_image
*texImage
,
1248 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1250 /* only return Z, not stencil data */
1251 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1252 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
1253 texel
[0] = (GLfloat
) (((*src
) >> 8) * scale
);
1254 ASSERT(texImage
->Base
.TexFormat
== MESA_FORMAT_S8_UINT_Z24_UNORM
||
1255 texImage
->Base
.TexFormat
== MESA_FORMAT_X8_UINT_Z24_UNORM
);
1256 ASSERT(texel
[0] >= 0.0F
);
1257 ASSERT(texel
[0] <= 1.0F
);
1262 FETCH(Z24_UNORM_S8_UINT
)(const struct swrast_texture_image
*texImage
,
1263 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1265 /* only return Z, not stencil data */
1266 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1267 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
1268 texel
[0] = (GLfloat
) (((*src
) & 0x00ffffff) * scale
);
1269 ASSERT(texImage
->Base
.TexFormat
== MESA_FORMAT_Z24_UNORM_S8_UINT
||
1270 texImage
->Base
.TexFormat
== MESA_FORMAT_Z24_UNORM_X8_UINT
);
1271 ASSERT(texel
[0] >= 0.0F
);
1272 ASSERT(texel
[0] <= 1.0F
);
1277 FETCH(R9G9B9E5_FLOAT
)(const struct swrast_texture_image
*texImage
,
1278 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1280 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1281 rgb9e5_to_float3(*src
, texel
);
1282 texel
[ACOMP
] = 1.0F
;
1287 FETCH(R11G11B10_FLOAT
)(const struct swrast_texture_image
*texImage
,
1288 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1290 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1291 r11g11b10f_to_float3(*src
, texel
);
1292 texel
[ACOMP
] = 1.0F
;
1297 FETCH(Z32_FLOAT_S8X24_UINT
)(const struct swrast_texture_image
*texImage
,
1298 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1300 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
1301 texel
[RCOMP
] = src
[0];
1302 texel
[GCOMP
] = 0.0F
;
1303 texel
[BCOMP
] = 0.0F
;
1304 texel
[ACOMP
] = 1.0F
;