Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/*
2
 * Mesa 3-D graphics library
3
 *
4
 * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5
 * Copyright (c) 2008-2009  VMware, Inc.
6
 *
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:
13
 *
14
 * The above copyright notice and this permission notice shall be included
15
 * in all copies or substantial portions of the Software.
16
 *
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.
24
 */
25
 
26
 
27
/**
28
 * \file texfetch_tmp.h
29
 * Texel fetch functions template.
30
 *
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.
33
 *
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.
37
 *
38
 * \author Gareth Hughes
39
 * \author Brian Paul
40
 */
41
 
42
 
43
#if DIM == 1
44
 
45
#define TEXEL_ADDR( type, image, i, j, k, size ) \
46
	((void) (j), (void) (k), ((type *)(image)->ImageSlices[0] + (i) * (size)))
47
 
48
#define FETCH(x) fetch_texel_1d_##x
49
 
50
#elif DIM == 2
51
 
52
#define TEXEL_ADDR( type, image, i, j, k, size )			\
53
       ((void) (k),							\
54
        ((type *)((GLubyte *) (image)->ImageSlices[0] + (image)->RowStride * (j)) + \
55
          (i) * (size)))
56
 
57
#define FETCH(x) fetch_texel_2d_##x
58
 
59
#elif DIM == 3
60
 
61
#define TEXEL_ADDR( type, image, i, j, k, size )			\
62
        ((type *)((GLubyte *) (image)->ImageSlices[k] +                      \
63
                  (image)->RowStride * (j)) + (i) * (size))
64
 
65
#define FETCH(x) fetch_texel_3d_##x
66
 
67
#else
68
#error	illegal number of texture dimensions
69
#endif
70
 
71
 
72
/* MESA_FORMAT_Z32 ***********************************************************/
73
 
74
/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture,
75
 * returning 1 GLfloat.
76
 * Note: no GLchan version of this function.
77
 */
78
static void FETCH(f_z32)( const struct swrast_texture_image *texImage,
79
                          GLint i, GLint j, GLint k, GLfloat *texel )
80
{
81
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
82
   texel[0] = src[0] * (1.0F / 0xffffffff);
83
}
84
 
85
 
86
/* MESA_FORMAT_Z16 ***********************************************************/
87
 
88
/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture,
89
 * returning 1 GLfloat.
90
 * Note: no GLchan version of this function.
91
 */
92
static void FETCH(f_z16)(const struct swrast_texture_image *texImage,
93
                         GLint i, GLint j, GLint k, GLfloat *texel )
94
{
95
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
96
   texel[0] = src[0] * (1.0F / 65535.0F);
97
}
98
 
99
 
100
 
101
/* MESA_FORMAT_RGBA_F32 ******************************************************/
102
 
103
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
104
 */
105
static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage,
106
                               GLint i, GLint j, GLint k, GLfloat *texel )
107
{
108
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
109
   texel[RCOMP] = src[0];
110
   texel[GCOMP] = src[1];
111
   texel[BCOMP] = src[2];
112
   texel[ACOMP] = src[3];
113
}
114
 
115
 
116
 
117
 
118
/* MESA_FORMAT_RGBA_F16 ******************************************************/
119
 
120
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
121
 * returning 4 GLfloats.
122
 */
123
static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage,
124
                               GLint i, GLint j, GLint k, GLfloat *texel )
125
{
126
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
127
   texel[RCOMP] = _mesa_half_to_float(src[0]);
128
   texel[GCOMP] = _mesa_half_to_float(src[1]);
129
   texel[BCOMP] = _mesa_half_to_float(src[2]);
130
   texel[ACOMP] = _mesa_half_to_float(src[3]);
131
}
132
 
133
 
134
 
135
/* MESA_FORMAT_RGB_F32 *******************************************************/
136
 
137
/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
138
 * returning 4 GLfloats.
139
 */
140
static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage,
141
                              GLint i, GLint j, GLint k, GLfloat *texel )
142
{
143
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
144
   texel[RCOMP] = src[0];
145
   texel[GCOMP] = src[1];
146
   texel[BCOMP] = src[2];
147
   texel[ACOMP] = 1.0F;
148
}
149
 
150
 
151
 
152
 
153
/* MESA_FORMAT_RGB_F16 *******************************************************/
154
 
155
/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
156
 * returning 4 GLfloats.
157
 */
158
static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage,
159
                              GLint i, GLint j, GLint k, GLfloat *texel )
160
{
161
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
162
   texel[RCOMP] = _mesa_half_to_float(src[0]);
163
   texel[GCOMP] = _mesa_half_to_float(src[1]);
164
   texel[BCOMP] = _mesa_half_to_float(src[2]);
165
   texel[ACOMP] = 1.0F;
166
}
167
 
168
 
169
 
170
 
171
/* MESA_FORMAT_ALPHA_F32 *****************************************************/
172
 
173
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
174
 * returning 4 GLfloats.
175
 */
176
static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage,
177
                              GLint i, GLint j, GLint k, GLfloat *texel )
178
{
179
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
180
   texel[RCOMP] =
181
   texel[GCOMP] =
182
   texel[BCOMP] = 0.0F;
183
   texel[ACOMP] = src[0];
184
}
185
 
186
 
187
 
188
 
189
/* MESA_FORMAT_ALPHA_F32 *****************************************************/
190
 
191
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
192
 * returning 4 GLfloats.
193
 */
194
static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage,
195
                              GLint i, GLint j, GLint k, GLfloat *texel )
196
{
197
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
198
   texel[RCOMP] =
199
   texel[GCOMP] =
200
   texel[BCOMP] = 0.0F;
201
   texel[ACOMP] = _mesa_half_to_float(src[0]);
202
}
203
 
204
 
205
 
206
 
207
/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
208
 
209
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
210
 * returning 4 GLfloats.
211
 */
212
static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage,
213
                                    GLint i, GLint j, GLint k, GLfloat *texel )
214
{
215
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
216
   texel[RCOMP] =
217
   texel[GCOMP] =
218
   texel[BCOMP] = src[0];
219
   texel[ACOMP] = 1.0F;
220
}
221
 
222
 
223
 
224
 
225
/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
226
 
227
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
228
 * returning 4 GLfloats.
229
 */
230
static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage,
231
                                    GLint i, GLint j, GLint k, GLfloat *texel )
232
{
233
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
234
   texel[RCOMP] =
235
   texel[GCOMP] =
236
   texel[BCOMP] = _mesa_half_to_float(src[0]);
237
   texel[ACOMP] = 1.0F;
238
}
239
 
240
 
241
 
242
 
243
/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
244
 
245
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
246
 * returning 4 GLfloats.
247
 */
248
static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *texImage,
249
                                    GLint i, GLint j, GLint k, GLfloat *texel )
250
{
251
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
252
   texel[RCOMP] =
253
   texel[GCOMP] =
254
   texel[BCOMP] = src[0];
255
   texel[ACOMP] = src[1];
256
}
257
 
258
 
259
 
260
 
261
/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
262
 
263
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
264
 * returning 4 GLfloats.
265
 */
266
static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *texImage,
267
                                    GLint i, GLint j, GLint k, GLfloat *texel )
268
{
269
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
270
   texel[RCOMP] =
271
   texel[GCOMP] =
272
   texel[BCOMP] = _mesa_half_to_float(src[0]);
273
   texel[ACOMP] = _mesa_half_to_float(src[1]);
274
}
275
 
276
 
277
 
278
 
279
/* MESA_FORMAT_INTENSITY_F32 *************************************************/
280
 
281
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
282
 * returning 4 GLfloats.
283
 */
284
static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage,
285
                                    GLint i, GLint j, GLint k, GLfloat *texel )
286
{
287
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
288
   texel[RCOMP] =
289
   texel[GCOMP] =
290
   texel[BCOMP] =
291
   texel[ACOMP] = src[0];
292
}
293
 
294
 
295
 
296
 
297
/* MESA_FORMAT_INTENSITY_F16 *************************************************/
298
 
299
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
300
 * returning 4 GLfloats.
301
 */
302
static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage,
303
                                    GLint i, GLint j, GLint k, GLfloat *texel )
304
{
305
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
306
   texel[RCOMP] =
307
   texel[GCOMP] =
308
   texel[BCOMP] =
309
   texel[ACOMP] = _mesa_half_to_float(src[0]);
310
}
311
 
312
 
313
 
314
 
315
/* MESA_FORMAT_R_FLOAT32 *****************************************************/
316
 
317
/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
318
 * returning 4 GLfloats.
319
 */
320
static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage,
321
                            GLint i, GLint j, GLint k, GLfloat *texel )
322
{
323
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
324
   texel[RCOMP] = src[0];
325
   texel[GCOMP] = 0.0F;
326
   texel[BCOMP] = 0.0F;
327
   texel[ACOMP] = 1.0F;
328
}
329
 
330
 
331
 
332
 
333
/* MESA_FORMAT_R_FLOAT16 *****************************************************/
334
 
335
/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
336
 * returning 4 GLfloats.
337
 */
338
static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage,
339
                            GLint i, GLint j, GLint k, GLfloat *texel )
340
{
341
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
342
   texel[RCOMP] = _mesa_half_to_float(src[0]);
343
   texel[GCOMP] = 0.0F;
344
   texel[BCOMP] = 0.0F;
345
   texel[ACOMP] = 1.0F;
346
}
347
 
348
 
349
 
350
 
351
/* MESA_FORMAT_RG_FLOAT32 ****************************************************/
352
 
353
/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
354
 * returning 4 GLfloats.
355
 */
356
static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage,
357
                             GLint i, GLint j, GLint k, GLfloat *texel )
358
{
359
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
360
   texel[RCOMP] = src[0];
361
   texel[GCOMP] = src[1];
362
   texel[BCOMP] = 0.0F;
363
   texel[ACOMP] = 1.0F;
364
}
365
 
366
 
367
 
368
 
369
/* MESA_FORMAT_RG_FLOAT16 ****************************************************/
370
 
371
/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
372
 * returning 4 GLfloats.
373
 */
374
static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage,
375
                             GLint i, GLint j, GLint k, GLfloat *texel )
376
{
377
   const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
378
   texel[RCOMP] = _mesa_half_to_float(src[0]);
379
   texel[GCOMP] = _mesa_half_to_float(src[1]);
380
   texel[BCOMP] = 0.0F;
381
   texel[ACOMP] = 1.0F;
382
}
383
 
384
 
385
 
386
 
387
/*
388
 * Begin Hardware formats
389
 */
390
 
391
/* MESA_FORMAT_RGBA8888 ******************************************************/
392
 
393
/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
394
static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage,
395
                               GLint i, GLint j, GLint k, GLfloat *texel )
396
{
397
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
398
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
399
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
400
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
401
   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
402
}
403
 
404
 
405
 
406
 
407
 
408
 
409
/* MESA_FORMAT_RGBA888_REV ***************************************************/
410
 
411
/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
412
static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage,
413
                                   GLint i, GLint j, GLint k, GLfloat *texel )
414
{
415
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
416
   texel[RCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
417
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
418
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
419
   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
420
}
421
 
422
 
423
 
424
 
425
/* MESA_FORMAT_ARGB8888 ******************************************************/
426
 
427
/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
428
static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage,
429
                               GLint i, GLint j, GLint k, GLfloat *texel )
430
{
431
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
432
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
433
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
434
   texel[BCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
435
   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
436
}
437
 
438
 
439
 
440
 
441
/* MESA_FORMAT_ARGB8888_REV **************************************************/
442
 
443
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
444
static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage,
445
                                   GLint i, GLint j, GLint k, GLfloat *texel )
446
{
447
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
448
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
449
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
450
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
451
   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
452
}
453
 
454
 
455
 
456
 
457
/* MESA_FORMAT_RGBX8888 ******************************************************/
458
 
459
/* Fetch texel from 1D, 2D or 3D rgbx8888 texture, return 4 GLfloats */
460
static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage,
461
                               GLint i, GLint j, GLint k, GLfloat *texel )
462
{
463
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
464
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
465
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
466
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
467
   texel[ACOMP] = 1.0f;
468
}
469
 
470
 
471
 
472
 
473
/* MESA_FORMAT_RGBX888_REV ***************************************************/
474
 
475
/* Fetch texel from 1D, 2D or 3D rgbx8888_rev texture, return 4 GLchans */
476
static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage,
477
                                   GLint i, GLint j, GLint k, GLfloat *texel )
478
{
479
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
480
   texel[RCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
481
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
482
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
483
   texel[ACOMP] = 1.0f;
484
}
485
 
486
 
487
 
488
 
489
/* MESA_FORMAT_XRGB8888 ******************************************************/
490
 
491
/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
492
static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage,
493
                               GLint i, GLint j, GLint k, GLfloat *texel )
494
{
495
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
496
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
497
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
498
   texel[BCOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff );
499
   texel[ACOMP] = 1.0f;
500
}
501
 
502
 
503
 
504
 
505
/* MESA_FORMAT_XRGB8888_REV **************************************************/
506
 
507
/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
508
static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage,
509
                                   GLint i, GLint j, GLint k, GLfloat *texel )
510
{
511
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
512
   texel[RCOMP] = UBYTE_TO_FLOAT( (s >>  8) & 0xff );
513
   texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
514
   texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24)        );
515
   texel[ACOMP] = 1.0f;
516
}
517
 
518
 
519
 
520
 
521
/* MESA_FORMAT_RGB888 ********************************************************/
522
 
523
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
524
static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage,
525
                             GLint i, GLint j, GLint k, GLfloat *texel )
526
{
527
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
528
   texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
529
   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
530
   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
531
   texel[ACOMP] = 1.0F;
532
}
533
 
534
 
535
 
536
 
537
/* MESA_FORMAT_BGR888 ********************************************************/
538
 
539
/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
540
static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage,
541
                             GLint i, GLint j, GLint k, GLfloat *texel )
542
{
543
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
544
   texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
545
   texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
546
   texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
547
   texel[ACOMP] = 1.0F;
548
}
549
 
550
 
551
 
552
 
553
/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
554
   instead of slow (g << 2) * 255 / 252 (always rounds down) */
555
 
556
/* MESA_FORMAT_RGB565 ********************************************************/
557
 
558
/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
559
static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage,
560
                             GLint i, GLint j, GLint k, GLfloat *texel )
561
{
562
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
563
   const GLushort s = *src;
564
   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
565
   texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
566
   texel[BCOMP] = ((s      ) & 0x1f) * (1.0F / 31.0F);
567
   texel[ACOMP] = 1.0F;
568
}
569
 
570
 
571
 
572
 
573
/* MESA_FORMAT_RGB565_REV ****************************************************/
574
 
575
/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
576
static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage,
577
                                 GLint i, GLint j, GLint k, GLfloat *texel )
578
{
579
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
580
   const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
581
   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
582
   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >>  9) & 0x3) );
583
   texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >>  2) & 0x7) );
584
   texel[ACOMP] = 1.0F;
585
}
586
 
587
 
588
 
589
 
590
/* MESA_FORMAT_ARGB4444 ******************************************************/
591
 
592
/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
593
static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage,
594
                               GLint i, GLint j, GLint k, GLfloat *texel )
595
{
596
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
597
   const GLushort s = *src;
598
   texel[RCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
599
   texel[GCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
600
   texel[BCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
601
   texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
602
}
603
 
604
 
605
 
606
 
607
/* MESA_FORMAT_ARGB4444_REV **************************************************/
608
 
609
/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
610
static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
611
                                   GLint i, GLint j, GLint k, GLfloat *texel )
612
{
613
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
614
   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
615
   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
616
   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
617
   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
618
}
619
 
620
 
621
 
622
/* MESA_FORMAT_RGBA5551 ******************************************************/
623
 
624
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
625
static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage,
626
                               GLint i, GLint j, GLint k, GLfloat *texel )
627
{
628
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
629
   const GLushort s = *src;
630
   texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
631
   texel[GCOMP] = ((s >>  6) & 0x1f) * (1.0F / 31.0F);
632
   texel[BCOMP] = ((s >>  1) & 0x1f) * (1.0F / 31.0F);
633
   texel[ACOMP] = ((s      ) & 0x01) * 1.0F;
634
}
635
 
636
 
637
 
638
/* MESA_FORMAT_ARGB1555 ******************************************************/
639
 
640
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
641
static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage,
642
			     GLint i, GLint j, GLint k, GLfloat *texel )
643
{
644
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
645
   const GLushort s = *src;
646
   texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
647
   texel[GCOMP] = ((s >>  5) & 0x1f) * (1.0F / 31.0F);
648
   texel[BCOMP] = ((s >>  0) & 0x1f) * (1.0F / 31.0F);
649
   texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
650
}
651
 
652
 
653
 
654
 
655
/* MESA_FORMAT_ARGB1555_REV **************************************************/
656
 
657
/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
658
static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage,
659
                                   GLint i, GLint j, GLint k, GLfloat *texel )
660
{
661
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
662
   const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
663
   texel[RCOMP] = UBYTE_TO_FLOAT( ((s >>  7) & 0xf8) | ((s >> 12) & 0x7) );
664
   texel[GCOMP] = UBYTE_TO_FLOAT( ((s >>  2) & 0xf8) | ((s >>  7) & 0x7) );
665
   texel[BCOMP] = UBYTE_TO_FLOAT( ((s <<  3) & 0xf8) | ((s >>  2) & 0x7) );
666
   texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
667
}
668
 
669
 
670
 
671
 
672
/* MESA_FORMAT_ARGB2101010 ***************************************************/
673
 
674
/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */
675
static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage,
676
                                  GLint i, GLint j, GLint k, GLfloat *texel )
677
{
678
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
679
   const GLuint s = *src;
680
   texel[RCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
681
   texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
682
   texel[BCOMP] = ((s >>  0) & 0x3ff) * (1.0F / 1023.0F);
683
   texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
684
}
685
 
686
 
687
 
688
 
689
/* MESA_FORMAT_GR88 **********************************************************/
690
 
691
/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
692
static void FETCH(f_gr88)( const struct swrast_texture_image *texImage,
693
                           GLint i, GLint j, GLint k, GLfloat *texel )
694
{
695
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
696
   texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
697
   texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
698
   texel[BCOMP] = 0.0;
699
   texel[ACOMP] = 1.0;
700
}
701
 
702
 
703
 
704
 
705
/* MESA_FORMAT_RG88 ******************************************************/
706
 
707
/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */
708
static void FETCH(f_rg88)( const struct swrast_texture_image *texImage,
709
                           GLint i, GLint j, GLint k, GLfloat *texel )
710
{
711
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
712
   texel[RCOMP] = UBYTE_TO_FLOAT( s >> 8 );
713
   texel[GCOMP] = UBYTE_TO_FLOAT( s & 0xff );
714
   texel[BCOMP] = 0.0;
715
   texel[ACOMP] = 1.0;
716
}
717
 
718
 
719
 
720
 
721
/* MESA_FORMAT_AL44 **********************************************************/
722
 
723
/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */
724
static void FETCH(f_al44)( const struct swrast_texture_image *texImage,
725
                           GLint i, GLint j, GLint k, GLfloat *texel )
726
{
727
   const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
728
   texel[RCOMP] =
729
   texel[GCOMP] =
730
   texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F);
731
   texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
732
}
733
 
734
 
735
 
736
 
737
/* MESA_FORMAT_AL88 **********************************************************/
738
 
739
/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
740
static void FETCH(f_al88)( const struct swrast_texture_image *texImage,
741
                           GLint i, GLint j, GLint k, GLfloat *texel )
742
{
743
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
744
   texel[RCOMP] =
745
   texel[GCOMP] =
746
   texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
747
   texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
748
}
749
 
750
 
751
 
752
 
753
/* MESA_FORMAT_R8 ************************************************************/
754
 
755
/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
756
static void FETCH(f_r8)(const struct swrast_texture_image *texImage,
757
			GLint i, GLint j, GLint k, GLfloat *texel)
758
{
759
   const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
760
   texel[RCOMP] = UBYTE_TO_FLOAT(s);
761
   texel[GCOMP] = 0.0;
762
   texel[BCOMP] = 0.0;
763
   texel[ACOMP] = 1.0;
764
}
765
 
766
 
767
 
768
 
769
/* MESA_FORMAT_R16 ***********************************************************/
770
 
771
/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */
772
static void FETCH(f_r16)(const struct swrast_texture_image *texImage,
773
			GLint i, GLint j, GLint k, GLfloat *texel)
774
{
775
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
776
   texel[RCOMP] = USHORT_TO_FLOAT(s);
777
   texel[GCOMP] = 0.0;
778
   texel[BCOMP] = 0.0;
779
   texel[ACOMP] = 1.0;
780
}
781
 
782
 
783
 
784
 
785
/* MESA_FORMAT_AL88_REV ******************************************************/
786
 
787
/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
788
static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage,
789
                               GLint i, GLint j, GLint k, GLfloat *texel )
790
{
791
   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
792
   texel[RCOMP] =
793
   texel[GCOMP] =
794
   texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
795
   texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
796
}
797
 
798
 
799
 
800
 
801
/* MESA_FORMAT_GR1616 ********************************************************/
802
 
803
/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */
804
static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage,
805
                           GLint i, GLint j, GLint k, GLfloat *texel )
806
{
807
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
808
   texel[RCOMP] = USHORT_TO_FLOAT( s & 0xffff );
809
   texel[GCOMP] = USHORT_TO_FLOAT( s >> 16 );
810
   texel[BCOMP] = 0.0;
811
   texel[ACOMP] = 1.0;
812
}
813
 
814
 
815
 
816
 
817
/* MESA_FORMAT_RG1616 ****************************************************/
818
 
819
/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */
820
static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage,
821
                           GLint i, GLint j, GLint k, GLfloat *texel )
822
{
823
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
824
   texel[RCOMP] = USHORT_TO_FLOAT( s >> 16 );
825
   texel[GCOMP] = USHORT_TO_FLOAT( s & 0xffff );
826
   texel[BCOMP] = 0.0;
827
   texel[ACOMP] = 1.0;
828
}
829
 
830
 
831
 
832
 
833
/* MESA_FORMAT_AL1616 ********************************************************/
834
 
835
/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
836
static void FETCH(f_al1616)( const struct swrast_texture_image *texImage,
837
			     GLint i, GLint j, GLint k, GLfloat *texel )
838
{
839
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
840
   texel[RCOMP] =
841
   texel[GCOMP] =
842
   texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
843
   texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
844
}
845
 
846
 
847
 
848
 
849
/* MESA_FORMAT_AL1616_REV ****************************************************/
850
 
851
/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
852
static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage,
853
				 GLint i, GLint j, GLint k, GLfloat *texel )
854
{
855
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
856
   texel[RCOMP] =
857
   texel[GCOMP] =
858
   texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
859
   texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
860
}
861
 
862
 
863
 
864
 
865
/* MESA_FORMAT_RGB332 ********************************************************/
866
 
867
/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
868
static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage,
869
                             GLint i, GLint j, GLint k, GLfloat *texel )
870
{
871
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
872
   const GLubyte s = *src;
873
   texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
874
   texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
875
   texel[BCOMP] = ((s     ) & 0x3) * (1.0F / 3.0F);
876
   texel[ACOMP] = 1.0F;
877
}
878
 
879
 
880
 
881
 
882
/* MESA_FORMAT_A8 ************************************************************/
883
 
884
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
885
static void FETCH(f_a8)( const struct swrast_texture_image *texImage,
886
                         GLint i, GLint j, GLint k, GLfloat *texel )
887
{
888
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
889
   texel[RCOMP] =
890
   texel[GCOMP] =
891
   texel[BCOMP] = 0.0F;
892
   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
893
}
894
 
895
 
896
 
897
 
898
/* MESA_FORMAT_A16 ************************************************************/
899
 
900
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
901
static void FETCH(f_a16)( const struct swrast_texture_image *texImage,
902
                          GLint i, GLint j, GLint k, GLfloat *texel )
903
{
904
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
905
   texel[RCOMP] =
906
   texel[GCOMP] =
907
   texel[BCOMP] = 0.0F;
908
   texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
909
}
910
 
911
 
912
 
913
 
914
/* MESA_FORMAT_L8 ************************************************************/
915
 
916
/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
917
static void FETCH(f_l8)( const struct swrast_texture_image *texImage,
918
                         GLint i, GLint j, GLint k, GLfloat *texel )
919
{
920
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
921
   texel[RCOMP] =
922
   texel[GCOMP] =
923
   texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
924
   texel[ACOMP] = 1.0F;
925
}
926
 
927
 
928
 
929
 
930
/* MESA_FORMAT_L16 ***********************************************************/
931
 
932
/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */
933
static void FETCH(f_l16)( const struct swrast_texture_image *texImage,
934
                          GLint i, GLint j, GLint k, GLfloat *texel )
935
{
936
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
937
   texel[RCOMP] =
938
   texel[GCOMP] =
939
   texel[BCOMP] = USHORT_TO_FLOAT( src[0] );
940
   texel[ACOMP] = 1.0F;
941
}
942
 
943
 
944
 
945
 
946
/* MESA_FORMAT_I8 ************************************************************/
947
 
948
/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
949
static void FETCH(f_i8)( const struct swrast_texture_image *texImage,
950
                         GLint i, GLint j, GLint k, GLfloat *texel )
951
{
952
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
953
   texel[RCOMP] =
954
   texel[GCOMP] =
955
   texel[BCOMP] =
956
   texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
957
}
958
 
959
 
960
 
961
 
962
/* MESA_FORMAT_I16 ***********************************************************/
963
 
964
/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
965
static void FETCH(f_i16)( const struct swrast_texture_image *texImage,
966
                          GLint i, GLint j, GLint k, GLfloat *texel )
967
{
968
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
969
   texel[RCOMP] =
970
   texel[GCOMP] =
971
   texel[BCOMP] =
972
   texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
973
}
974
 
975
 
976
 
977
 
978
/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
979
/* Note: component order is same as for MESA_FORMAT_RGB888 */
980
static void FETCH(srgb8)(const struct swrast_texture_image *texImage,
981
                         GLint i, GLint j, GLint k, GLfloat *texel )
982
{
983
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
984
   texel[RCOMP] = nonlinear_to_linear(src[2]);
985
   texel[GCOMP] = nonlinear_to_linear(src[1]);
986
   texel[BCOMP] = nonlinear_to_linear(src[0]);
987
   texel[ACOMP] = 1.0F;
988
}
989
 
990
 
991
 
992
/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
993
static void FETCH(srgba8)(const struct swrast_texture_image *texImage,
994
                          GLint i, GLint j, GLint k, GLfloat *texel )
995
{
996
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
997
   texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
998
   texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
999
   texel[BCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
1000
   texel[ACOMP] = UBYTE_TO_FLOAT( (s      ) & 0xff ); /* linear! */
1001
}
1002
 
1003
 
1004
 
1005
/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
1006
static void FETCH(sargb8)(const struct swrast_texture_image *texImage,
1007
                          GLint i, GLint j, GLint k, GLfloat *texel )
1008
{
1009
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1010
   texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
1011
   texel[GCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
1012
   texel[BCOMP] = nonlinear_to_linear( (s      ) & 0xff );
1013
   texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
1014
}
1015
 
1016
 
1017
 
1018
/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
1019
static void FETCH(sl8)(const struct swrast_texture_image *texImage,
1020
                       GLint i, GLint j, GLint k, GLfloat *texel )
1021
{
1022
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
1023
   texel[RCOMP] =
1024
   texel[GCOMP] =
1025
   texel[BCOMP] = nonlinear_to_linear(src[0]);
1026
   texel[ACOMP] = 1.0F;
1027
}
1028
 
1029
 
1030
 
1031
/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
1032
static void FETCH(sla8)(const struct swrast_texture_image *texImage,
1033
                       GLint i, GLint j, GLint k, GLfloat *texel )
1034
{
1035
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
1036
   texel[RCOMP] =
1037
   texel[GCOMP] =
1038
   texel[BCOMP] = nonlinear_to_linear(src[0]);
1039
   texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
1040
}
1041
 
1042
 
1043
 
1044
 
1045
/* MESA_FORMAT_RGBA_INT8 **************************************************/
1046
 
1047
static void
1048
FETCH(rgba_int8)(const struct swrast_texture_image *texImage,
1049
                 GLint i, GLint j, GLint k, GLfloat *texel )
1050
{
1051
   const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
1052
   texel[RCOMP] = (GLfloat) src[0];
1053
   texel[GCOMP] = (GLfloat) src[1];
1054
   texel[BCOMP] = (GLfloat) src[2];
1055
   texel[ACOMP] = (GLfloat) src[3];
1056
}
1057
 
1058
 
1059
 
1060
 
1061
/* MESA_FORMAT_RGBA_INT16 **************************************************/
1062
 
1063
static void
1064
FETCH(rgba_int16)(const struct swrast_texture_image *texImage,
1065
                  GLint i, GLint j, GLint k, GLfloat *texel )
1066
{
1067
   const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
1068
   texel[RCOMP] = (GLfloat) src[0];
1069
   texel[GCOMP] = (GLfloat) src[1];
1070
   texel[BCOMP] = (GLfloat) src[2];
1071
   texel[ACOMP] = (GLfloat) src[3];
1072
}
1073
 
1074
 
1075
 
1076
 
1077
/* MESA_FORMAT_RGBA_INT32 **************************************************/
1078
 
1079
static void
1080
FETCH(rgba_int32)(const struct swrast_texture_image *texImage,
1081
                  GLint i, GLint j, GLint k, GLfloat *texel )
1082
{
1083
   const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
1084
   texel[RCOMP] = (GLfloat) src[0];
1085
   texel[GCOMP] = (GLfloat) src[1];
1086
   texel[BCOMP] = (GLfloat) src[2];
1087
   texel[ACOMP] = (GLfloat) src[3];
1088
}
1089
 
1090
 
1091
 
1092
 
1093
/* MESA_FORMAT_RGBA_UINT8 **************************************************/
1094
 
1095
static void
1096
FETCH(rgba_uint8)(const struct swrast_texture_image *texImage,
1097
                 GLint i, GLint j, GLint k, GLfloat *texel )
1098
{
1099
   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
1100
   texel[RCOMP] = (GLfloat) src[0];
1101
   texel[GCOMP] = (GLfloat) src[1];
1102
   texel[BCOMP] = (GLfloat) src[2];
1103
   texel[ACOMP] = (GLfloat) src[3];
1104
}
1105
 
1106
 
1107
 
1108
 
1109
/* MESA_FORMAT_RGBA_UINT16 **************************************************/
1110
 
1111
static void
1112
FETCH(rgba_uint16)(const struct swrast_texture_image *texImage,
1113
                  GLint i, GLint j, GLint k, GLfloat *texel )
1114
{
1115
   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
1116
   texel[RCOMP] = (GLfloat) src[0];
1117
   texel[GCOMP] = (GLfloat) src[1];
1118
   texel[BCOMP] = (GLfloat) src[2];
1119
   texel[ACOMP] = (GLfloat) src[3];
1120
}
1121
 
1122
 
1123
 
1124
 
1125
/* MESA_FORMAT_RGBA_UINT32 **************************************************/
1126
 
1127
static void
1128
FETCH(rgba_uint32)(const struct swrast_texture_image *texImage,
1129
                  GLint i, GLint j, GLint k, GLfloat *texel )
1130
{
1131
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
1132
   texel[RCOMP] = (GLfloat) src[0];
1133
   texel[GCOMP] = (GLfloat) src[1];
1134
   texel[BCOMP] = (GLfloat) src[2];
1135
   texel[ACOMP] = (GLfloat) src[3];
1136
}
1137
 
1138
 
1139
 
1140
 
1141
/* MESA_FORMAT_DUDV8 ********************************************************/
1142
 
1143
/* this format by definition produces 0,0,0,1 as rgba values,
1144
   however we'll return the dudv values as rg and fix up elsewhere */
1145
static void FETCH(dudv8)(const struct swrast_texture_image *texImage,
1146
                         GLint i, GLint j, GLint k, GLfloat *texel )
1147
{
1148
   const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
1149
   texel[RCOMP] = BYTE_TO_FLOAT(src[0]);
1150
   texel[GCOMP] = BYTE_TO_FLOAT(src[1]);
1151
   texel[BCOMP] = 0;
1152
   texel[ACOMP] = 0;
1153
}
1154
 
1155
 
1156
/* MESA_FORMAT_SIGNED_R8 ***********************************************/
1157
 
1158
static void FETCH(signed_r8)( const struct swrast_texture_image *texImage,
1159
                              GLint i, GLint j, GLint k, GLfloat *texel )
1160
{
1161
   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
1162
   texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
1163
   texel[GCOMP] = 0.0F;
1164
   texel[BCOMP] = 0.0F;
1165
   texel[ACOMP] = 1.0F;
1166
}
1167
 
1168
 
1169
 
1170
 
1171
/* MESA_FORMAT_SIGNED_A8 ***********************************************/
1172
 
1173
static void FETCH(signed_a8)( const struct swrast_texture_image *texImage,
1174
                              GLint i, GLint j, GLint k, GLfloat *texel )
1175
{
1176
   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
1177
   texel[RCOMP] = 0.0F;
1178
   texel[GCOMP] = 0.0F;
1179
   texel[BCOMP] = 0.0F;
1180
   texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
1181
}
1182
 
1183
 
1184
 
1185
 
1186
/* MESA_FORMAT_SIGNED_L8 ***********************************************/
1187
 
1188
static void FETCH(signed_l8)( const struct swrast_texture_image *texImage,
1189
                              GLint i, GLint j, GLint k, GLfloat *texel )
1190
{
1191
   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
1192
   texel[RCOMP] =
1193
   texel[GCOMP] =
1194
   texel[BCOMP] = BYTE_TO_FLOAT_TEX( s );
1195
   texel[ACOMP] = 1.0F;
1196
}
1197
 
1198
 
1199
 
1200
 
1201
/* MESA_FORMAT_SIGNED_I8 ***********************************************/
1202
 
1203
static void FETCH(signed_i8)( const struct swrast_texture_image *texImage,
1204
                              GLint i, GLint j, GLint k, GLfloat *texel )
1205
{
1206
   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
1207
   texel[RCOMP] =
1208
   texel[GCOMP] =
1209
   texel[BCOMP] =
1210
   texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
1211
}
1212
 
1213
 
1214
 
1215
 
1216
/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
1217
 
1218
static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage,
1219
                                    GLint i, GLint j, GLint k, GLfloat *texel )
1220
{
1221
   const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1222
   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
1223
   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
1224
   texel[BCOMP] = 0.0F;
1225
   texel[ACOMP] = 1.0F;
1226
}
1227
 
1228
 
1229
 
1230
 
1231
/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
1232
 
1233
static void FETCH(signed_al88)( const struct swrast_texture_image *texImage,
1234
                                GLint i, GLint j, GLint k, GLfloat *texel )
1235
{
1236
   const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1237
   texel[RCOMP] =
1238
   texel[GCOMP] =
1239
   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
1240
   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
1241
}
1242
 
1243
 
1244
 
1245
 
1246
/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
1247
 
1248
static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage,
1249
			            GLint i, GLint j, GLint k, GLfloat *texel )
1250
{
1251
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1252
   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
1253
   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
1254
   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
1255
   texel[ACOMP] = 1.0f;
1256
}
1257
 
1258
 
1259
 
1260
 
1261
/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
1262
 
1263
static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage,
1264
			            GLint i, GLint j, GLint k, GLfloat *texel )
1265
{
1266
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1267
   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
1268
   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
1269
   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
1270
   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s      ) );
1271
}
1272
 
1273
 
1274
 
1275
static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texImage,
1276
                                        GLint i, GLint j, GLint k, GLfloat *texel )
1277
{
1278
   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1279
   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s      ) );
1280
   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
1281
   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
1282
   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
1283
}
1284
 
1285
 
1286
 
1287
 
1288
 
1289
/* MESA_FORMAT_SIGNED_R16 ***********************************************/
1290
 
1291
static void
1292
FETCH(signed_r16)(const struct swrast_texture_image *texImage,
1293
                  GLint i, GLint j, GLint k, GLfloat *texel)
1294
{
1295
   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1296
   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
1297
   texel[GCOMP] = 0.0F;
1298
   texel[BCOMP] = 0.0F;
1299
   texel[ACOMP] = 1.0F;
1300
}
1301
 
1302
 
1303
 
1304
 
1305
/* MESA_FORMAT_SIGNED_A16 ***********************************************/
1306
 
1307
static void
1308
FETCH(signed_a16)(const struct swrast_texture_image *texImage,
1309
                  GLint i, GLint j, GLint k, GLfloat *texel)
1310
{
1311
   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1312
   texel[RCOMP] = 0.0F;
1313
   texel[GCOMP] = 0.0F;
1314
   texel[BCOMP] = 0.0F;
1315
   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
1316
}
1317
 
1318
 
1319
 
1320
 
1321
/* MESA_FORMAT_SIGNED_L16 ***********************************************/
1322
 
1323
static void
1324
FETCH(signed_l16)(const struct swrast_texture_image *texImage,
1325
                  GLint i, GLint j, GLint k, GLfloat *texel)
1326
{
1327
   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1328
   texel[RCOMP] =
1329
   texel[GCOMP] =
1330
   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s );
1331
   texel[ACOMP] = 1.0F;
1332
}
1333
 
1334
 
1335
 
1336
 
1337
/* MESA_FORMAT_SIGNED_I16 ***********************************************/
1338
 
1339
static void
1340
FETCH(signed_i16)(const struct swrast_texture_image *texImage,
1341
                  GLint i, GLint j, GLint k, GLfloat *texel)
1342
{
1343
   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
1344
   texel[RCOMP] =
1345
   texel[GCOMP] =
1346
   texel[BCOMP] =
1347
   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
1348
}
1349
 
1350
 
1351
 
1352
 
1353
/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
1354
 
1355
static void
1356
FETCH(signed_rg1616)(const struct swrast_texture_image *texImage,
1357
                    GLint i, GLint j, GLint k, GLfloat *texel)
1358
{
1359
   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
1360
   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
1361
   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
1362
   texel[BCOMP] = 0.0F;
1363
   texel[ACOMP] = 1.0F;
1364
}
1365
 
1366
 
1367
 
1368
 
1369
/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
1370
 
1371
static void
1372
FETCH(signed_al1616)(const struct swrast_texture_image *texImage,
1373
                    GLint i, GLint j, GLint k, GLfloat *texel)
1374
{
1375
   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
1376
   texel[RCOMP] =
1377
   texel[GCOMP] =
1378
   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
1379
   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
1380
}
1381
 
1382
 
1383
 
1384
 
1385
/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
1386
 
1387
static void
1388
FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage,
1389
                     GLint i, GLint j, GLint k, GLfloat *texel)
1390
{
1391
   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
1392
   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
1393
   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
1394
   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
1395
   texel[ACOMP] = 1.0F;
1396
}
1397
 
1398
 
1399
 
1400
 
1401
/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
1402
 
1403
static void
1404
FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage,
1405
                      GLint i, GLint j, GLint k, GLfloat *texel)
1406
{
1407
   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
1408
   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
1409
   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
1410
   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
1411
   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
1412
}
1413
 
1414
 
1415
 
1416
 
1417
 
1418
/* MESA_FORMAT_RGBA_16 ***********************************************/
1419
 
1420
static void
1421
FETCH(rgba_16)(const struct swrast_texture_image *texImage,
1422
               GLint i, GLint j, GLint k, GLfloat *texel)
1423
{
1424
   const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
1425
   texel[RCOMP] = USHORT_TO_FLOAT( s[0] );
1426
   texel[GCOMP] = USHORT_TO_FLOAT( s[1] );
1427
   texel[BCOMP] = USHORT_TO_FLOAT( s[2] );
1428
   texel[ACOMP] = USHORT_TO_FLOAT( s[3] );
1429
}
1430
 
1431
 
1432
 
1433
/* MESA_FORMAT_XBGR.... **********************************************/
1434
 
1435
static void
1436
FETCH(xbgr16161616_unorm)(const struct swrast_texture_image *texImage,
1437
                          GLint i, GLint j, GLint k, GLfloat *texel)
1438
{
1439
   const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
1440
   texel[RCOMP] = USHORT_TO_FLOAT(s[0]);
1441
   texel[GCOMP] = USHORT_TO_FLOAT(s[1]);
1442
   texel[BCOMP] = USHORT_TO_FLOAT(s[2]);
1443
   texel[ACOMP] = 1.0f;
1444
}
1445
 
1446
static void
1447
FETCH(xbgr16161616_float)(const struct swrast_texture_image *texImage,
1448
                          GLint i, GLint j, GLint k, GLfloat *texel)
1449
{
1450
   const GLhalfARB *s = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
1451
   texel[RCOMP] = _mesa_half_to_float(s[0]);
1452
   texel[GCOMP] = _mesa_half_to_float(s[1]);
1453
   texel[BCOMP] = _mesa_half_to_float(s[2]);
1454
   texel[ACOMP] = 1.0f;
1455
}
1456
 
1457
static void
1458
FETCH(xbgr32323232_float)(const struct swrast_texture_image *texImage,
1459
                          GLint i, GLint j, GLint k, GLfloat *texel)
1460
{
1461
   const GLfloat *s = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
1462
   texel[RCOMP] = s[0];
1463
   texel[GCOMP] = s[1];
1464
   texel[BCOMP] = s[2];
1465
   texel[ACOMP] = 1.0f;
1466
}
1467
 
1468
/* XXX other XBGR formats need to be implemented here */
1469
 
1470
 
1471
 
1472
/* MESA_FORMAT_YCBCR *********************************************************/
1473
 
1474
/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.
1475
 * We convert YCbCr to RGB here.
1476
 */
1477
static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage,
1478
                            GLint i, GLint j, GLint k, GLfloat *texel )
1479
{
1480
   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
1481
   const GLushort *src1 = src0 + 1;                               /* odd */
1482
   const GLubyte y0 = (*src0 >> 8) & 0xff;  /* luminance */
1483
   const GLubyte cb = *src0 & 0xff;         /* chroma U */
1484
   const GLubyte y1 = (*src1 >> 8) & 0xff;  /* luminance */
1485
   const GLubyte cr = *src1 & 0xff;         /* chroma V */
1486
   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
1487
   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
1488
   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
1489
   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
1490
   r *= (1.0F / 255.0F);
1491
   g *= (1.0F / 255.0F);
1492
   b *= (1.0F / 255.0F);
1493
   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
1494
   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
1495
   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
1496
   texel[ACOMP] = 1.0F;
1497
}
1498
 
1499
 
1500
 
1501
 
1502
/* MESA_FORMAT_YCBCR_REV *****************************************************/
1503
 
1504
/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
1505
 * We convert YCbCr to RGB here.
1506
 */
1507
static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage,
1508
                                GLint i, GLint j, GLint k, GLfloat *texel )
1509
{
1510
   const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
1511
   const GLushort *src1 = src0 + 1;                               /* odd */
1512
   const GLubyte y0 = *src0 & 0xff;         /* luminance */
1513
   const GLubyte cr = (*src0 >> 8) & 0xff;  /* chroma V */
1514
   const GLubyte y1 = *src1 & 0xff;         /* luminance */
1515
   const GLubyte cb = (*src1 >> 8) & 0xff;  /* chroma U */
1516
   const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
1517
   GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
1518
   GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
1519
   GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
1520
   r *= (1.0F / 255.0F);
1521
   g *= (1.0F / 255.0F);
1522
   b *= (1.0F / 255.0F);
1523
   texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
1524
   texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
1525
   texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
1526
   texel[ACOMP] = 1.0F;
1527
}
1528
 
1529
 
1530
 
1531
 
1532
/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
1533
 
1534
static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage,
1535
                             GLint i, GLint j, GLint k, GLfloat *texel )
1536
{
1537
   /* only return Z, not stencil data */
1538
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1539
   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
1540
   texel[0] = ((*src) >> 8) * scale;
1541
   ASSERT(texImage->Base.TexFormat == MESA_FORMAT_Z24_S8 ||
1542
	  texImage->Base.TexFormat == MESA_FORMAT_Z24_X8);
1543
   ASSERT(texel[0] >= 0.0F);
1544
   ASSERT(texel[0] <= 1.0F);
1545
}
1546
 
1547
 
1548
 
1549
 
1550
/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
1551
 
1552
static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage,
1553
                             GLint i, GLint j, GLint k, GLfloat *texel )
1554
{
1555
   /* only return Z, not stencil data */
1556
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1557
   const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
1558
   texel[0] = ((*src) & 0x00ffffff) * scale;
1559
   ASSERT(texImage->Base.TexFormat == MESA_FORMAT_S8_Z24 ||
1560
	  texImage->Base.TexFormat == MESA_FORMAT_X8_Z24);
1561
   ASSERT(texel[0] >= 0.0F);
1562
   ASSERT(texel[0] <= 1.0F);
1563
}
1564
 
1565
 
1566
 
1567
 
1568
/* MESA_FORMAT_RGB9_E5 ******************************************************/
1569
 
1570
static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage,
1571
                            GLint i, GLint j, GLint k, GLfloat *texel )
1572
{
1573
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1574
   rgb9e5_to_float3(*src, texel);
1575
   texel[ACOMP] = 1.0F;
1576
}
1577
 
1578
 
1579
 
1580
 
1581
/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
1582
 
1583
static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage,
1584
                                 GLint i, GLint j, GLint k, GLfloat *texel )
1585
{
1586
   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
1587
   r11g11b10f_to_float3(*src, texel);
1588
   texel[ACOMP] = 1.0F;
1589
}
1590
 
1591
 
1592
 
1593
 
1594
/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
1595
 
1596
static void FETCH(z32f_x24s8)(const struct swrast_texture_image *texImage,
1597
			      GLint i, GLint j, GLint k, GLfloat *texel)
1598
{
1599
   const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
1600
   texel[RCOMP] = src[0];
1601
   texel[GCOMP] = 0.0F;
1602
   texel[BCOMP] = 0.0F;
1603
   texel[ACOMP] = 1.0F;
1604
}
1605
 
1606
 
1607
 
1608
#undef TEXEL_ADDR
1609
#undef DIM
1610
#undef FETCH