Skip to content

Thread-local error scopes #5375

@kpreid

Description

@kpreid

Is your feature request related to a problem? Please describe.
It should be possible to catch errors in a manner which is compatible with multi-threaded use of a wgpu::Device. The current push_error_scope() and pop_error_scope() use a scope stack global to the Device and thus would require a mutex to be used correctly from a program where multiple threads access the Device or Queue.

My own application for this is catching shader compilation errors to allow shader reloading during development without aborting the program on any error.

Describe the solution you'd like
#3767 already says that

This actually wasn't really previously defined - webgpu.h we decided they're going to be thread local. We need to redefine the api in wgpu to use a thread local.

which seems like a fine solution, but that's labeled as a documentation issue, so I'm filing this issue to make sure the functional change isn't overlooked.

It would also be good if the Rust interface to these error scopes was a "RAII" guard type rather than a pair of push and pop, to ensure correct cleanup on unwinding and to make push-without-pop/pop-without-push mistakes unlikely.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions