rust-windowing/glutin

Support `EGL_KHR_display_reference` to clean up `EGL` properly

kchibisov opened this issue · 3 comments

This extension defines a ref counting for the EGLDisplay which we could use to properly call eglTerminate instead of leaking like we have it now.

cc @i509VCB given that you had some concerns about not calling eglTerminate before.

This is definitely a solution to the problem for displays which glutin has created and owns.

For glutin do we want to always set that attribute if supported? What about things which borrow the display, should cloning the display increment the ref count of the display reference or should we continue with the interior mutability in that case?

For displays which glutin does not own or takes ownership of it appears we can query if EGL_TRACK_REFERENCES_KHR is set for the display.

Also what how does driver support look for this extension?

it's not a driver extension, it's a platform extension, like a buffer_age.

We want to always set it if supported and don't anything otherwise.

We should increment on Clone, and we don't use interior mutability at all(we simply keep it inside the Arc).

The GetGlDisplay simply clones and rebuilds the display, so the reference must be incremented each time internal Arc is cloned.