~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r300/r300_tex.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
297
297
        return t;
298
298
}
299
299
 
 
300
/* try to find a format which will only need a memcopy */
 
301
static const struct gl_texture_format *r300Choose8888TexFormat( GLenum srcFormat,
 
302
                                                                GLenum srcType )
 
303
{
 
304
        const GLuint ui = 1;
 
305
        const GLubyte littleEndian = *((const GLubyte *) &ui);
 
306
 
 
307
        if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
 
308
            (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
 
309
            (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
 
310
            (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
 
311
                return &_mesa_texformat_rgba8888;
 
312
        }
 
313
        else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
 
314
                 (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
 
315
                 (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
 
316
                 (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
 
317
                return &_mesa_texformat_rgba8888_rev;
 
318
        }
 
319
        else if (srcFormat == GL_BGRA &&
 
320
                ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
 
321
                  srcType == GL_UNSIGNED_INT_8_8_8_8)) {
 
322
                return &_mesa_texformat_argb8888_rev;
 
323
        }
 
324
        else if (srcFormat == GL_BGRA &&
 
325
                ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
 
326
                  srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
 
327
                return &_mesa_texformat_argb8888;
 
328
        }
 
329
        else return _dri_texformat_argb8888;
 
330
}
 
331
 
300
332
static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
301
333
                                                               GLint
302
334
                                                               internalFormat,
335
367
                case GL_UNSIGNED_SHORT_1_5_5_5_REV:
336
368
                        return _dri_texformat_argb1555;
337
369
                default:
338
 
                        return do32bpt ? _dri_texformat_rgba8888 :
 
370
                        return do32bpt ? r300Choose8888TexFormat(format, type) :
339
371
                            _dri_texformat_argb4444;
340
372
                }
341
373
 
353
385
                case GL_UNSIGNED_SHORT_5_6_5_REV:
354
386
                        return _dri_texformat_rgb565;
355
387
                default:
356
 
                        return do32bpt ? _dri_texformat_rgba8888 :
 
388
                        return do32bpt ? _dri_texformat_argb8888 :
357
389
                            _dri_texformat_rgb565;
358
390
                }
359
391
 
362
394
        case GL_RGBA12:
363
395
        case GL_RGBA16:
364
396
                return !force16bpt ?
365
 
                    _dri_texformat_rgba8888 : _dri_texformat_argb4444;
 
397
                    r300Choose8888TexFormat(format, type) : _dri_texformat_argb4444;
366
398
 
367
399
        case GL_RGBA4:
368
400
        case GL_RGBA2:
375
407
        case GL_RGB10:
376
408
        case GL_RGB12:
377
409
        case GL_RGB16:
378
 
                return !force16bpt ? _dri_texformat_rgba8888 :
 
410
                return !force16bpt ? _dri_texformat_argb8888 :
379
411
                    _dri_texformat_rgb565;
380
412
 
381
413
        case GL_RGB5: