tess 1.0.0
Performance-first tile and path simulation substrate
Loading...
Searching...
No Matches
tess::gpu::WebGpuBackend Class Reference

#include <tess/gpu/webgpu_backend.h>

Public Member Functions

 WebGpuBackend (WGPUDevice device, WebGpuBackendConfig config={})
 WebGpuBackend (const WebGpuBackend &)=delete
auto operator= (const WebGpuBackend &) -> WebGpuBackend &=delete
 WebGpuBackend (WebGpuBackend &&)=delete
auto operator= (WebGpuBackend &&) -> WebGpuBackend &=delete
 ~WebGpuBackend ()
auto capabilities () const noexcept -> GpuCapabilities
bool register_field (FieldMirrorDesc desc)
auto field_buffer (std::uint32_t field_index) const noexcept -> WGPUBuffer
auto register_product (WebGpuProductDesc desc) -> std::optional< GpuProductHandle >
bool unregister_product (GpuProductHandle handle) noexcept
bool valid (GpuProductHandle handle) const noexcept
bool upload (const UploadDesc &upload)
bool dispatch (const DispatchDesc &dispatch)
bool readback (const ReadbackDesc &readback)
void notify_device_lost () noexcept
void notify_device_error () noexcept

Detailed Description

Optional stable-C-API WebGPU transport backend.

The backend owns field mirror buffers and retained algorithm handles. It submits compute asynchronously; a successful boolean means submitted, not completed. CPU state remains authoritative. Forward device-loss and uncaptured/error-scope failures through the notification methods so all later work refuses cleanly. Those notifications are thread-safe; other public operations must be externally serialized. Callback completion performs only its separately synchronized operation cleanup.

Constructor & Destructor Documentation

◆ WebGpuBackend()

tess::gpu::WebGpuBackend::WebGpuBackend ( WGPUDevice device,
WebGpuBackendConfig config = {} )
inlineexplicit

Retains device, obtains its queue, and reserves fixed registries.

◆ ~WebGpuBackend()

tess::gpu::WebGpuBackend::~WebGpuBackend ( )
inline

Releases registries and retained device objects; readbacks remain safe.

Member Function Documentation

◆ capabilities()

auto tess::gpu::WebGpuBackend::capabilities ( ) const -> GpuCapabilities
inlinenodiscardnoexcept

Reports configured limits, or no compute after invalidation/device loss.

◆ dispatch()

bool tess::gpu::WebGpuBackend::dispatch ( const DispatchDesc & dispatch)
inlinenodiscard

Encodes and submits one registered compute product asynchronously.

◆ field_buffer()

auto tess::gpu::WebGpuBackend::field_buffer ( std::uint32_t field_index) const -> WGPUBuffer
inlinenodiscardnoexcept

Returns a registered mirror buffer, or null when the field is absent.

◆ notify_device_error()

void tess::gpu::WebGpuBackend::notify_device_error ( )
inlinenoexcept

Permanently disables GPU work after a validation, OOM, or internal error.

Stable-C WebGPU reports device-side failures asynchronously through error scopes or the application's uncaptured-error callback. A submission method's true result therefore cannot observe them. While this backend is alive, forward either callback here to fail closed onto the CPU path. A pending readback reports Failed when this notification wins the callback's atomic terminal-state race, even if its map itself succeeds.

◆ notify_device_lost()

void tess::gpu::WebGpuBackend::notify_device_lost ( )
inlinenoexcept

Permanently disables new work after the application reports device loss.

◆ readback()

bool tess::gpu::WebGpuBackend::readback ( const ReadbackDesc & readback)
inlinenodiscard

Queues an explicit bounded copy/map readback.

The application callback may run inline before this function returns or later on an arbitrary thread; see WebGpuReadbackCallback.

◆ register_field()

bool tess::gpu::WebGpuBackend::register_field ( FieldMirrorDesc desc)
inlinenodiscard

Creates a chunk-major storage/copy-destination buffer for one field.

◆ register_product()

auto tess::gpu::WebGpuBackend::register_product ( WebGpuProductDesc desc) -> std::optional< GpuProductHandle >
inlinenodiscard

Retains one algorithm pipeline/bind group under a generation handle.

◆ unregister_product()

bool tess::gpu::WebGpuBackend::unregister_product ( GpuProductHandle handle)
inlinenoexcept

Releases a currently valid product and invalidates its generation.

◆ upload()

bool tess::gpu::WebGpuBackend::upload ( const UploadDesc & upload)
inlinenodiscard

Writes one aligned chunk field slice into its registered mirror.

◆ valid()

bool tess::gpu::WebGpuBackend::valid ( GpuProductHandle handle) const
inlinenodiscardnoexcept

Returns whether handle still names its registered product interval.


The documentation for this class was generated from the following file: