anv/cmd_buffer: Enable stencil-only HZ clears
[mesa.git] / src / egl / main / egldisplay.c
index 907a60747d0c815061c9ac0f77fb574b371494d0..37711bd8695ea744dd18d66053e89d1946a57d0e 100644 (file)
@@ -44,6 +44,8 @@
 #include "egldriver.h"
 #include "eglglobals.h"
 #include "egllog.h"
+#include "eglimage.h"
+#include "eglsync.h"
 
 /* Includes for _eglNativePlatformDetectNativeDisplay */
 #ifdef HAVE_MINCORE
@@ -178,25 +180,24 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
 _EGLPlatformType
 _eglGetNativePlatform(void *nativeDisplay)
 {
-   static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
-   char *detection_method = NULL;
+   static _EGLPlatformType native_platform;
+   char *detection_method;
+
+   native_platform = _eglGetNativePlatformFromEnv();
+   detection_method = "environment overwrite";
 
    if (native_platform == _EGL_INVALID_PLATFORM) {
-      native_platform = _eglGetNativePlatformFromEnv();
-      detection_method = "environment overwrite";
-      if (native_platform == _EGL_INVALID_PLATFORM) {
-         native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
-         detection_method = "autodetected";
-         if (native_platform == _EGL_INVALID_PLATFORM) {
-            native_platform = _EGL_NATIVE_PLATFORM;
-            detection_method = "build-time configuration";
-         }
-      }
+      native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
+      detection_method = "autodetected";
+   }
+
+   if (native_platform == _EGL_INVALID_PLATFORM) {
+      native_platform = _EGL_NATIVE_PLATFORM;
+      detection_method = "build-time configuration";
    }
 
-   if (detection_method != NULL)
-      _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
-              egl_platforms[native_platform].name, detection_method);
+   _eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
+           egl_platforms[native_platform].name, detection_method);
 
    return native_platform;
 }
@@ -240,7 +241,6 @@ _EGLDisplay *
 _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy)
 {
    _EGLDisplay *dpy;
-   _EGLThreadInfo *thread = _eglGetCurrentThread();
 
    if (plat == _EGL_INVALID_PLATFORM)
       return NULL;
@@ -266,13 +266,9 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy)
          /* add to the display list */ 
          dpy->Next = _eglGlobal.DisplayList;
          _eglGlobal.DisplayList = dpy;
-         dpy->ThreadList = NULL;
       }
    }
 
-   thread->Next = dpy->ThreadList;
-   dpy->ThreadList = thread;
-
    mtx_unlock(_eglGlobal.Mutex);
 
    return dpy;
@@ -306,6 +302,26 @@ _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display)
       drv->API.DestroySurface(drv, display, surf);
    }
    assert(!display->ResourceLists[_EGL_RESOURCE_SURFACE]);
+
+   list = display->ResourceLists[_EGL_RESOURCE_IMAGE];
+   while (list) {
+      _EGLImage *image = (_EGLImage *) list;
+      list = list->Next;
+
+      _eglUnlinkImage(image);
+      drv->API.DestroyImageKHR(drv, display, image);
+   }
+   assert(!display->ResourceLists[_EGL_RESOURCE_IMAGE]);
+
+   list = display->ResourceLists[_EGL_RESOURCE_SYNC];
+   while (list) {
+      _EGLSync *sync = (_EGLSync *) list;
+      list = list->Next;
+
+      _eglUnlinkSync(sync);
+      drv->API.DestroySyncKHR(drv, display, sync);
+   }
+   assert(!display->ResourceLists[_EGL_RESOURCE_SYNC]);
 }
 
 
@@ -524,3 +540,24 @@ _eglGetWaylandDisplay(struct wl_display *native_display,
    return _eglFindDisplay(_EGL_PLATFORM_WAYLAND, native_display);
 }
 #endif /* HAVE_WAYLAND_PLATFORM */
+
+#ifdef HAVE_SURFACELESS_PLATFORM
+_EGLDisplay*
+_eglGetSurfacelessDisplay(void *native_display,
+                          const EGLint *attrib_list)
+{
+   /* This platform has no native display. */
+   if (native_display != NULL) {
+      _eglError(EGL_BAD_PARAMETER, "eglGetPlatformDisplay");
+      return NULL;
+   }
+
+   /* This platform recognizes no display attributes. */
+   if (attrib_list != NULL && attrib_list[0] != EGL_NONE) {
+      _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
+      return NULL;
+   }
+
+   return _eglFindDisplay(_EGL_PLATFORM_SURFACELESS, native_display);
+}
+#endif /* HAVE_SURFACELESS_PLATFORM */