mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 15:10:10 +01:00
egl: Make native display detection work more than once
eglGetDisplay is awful because you have to inspect the pointer you're given and guess what type of native display it corresponds to. We make it worse by caching the type of the first such display we detect, so if the second call to eglGetDisplay is to a different display type, kaboom. Fortunately this is a problem that can be solved with the delete key. Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/156
This commit is contained in:
parent
3f6e91a8d8
commit
5218c3b27e
1 changed files with 13 additions and 23 deletions
|
|
@ -159,33 +159,23 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
|
|||
_EGLPlatformType
|
||||
_eglGetNativePlatform(void *nativeDisplay)
|
||||
{
|
||||
static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
|
||||
_EGLPlatformType detected_platform = native_platform;
|
||||
_EGLPlatformType detected_platform = _eglGetNativePlatformFromEnv();
|
||||
const char *detection_method = "environment";
|
||||
|
||||
if (detected_platform == _EGL_INVALID_PLATFORM) {
|
||||
const char *detection_method;
|
||||
|
||||
detected_platform = _eglGetNativePlatformFromEnv();
|
||||
detection_method = "environment overwrite";
|
||||
|
||||
if (detected_platform == _EGL_INVALID_PLATFORM) {
|
||||
detected_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
|
||||
detection_method = "autodetected";
|
||||
}
|
||||
|
||||
if (detected_platform == _EGL_INVALID_PLATFORM) {
|
||||
detected_platform = _EGL_NATIVE_PLATFORM;
|
||||
detection_method = "build-time configuration";
|
||||
}
|
||||
|
||||
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
|
||||
egl_platforms[detected_platform].name, detection_method);
|
||||
|
||||
p_atomic_cmpxchg(&native_platform, _EGL_INVALID_PLATFORM,
|
||||
detected_platform);
|
||||
detected_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
|
||||
detection_method = "autodetected";
|
||||
}
|
||||
|
||||
return native_platform;
|
||||
if (detected_platform == _EGL_INVALID_PLATFORM) {
|
||||
detected_platform = _EGL_NATIVE_PLATFORM;
|
||||
detection_method = "build-time configuration";
|
||||
}
|
||||
|
||||
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
|
||||
egl_platforms[detected_platform].name, detection_method);
|
||||
|
||||
return detected_platform;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue