servo / surfman

Accelerated offscreen graphics for WebGL
Apache License 2.0
173 stars 84 forks source link

How to draw to a surface with a platform-specific GPU API? #324

Open nicoburns opened 3 days ago

nicoburns commented 3 days ago

The README mentions that surfman allows one to:

draw to a surface with a platform-specific GPU API like Metal

This sounds like it could be really useful to bridge the gap between libraries using OpenGL and libraries using WGPU. But I don't actually see any reference to APIs other than OpenGL in the docs. So my questions are:

jdm commented 3 days ago

I'm not aware of any examples of this, but I believe it would work like this (using macOS with Metal as an example):

  1. create a generic surface
  2. obtain the native surface for the new surface
  3. create a new Metal texture that uses the iosurface as a backing store
  4. possibly ensure that synchronization occurs?