163
164
_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
165
const GLchan *pixels;
166
const GLubyte *pixels;
167
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
168
const GLchan *tempImage = NULL;
168
const GLubyte *tempImage = NULL;
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);
176
(void) dstImageOffsets;
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;
195
pixels = (const GLchan *) srcAddr;
191
pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
192
srcFormat, srcType, 0, 0);
198
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
200
texWidth, (GLubyte *) dstAddr);
202
197
if (ext_tx_compress_dxtn) {
203
198
(*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
222
217
_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
224
const GLchan *pixels;
219
const GLubyte *pixels;
226
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
227
const GLchan *tempImage = NULL;
221
const GLubyte *tempImage = NULL;
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);
235
(void) dstImageOffsets;
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;
254
pixels = (const GLchan *) srcAddr;
244
pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
245
srcFormat, srcType, 0, 0);
257
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
259
texWidth, (GLubyte *) dstAddr);
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,
280
270
_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
282
const GLchan *pixels;
272
const GLubyte *pixels;
284
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
285
const GLchan *tempImage = NULL;
274
const GLubyte *tempImage = NULL;
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);
293
(void) dstImageOffsets;
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;
311
pixels = (const GLchan *) srcAddr;
296
pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
297
srcFormat, srcType, 0, 0);
314
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
316
texWidth, (GLubyte *) dstAddr);
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,
337
322
_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
339
const GLchan *pixels;
324
const GLubyte *pixels;
341
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
342
const GLchan *tempImage = NULL;
326
const GLubyte *tempImage = NULL;
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);
350
(void) dstImageOffsets;
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;
368
pixels = (const GLchan *) srcAddr;
348
pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
349
srcFormat, srcType, 0, 0);
371
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
373
texWidth, (GLubyte *) dstAddr);
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,
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 )
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);
401
380
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
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)
409
/* just sample as GLchan and convert to float here */
388
/* just sample as GLubyte and convert to float here */
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]);
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 )
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);
429
408
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
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)
437
/* just sample as GLchan and convert to float here */
416
/* just sample as GLubyte and convert to float here */
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]);
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 )
452
431
if (fetch_ext_rgba_dxt3) {
453
ASSERT (sizeof(GLchan) == sizeof(GLubyte));
454
fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
432
fetch_ext_rgba_dxt3(texImage->RowStride,
433
texImage->Map, i, j, texel);
458
436
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
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)
466
/* just sample as GLchan and convert to float here */
444
/* just sample as GLubyte and convert to float here */
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]);
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 )
481
459
if (fetch_ext_rgba_dxt5) {
482
fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
460
fetch_ext_rgba_dxt5(texImage->RowStride,
461
texImage->Map, i, j, texel);
486
464
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
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)
494
/* just sample as GLchan and convert to float here */
472
/* just sample as GLubyte and convert to float here */
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]);
503
481
#if FEATURE_EXT_texture_sRGB
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 )
508
/* just sample as GLchan and convert to float here */
486
/* just sample as GLubyte and convert to float here */
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]);
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)
521
/* just sample as GLchan and convert to float here */
499
/* just sample as GLubyte and convert to float here */
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]);
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)
534
/* just sample as GLchan and convert to float here */
512
/* just sample as GLubyte and convert to float here */
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]);
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)
547
/* just sample as GLchan and convert to float here */
525
/* just sample as GLubyte and convert to float here */
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]);
555
533
#endif /* FEATURE_EXT_texture_sRGB */