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
>> 8) | (*src
<< 8); /* byte swap */
421 texel
[RCOMP
] = UBYTE_TO_FLOAT( ((s
>> 8) & 0xf8) | ((s
>> 13) & 0x7) );
422 texel
[GCOMP
] = UBYTE_TO_FLOAT( ((s
>> 3) & 0xfc) | ((s
>> 9) & 0x3) );
423 texel
[BCOMP
] = UBYTE_TO_FLOAT( ((s
<< 3) & 0xf8) | ((s
>> 2) & 0x7) );
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
] = UBYTE_TO_FLOAT( ((s
>> 7) & 0xf8) | ((s
>> 12) & 0x7) );
486 texel
[GCOMP
] = UBYTE_TO_FLOAT( ((s
>> 2) & 0xf8) | ((s
>> 7) & 0x7) );
487 texel
[BCOMP
] = UBYTE_TO_FLOAT( ((s
<< 3) & 0xf8) | ((s
>> 2) & 0x7) );
488 texel
[ACOMP
] = UBYTE_TO_FLOAT( ((s
>> 15) & 0x01) * 255 );
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
] = nonlinear_to_linear(src
[2]);
741 texel
[GCOMP
] = nonlinear_to_linear(src
[1]);
742 texel
[BCOMP
] = nonlinear_to_linear(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
] = nonlinear_to_linear( (s
>> 24) );
753 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 16) & 0xff );
754 texel
[BCOMP
] = nonlinear_to_linear( (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
] = nonlinear_to_linear( (s
>> 16) & 0xff );
765 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 8) & 0xff );
766 texel
[BCOMP
] = nonlinear_to_linear( (s
) & 0xff );
767 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) ); /* linear! */
772 FETCH(R8G8B8A8_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
] = nonlinear_to_linear( (s
) & 0xff );
777 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 8) & 0xff );
778 texel
[BCOMP
] = nonlinear_to_linear( (s
>> 16) & 0xff );
779 texel
[ACOMP
] = UBYTE_TO_FLOAT( (s
>> 24) ); /* linear! */
784 FETCH(R8G8B8X8_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
] = nonlinear_to_linear( (s
) & 0xff );
789 texel
[GCOMP
] = nonlinear_to_linear( (s
>> 8) & 0xff );
790 texel
[BCOMP
] = nonlinear_to_linear( (s
>> 16) & 0xff );
796 FETCH(L_SRGB8
)(const struct swrast_texture_image
*texImage
,
797 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
799 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 1);
802 texel
[BCOMP
] = nonlinear_to_linear(src
[0]);
808 FETCH(L8A8_SRGB
)(const struct swrast_texture_image
*texImage
,
809 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
811 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, texImage
, i
, j
, k
, 2);
814 texel
[BCOMP
] = nonlinear_to_linear(src
[0]);
815 texel
[ACOMP
] = UBYTE_TO_FLOAT(src
[1]); /* linear */
820 FETCH(RGBA_SINT8
)(const struct swrast_texture_image
*texImage
,
821 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
823 const GLbyte
*src
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 4);
824 texel
[RCOMP
] = (GLfloat
) src
[0];
825 texel
[GCOMP
] = (GLfloat
) src
[1];
826 texel
[BCOMP
] = (GLfloat
) src
[2];
827 texel
[ACOMP
] = (GLfloat
) src
[3];
832 FETCH(RGBA_SINT16
)(const struct swrast_texture_image
*texImage
,
833 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
835 const GLshort
*src
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
836 texel
[RCOMP
] = (GLfloat
) src
[0];
837 texel
[GCOMP
] = (GLfloat
) src
[1];
838 texel
[BCOMP
] = (GLfloat
) src
[2];
839 texel
[ACOMP
] = (GLfloat
) src
[3];
844 FETCH(RGBA_SINT32
)(const struct swrast_texture_image
*texImage
,
845 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
847 const GLint
*src
= TEXEL_ADDR(GLint
, texImage
, i
, j
, k
, 4);
848 texel
[RCOMP
] = (GLfloat
) src
[0];
849 texel
[GCOMP
] = (GLfloat
) src
[1];
850 texel
[BCOMP
] = (GLfloat
) src
[2];
851 texel
[ACOMP
] = (GLfloat
) src
[3];
856 FETCH(RGBA_UINT8
)(const struct swrast_texture_image
*texImage
,
857 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
859 const GLubyte
*src
= TEXEL_ADDR(GLubyte
, 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_UINT16
)(const struct swrast_texture_image
*texImage
,
869 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
871 const GLushort
*src
= TEXEL_ADDR(GLushort
, 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_UINT32
)(const struct swrast_texture_image
*texImage
,
881 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
883 const GLuint
*src
= TEXEL_ADDR(GLuint
, 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 * This format by definition produces 0,0,0,1 as rgba values,
893 * however we'll return the dudv values as rg and fix up elsewhere.
896 FETCH(DUDV8
)(const struct swrast_texture_image
*texImage
,
897 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
899 const GLbyte
*src
= TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 2);
900 texel
[RCOMP
] = BYTE_TO_FLOAT(src
[0]);
901 texel
[GCOMP
] = BYTE_TO_FLOAT(src
[1]);
908 FETCH(R_SNORM8
)(const struct swrast_texture_image
*texImage
,
909 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
911 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
912 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( s
);
920 FETCH(A_SNORM8
)(const struct swrast_texture_image
*texImage
,
921 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
923 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
927 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
932 FETCH(L_SNORM8
)(const struct swrast_texture_image
*texImage
,
933 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
935 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
938 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( s
);
944 FETCH(I_SNORM8
)(const struct swrast_texture_image
*texImage
,
945 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
947 const GLbyte s
= *TEXEL_ADDR(GLbyte
, texImage
, i
, j
, k
, 1);
951 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( s
);
956 FETCH(R8G8_SNORM
)(const struct swrast_texture_image
*texImage
,
957 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
959 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
960 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
961 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
968 FETCH(L8A8_SNORM
)(const struct swrast_texture_image
*texImage
,
969 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
971 const GLushort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
974 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
& 0xff) );
975 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
980 FETCH(X8B8G8R8_SNORM
)(const struct swrast_texture_image
*texImage
,
981 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
983 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
984 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
985 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
986 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
992 FETCH(A8B8G8R8_SNORM
)(const struct swrast_texture_image
*texImage
,
993 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
995 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
996 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
997 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
998 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
999 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1004 FETCH(R8G8B8A8_SNORM
)(const struct swrast_texture_image
*texImage
,
1005 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1007 const GLuint s
= *TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1008 texel
[RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
) );
1009 texel
[GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 8) );
1010 texel
[BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 16) );
1011 texel
[ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
>> 24) );
1016 FETCH(R_SNORM16
)(const struct swrast_texture_image
*texImage
,
1017 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1019 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1020 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1021 texel
[GCOMP
] = 0.0F
;
1022 texel
[BCOMP
] = 0.0F
;
1023 texel
[ACOMP
] = 1.0F
;
1028 FETCH(A_SNORM16
)(const struct swrast_texture_image
*texImage
,
1029 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1031 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1032 texel
[RCOMP
] = 0.0F
;
1033 texel
[GCOMP
] = 0.0F
;
1034 texel
[BCOMP
] = 0.0F
;
1035 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1040 FETCH(L_SNORM16
)(const struct swrast_texture_image
*texImage
,
1041 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1043 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1046 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
);
1047 texel
[ACOMP
] = 1.0F
;
1052 FETCH(I_SNORM16
)(const struct swrast_texture_image
*texImage
,
1053 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1055 const GLshort s
= *TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 1);
1059 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
);
1064 FETCH(R16G16_SNORM
)(const struct swrast_texture_image
*texImage
,
1065 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1067 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
1068 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1069 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1070 texel
[BCOMP
] = 0.0F
;
1071 texel
[ACOMP
] = 1.0F
;
1076 FETCH(LA_SNORM16
)(const struct swrast_texture_image
*texImage
,
1077 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1079 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 2);
1082 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1083 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1089 FETCH(RGB_SNORM16
)(const struct swrast_texture_image
*texImage
,
1090 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1092 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 3);
1093 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1094 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1095 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
1096 texel
[ACOMP
] = 1.0F
;
1101 FETCH(RGBA_SNORM16
)(const struct swrast_texture_image
*texImage
,
1102 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1104 const GLshort
*s
= TEXEL_ADDR(GLshort
, texImage
, i
, j
, k
, 4);
1105 texel
[RCOMP
] = SHORT_TO_FLOAT_TEX( s
[0] );
1106 texel
[GCOMP
] = SHORT_TO_FLOAT_TEX( s
[1] );
1107 texel
[BCOMP
] = SHORT_TO_FLOAT_TEX( s
[2] );
1108 texel
[ACOMP
] = SHORT_TO_FLOAT_TEX( s
[3] );
1113 FETCH(RGBA_UNORM16
)(const struct swrast_texture_image
*texImage
,
1114 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1116 const GLushort
*s
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1117 texel
[RCOMP
] = USHORT_TO_FLOAT( s
[0] );
1118 texel
[GCOMP
] = USHORT_TO_FLOAT( s
[1] );
1119 texel
[BCOMP
] = USHORT_TO_FLOAT( s
[2] );
1120 texel
[ACOMP
] = USHORT_TO_FLOAT( s
[3] );
1125 FETCH(RGBX_UNORM16
)(const struct swrast_texture_image
*texImage
,
1126 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1128 const GLushort
*s
= TEXEL_ADDR(GLushort
, texImage
, i
, j
, k
, 4);
1129 texel
[RCOMP
] = USHORT_TO_FLOAT(s
[0]);
1130 texel
[GCOMP
] = USHORT_TO_FLOAT(s
[1]);
1131 texel
[BCOMP
] = USHORT_TO_FLOAT(s
[2]);
1132 texel
[ACOMP
] = 1.0f
;
1137 FETCH(RGBX_FLOAT16
)(const struct swrast_texture_image
*texImage
,
1138 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1140 const GLhalfARB
*s
= TEXEL_ADDR(GLhalfARB
, texImage
, i
, j
, k
, 4);
1141 texel
[RCOMP
] = _mesa_half_to_float(s
[0]);
1142 texel
[GCOMP
] = _mesa_half_to_float(s
[1]);
1143 texel
[BCOMP
] = _mesa_half_to_float(s
[2]);
1144 texel
[ACOMP
] = 1.0f
;
1149 FETCH(RGBX_FLOAT32
)(const struct swrast_texture_image
*texImage
,
1150 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1152 const GLfloat
*s
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 4);
1153 texel
[RCOMP
] = s
[0];
1154 texel
[GCOMP
] = s
[1];
1155 texel
[BCOMP
] = s
[2];
1156 texel
[ACOMP
] = 1.0f
;
1161 * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
1164 FETCH(YCBCR
)(const struct swrast_texture_image
*texImage
,
1165 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1167 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
1168 const GLushort
*src1
= src0
+ 1; /* odd */
1169 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
1170 const GLubyte cb
= *src0
& 0xff; /* chroma U */
1171 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
1172 const GLubyte cr
= *src1
& 0xff; /* chroma V */
1173 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
1174 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
1175 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
1176 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
1177 r
*= (1.0F
/ 255.0F
);
1178 g
*= (1.0F
/ 255.0F
);
1179 b
*= (1.0F
/ 255.0F
);
1180 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
1181 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
1182 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
1183 texel
[ACOMP
] = 1.0F
;
1188 * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
1191 FETCH(YCBCR_REV
)(const struct swrast_texture_image
*texImage
,
1192 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1194 const GLushort
*src0
= TEXEL_ADDR(GLushort
, texImage
, (i
& ~1), j
, k
, 1); /* even */
1195 const GLushort
*src1
= src0
+ 1; /* odd */
1196 const GLubyte y0
= *src0
& 0xff; /* luminance */
1197 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
1198 const GLubyte y1
= *src1
& 0xff; /* luminance */
1199 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
1200 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
1201 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
1202 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
1203 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
1204 r
*= (1.0F
/ 255.0F
);
1205 g
*= (1.0F
/ 255.0F
);
1206 b
*= (1.0F
/ 255.0F
);
1207 texel
[RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
1208 texel
[GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
1209 texel
[BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
1210 texel
[ACOMP
] = 1.0F
;
1215 FETCH(S8_UINT_Z24_UNORM
)(const struct swrast_texture_image
*texImage
,
1216 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1218 /* only return Z, not stencil data */
1219 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1220 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
1221 texel
[0] = (GLfloat
) (((*src
) >> 8) * scale
);
1222 ASSERT(texImage
->Base
.TexFormat
== MESA_FORMAT_S8_UINT_Z24_UNORM
||
1223 texImage
->Base
.TexFormat
== MESA_FORMAT_X8_UINT_Z24_UNORM
);
1224 ASSERT(texel
[0] >= 0.0F
);
1225 ASSERT(texel
[0] <= 1.0F
);
1230 FETCH(Z24_UNORM_S8_UINT
)(const struct swrast_texture_image
*texImage
,
1231 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1233 /* only return Z, not stencil data */
1234 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1235 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
1236 texel
[0] = (GLfloat
) (((*src
) & 0x00ffffff) * scale
);
1237 ASSERT(texImage
->Base
.TexFormat
== MESA_FORMAT_Z24_UNORM_S8_UINT
||
1238 texImage
->Base
.TexFormat
== MESA_FORMAT_Z24_UNORM_X8_UINT
);
1239 ASSERT(texel
[0] >= 0.0F
);
1240 ASSERT(texel
[0] <= 1.0F
);
1245 FETCH(R9G9B9E5_FLOAT
)(const struct swrast_texture_image
*texImage
,
1246 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1248 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1249 rgb9e5_to_float3(*src
, texel
);
1250 texel
[ACOMP
] = 1.0F
;
1255 FETCH(R11G11B10_FLOAT
)(const struct swrast_texture_image
*texImage
,
1256 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1258 const GLuint
*src
= TEXEL_ADDR(GLuint
, texImage
, i
, j
, k
, 1);
1259 r11g11b10f_to_float3(*src
, texel
);
1260 texel
[ACOMP
] = 1.0F
;
1265 FETCH(Z32_FLOAT_S8X24_UINT
)(const struct swrast_texture_image
*texImage
,
1266 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
1268 const GLfloat
*src
= TEXEL_ADDR(GLfloat
, texImage
, i
, j
, k
, 2);
1269 texel
[RCOMP
] = src
[0];
1270 texel
[GCOMP
] = 0.0F
;
1271 texel
[BCOMP
] = 0.0F
;
1272 texel
[ACOMP
] = 1.0F
;