servo / servo/surfman

Revamped API Proposal

Open
#370 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
193
Forks
100
Avg merge
17h 55m
Merged PRs (30d)
9

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This is an API design proposal: no files, tests, or implementation entry points are named. Review the proposed Connection, Adapter, Surface, BufferSurface, and WindowSurface shapes first, then establish compatibility and acceptance criteria for wgpu and cross-process handles; the issue does not define what completion looks like.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.