Skip to content

[GPU 05/20] Implement macOS IOSurface and Metal synchronization interop #27

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 05 of 20.
Depends on: #25.

Outcome

Provide a macOS GPU-resident image bridge for Dawn Metal and ANGLE Metal, with lifetime and synchronization suitable for both presenters.

Implementation

  • Allocate/import IOSurface-backed single-sample canvas color images. Negotiate pixel formats, alpha, orientation, adapter identity and actual OS/backend capabilities.
  • Use Dawn shared-texture BeginAccess/EndAccess and Metal shared-event/completion mechanisms where supported. Implement the corresponding ANGLE producer access protocol.
  • Define producer→consumer and consumer→producer completion explicitly. An IOSurface reference alone is not proof that GPU writes or reads have finished.
  • Keep MSAA/depth private and resolve into the shared image; classify required conversion copies.
  • Supply typed native import hooks for actual presenter backends. If a selected host backend cannot express safe interop, expose the missing capability and implement the narrowly pinned hook in the presenter integration issue; do not fall back to CPU copies.
  • Manage Objective-C/CF/Metal/IOSurface references independently from scene leases and resize generations.
  • Handle unsupported OS/backend features, device loss, detached views, mixed scale factors and delayed completion.

Tests

  • Dawn and ANGLE patterns, transparent edges, correct channel order/orientation and four-sample resolve.
  • Resize at DPR 1/2, minimize/restore, detach/reparent and multi-window/document use.
  • Consumer still reading during producer reuse attempts; old IOSurface generations retained until release.
  • Long-run IOSurface/Metal resource plateau and failure cleanup.

Verification evidence

Provide macOS/GPU/OS manifest plus Metal trace/counters that separate resolve/composition from copies and establish zero ordinary CPU pixel readback. State exactly which host graphics backend/interop route was proven.

Acceptance

  • Both producer paths present correct GPU-resident images to the probe consumer.
  • Producer/consumer GPU completion is explicit and race-tested.
  • IOSurface/native object lifetime survives resize and delayed release.
  • No synchronous full-device wait or CPU pixel transport is used in the ordinary bridge.
  • Unsupported configurations are clearly diagnosed.

Completion requirements

Link the implementation PR, exact test commands, native/runtime/framework revisions and verification artifacts before closing. Follow the epic's architecture and copy/lifetime invariants. Any unavailable mandatory hardware or missing required functionality remains incomplete, not a pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions