Skip to content

Idiomatic OpenGL context directly on EGL #3468

@kvark

Description

@kvark

Intro

Looking more at our current issues with GL presentation (#3353), at surfman code (servo/surfman#202), and around, I think we need to approach this from the ground up again.

First of all, surfman (used in #3375) brings a lot of friction:

We contributed a bit to it, but it takes a lot of effort to truly become fluent enough to land the changes we need. But we know what OpenGL backend of gfx-rs needs. What if we could reduce the scope of work here?

On Windows, we have Vulkan, D3D12 and D3D11. There is no need for OpenGL there. On macOS, OpenGL has been deprecated for a while already, and Metal is widely supported. This leaves us with only non-Apple unix systems, including Android. All of them, if I understand correctly, are designed to support EGL as the main context/window manager for GL.

Proposal

Therefore, what if we can just directly depend on EGL unconditionally (on non-wasm targets)? No need for optional glutin, surfman, etc, features. Just make it so our GL backend uses EGL for context creation.

  • Instance = egl::Display, created by eglGetDisplay. We could choose the default one - I think this is the most tricky part in the proposal so far.
  • Surface = egl::Surface, created by eglCreateWindowSurface
  • Adapter = egl::Config. When enumerate_adapters is called, we could get all the contexts supported by the display, and then query their attributes to find out which are software renderers, which support presentation, etc
  • Device = egl::Context, created by eglCreateContext.

Note: this elaboration doesn't include WebGL target. I don't know how to properly fit it in here, just yet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions