~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/main/texcompress_s3tc.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "texcompress.h"
45
45
#include "texcompress_s3tc.h"
46
46
#include "texstore.h"
 
47
#include "swrast/s_context.h"
47
48
 
48
49
 
49
50
#if FEATURE_texture_s3tc
65
66
 * linear RGB value in [0, 1].
66
67
 * Implemented with a 256-entry lookup table.
67
68
 */
68
 
static INLINE GLfloat
 
69
static inline GLfloat
69
70
nonlinear_to_linear(GLubyte cs8)
70
71
{
71
72
   static GLfloat table[256];
96
97
dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
97
98
 
98
99
typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width,
99
 
                                      GLint height, const GLchan *srcPixData,
 
100
                                      GLint height, const GLubyte *srcPixData,
100
101
                                      GLenum destformat, GLubyte *dest,
101
102
                                      GLint dstRowStride);
102
103
 
162
163
GLboolean
163
164
_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
164
165
{
165
 
   const GLchan *pixels;
 
166
   const GLubyte *pixels;
166
167
   GLubyte *dst;
167
 
   const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
168
 
   const GLchan *tempImage = NULL;
 
168
   const GLubyte *tempImage = NULL;
169
169
 
170
170
   ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
171
171
          dstFormat == MESA_FORMAT_SRGB_DXT1);
172
 
   ASSERT(dstXoffset % 4 == 0);
173
 
   ASSERT(dstYoffset % 4 == 0);
174
 
   ASSERT(dstZoffset % 4 == 0);
175
 
   (void) dstZoffset;
176
 
   (void) dstImageOffsets;
177
172
 
178
173
   if (srcFormat != GL_RGB ||
179
 
       srcType != CHAN_TYPE ||
 
174
       srcType != GL_UNSIGNED_BYTE ||
180
175
       ctx->_ImageTransferState ||
 
176
       srcPacking->RowLength != srcWidth ||
181
177
       srcPacking->SwapBytes) {
182
 
      /* convert image to RGB/GLchan */
183
 
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
 
178
      /* convert image to RGB/GLubyte */
 
179
      tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
184
180
                                             baseInternalFormat,
185
181
                                             _mesa_get_format_base_format(dstFormat),
186
182
                                             srcWidth, srcHeight, srcDepth,
192
188
      srcFormat = GL_RGB;
193
189
   }
194
190
   else {
195
 
      pixels = (const GLchan *) srcAddr;
 
191
      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
 
192
                                     srcFormat, srcType, 0, 0);
196
193
   }
197
194
 
198
 
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
199
 
                                        dstFormat,
200
 
                                        texWidth, (GLubyte *) dstAddr);
 
195
   dst = dstSlices[0];
201
196
 
202
197
   if (ext_tx_compress_dxtn) {
203
198
      (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
221
216
GLboolean
222
217
_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
223
218
{
224
 
   const GLchan *pixels;
 
219
   const GLubyte *pixels;
225
220
   GLubyte *dst;
226
 
   const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
227
 
   const GLchan *tempImage = NULL;
 
221
   const GLubyte *tempImage = NULL;
228
222
 
229
223
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
230
224
          dstFormat == MESA_FORMAT_SRGBA_DXT1);
231
 
   ASSERT(dstXoffset % 4 == 0);
232
 
   ASSERT(dstYoffset % 4 == 0);
233
 
   ASSERT(dstZoffset % 4 == 0);
234
 
   (void) dstZoffset;
235
 
   (void) dstImageOffsets;
236
225
 
237
226
   if (srcFormat != GL_RGBA ||
238
 
       srcType != CHAN_TYPE ||
 
227
       srcType != GL_UNSIGNED_BYTE ||
239
228
       ctx->_ImageTransferState ||
 
229
       srcPacking->RowLength != srcWidth ||
240
230
       srcPacking->SwapBytes) {
241
 
      /* convert image to RGBA/GLchan */
242
 
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
 
231
      /* convert image to RGBA/GLubyte */
 
232
      tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
243
233
                                             baseInternalFormat,
244
234
                                             _mesa_get_format_base_format(dstFormat),
245
235
                                             srcWidth, srcHeight, srcDepth,
251
241
      srcFormat = GL_RGBA;
252
242
   }
253
243
   else {
254
 
      pixels = (const GLchan *) srcAddr;
 
244
      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
 
245
                                     srcFormat, srcType, 0, 0);
255
246
   }
256
247
 
257
 
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
258
 
                                        dstFormat,
259
 
                                        texWidth, (GLubyte *) dstAddr);
 
248
   dst = dstSlices[0];
 
249
 
260
250
   if (ext_tx_compress_dxtn) {
261
251
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
262
252
                              GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
279
269
GLboolean
280
270
_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
281
271
{
282
 
   const GLchan *pixels;
 
272
   const GLubyte *pixels;
283
273
   GLubyte *dst;
284
 
   const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
285
 
   const GLchan *tempImage = NULL;
 
274
   const GLubyte *tempImage = NULL;
286
275
 
287
276
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
288
277
          dstFormat == MESA_FORMAT_SRGBA_DXT3);
289
 
   ASSERT(dstXoffset % 4 == 0);
290
 
   ASSERT(dstYoffset % 4 == 0);
291
 
   ASSERT(dstZoffset % 4 == 0);
292
 
   (void) dstZoffset;
293
 
   (void) dstImageOffsets;
294
278
 
295
279
   if (srcFormat != GL_RGBA ||
296
 
       srcType != CHAN_TYPE ||
 
280
       srcType != GL_UNSIGNED_BYTE ||
297
281
       ctx->_ImageTransferState ||
 
282
       srcPacking->RowLength != srcWidth ||
298
283
       srcPacking->SwapBytes) {
299
 
      /* convert image to RGBA/GLchan */
300
 
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
 
284
      /* convert image to RGBA/GLubyte */
 
285
      tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
301
286
                                             baseInternalFormat,
302
287
                                             _mesa_get_format_base_format(dstFormat),
303
288
                                             srcWidth, srcHeight, srcDepth,
308
293
      pixels = tempImage;
309
294
   }
310
295
   else {
311
 
      pixels = (const GLchan *) srcAddr;
 
296
      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
 
297
                                     srcFormat, srcType, 0, 0);
312
298
   }
313
299
 
314
 
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
315
 
                                        dstFormat,
316
 
                                        texWidth, (GLubyte *) dstAddr);
 
300
   dst = dstSlices[0];
 
301
 
317
302
   if (ext_tx_compress_dxtn) {
318
303
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
319
304
                              GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
336
321
GLboolean
337
322
_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
338
323
{
339
 
   const GLchan *pixels;
 
324
   const GLubyte *pixels;
340
325
   GLubyte *dst;
341
 
   const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
342
 
   const GLchan *tempImage = NULL;
 
326
   const GLubyte *tempImage = NULL;
343
327
 
344
328
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
345
329
          dstFormat == MESA_FORMAT_SRGBA_DXT5);
346
 
   ASSERT(dstXoffset % 4 == 0);
347
 
   ASSERT(dstYoffset % 4 == 0);
348
 
   ASSERT(dstZoffset % 4 == 0);
349
 
   (void) dstZoffset;
350
 
   (void) dstImageOffsets;
351
330
 
352
331
   if (srcFormat != GL_RGBA ||
353
 
       srcType != CHAN_TYPE ||
 
332
       srcType != GL_UNSIGNED_BYTE ||
354
333
       ctx->_ImageTransferState ||
 
334
       srcPacking->RowLength != srcWidth ||
355
335
       srcPacking->SwapBytes) {
356
 
      /* convert image to RGBA/GLchan */
357
 
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
 
336
      /* convert image to RGBA/GLubyte */
 
337
      tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
358
338
                                             baseInternalFormat,
359
339
                                             _mesa_get_format_base_format(dstFormat),
360
340
                                             srcWidth, srcHeight, srcDepth,
365
345
      pixels = tempImage;
366
346
   }
367
347
   else {
368
 
      pixels = (const GLchan *) srcAddr;
 
348
      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
 
349
                                     srcFormat, srcType, 0, 0);
369
350
   }
370
351
 
371
 
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
372
 
                                        dstFormat,
373
 
                                        texWidth, (GLubyte *) dstAddr);
 
352
   dst = dstSlices[0];
 
353
 
374
354
   if (ext_tx_compress_dxtn) {
375
355
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
376
356
                              GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
388
368
 
389
369
 
390
370
static void
391
 
fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
392
 
                         GLint i, GLint j, GLint k, GLchan *texel )
 
371
fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage,
 
372
                         GLint i, GLint j, GLint k, GLubyte *texel )
393
373
{
394
374
   (void) k;
395
375
   if (fetch_ext_rgb_dxt1) {
396
 
      ASSERT (sizeof(GLchan) == sizeof(GLubyte));
397
376
      fetch_ext_rgb_dxt1(texImage->RowStride,
398
 
                         (GLubyte *)(texImage)->Data, i, j, texel);
 
377
                         texImage->Map, i, j, texel);
399
378
   }
400
379
   else
401
380
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
403
382
 
404
383
 
405
384
void
406
 
_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
 
385
_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
407
386
                                GLint i, GLint j, GLint k, GLfloat *texel)
408
387
{
409
 
   /* just sample as GLchan and convert to float here */
410
 
   GLchan rgba[4];
 
388
   /* just sample as GLubyte and convert to float here */
 
389
   GLubyte rgba[4];
411
390
   fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
412
 
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
413
 
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
414
 
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
415
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
391
   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
 
392
   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
 
393
   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
 
394
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
416
395
}
417
396
 
418
397
 
419
398
static void
420
 
fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
421
 
                          GLint i, GLint j, GLint k, GLchan *texel )
 
399
fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage,
 
400
                          GLint i, GLint j, GLint k, GLubyte *texel )
422
401
{
423
402
   (void) k;
424
403
   if (fetch_ext_rgba_dxt1) {
425
404
      fetch_ext_rgba_dxt1(texImage->RowStride,
426
 
                          (GLubyte *)(texImage)->Data, i, j, texel);
 
405
                          texImage->Map, i, j, texel);
427
406
   }
428
407
   else
429
408
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
431
410
 
432
411
 
433
412
void
434
 
_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
 
413
_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
435
414
                                 GLint i, GLint j, GLint k, GLfloat *texel)
436
415
{
437
 
   /* just sample as GLchan and convert to float here */
438
 
   GLchan rgba[4];
 
416
   /* just sample as GLubyte and convert to float here */
 
417
   GLubyte rgba[4];
439
418
   fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
440
 
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
441
 
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
442
 
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
443
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
419
   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
 
420
   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
 
421
   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
 
422
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
444
423
}
445
424
 
446
425
 
447
426
static void
448
 
fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
449
 
                          GLint i, GLint j, GLint k, GLchan *texel )
 
427
fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage,
 
428
                          GLint i, GLint j, GLint k, GLubyte *texel )
450
429
{
451
430
   (void) k;
452
431
   if (fetch_ext_rgba_dxt3) {
453
 
      ASSERT (sizeof(GLchan) == sizeof(GLubyte));
454
 
      fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
455
 
                          i, j, texel);
 
432
      fetch_ext_rgba_dxt3(texImage->RowStride,
 
433
                          texImage->Map, i, j, texel);
456
434
   }
457
435
   else
458
436
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
460
438
 
461
439
 
462
440
void
463
 
_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
 
441
_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
464
442
                                 GLint i, GLint j, GLint k, GLfloat *texel)
465
443
{
466
 
   /* just sample as GLchan and convert to float here */
467
 
   GLchan rgba[4];
 
444
   /* just sample as GLubyte and convert to float here */
 
445
   GLubyte rgba[4];
468
446
   fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
469
 
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
470
 
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
471
 
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
472
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
447
   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
 
448
   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
 
449
   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
 
450
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
473
451
}
474
452
 
475
453
 
476
454
static void
477
 
fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
478
 
                          GLint i, GLint j, GLint k, GLchan *texel )
 
455
fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage,
 
456
                          GLint i, GLint j, GLint k, GLubyte *texel )
479
457
{
480
458
   (void) k;
481
459
   if (fetch_ext_rgba_dxt5) {
482
 
      fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
483
 
                          i, j, texel);
 
460
      fetch_ext_rgba_dxt5(texImage->RowStride,
 
461
                          texImage->Map, i, j, texel);
484
462
   }
485
463
   else
486
464
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
488
466
 
489
467
 
490
468
void
491
 
_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
 
469
_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
492
470
                                 GLint i, GLint j, GLint k, GLfloat *texel)
493
471
{
494
 
   /* just sample as GLchan and convert to float here */
495
 
   GLchan rgba[4];
 
472
   /* just sample as GLubyte and convert to float here */
 
473
   GLubyte rgba[4];
496
474
   fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
497
 
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
498
 
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
499
 
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
500
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
475
   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
 
476
   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
 
477
   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
 
478
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
501
479
}
502
480
 
503
481
#if FEATURE_EXT_texture_sRGB
504
482
void
505
 
_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
 
483
_mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage,
506
484
                                  GLint i, GLint j, GLint k, GLfloat *texel )
507
485
{
508
 
   /* just sample as GLchan and convert to float here */
509
 
   GLchan rgba[4];
 
486
   /* just sample as GLubyte and convert to float here */
 
487
   GLubyte rgba[4];
510
488
   fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
511
489
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
512
490
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
513
491
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
514
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
492
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
515
493
}
516
494
 
517
495
void
518
 
_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
 
496
_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
519
497
                                  GLint i, GLint j, GLint k, GLfloat *texel)
520
498
{
521
 
   /* just sample as GLchan and convert to float here */
522
 
   GLchan rgba[4];
 
499
   /* just sample as GLubyte and convert to float here */
 
500
   GLubyte rgba[4];
523
501
   fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
524
502
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
525
503
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
526
504
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
527
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
505
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
528
506
}
529
507
 
530
508
void
531
 
_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
 
509
_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
532
510
                                  GLint i, GLint j, GLint k, GLfloat *texel)
533
511
{
534
 
   /* just sample as GLchan and convert to float here */
535
 
   GLchan rgba[4];
 
512
   /* just sample as GLubyte and convert to float here */
 
513
   GLubyte rgba[4];
536
514
   fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
537
515
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
538
516
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
539
517
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
540
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
518
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
541
519
}
542
520
 
543
521
void
544
 
_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
 
522
_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
545
523
                                  GLint i, GLint j, GLint k, GLfloat *texel)
546
524
{
547
 
   /* just sample as GLchan and convert to float here */
548
 
   GLchan rgba[4];
 
525
   /* just sample as GLubyte and convert to float here */
 
526
   GLubyte rgba[4];
549
527
   fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
550
528
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
551
529
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
552
530
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
553
 
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
 
531
   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
554
532
}
555
533
#endif /* FEATURE_EXT_texture_sRGB */
556
534