summaryrefslogtreecommitdiffstats
path: root/src/egl/main/egldisplay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main/egldisplay.c')
-rw-r--r--src/egl/main/egldisplay.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 53c6e6346d7..6eeaa35eb63 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
#include "c11/threads.h"
+#include "util/u_atomic.h"
#include "eglcontext.h"
#include "eglcurrent.h"
@@ -181,25 +182,29 @@ _EGLPlatformType
_eglGetNativePlatform(void *nativeDisplay)
{
static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
+ _EGLPlatformType detected_platform = native_platform;
- if (native_platform == _EGL_INVALID_PLATFORM) {
+ if (detected_platform == _EGL_INVALID_PLATFORM) {
const char *detection_method;
- native_platform = _eglGetNativePlatformFromEnv();
+ detected_platform = _eglGetNativePlatformFromEnv();
detection_method = "environment overwrite";
- if (native_platform == _EGL_INVALID_PLATFORM) {
- native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
+ if (detected_platform == _EGL_INVALID_PLATFORM) {
+ detected_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
detection_method = "autodetected";
}
- if (native_platform == _EGL_INVALID_PLATFORM) {
- native_platform = _EGL_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[native_platform].name, detection_method);
+ egl_platforms[detected_platform].name, detection_method);
+
+ p_atomic_cmpxchg(&native_platform, _EGL_INVALID_PLATFORM,
+ detected_platform);
}
return native_platform;