@@ -234,10 +234,21 @@ that occur. To solve this, WebGPU uses *Error Scopes*.
234234
235235### Error Scopes ### {#errors-errorscopes}
236236
237+ WebGL exposed errors using a `getError` function returning the first error the last `getError` call.
238+ This is simple, but has two problems.
239+
240+ - It is synchronous, incurring a round-trip and requiring all previously issued work to be finished.
241+ We solve this by returning errors asynchronously.
242+ - Its flat state model composes poorly: errors can leak to/from unrelated code, possibly in
243+ libraries/middleware, browser extensions, etc. We solve this with a stack of error "scopes",
244+ allowing each component to hermetically capture and handle its own errors.
245+
237246Each device<sup> 1</sup> maintains a persistent "error scope" stack state.
238247Initially, the device's error scope stack is empty.
239248`GPUDevice.pushErrorScope('validation' )` or `GPUDevice.pushErrorScope('out-of-memory' )`
240249begins an error scope and pushes it onto the stack.
250+ This scope captures only errors of a particular type depending on the type of error the application
251+ wants to detect.
241252
242253`GPUDevice.popErrorScope()` ends an error scope, popping it from the stack and returning a
243254`Promise<GPUError?>`, which resolves once all enclosed fallible operations have completed and
@@ -246,11 +257,6 @@ It resolves to `null` if no errors were captured, and otherwise resolves to an o
246257the first error that was captured by the scope - either a `GPUValidationError` or a
247258`GPUOutOfMemoryError`.
248259
249- An error scope captures an error if its filter (`'validation' ` or `'out-of-memory' `) matches the
250- type of the error.
251- This filter mechanism avoids, e.g., accidentally silencing validation errors when trying to
252- implement fallible allocation.
253-
254260Any device-timeline error from an operation is passed to the top-most error scope on the stack at
255261the time it was issued.
256262
0 commit comments