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?
The
GPUSharedTextureMemoryheader notes that fence-based sync isn't exposed yet:react-native-webgpu/packages/webgpu/cpp/rnwgpu/api/GPUSharedTextureMemory.h
Lines 34 to 37 in 0ccc35a
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 theMTLSharedEventDawn exports fromEndAccesson iOS, and thesync-fdon 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 fencesendAccess(texture)→{ fences, signaledValues, ... }- surfaces the fences (this changes the currentbooleanreturn)Does this match what you had in mind, or would you prefer a different shape?