diff options
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 18 | ||||
-rw-r--r-- | src/egl/main/eglarray.c | 39 | ||||
-rw-r--r-- | src/egl/main/eglarray.h | 4 | ||||
-rw-r--r-- | src/egl/main/eglconfig.c | 13 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 16 |
5 files changed, 62 insertions, 28 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 6db44c7aa8..6f40ab951f 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -899,10 +899,20 @@ const int i915_chip_ids[] = { 0x29b2, /* PCI_CHIP_Q35_G */ 0x29c2, /* PCI_CHIP_G33_G */ 0x29d2, /* PCI_CHIP_Q33_G */ + 0xa001, /* PCI_CHIP_IGD_G */ 0xa011, /* Pineview */ }; const int i965_chip_ids[] = { + 0x0042, /* PCI_CHIP_ILD_G */ + 0x0046, /* PCI_CHIP_ILM_G */ + 0x0102, /* PCI_CHIP_SANDYBRIDGE_GT1 */ + 0x0106, /* PCI_CHIP_SANDYBRIDGE_M_GT1 */ + 0x010a, /* PCI_CHIP_SANDYBRIDGE_S */ + 0x0112, /* PCI_CHIP_SANDYBRIDGE_GT2 */ + 0x0116, /* PCI_CHIP_SANDYBRIDGE_M_GT2 */ + 0x0122, /* PCI_CHIP_SANDYBRIDGE_GT2_PLUS */ + 0x0126, /* PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS */ 0x29a2, /* PCI_CHIP_I965_G */ 0x2992, /* PCI_CHIP_I965_Q */ 0x2982, /* PCI_CHIP_I965_G_1 */ @@ -914,6 +924,8 @@ const int i965_chip_ids[] = { 0x2e12, /* PCI_CHIP_Q45_G */ 0x2e22, /* PCI_CHIP_G45_G */ 0x2e32, /* PCI_CHIP_G41_G */ + 0x2e42, /* PCI_CHIP_B43_G */ + 0x2e92, /* PCI_CHIP_B43_G1 */ }; const int r100_chip_ids[] = { @@ -1636,7 +1648,11 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, dri2_destroy_surface(drv, disp, old_dsurf); dri2_destroy_surface(drv, disp, old_rsurf); if (old_ctx) { - dri2_dpy->core->unbindContext(dri2_egl_context(old_ctx)->dri_context); + /* unbind the old context only when there is no new context bound */ + if (!ctx) { + __DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context; + dri2_dpy->core->unbindContext(old_cctx); + } /* no destroy? */ _eglPutContext(old_ctx); } diff --git a/src/egl/main/eglarray.c b/src/egl/main/eglarray.c index d686fa162d..fe2f1a7f32 100644 --- a/src/egl/main/eglarray.c +++ b/src/egl/main/eglarray.c @@ -118,38 +118,39 @@ _eglFindArray(_EGLArray *array, void *elem) /** - * Filter an array and return the filtered data. The returned data pointer - * should be freed. + * Filter an array and return the number of filtered elements. */ -void ** -_eglFilterArray(_EGLArray *array, EGLint *size, +EGLint +_eglFilterArray(_EGLArray *array, void **data, EGLint size, _EGLArrayForEach filter, void *filter_data) { - void **data; EGLint count = 0, i; - if (!array) { - *size = 0; - return malloc(0); - } - - data = malloc(array->Size * sizeof(array->Elements[0])); - if (!data) - return NULL; + if (!array) + return 0; if (filter) { for (i = 0; i < array->Size; i++) { - if (filter(array->Elements[i], filter_data)) - data[count++] = array->Elements[i]; + if (filter(array->Elements[i], filter_data)) { + if (data && count < size) + data[count] = array->Elements[i]; + count++; + } + if (data && count >= size) + break; } } else { - memcpy(data, array->Elements, array->Size * sizeof(array->Elements[0])); + if (data) { + count = (size < array->Size) ? size : array->Size; + memcpy(data, array->Elements, count * sizeof(array->Elements[0])); + } + else { + count = array->Size; + } } - *size = count; - - return data; + return count; } diff --git a/src/egl/main/eglarray.h b/src/egl/main/eglarray.h index c8309fb066..a88189a625 100644 --- a/src/egl/main/eglarray.h +++ b/src/egl/main/eglarray.h @@ -37,8 +37,8 @@ void * _eglFindArray(_EGLArray *array, void *elem); -PUBLIC void ** -_eglFilterArray(_EGLArray *array, EGLint *size, +PUBLIC EGLint +_eglFilterArray(_EGLArray *array, void **data, EGLint size, _EGLArrayForEach filter, void *filter_data); diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index fec94fb20c..5b377b7f61 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -697,11 +697,22 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, if (!_eglParseConfigAttribList(&criteria, disp, attrib_list)) return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); - configList = (_EGLConfig **) _eglFilterArray(disp->Configs, &count, + /* get the number of matched configs */ + count = _eglFilterArray(disp->Configs, NULL, 0, (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria); + if (!count) { + *num_configs = count; + return EGL_TRUE; + } + + configList = malloc(sizeof(*configList) * count); if (!configList) return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)"); + /* get the matched configs */ + _eglFilterArray(disp->Configs, (void **) configList, count, + (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria); + /* perform sorting of configs */ if (configs && count) { _eglSortConfigs((const _EGLConfig **) configList, count, diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index ff0011c4b1..e5d8a39a4c 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -186,11 +186,22 @@ _eglLoadModule(_EGLModule *mod) static void _eglUnloadModule(_EGLModule *mod) { +#if defined(_EGL_OS_UNIX) /* destroy the driver */ if (mod->Driver && mod->Driver->Unload) mod->Driver->Unload(mod->Driver); + + /* + * XXX At this point (atexit), the module might be the last reference to + * libEGL. Closing the module might unmap libEGL and give problems. + */ +#if 0 if (mod->Handle) close_library(mod->Handle); +#endif +#elif defined(_EGL_OS_WINDOWS) + /* XXX Windows unloads DLLs before atexit */ +#endif mod->Driver = NULL; mod->Handle = NULL; @@ -670,12 +681,7 @@ _eglUnloadDrivers(void) { /* this is called at atexit time */ if (_eglModules) { -#if defined(_EGL_OS_UNIX) _eglDestroyArray(_eglModules, _eglFreeModule); -#elif defined(_EGL_OS_WINDOWS) - /* XXX Windows unloads DLLs before atexit */ - _eglDestroyArray(_eglModules, NULL); -#endif _eglModules = NULL; } } |