~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "texfetch.h"
47
47
#include "teximage.h"
48
48
#include "texstate.h"
 
49
#include "texpal.h"
49
50
#include "mtypes.h"
50
51
 
51
52
 
347
348
      case GL_SLUMINANCE8_EXT:
348
349
         return GL_LUMINANCE;
349
350
      default:
350
 
            ; /* fallthrough */
 
351
         ; /* fallthrough */
351
352
      }
352
353
   }
353
 
 
354
354
#endif /* FEATURE_EXT_texture_sRGB */
355
355
 
 
356
   if (ctx->Extensions.EXT_texture_integer) {
 
357
      switch (internalFormat) {
 
358
      case GL_RGBA8UI_EXT:
 
359
      case GL_RGBA16UI_EXT:
 
360
      case GL_RGBA32UI_EXT:
 
361
      case GL_RGBA8I_EXT:
 
362
      case GL_RGBA16I_EXT:
 
363
      case GL_RGBA32I_EXT:
 
364
         return GL_RGBA;
 
365
      case GL_RGB8UI_EXT:
 
366
      case GL_RGB16UI_EXT:
 
367
      case GL_RGB32UI_EXT:
 
368
      case GL_RGB8I_EXT:
 
369
      case GL_RGB16I_EXT:
 
370
      case GL_RGB32I_EXT:
 
371
         return GL_RGB;
 
372
      case GL_ALPHA8UI_EXT:
 
373
      case GL_ALPHA16UI_EXT:
 
374
      case GL_ALPHA32UI_EXT:
 
375
      case GL_ALPHA8I_EXT:
 
376
      case GL_ALPHA16I_EXT:
 
377
      case GL_ALPHA32I_EXT:
 
378
         return GL_ALPHA;
 
379
      case GL_INTENSITY8UI_EXT:
 
380
      case GL_INTENSITY16UI_EXT:
 
381
      case GL_INTENSITY32UI_EXT:
 
382
      case GL_INTENSITY8I_EXT:
 
383
      case GL_INTENSITY16I_EXT:
 
384
      case GL_INTENSITY32I_EXT:
 
385
         return GL_INTENSITY;
 
386
      case GL_LUMINANCE8UI_EXT:
 
387
      case GL_LUMINANCE16UI_EXT:
 
388
      case GL_LUMINANCE32UI_EXT:
 
389
      case GL_LUMINANCE8I_EXT:
 
390
      case GL_LUMINANCE16I_EXT:
 
391
      case GL_LUMINANCE32I_EXT:
 
392
         return GL_LUMINANCE;
 
393
      case GL_LUMINANCE_ALPHA8UI_EXT:
 
394
      case GL_LUMINANCE_ALPHA16UI_EXT:
 
395
      case GL_LUMINANCE_ALPHA32UI_EXT:
 
396
      case GL_LUMINANCE_ALPHA8I_EXT:
 
397
      case GL_LUMINANCE_ALPHA16I_EXT:
 
398
      case GL_LUMINANCE_ALPHA32I_EXT:
 
399
         return GL_LUMINANCE_ALPHA;
 
400
      default:
 
401
         ; /* fallthrough */
 
402
      }
 
403
   }
 
404
 
 
405
   if (ctx->Extensions.ARB_texture_rg) {
 
406
      switch (internalFormat) {
 
407
      case GL_R8:
 
408
      case GL_R16:
 
409
      case GL_R16F:
 
410
      case GL_R32F:
 
411
      case GL_R8I:
 
412
      case GL_R8UI:
 
413
      case GL_R16I:
 
414
      case GL_R16UI:
 
415
      case GL_R32I:
 
416
      case GL_R32UI:
 
417
         return GL_R;
 
418
      case GL_RG:
 
419
      case GL_RG_INTEGER:
 
420
      case GL_RG8:
 
421
      case GL_RG16:
 
422
      case GL_RG16F:
 
423
      case GL_RG32F:
 
424
      case GL_RG8I:
 
425
      case GL_RG8UI:
 
426
      case GL_RG16I:
 
427
      case GL_RG16UI:
 
428
      case GL_RG32I:
 
429
      case GL_RG32UI:
 
430
         return GL_RG;
 
431
      default:
 
432
         ; /* fallthrough */
 
433
      }
 
434
   }
 
435
 
 
436
   if (ctx->Extensions.EXT_texture_shared_exponent) {
 
437
      switch (internalFormat) {
 
438
      case GL_RGB9_E5_EXT:
 
439
         return GL_RGB;
 
440
      default:
 
441
         ; /* fallthrough */
 
442
      }
 
443
   }
 
444
 
 
445
   if (ctx->Extensions.EXT_packed_float) {
 
446
      switch (internalFormat) {
 
447
      case GL_R11F_G11F_B10F_EXT:
 
448
         return GL_RGB;
 
449
      default:
 
450
         ; /* fallthrough */
 
451
      }
 
452
   }
 
453
 
 
454
   if (ctx->Extensions.ARB_depth_buffer_float) {
 
455
      switch (internalFormat) {
 
456
      case GL_DEPTH_COMPONENT32F:
 
457
         return GL_DEPTH_COMPONENT;
 
458
      case GL_DEPTH32F_STENCIL8:
 
459
         return GL_DEPTH_STENCIL;
 
460
      default:
 
461
         ; /* fallthrough */
 
462
      }
 
463
   }
 
464
 
 
465
   if (ctx->Extensions.EXT_texture_compression_rgtc) {
 
466
      switch (internalFormat) {
 
467
      case GL_COMPRESSED_RED:
 
468
      case GL_COMPRESSED_RED_RGTC1_EXT:
 
469
      case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT:
 
470
         return GL_RED;
 
471
      case GL_COMPRESSED_RG:
 
472
      case GL_COMPRESSED_RED_GREEN_RGTC2_EXT:
 
473
      case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
 
474
         return GL_RG;
 
475
      default:
 
476
         ; /* fallthrough */
 
477
      }
 
478
   }
 
479
 
356
480
   return -1; /* error */
357
481
}
358
482
 
359
483
 
360
484
/**
361
 
 * Test if it is a supported compressed format.
362
 
 * 
363
 
 * \param internalFormat the internal format token provided by the user.
364
 
 * 
365
 
 * \ret GL_TRUE if \p internalFormat is a supported compressed format, or
366
 
 * GL_FALSE otherwise.
367
 
 *
368
 
 * Currently only GL_COMPRESSED_RGB_FXT1_3DFX and GL_COMPRESSED_RGBA_FXT1_3DFX
369
 
 * are supported.
370
 
 */
371
 
static GLboolean
372
 
is_compressed_format(GLcontext *ctx, GLenum internalFormat)
373
 
{
374
 
   GLint supported[100]; /* 100 should be plenty */
375
 
   GLuint i, n;
376
 
 
377
 
   n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE);
378
 
   ASSERT(n < 100);
379
 
   for (i = 0; i < n; i++) {
380
 
      if ((GLint) internalFormat == supported[i]) {
381
 
         return GL_TRUE;
382
 
      }
383
 
   }
384
 
   return GL_FALSE;
385
 
}
386
 
 
387
 
 
388
 
/**
389
485
 * For cube map faces, return a face index in [0,5].
390
486
 * For other targets return 0;
391
487
 */
1307
1403
      if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
1308
1404
          type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
1309
1405
         char message[100];
1310
 
         sprintf(message,
1311
 
                 "glTexImage%d(format/type YCBCR mismatch", dimensions);
1312
 
         _mesa_error(ctx, GL_INVALID_ENUM, message);
 
1406
         _mesa_snprintf(message, sizeof(message),
 
1407
                        "glTexImage%dD(format/type YCBCR mismatch", dimensions);
 
1408
         _mesa_error(ctx, GL_INVALID_ENUM, "%s", message);
1313
1409
         return GL_TRUE; /* error */
1314
1410
      }
1315
1411
      if (target != GL_TEXTURE_2D &&
1323
1419
      if (border != 0) {
1324
1420
         if (!isProxy) {
1325
1421
            char message[100];
1326
 
            sprintf(message,
1327
 
                    "glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
1328
 
                    dimensions, border);
1329
 
            _mesa_error(ctx, GL_INVALID_VALUE, message);
 
1422
            _mesa_snprintf(message, sizeof(message),
 
1423
                           "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)",
 
1424
                           dimensions, border);
 
1425
            _mesa_error(ctx, GL_INVALID_VALUE, "%s", message);
1330
1426
         }
1331
1427
         return GL_TRUE;
1332
1428
      }
1349
1445
   }
1350
1446
 
1351
1447
   /* additional checks for compressed textures */
1352
 
   if (is_compressed_format(ctx, internalFormat)) {
 
1448
   if (_mesa_is_compressed_format(ctx, internalFormat)) {
1353
1449
      if (!target_can_be_compressed(ctx, target) && !isProxy) {
1354
1450
         _mesa_error(ctx, GL_INVALID_ENUM,
1355
 
                     "glTexImage%d(target)", dimensions);
 
1451
                     "glTexImage%dD(target)", dimensions);
1356
1452
         return GL_TRUE;
1357
1453
      }
1358
1454
      if (border != 0) {
1359
1455
         if (!isProxy) {
1360
1456
            _mesa_error(ctx, GL_INVALID_OPERATION,
1361
 
                        "glTexImage%D(border!=0)", dimensions);
 
1457
                        "glTexImage%dD(border!=0)", dimensions);
1362
1458
         }
1363
1459
         return GL_TRUE;
1364
1460
      }
1536
1632
 
1537
1633
      if (!target_can_be_compressed(ctx, target)) {
1538
1634
         _mesa_error(ctx, GL_INVALID_ENUM,
1539
 
                     "glTexSubImage%D(target=%s)", dimensions,
 
1635
                     "glTexSubImage%dD(target=%s)", dimensions,
1540
1636
                     _mesa_lookup_enum_by_nr(target));
1541
1637
         return GL_TRUE;
1542
1638
      }
1547
1643
      /* offset must be multiple of block size */
1548
1644
      if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
1549
1645
         _mesa_error(ctx, GL_INVALID_OPERATION,
1550
 
                     "glTexSubImage%D(xoffset = %d, yoffset = %d)",
 
1646
                     "glTexSubImage%dD(xoffset = %d, yoffset = %d)",
1551
1647
                     dimensions, xoffset, yoffset);
1552
1648
         return GL_TRUE;
1553
1649
      }
1554
1650
      /* size must be multiple of bw by bh or equal to whole texture size */
1555
1651
      if ((width % bw != 0) && (GLuint) width != destTex->Width) {
1556
1652
         _mesa_error(ctx, GL_INVALID_OPERATION,
1557
 
                     "glTexSubImage%D(width = %d)", dimensions, width);
 
1653
                     "glTexSubImage%dD(width = %d)", dimensions, width);
1558
1654
         return GL_TRUE;
1559
1655
      }         
1560
1656
      if ((height % bh != 0) && (GLuint) height != destTex->Height) {
1561
1657
         _mesa_error(ctx, GL_INVALID_OPERATION,
1562
 
                     "glTexSubImage%D(height = %d)", dimensions, height);
 
1658
                     "glTexSubImage%dD(height = %d)", dimensions, height);
1563
1659
         return GL_TRUE;
1564
1660
      }         
1565
1661
   }
1715
1811
      return GL_TRUE;
1716
1812
   }
1717
1813
 
1718
 
   if (is_compressed_format(ctx, internalFormat)) {
 
1814
   if (_mesa_is_compressed_format(ctx, internalFormat)) {
1719
1815
      if (!target_can_be_compressed(ctx, target)) {
1720
1816
         _mesa_error(ctx, GL_INVALID_ENUM,
1721
 
                     "glCopyTexImage%d(target)", dimensions);
 
1817
                     "glCopyTexImage%dD(target)", dimensions);
1722
1818
         return GL_TRUE;
1723
1819
      }
1724
1820
      if (border != 0) {
1725
1821
         _mesa_error(ctx, GL_INVALID_OPERATION,
1726
 
                     "glCopyTexImage%D(border!=0)", dimensions);
 
1822
                     "glCopyTexImage%dD(border!=0)", dimensions);
1727
1823
         return GL_TRUE;
1728
1824
      }
1729
1825
   }
1731
1827
      /* make sure we have depth/stencil buffers */
1732
1828
      if (!ctx->ReadBuffer->_DepthBuffer) {
1733
1829
         _mesa_error(ctx, GL_INVALID_OPERATION,
1734
 
                     "glCopyTexImage%D(no depth)", dimensions);
 
1830
                     "glCopyTexImage%dD(no depth)", dimensions);
1735
1831
         return GL_TRUE;
1736
1832
      }
1737
1833
   }
1739
1835
      /* make sure we have depth/stencil buffers */
1740
1836
      if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) {
1741
1837
         _mesa_error(ctx, GL_INVALID_OPERATION,
1742
 
                     "glCopyTexImage%D(no depth/stencil buffer)", dimensions);
 
1838
                     "glCopyTexImage%dD(no depth/stencil buffer)", dimensions);
1743
1839
         return GL_TRUE;
1744
1840
      }
1745
1841
   }
1904
2000
   if (_mesa_is_format_compressed(teximage->TexFormat)) {
1905
2001
      if (!target_can_be_compressed(ctx, target)) {
1906
2002
         _mesa_error(ctx, GL_INVALID_ENUM,
1907
 
                     "glCopyTexSubImage%d(target)", dimensions);
 
2003
                     "glCopyTexSubImage%dD(target)", dimensions);
1908
2004
         return GL_TRUE;
1909
2005
      }
1910
2006
      /* offset must be multiple of 4 */
1911
2007
      if ((xoffset & 3) || (yoffset & 3)) {
1912
2008
         _mesa_error(ctx, GL_INVALID_VALUE,
1913
 
                     "glCopyTexSubImage%D(xoffset or yoffset)", dimensions);
 
2009
                     "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions);
1914
2010
         return GL_TRUE;
1915
2011
      }
1916
2012
      /* size must be multiple of 4 */
1917
2013
      if ((width & 3) != 0 && (GLuint) width != teximage->Width) {
1918
2014
         _mesa_error(ctx, GL_INVALID_VALUE,
1919
 
                     "glCopyTexSubImage%D(width)", dimensions);
 
2015
                     "glCopyTexSubImage%dD(width)", dimensions);
1920
2016
         return GL_TRUE;
1921
2017
      }         
1922
2018
      if ((height & 3) != 0 && (GLuint) height != teximage->Height) {
1923
2019
         _mesa_error(ctx, GL_INVALID_VALUE,
1924
 
                     "glCopyTexSubImage%D(height)", dimensions);
 
2020
                     "glCopyTexSubImage%dD(height)", dimensions);
1925
2021
         return GL_TRUE;
1926
2022
      }         
1927
2023
   }
1941
2037
   if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) {
1942
2038
      if (!ctx->ReadBuffer->_DepthBuffer) {
1943
2039
         _mesa_error(ctx, GL_INVALID_OPERATION,
1944
 
                     "glCopyTexSubImage%D(no depth buffer)",
 
2040
                     "glCopyTexSubImage%dD(no depth buffer)",
1945
2041
                     dimensions);
1946
2042
         return GL_TRUE;
1947
2043
      }
1949
2045
   else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
1950
2046
      if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) {
1951
2047
         _mesa_error(ctx, GL_INVALID_OPERATION,
1952
 
                     "glCopyTexSubImage%D(no depth/stencil buffer)",
 
2048
                     "glCopyTexSubImage%dD(no depth/stencil buffer)",
1953
2049
                     dimensions);
1954
2050
         return GL_TRUE;
1955
2051
      }
2087
2183
}
2088
2184
 
2089
2185
 
 
2186
/**
 
2187
 * Choose the actual hardware format for a texture image.
 
2188
 * Try to use the same format as the previous image level when possible.
 
2189
 * Otherwise, ask the driver for the best format.
 
2190
 * It's important to try to choose a consistant format for all levels
 
2191
 * for efficient texture memory layout/allocation.  In particular, this
 
2192
 * comes up during automatic mipmap generation.
 
2193
 */
 
2194
void
 
2195
_mesa_choose_texture_format(GLcontext *ctx,
 
2196
                            struct gl_texture_object *texObj,
 
2197
                            struct gl_texture_image *texImage,
 
2198
                            GLenum target, GLint level,
 
2199
                            GLenum internalFormat, GLenum format, GLenum type)
 
2200
{
 
2201
   /* see if we've already chosen a format for the previous level */
 
2202
   if (level > 0) {
 
2203
      struct gl_texture_image *prevImage =
 
2204
         _mesa_select_tex_image(ctx, texObj, target, level - 1);
 
2205
      /* See if the prev level is defined and has an internal format which
 
2206
       * matches the new internal format.
 
2207
       */
 
2208
      if (prevImage &&
 
2209
          prevImage->Width > 0 &&
 
2210
          prevImage->InternalFormat == internalFormat) {
 
2211
         /* use the same format */
 
2212
         texImage->TexFormat = prevImage->TexFormat;
 
2213
         return;
 
2214
      }
 
2215
   }
 
2216
 
 
2217
   /* choose format from scratch */
 
2218
   texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
 
2219
                                                         format, type);
 
2220
   ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2221
}
 
2222
 
 
2223
 
 
2224
 
2090
2225
/*
2091
2226
 * Called from the API.  Note that width includes the border.
2092
2227
 */
2147
2282
                                       postConvWidth, 1, 1,
2148
2283
                                       border, internalFormat);
2149
2284
 
2150
 
            /* Choose actual texture format */
2151
 
            texImage->TexFormat =
2152
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
2153
 
                                               format, type);
2154
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2285
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2286
                                        internalFormat, format, type);
2155
2287
 
2156
2288
            /* Give the texture to the driver.  <pixels> may be null. */
2157
2289
            ASSERT(ctx->Driver.TexImage1D);
2186
2318
      }
2187
2319
      else {
2188
2320
         /* no error, set the tex image parameters */
 
2321
         struct gl_texture_object *texObj =
 
2322
            _mesa_get_current_tex_object(ctx, target);
2189
2323
         ASSERT(texImage);
2190
2324
         _mesa_init_teximage_fields(ctx, target, texImage,
2191
2325
                                    postConvWidth, 1, 1,
2192
2326
                                    border, internalFormat);
2193
 
         texImage->TexFormat =
2194
 
            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
 
2327
         _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2328
                                     internalFormat, format, type);
2195
2329
      }
2196
2330
   }
2197
2331
   else {
2267
2401
                                       postConvWidth, postConvHeight, 1,
2268
2402
                                       border, internalFormat);
2269
2403
 
2270
 
            /* Choose actual texture format */
2271
 
            texImage->TexFormat =
2272
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
2273
 
                                               format, type);
2274
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2404
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2405
                                        internalFormat, format, type);
2275
2406
 
2276
2407
            /* Give the texture to the driver.  <pixels> may be null. */
2277
2408
            ASSERT(ctx->Driver.TexImage2D);
2313
2444
      }
2314
2445
      else {
2315
2446
         /* no error, set the tex image parameters */
 
2447
         struct gl_texture_object *texObj =
 
2448
            _mesa_get_current_tex_object(ctx, target);
2316
2449
         _mesa_init_teximage_fields(ctx, target, texImage,
2317
2450
                                    postConvWidth, postConvHeight, 1,
2318
2451
                                    border, internalFormat);
2319
 
         texImage->TexFormat =
2320
 
            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
 
2452
         _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2453
                                     internalFormat, format, type);
2321
2454
      }
2322
2455
   }
2323
2456
   else {
2383
2516
                                       width, height, depth,
2384
2517
                                       border, internalFormat);
2385
2518
 
2386
 
            /* Choose actual texture format */
2387
 
            texImage->TexFormat =
2388
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
2389
 
                                               format, type);
2390
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2519
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2520
                                        internalFormat, format, type);
2391
2521
 
2392
2522
            /* Give the texture to the driver.  <pixels> may be null. */
2393
2523
            ASSERT(ctx->Driver.TexImage3D);
2424
2554
      }
2425
2555
      else {
2426
2556
         /* no error, set the tex image parameters */
 
2557
         struct gl_texture_object *texObj =
 
2558
            _mesa_get_current_tex_object(ctx, target);
2427
2559
         _mesa_init_teximage_fields(ctx, target, texImage, width, height,
2428
2560
                                    depth, border, internalFormat);
2429
 
         texImage->TexFormat =
2430
 
            ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
 
2561
         _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2562
                                     internalFormat, format, type);
2431
2563
      }
2432
2564
   }
2433
2565
   else {
2457
2589
   GET_CURRENT_CONTEXT(ctx);
2458
2590
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
2459
2591
 
 
2592
   if (!ctx->Extensions.OES_EGL_image) {
 
2593
      _mesa_error(ctx, GL_INVALID_OPERATION,
 
2594
                  "glEGLImageTargetTexture2DOES(unsupported)");
 
2595
      return;
 
2596
   }
 
2597
 
2460
2598
   if (target != GL_TEXTURE_2D) {
2461
2599
      _mesa_error(ctx, GL_INVALID_ENUM,
2462
2600
                  "glEGLImageTargetTexture2D(target=%d)", target);
2734
2872
         _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1,
2735
2873
                                    border, internalFormat);
2736
2874
 
2737
 
         /* Choose actual texture format */
2738
 
         texImage->TexFormat =
2739
 
            ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
2740
 
                                            GL_NONE, GL_NONE);
2741
 
         ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2875
         _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2876
                                     internalFormat, GL_NONE, GL_NONE);
2742
2877
 
2743
2878
         ASSERT(ctx->Driver.CopyTexImage1D);
2744
2879
         ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat,
2815
2950
                                    postConvWidth, postConvHeight, 1,
2816
2951
                                    border, internalFormat);
2817
2952
 
2818
 
         /* Choose actual texture format */
2819
 
         texImage->TexFormat =
2820
 
            ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
2821
 
                                            GL_NONE, GL_NONE);
2822
 
         ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
2953
         _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
2954
                                     internalFormat, GL_NONE, GL_NONE);
2823
2955
 
2824
2956
         ASSERT(ctx->Driver.CopyTexImage2D);
2825
2957
         ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat,
3103
3235
      /* 3D compressed textures not allowed */
3104
3236
      return GL_INVALID_ENUM;
3105
3237
   }
 
3238
   else {
 
3239
      assert(0);
 
3240
      return GL_INVALID_ENUM;
 
3241
   }
3106
3242
 
3107
3243
   maxTextureSize = 1 << (maxLevels - 1);
3108
3244
 
3109
3245
   /* This will detect any invalid internalFormat value */
3110
 
   if (!is_compressed_format(ctx, internalFormat))
 
3246
   if (!_mesa_is_compressed_format(ctx, internalFormat))
3111
3247
      return GL_INVALID_ENUM;
3112
3248
 
3113
3249
   /* This should really never fail */
3212
3348
   maxTextureSize = 1 << (maxLevels - 1);
3213
3349
 
3214
3350
   /* this will catch any invalid compressed format token */
3215
 
   if (!is_compressed_format(ctx, format))
 
3351
   if (!_mesa_is_compressed_format(ctx, format))
3216
3352
      return GL_INVALID_ENUM;
3217
3353
 
3218
3354
   if (width < 1 || width > maxTextureSize)
3340
3476
            _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
3341
3477
                                       border, internalFormat);
3342
3478
 
3343
 
            /* Choose actual texture format */
3344
 
            texImage->TexFormat =
3345
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
3346
 
                                               GL_NONE, GL_NONE);
3347
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
3479
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3480
                                        internalFormat, GL_NONE, GL_NONE);
3348
3481
 
3349
3482
            ASSERT(ctx->Driver.CompressedTexImage1D);
3350
3483
            ctx->Driver.CompressedTexImage1D(ctx, target, level,
3392
3525
            texImage = _mesa_select_tex_image(ctx, texObj, target, level);
3393
3526
            _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
3394
3527
                                       border, internalFormat);
 
3528
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3529
                                        internalFormat, GL_NONE, GL_NONE);
3395
3530
         }
3396
3531
         _mesa_unlock_texture(ctx, texObj);
3397
3532
      }
3402
3537
   }
3403
3538
}
3404
3539
 
3405
 
 
3406
3540
void GLAPIENTRY
3407
3541
_mesa_CompressedTexImage2DARB(GLenum target, GLint level,
3408
3542
                              GLenum internalFormat, GLsizei width,
3418
3552
                  _mesa_lookup_enum_by_nr(internalFormat),
3419
3553
                  width, height, border, imageSize, data);
3420
3554
 
 
3555
#if FEATURE_ES
 
3556
   switch (internalFormat) {
 
3557
   case GL_PALETTE4_RGB8_OES:
 
3558
   case GL_PALETTE4_RGBA8_OES:
 
3559
   case GL_PALETTE4_R5_G6_B5_OES:
 
3560
   case GL_PALETTE4_RGBA4_OES:
 
3561
   case GL_PALETTE4_RGB5_A1_OES:
 
3562
   case GL_PALETTE8_RGB8_OES:
 
3563
   case GL_PALETTE8_RGBA8_OES:
 
3564
   case GL_PALETTE8_R5_G6_B5_OES:
 
3565
   case GL_PALETTE8_RGBA4_OES:
 
3566
   case GL_PALETTE8_RGB5_A1_OES:
 
3567
      _mesa_cpal_compressed_teximage2d(target, level, internalFormat,
 
3568
                                       width, height, imageSize, data);
 
3569
      return;
 
3570
   }
 
3571
#endif
 
3572
 
3421
3573
   if (target == GL_TEXTURE_2D ||
3422
3574
       (ctx->Extensions.ARB_texture_cube_map &&
3423
3575
        target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
3450
3602
            _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
3451
3603
                                       border, internalFormat);
3452
3604
 
3453
 
            /* Choose actual texture format */
3454
 
            texImage->TexFormat =
3455
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
3456
 
                                               GL_NONE, GL_NONE);
3457
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
3605
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3606
                                        internalFormat, GL_NONE, GL_NONE);
3458
3607
 
3459
3608
            ASSERT(ctx->Driver.CompressedTexImage2D);
3460
3609
            ctx->Driver.CompressedTexImage2D(ctx, target, level,
3504
3653
            texImage = _mesa_select_tex_image(ctx, texObj, target, level);
3505
3654
            _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
3506
3655
                                       border, internalFormat);
 
3656
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3657
                                        internalFormat, GL_NONE, GL_NONE);
3507
3658
         }
3508
3659
         _mesa_unlock_texture(ctx, texObj);
3509
3660
      }
3560
3711
                                       border, internalFormat);
3561
3712
 
3562
3713
            /* Choose actual texture format */
3563
 
            texImage->TexFormat =
3564
 
               ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
3565
 
                                               GL_NONE, GL_NONE);
3566
 
            ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
3714
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3715
                                        internalFormat, GL_NONE, GL_NONE);
3567
3716
 
3568
3717
            ASSERT(ctx->Driver.CompressedTexImage3D);
3569
3718
            ctx->Driver.CompressedTexImage3D(ctx, target, level,
3612
3761
            texImage = _mesa_select_tex_image(ctx, texObj, target, level);
3613
3762
            _mesa_init_teximage_fields(ctx, target, texImage, width, height,
3614
3763
                                       depth, border, internalFormat);
 
3764
            _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
 
3765
                                        internalFormat, GL_NONE, GL_NONE);
3615
3766
         }
3616
3767
         _mesa_unlock_texture(ctx, texObj);
3617
3768
      }