Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1901 serge 1
/*
2
 * Mesa 3-D graphics library
3
 * Version:  6.5.3
4
 *
5
 * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
6
 * Copyright (c) 2008 VMware, Inc.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a
9
 * copy of this software and associated documentation files (the "Software"),
10
 * to deal in the Software without restriction, including without limitation
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
 * and/or sell copies of the Software, and to permit persons to whom the
13
 * Software is furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included
16
 * in all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 */
25
 
26
 
27
/**
28
 * \file texcompress_s3tc.c
29
 * GL_EXT_texture_compression_s3tc support.
30
 */
31
 
32
#ifndef USE_EXTERNAL_DXTN_LIB
33
#define USE_EXTERNAL_DXTN_LIB 1
34
#endif
35
 
36
#include "glheader.h"
37
#include "imports.h"
38
#include "colormac.h"
39
#include "dlopen.h"
40
#include "image.h"
41
#include "macros.h"
42
#include "texcompress.h"
43
#include "texcompress_s3tc.h"
44
#include "texstore.h"
45
 
46
 
47
#if FEATURE_texture_s3tc
48
 
49
 
50
#if defined(_WIN32) || defined(WIN32)
51
#define DXTN_LIBNAME "dxtn.dll"
52
#define RTLD_LAZY 0
53
#define RTLD_GLOBAL 0
54
#elif defined(__DJGPP__)
55
#define DXTN_LIBNAME "dxtn.dxe"
56
#else
57
#define DXTN_LIBNAME "libtxc_dxtn.so"
58
#endif
59
 
60
#if FEATURE_EXT_texture_sRGB
61
/**
62
 * Convert an 8-bit sRGB value from non-linear space to a
63
 * linear RGB value in [0, 1].
64
 * Implemented with a 256-entry lookup table.
65
 */
66
static INLINE GLfloat
67
nonlinear_to_linear(GLubyte cs8)
68
{
69
   static GLfloat table[256];
70
   static GLboolean tableReady = GL_FALSE;
71
   if (!tableReady) {
72
      /* compute lookup table now */
73
      GLuint i;
74
      for (i = 0; i < 256; i++) {
75
         const GLfloat cs = UBYTE_TO_FLOAT(i);
76
         if (cs <= 0.04045) {
77
            table[i] = cs / 12.92f;
78
         }
79
         else {
80
            table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
81
         }
82
      }
83
      tableReady = GL_TRUE;
84
   }
85
   return table[cs8];
86
}
87
#endif /* FEATURE_EXT_texture_sRGB */
88
 
89
typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
90
 
91
dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
92
dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL;
93
dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL;
94
dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
95
 
96
typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width,
97
                                      GLint height, const GLchan *srcPixData,
98
                                      GLenum destformat, GLubyte *dest,
99
                                      GLint dstRowStride);
100
 
101
static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL;
102
 
103
static void *dxtlibhandle = NULL;
104
 
105
 
106
void
107
_mesa_init_texture_s3tc( struct gl_context *ctx )
108
{
109
   /* called during context initialization */
110
   ctx->Mesa_DXTn = GL_FALSE;
111
#if USE_EXTERNAL_DXTN_LIB
112
   if (!dxtlibhandle) {
113
      dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0);
114
      if (!dxtlibhandle) {
115
	 _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn "
116
	    "compression/decompression unavailable");
117
      }
118
      else {
119
         /* the fetch functions are not per context! Might be problematic... */
120
         fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt)
121
            _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1");
122
         fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt)
123
            _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1");
124
         fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt)
125
            _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3");
126
         fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt)
127
            _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5");
128
         ext_tx_compress_dxtn = (dxtCompressTexFuncExt)
129
            _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn");
130
 
131
         if (!fetch_ext_rgb_dxt1 ||
132
             !fetch_ext_rgba_dxt1 ||
133
             !fetch_ext_rgba_dxt3 ||
134
             !fetch_ext_rgba_dxt5 ||
135
             !ext_tx_compress_dxtn) {
136
	    _mesa_warning(ctx, "couldn't reference all symbols in "
137
	       DXTN_LIBNAME ", software DXTn compression/decompression "
138
	       "unavailable");
139
            fetch_ext_rgb_dxt1 = NULL;
140
            fetch_ext_rgba_dxt1 = NULL;
141
            fetch_ext_rgba_dxt3 = NULL;
142
            fetch_ext_rgba_dxt5 = NULL;
143
            ext_tx_compress_dxtn = NULL;
144
            _mesa_dlclose(dxtlibhandle);
145
            dxtlibhandle = NULL;
146
         }
147
      }
148
   }
149
   if (dxtlibhandle) {
150
      ctx->Mesa_DXTn = GL_TRUE;
151
   }
152
#else
153
   (void) ctx;
154
#endif
155
}
156
 
157
/**
158
 * Store user's image in rgb_dxt1 format.
159
 */
160
GLboolean
161
_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
162
{
163
   const GLchan *pixels;
164
   GLint srcRowStride;
165
   GLubyte *dst;
166
   const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
167
   const GLchan *tempImage = NULL;
168
 
169
   ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
170
          dstFormat == MESA_FORMAT_SRGB_DXT1);
171
   ASSERT(dstXoffset % 4 == 0);
172
   ASSERT(dstYoffset % 4 == 0);
173
   ASSERT(dstZoffset % 4 == 0);
174
   (void) dstZoffset;
175
   (void) dstImageOffsets;
176
 
177
   if (srcFormat != GL_RGB ||
178
       srcType != CHAN_TYPE ||
179
       ctx->_ImageTransferState ||
180
       srcPacking->SwapBytes) {
181
      /* convert image to RGB/GLchan */
182
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
183
                                             baseInternalFormat,
184
                                             _mesa_get_format_base_format(dstFormat),
185
                                             srcWidth, srcHeight, srcDepth,
186
                                             srcFormat, srcType, srcAddr,
187
                                             srcPacking);
188
      if (!tempImage)
189
         return GL_FALSE; /* out of memory */
190
      pixels = tempImage;
191
      srcRowStride = 3 * srcWidth;
192
      srcFormat = GL_RGB;
193
   }
194
   else {
195
      pixels = (const GLchan *) srcAddr;
196
      srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
197
                                            srcType) / sizeof(GLchan);
198
   }
199
 
200
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
201
                                        dstFormat,
202
                                        texWidth, (GLubyte *) dstAddr);
203
 
204
   if (ext_tx_compress_dxtn) {
205
      (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
206
                              GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
207
                              dst, dstRowStride);
208
   }
209
   else {
210
      _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1");
211
   }
212
 
213
   if (tempImage)
214
      free((void *) tempImage);
215
 
216
   return GL_TRUE;
217
}
218
 
219
 
220
/**
221
 * Store user's image in rgba_dxt1 format.
222
 */
223
GLboolean
224
_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
225
{
226
   const GLchan *pixels;
227
   GLint srcRowStride;
228
   GLubyte *dst;
229
   const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
230
   const GLchan *tempImage = NULL;
231
 
232
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
233
          dstFormat == MESA_FORMAT_SRGBA_DXT1);
234
   ASSERT(dstXoffset % 4 == 0);
235
   ASSERT(dstYoffset % 4 == 0);
236
   ASSERT(dstZoffset % 4 == 0);
237
   (void) dstZoffset;
238
   (void) dstImageOffsets;
239
 
240
   if (srcFormat != GL_RGBA ||
241
       srcType != CHAN_TYPE ||
242
       ctx->_ImageTransferState ||
243
       srcPacking->SwapBytes) {
244
      /* convert image to RGBA/GLchan */
245
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
246
                                             baseInternalFormat,
247
                                             _mesa_get_format_base_format(dstFormat),
248
                                             srcWidth, srcHeight, srcDepth,
249
                                             srcFormat, srcType, srcAddr,
250
                                             srcPacking);
251
      if (!tempImage)
252
         return GL_FALSE; /* out of memory */
253
      pixels = tempImage;
254
      srcRowStride = 4 * srcWidth;
255
      srcFormat = GL_RGBA;
256
   }
257
   else {
258
      pixels = (const GLchan *) srcAddr;
259
      srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
260
                                            srcType) / sizeof(GLchan);
261
   }
262
 
263
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
264
                                        dstFormat,
265
                                        texWidth, (GLubyte *) dstAddr);
266
   if (ext_tx_compress_dxtn) {
267
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
268
                              GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
269
                              dst, dstRowStride);
270
   }
271
   else {
272
      _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1");
273
   }
274
 
275
   if (tempImage)
276
      free((void*) tempImage);
277
 
278
   return GL_TRUE;
279
}
280
 
281
 
282
/**
283
 * Store user's image in rgba_dxt3 format.
284
 */
285
GLboolean
286
_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
287
{
288
   const GLchan *pixels;
289
   GLint srcRowStride;
290
   GLubyte *dst;
291
   const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
292
   const GLchan *tempImage = NULL;
293
 
294
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
295
          dstFormat == MESA_FORMAT_SRGBA_DXT3);
296
   ASSERT(dstXoffset % 4 == 0);
297
   ASSERT(dstYoffset % 4 == 0);
298
   ASSERT(dstZoffset % 4 == 0);
299
   (void) dstZoffset;
300
   (void) dstImageOffsets;
301
 
302
   if (srcFormat != GL_RGBA ||
303
       srcType != CHAN_TYPE ||
304
       ctx->_ImageTransferState ||
305
       srcPacking->SwapBytes) {
306
      /* convert image to RGBA/GLchan */
307
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
308
                                             baseInternalFormat,
309
                                             _mesa_get_format_base_format(dstFormat),
310
                                             srcWidth, srcHeight, srcDepth,
311
                                             srcFormat, srcType, srcAddr,
312
                                             srcPacking);
313
      if (!tempImage)
314
         return GL_FALSE; /* out of memory */
315
      pixels = tempImage;
316
      srcRowStride = 4 * srcWidth;
317
   }
318
   else {
319
      pixels = (const GLchan *) srcAddr;
320
      srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
321
                                            srcType) / sizeof(GLchan);
322
   }
323
 
324
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
325
                                        dstFormat,
326
                                        texWidth, (GLubyte *) dstAddr);
327
   if (ext_tx_compress_dxtn) {
328
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
329
                              GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
330
                              dst, dstRowStride);
331
   }
332
   else {
333
      _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3");
334
   }
335
 
336
   if (tempImage)
337
      free((void *) tempImage);
338
 
339
   return GL_TRUE;
340
}
341
 
342
 
343
/**
344
 * Store user's image in rgba_dxt5 format.
345
 */
346
GLboolean
347
_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
348
{
349
   const GLchan *pixels;
350
   GLint srcRowStride;
351
   GLubyte *dst;
352
   const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
353
   const GLchan *tempImage = NULL;
354
 
355
   ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
356
          dstFormat == MESA_FORMAT_SRGBA_DXT5);
357
   ASSERT(dstXoffset % 4 == 0);
358
   ASSERT(dstYoffset % 4 == 0);
359
   ASSERT(dstZoffset % 4 == 0);
360
   (void) dstZoffset;
361
   (void) dstImageOffsets;
362
 
363
   if (srcFormat != GL_RGBA ||
364
       srcType != CHAN_TYPE ||
365
       ctx->_ImageTransferState ||
366
       srcPacking->SwapBytes) {
367
      /* convert image to RGBA/GLchan */
368
      tempImage = _mesa_make_temp_chan_image(ctx, dims,
369
                                             baseInternalFormat,
370
                                   	     _mesa_get_format_base_format(dstFormat),
371
                                             srcWidth, srcHeight, srcDepth,
372
                                             srcFormat, srcType, srcAddr,
373
                                             srcPacking);
374
      if (!tempImage)
375
         return GL_FALSE; /* out of memory */
376
      pixels = tempImage;
377
      srcRowStride = 4 * srcWidth;
378
   }
379
   else {
380
      pixels = (const GLchan *) srcAddr;
381
      srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
382
                                            srcType) / sizeof(GLchan);
383
   }
384
 
385
   dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
386
                                        dstFormat,
387
                                        texWidth, (GLubyte *) dstAddr);
388
   if (ext_tx_compress_dxtn) {
389
      (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
390
                              GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
391
                              dst, dstRowStride);
392
   }
393
   else {
394
      _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5");
395
   }
396
 
397
   if (tempImage)
398
      free((void *) tempImage);
399
 
400
   return GL_TRUE;
401
}
402
 
403
 
404
static void
405
fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
406
                         GLint i, GLint j, GLint k, GLchan *texel )
407
{
408
   (void) k;
409
   if (fetch_ext_rgb_dxt1) {
410
      ASSERT (sizeof(GLchan) == sizeof(GLubyte));
411
      fetch_ext_rgb_dxt1(texImage->RowStride,
412
                         (GLubyte *)(texImage)->Data, i, j, texel);
413
   }
414
   else
415
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
416
}
417
 
418
 
419
void
420
_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
421
                                GLint i, GLint j, GLint k, GLfloat *texel)
422
{
423
   /* just sample as GLchan and convert to float here */
424
   GLchan rgba[4];
425
   fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
426
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
427
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
428
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
429
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
430
}
431
 
432
 
433
static void
434
fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
435
                          GLint i, GLint j, GLint k, GLchan *texel )
436
{
437
   (void) k;
438
   if (fetch_ext_rgba_dxt1) {
439
      fetch_ext_rgba_dxt1(texImage->RowStride,
440
                          (GLubyte *)(texImage)->Data, i, j, texel);
441
   }
442
   else
443
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
444
}
445
 
446
 
447
void
448
_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
449
                                 GLint i, GLint j, GLint k, GLfloat *texel)
450
{
451
   /* just sample as GLchan and convert to float here */
452
   GLchan rgba[4];
453
   fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
454
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
455
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
456
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
457
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
458
}
459
 
460
 
461
static void
462
fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
463
                          GLint i, GLint j, GLint k, GLchan *texel )
464
{
465
   (void) k;
466
   if (fetch_ext_rgba_dxt3) {
467
      ASSERT (sizeof(GLchan) == sizeof(GLubyte));
468
      fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
469
                          i, j, texel);
470
   }
471
   else
472
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
473
}
474
 
475
 
476
void
477
_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
478
                                 GLint i, GLint j, GLint k, GLfloat *texel)
479
{
480
   /* just sample as GLchan and convert to float here */
481
   GLchan rgba[4];
482
   fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
483
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
484
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
485
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
486
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
487
}
488
 
489
 
490
static void
491
fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
492
                          GLint i, GLint j, GLint k, GLchan *texel )
493
{
494
   (void) k;
495
   if (fetch_ext_rgba_dxt5) {
496
      fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
497
                          i, j, texel);
498
   }
499
   else
500
      _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
501
}
502
 
503
 
504
void
505
_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
506
                                 GLint i, GLint j, GLint k, GLfloat *texel)
507
{
508
   /* just sample as GLchan and convert to float here */
509
   GLchan rgba[4];
510
   fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
511
   texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
512
   texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
513
   texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
514
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
515
}
516
 
517
#if FEATURE_EXT_texture_sRGB
518
void
519
_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
520
                                  GLint i, GLint j, GLint k, GLfloat *texel )
521
{
522
   /* just sample as GLchan and convert to float here */
523
   GLchan rgba[4];
524
   fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
525
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
526
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
527
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
528
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
529
}
530
 
531
void
532
_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
533
                                  GLint i, GLint j, GLint k, GLfloat *texel)
534
{
535
   /* just sample as GLchan and convert to float here */
536
   GLchan rgba[4];
537
   fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
538
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
539
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
540
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
541
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
542
}
543
 
544
void
545
_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
546
                                  GLint i, GLint j, GLint k, GLfloat *texel)
547
{
548
   /* just sample as GLchan and convert to float here */
549
   GLchan rgba[4];
550
   fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
551
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
552
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
553
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
554
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
555
}
556
 
557
void
558
_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
559
                                  GLint i, GLint j, GLint k, GLfloat *texel)
560
{
561
   /* just sample as GLchan and convert to float here */
562
   GLchan rgba[4];
563
   fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
564
   texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
565
   texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
566
   texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
567
   texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
568
}
569
#endif /* FEATURE_EXT_texture_sRGB */
570
 
571
 
572
#endif /* FEATURE_texture_s3tc */