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

« back to all changes in this revision

Viewing changes to src/egl/main/eglconfig.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:
13
13
 
14
14
 
15
15
#define MIN2(A, B)  (((A) < (B)) ? (A) : (B))
16
 
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
17
16
 
18
17
 
19
18
/**
51
50
EGLConfig
52
51
_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
53
52
{
54
 
   _EGLConfig **configs;
55
 
 
56
53
   /* sanity check */
57
54
   assert(GET_CONFIG_ATTRIB(conf, EGL_CONFIG_ID) > 0);
58
55
 
59
 
   configs = dpy->Configs;
60
 
   if (dpy->NumConfigs >= dpy->MaxConfigs) {
61
 
      EGLint new_size = dpy->MaxConfigs + 16;
62
 
      assert(dpy->NumConfigs < new_size);
63
 
 
64
 
      configs = realloc(dpy->Configs, new_size * sizeof(dpy->Configs[0]));
65
 
      if (!configs)
 
56
   if (!dpy->Configs) {
 
57
      dpy->Configs = _eglCreateArray("Config", 16);
 
58
      if (!dpy->Configs)
66
59
         return (EGLConfig) NULL;
67
 
 
68
 
      dpy->Configs = configs;
69
 
      dpy->MaxConfigs = new_size;
70
60
   }
71
61
 
72
62
   conf->Display = dpy;
73
 
   dpy->Configs[dpy->NumConfigs++] = conf;
 
63
   _eglAppendArray(dpy->Configs, (void *) conf);
74
64
 
75
65
   return (EGLConfig) conf;
76
66
}
79
69
EGLBoolean
80
70
_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
81
71
{
82
 
   EGLint num_configs = (dpy) ? dpy->NumConfigs : 0;
83
 
   EGLint i;
84
 
 
85
 
   for (i = 0; i < num_configs; i++) {
86
 
      _EGLConfig *conf = dpy->Configs[i];
87
 
      if (conf == (_EGLConfig *) config) {
88
 
         assert(conf->Display == dpy);
89
 
         break;
90
 
      }
91
 
   }
92
 
   return (i < num_configs);
 
72
   _EGLConfig *conf;
 
73
 
 
74
   conf = (_EGLConfig *) _eglFindArray(dpy->Configs, (void *) config);
 
75
   if (conf)
 
76
      assert(conf->Display == dpy);
 
77
 
 
78
   return (conf != NULL);
93
79
}
94
80
 
95
81
 
224
210
                                    0 },
225
211
   { EGL_NONE,                      ATTRIB_TYPE_PSEUDO,
226
212
                                    ATTRIB_CRITERION_IGNORE,
227
 
                                    0 }
 
213
                                    0 },
 
214
 
 
215
   { EGL_Y_INVERTED_NOK,            ATTRIB_TYPE_BOOLEAN,
 
216
                                    ATTRIB_CRITERION_EXACT,
 
217
                                    EGL_DONT_CARE },
 
218
 
228
219
};
229
220
 
230
221
 
323
314
                   EGL_VG_ALPHA_FORMAT_PRE_BIT |
324
315
                   EGL_MULTISAMPLE_RESOLVE_BOX_BIT |
325
316
                   EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
 
317
#ifdef EGL_MESA_screen_surface
326
318
            if (conf->Display->Extensions.MESA_screen_surface)
327
319
               mask |= EGL_SCREEN_BIT_MESA;
 
320
#endif
328
321
            break;
329
322
         case EGL_RENDERABLE_TYPE:
330
323
         case EGL_CONFORMANT:
467
460
      }
468
461
 
469
462
      if (!matched) {
470
 
#ifdef DEBUG
 
463
#ifndef DEBUG
 
464
         /* only print the common errors when DEBUG is not defined */
 
465
         if (attr != EGL_RENDERABLE_TYPE)
 
466
            break;
 
467
#endif
471
468
         _eglLog(_EGL_DEBUG,
472
469
               "the value (0x%x) of attribute 0x%04x did not meet the criteria (0x%x)",
473
470
               val, attr, cmp);
474
 
#endif
475
471
         break;
476
472
      }
477
473
   }
479
475
   return matched;
480
476
}
481
477
 
 
478
static INLINE EGLBoolean
 
479
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
 
480
{
 
481
   if (_eglIndexConfig(conf, attr) < 0)
 
482
      return EGL_FALSE;
 
483
 
 
484
   /* there are some holes in the range */
 
485
   switch (attr) {
 
486
   case 0x3030 /* a gap before EGL_SAMPLES */:
 
487
   case EGL_NONE:
 
488
#ifdef EGL_VERSION_1_4
 
489
   case EGL_MATCH_NATIVE_PIXMAP:
 
490
#endif
 
491
      return EGL_FALSE;
 
492
   case EGL_Y_INVERTED_NOK:
 
493
      return conf->Display->Extensions.NOK_texture_from_pixmap;
 
494
   default:
 
495
      break;
 
496
   }
 
497
 
 
498
   return EGL_TRUE;
 
499
}
482
500
 
483
501
/**
484
502
 * Initialize a criteria config from the given attribute list.
501
519
 
502
520
   /* parse the list */
503
521
   for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) {
504
 
      EGLint idx;
505
 
 
506
522
      attr = attrib_list[i];
507
523
      val = attrib_list[i + 1];
508
524
 
509
 
      idx = _eglIndexConfig(conf, attr);
510
 
      if (idx < 0)
511
 
         return EGL_FALSE;
512
 
      conf->Storage[idx] = val;
 
525
      if (!_eglIsConfigAttribValid(conf, attr))
 
526
         return EGL_FALSE;
 
527
              
 
528
      SET_CONFIG_ATTRIB(conf, attr, val);
513
529
 
514
530
      /* rememeber some attributes for post-processing */
515
531
      switch (attr) {
752
768
   if (!_eglParseConfigAttribList(&criteria, attrib_list))
753
769
      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
754
770
 
755
 
   /* allocate array of config pointers */
756
 
   configList = (_EGLConfig **)
757
 
      malloc(disp->NumConfigs * sizeof(_EGLConfig *));
 
771
   configList = (_EGLConfig **) _eglFilterArray(disp->Configs, &count,
 
772
         (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
758
773
   if (!configList)
759
774
      return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
760
775
 
761
 
   /* perform selection of configs */
762
 
   count = 0;
763
 
   for (i = 0; i < disp->NumConfigs; i++) {
764
 
      if (_eglMatchConfig(disp->Configs[i], &criteria))
765
 
         configList[count++] = disp->Configs[i];
766
 
   }
767
 
 
768
776
   /* perform sorting of configs */
769
777
   if (configs && count) {
770
778
      _eglSortConfigs((const _EGLConfig **) configList, count,
782
790
}
783
791
 
784
792
 
785
 
static INLINE EGLBoolean
786
 
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
787
 
{
788
 
   if (_eglIndexConfig(conf, attr) < 0)
789
 
      return EGL_FALSE;
790
 
 
791
 
   /* there are some holes in the range */
792
 
   switch (attr) {
793
 
   case 0x3030 /* a gap before EGL_SAMPLES */:
794
 
   case EGL_NONE:
795
 
#ifdef EGL_VERSION_1_4
796
 
   case EGL_MATCH_NATIVE_PIXMAP:
797
 
#endif
798
 
      return EGL_FALSE;
799
 
   default:
800
 
      break;
801
 
   }
802
 
 
803
 
   return EGL_TRUE;
804
 
}
805
 
 
806
 
 
807
793
/**
808
794
 * Fallback for eglGetConfigAttrib.
809
795
 */
821
807
}
822
808
 
823
809
 
 
810
static EGLBoolean
 
811
_eglFlattenConfig(void *elem, void *buffer)
 
812
{
 
813
   _EGLConfig *conf = (_EGLConfig *) elem;
 
814
   EGLConfig *handle = (EGLConfig *) buffer;
 
815
   *handle = _eglGetConfigHandle(conf);
 
816
   return EGL_TRUE;
 
817
}
 
818
 
824
819
/**
825
820
 * Fallback for eglGetConfigs.
826
821
 */
831
826
   if (!num_config)
832
827
      return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs");
833
828
 
834
 
   if (configs) {
835
 
      EGLint i;
836
 
      *num_config = MIN2(disp->NumConfigs, config_size);
837
 
      for (i = 0; i < *num_config; i++)
838
 
         configs[i] = _eglGetConfigHandle(disp->Configs[i]);
839
 
   }
840
 
   else {
841
 
      /* just return total number of supported configs */
842
 
      *num_config = disp->NumConfigs;
843
 
   }
 
829
   *num_config = _eglFlattenArray(disp->Configs, (void *) configs,
 
830
         sizeof(configs[0]), config_size, _eglFlattenConfig);
844
831
 
845
832
   return EGL_TRUE;
846
833
}