diff options
author | Adam Jackson <[email protected]> | 2019-10-08 20:20:36 -0400 |
---|---|---|
committer | Adam Jackson <[email protected]> | 2019-10-09 18:12:29 +0000 |
commit | 5218c3b27e41aefa9f4424a25a22b13895bd2d6f (patch) | |
tree | 65da32c20b3c19a0fe1bb945d2d202ddb05beb11 /src | |
parent | 3f6e91a8d8576f0d6472d54a178600a25eec6fa2 (diff) |
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 <[email protected]>
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/156
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/main/egldisplay.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 8d06e717c20..aea2156cccf 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -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); + detected_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); + detection_method = "autodetected"; + } - p_atomic_cmpxchg(&native_platform, _EGL_INVALID_PLATFORM, - detected_platform); + if (detected_platform == _EGL_INVALID_PLATFORM) { + detected_platform = _EGL_NATIVE_PLATFORM; + detection_method = "build-time configuration"; } - return native_platform; + _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", + egl_platforms[detected_platform].name, detection_method); + + return detected_platform; } |