Sitelet https://github.com/gpuweb/gpuweb/pull/2853/files
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ For each [=usage scope=], the implementation performs
[=internal usage=] flags of each [=subresource=] used in the [=usage scope=].
If any of those lists is not a [=compatible usage list=],
{{GPUCommandEncoder/finish()|GPUCommandEncoder.finish()}}
generates a {{GPUValidationError}} in the current error scope.
will [$generate a validation error$].


## Core Internal Objects ## {#core-internal-objects}
Expand Down Expand Up @@ -6588,7 +6588,7 @@ The <dfn dfn>encoder state</dfn> may be one of the following:
::
The encoder has been ended and new commands can no longer be encoded.

Any command issued in this state generates a {{GPUValidationError}}.
Any command issued in this state will [$generate a validation error$].
</dl>

<div algorithm>
Expand Down Expand Up @@ -10253,19 +10253,43 @@ enum GPUErrorFilter {

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUOutOfMemoryError {
constructor();
interface GPUError {
constructor(DOMString message);
readonly attribute DOMString message;
};

[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUValidationError {
constructor(DOMString message);
readonly attribute DOMString message;
interface GPUOutOfMemoryError : GPUError {
};

typedef (GPUOutOfMemoryError or GPUValidationError) GPUError;
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUValidationError : GPUError {
};
</script>

{{GPUError}} is the base interface for all errors surfaced from {{GPUDevice/popErrorScope()}}
and the {{GPUDevice/uncapturederror}} event.

Note: {{GPUError}} may gain new subtypes in future versions of this spec. Applications should handle
this possibility, using only the error's {{GPUError/message}} when possible, and specializing using
`instanceof`. Use `error.constructor.name` when it's necessary to serialize an error (e.g. into
JSON, for a debug report).

{{GPUError}} has the following attributes:

<dl dfn-type=attribute dfn-for=GPUError>
: <dfn>message</dfn>
::
A human-readable message providing information about the error that occurred.

Note: This message is generally intended for application developers to debug their
applications and capture information for debug reports, not to be surfaced to end-users.

Note: User agents should not include potentially machine-parsable details in this message,
such as free system memory on "out-of-memory" errors, or other details
about the conditions under which memory was exhausted.
</dl>

<script type=idl>
partial interface GPUDevice {
undefined pushErrorScope(GPUErrorFilter filter);
Expand Down Expand Up @@ -10455,11 +10479,16 @@ partial interface GPUDevice {

<div class="example">
Listening for uncaptured errors from a {{GPUDevice}}:

<pre highlight="js">
gpuDevice.addEventListener('uncapturederror', (event) => {
if (event.error instanceof GPUValidationError) {
console.error(\`An uncaught WebGPU validation error was raised: ${event.error.message}\`);
}
// Re-surface the error, because adding an event listener may silence console logs.
console.error('A WebGPU error was not captured:', event.error);

myEngineDebugReport.uncapturedErrors.push({
type: event.error.constructor.name,
message: event.error.message,
});
});
</pre>
</div>
Expand Down