mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
render/egl: add support for EGL_KHR_display_reference
See the spec at [1]. tl;dr EGL has terrible defaults: eglTerminate() may have side-effects on completely unrelated EGLDisplay objects. This extension allows us to opt-in to get the sane behavior: eglTerminate() only free's our own EGLDisplay without affecting others. [1]: https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_display_reference.txt
This commit is contained in:
parent
2ad25b1460
commit
5206cea566
2 changed files with 15 additions and 2 deletions
|
@ -24,6 +24,7 @@ struct wlr_egl {
|
||||||
bool EXT_device_query;
|
bool EXT_device_query;
|
||||||
bool KHR_platform_gbm;
|
bool KHR_platform_gbm;
|
||||||
bool EXT_platform_device;
|
bool EXT_platform_device;
|
||||||
|
bool KHR_display_reference;
|
||||||
} exts;
|
} exts;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
16
render/egl.c
16
render/egl.c
|
@ -207,9 +207,10 @@ static struct wlr_egl *egl_create(void) {
|
||||||
|
|
||||||
egl->exts.KHR_platform_gbm = check_egl_ext(client_exts_str,
|
egl->exts.KHR_platform_gbm = check_egl_ext(client_exts_str,
|
||||||
"EGL_KHR_platform_gbm");
|
"EGL_KHR_platform_gbm");
|
||||||
|
|
||||||
egl->exts.EXT_platform_device = check_egl_ext(client_exts_str,
|
egl->exts.EXT_platform_device = check_egl_ext(client_exts_str,
|
||||||
"EGL_EXT_platform_device");
|
"EGL_EXT_platform_device");
|
||||||
|
egl->exts.KHR_display_reference = check_egl_ext(client_exts_str,
|
||||||
|
"EGL_KHR_display_reference");
|
||||||
|
|
||||||
if (check_egl_ext(client_exts_str, "EGL_EXT_device_base") || check_egl_ext(client_exts_str, "EGL_EXT_device_enumeration")) {
|
if (check_egl_ext(client_exts_str, "EGL_EXT_device_base") || check_egl_ext(client_exts_str, "EGL_EXT_device_enumeration")) {
|
||||||
load_egl_proc(&egl->procs.eglQueryDevicesEXT, "eglQueryDevicesEXT");
|
load_egl_proc(&egl->procs.eglQueryDevicesEXT, "eglQueryDevicesEXT");
|
||||||
|
@ -351,8 +352,19 @@ static bool egl_init_display(struct wlr_egl *egl, EGLDisplay display) {
|
||||||
|
|
||||||
static bool egl_init(struct wlr_egl *egl, EGLenum platform,
|
static bool egl_init(struct wlr_egl *egl, EGLenum platform,
|
||||||
void *remote_display) {
|
void *remote_display) {
|
||||||
|
EGLint display_attribs[3] = {0};
|
||||||
|
size_t display_attribs_len = 0;
|
||||||
|
|
||||||
|
if (egl->exts.KHR_display_reference) {
|
||||||
|
display_attribs[display_attribs_len++] = EGL_TRACK_REFERENCES_KHR;
|
||||||
|
display_attribs[display_attribs_len++] = EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
display_attribs[display_attribs_len++] = EGL_NONE;
|
||||||
|
assert(display_attribs_len < sizeof(display_attribs) / sizeof(display_attribs[0]));
|
||||||
|
|
||||||
EGLDisplay display = egl->procs.eglGetPlatformDisplayEXT(platform,
|
EGLDisplay display = egl->procs.eglGetPlatformDisplayEXT(platform,
|
||||||
remote_display, NULL);
|
remote_display, display_attribs);
|
||||||
if (display == EGL_NO_DISPLAY) {
|
if (display == EGL_NO_DISPLAY) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create EGL display");
|
wlr_log(WLR_ERROR, "Failed to create EGL display");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue