Skip to content

SharedTextureMemory: expose fences on beginAccess/endAccess? #369

@pepperoni505

Description

@pepperoni505

The GPUSharedTextureMemory header notes that fence-based sync isn't exposed yet:

// texture's content is preserved (or not). Callers that want fence-based
// synchronization should pass fences via beginAccess descriptor (not yet
// exposed - we currently take the implicit/no-fence path that matches the
// most common RN use cases: still images, single-producer video frames).

We have a use case that needs it: we import an app-owned IOSurface / AHardwareBuffer via importSharedTextureMemory, render into it with the WebGPU device, then composite that surface into a separate GPU pass (Mapbox) on a different queue, so we need the MTLSharedEvent Dawn exports from EndAccess on iOS, and the sync-fd on Android to protect against texture reads before rendering is finished.

I've prototyped this and am happy to open a PR, but wanted your take on the API shape first. The current sketch:

  • device.importSharedFence({ type, handle })GPUSharedFence (with .export())
  • beginAccess(texture, initialized, fences?, signaledValues?) - wait fences
  • endAccess(texture){ fences, signaledValues, ... } - surfaces the fences (this changes the current boolean return)

Does this match what you had in mind, or would you prefer a different shape?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions