Skip to content

Revamped API Proposal #370

@mrobinson

Description

@mrobinson

In the interest of simplifying the surfman and preparing for adding support for interoperability with wgpu and for cross-process surface handles, I would like to propose version 2 of the API:

Connection

pub enum Connection {
    Android(...),
    Angle(...),
    Cgl(...),
    Ohos(...),
    SurfacelessMesa(...),
    Wayland(...),
    Wgl(...),
    X11(...),
}

Adapter

pub enum Adapter {
    Android(...),
    Angle(...),
    Cgl(...),
    Egl(...),
    Ohos(...),
    Wgl(...),
}

Surface

pub enum Surface {
    Window(WindowSurface),
    Buffer(BufferSurface),
}

pub enum BufferSurface {
    Android(...),
    Direct3d(...),
    IoSurface(...)
    Ohos(...),
    Pbuffer(...),
}

pub enum WindowSurface {
    Android(...),
    AppKit(...)
    Ohos(...),
    Wayland(...),
    Win32(...),
    X11(...),
}

Notes:

  • Only WindowSurface would implement present meaning it's not possible to call present on a buffer surface (this causes an error today).
  • Mutability concerns would be handled by a mutable getter for the currently bound surface:
    if let Some(Surface::Window(window_surface)) = cnnection.bound_surface_mut() {
        window_surface.present(&device);
    }
  • Multi is eliminated. Instead a factory returns the most appropriate context given what is enabled at compile-time and what is currently running (when choosing between X11 and Wayland).
  • This opens up the possibility of other kinds of offscreen buffers such as GBM, which will be necessary for cross-process rendering and integration with wgpu.
  • The idea is that BufferSurface will provide a fallible method to get a shareable handle to be used for cross-process surfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions