zerocopy-handoff

command
v0.6.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

zerocopy-handoff

Demonstrates zero-copy IOSurface <-> MTLBuffer physical page aliasing and bidirectional GPU <-> ANE Mach-port shared-event synchronization using github.com/tmc/apple/x/zerocopy.

What it does

  1. Creates a zerocopy.SurfacePool on the system default Metal device, bridging an IOSurfaceSharedEvent and MTLSharedEvent over the same Mach port.
  2. Acquires a 4096-byte SurfaceSlab and calls slab.Verify() to prove both views alias the same physical memory pages.
  3. Dispatches a Metal compute shader (scale_by_two) and signals the shared event from the GPU; waits on the IOSurfaceSharedEvent side and mutates the shared surface directly without copying.
  4. Queues a second Metal pass guarded by EncodeWaitForEventValue, releases it by signaling from IOSurfaceSharedEvent, and verifies the chained result.
  5. Releases and re-acquires the slab to confirm zero-allocation pool reuse.

Run

go run ./examples/compute/zerocopy-handoff

Documentation

Rendered for darwin/amd64

Overview

Command zerocopy-handoff demonstrates zero-copy IOSurface <-> MTLBuffer page aliasing and bidirectional GPU <-> ANE Mach-port shared-event handoff using github.com/tmc/apple/x/zerocopy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL