2025-11-21 06:43:26 -05:00

1.6 KiB

Fence

A GPU->CPU synchronization primitive that signals / resolves when any GPU commands submitted prior to the Fence have completed.

Remarks:

  • Fences can e.g. be useful in WebGL to avoid starting a synchronous GPU->CPU data readback until all GPU commands affecting the buffer in question have completed.
  • In contrast to WebGL 2, WebGPU does not provide an actual "GPUFence" primitive. Instead a function GPUDevice.onSubmittedWorkDone() is used. This means that the "fence" is inserted after the last submitted (completed) command buffer (render pass, compute pass etc), rather than into the stream of commands in a command buffer.

Props

FenceProps

FenceProps extends ResourceProps and accepts the following fields.

Property Type Default Description
id? string autogenerated Optional human readable identifier inherited from Resource.
handle? unknown undefined Optional handle to the underlying platform resource.
userData? Record<string, any> undefined Application reserved data stored on the fence instance.

Members

  • signaled: Promise<void> - resolves when the fence is signaled.

Methods

isSignaled(): boolean

Checks if the fence has already been signaled.

destroy(): void

Destroys the fence and releases any associated resources.