Skip to content

Commit

Permalink
Split into two different error types again
Browse files Browse the repository at this point in the history
  • Loading branch information
toji committed Aug 31, 2022
1 parent 4c93612 commit 94bf9a4
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions spec/index.bs
Expand Up @@ -12871,6 +12871,9 @@ interface GPUError {
{{GPUError}} is the base interface for all errors surfaced from {{GPUDevice/popErrorScope()}}
and the {{GPUDevice/uncapturederror}} event.

Errors must only be generated for operations that explicitly state the conditions one may
be generated under in their respective algorithms, and the subtype of error that is generated.

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
Expand All @@ -12887,8 +12890,8 @@ JSON, for a debug report).
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 {{GPUErrorFilter/"internal"}} errors raised due to memory
constraints, or other details about the conditions under which memory was exhausted.
such as free system memory on {{GPUErrorFilter/"out-of-memory"}} or other details about the
conditions under which memory was exhausted.
</dl>

<script type=idl>
Expand Down Expand Up @@ -12916,57 +12919,50 @@ error, and is expected to fail the same way across all devices assuming the same
</div>

<script type=idl>
enum GPUInternalErrorReason {
"out-of-memory"
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUOutOfMemoryError : GPUError {
constructor(DOMString message);
};
</script>

{{GPUOutOfMemoryError}} is a subtype of {{GPUError}} which indicates that there was not enough free
memory to complete the requested operation. The operation may succeed if attempted again with a
lower memory requirement (like using smaller texture dimensions), or if memory used by other
resources is released first.

<div algorithm>
To <dfn abstract-op lt="Generate an out-of-memory error|generate an out-of-memory error">
generate an out-of-memory error</dfn> for {{GPUDevice}} |device|, run the following steps:

<div data-timeline=content>
[=Content timeline=] steps:

1. Let |error| be a new {{GPUOutOfMemoryError}} with an appropriate error message.
1. [$Dispatch error$] |error| to |device|.
</div>
</div>

<script type=idl>
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUInternalError : GPUError {
constructor(DOMString message, optional GPUInternalErrorReason reason);

readonly attribute (GPUInternalErrorReason or undefined) reason;
constructor(DOMString message);
};
</script>

{{GPUInternalError}} is a subtype of {{GPUError}} which indicates than an operation failed for a
system or implementation-specific reason even when all validation requirements have been satisfied.
For example, the operation may exceede the capabilities of the implementation in a way not easily
For example, the operation may exceed the capabilities of the implementation in a way not easily
captured by the [=supported limits=]. The same operation may succeed on other devices or under
difference circumstances.

Internal errors must only be generated for operations that explicitly state the conditions one may
be generated under in their respective algorithms.

{{GPUInternalErrorReason}} defines possible reasons why a {{GPUInternalError}} occurred, though the
list is not exhaustive:

<dl dfn-type=enum-value dfn-for=GPUInternalErrorReason>
: <dfn>"out-of-memory"</dfn>
::
Indicate there was not enough free memory to complete the requested operation. The operation
may succeed if attempted again with a lower memory requirement (like using smaller texture
dimensions), or if memory used by other resources is released first.
</dl>

{{GPUInternalError}} has the following attributes:

<dl dfn-type=attribute dfn-for=GPUInternalError>
: <dfn>reason</dfn>
::
The reason the internal error was generated, if known. If a reason is not known or not
one of the available {{GPUInternalErrorReason}} options, must be `undefined`.
</dl>

<div algorithm>
To <dfn abstract-op lt="Generate an internal error|generate an internal error">generate an
internal error</dfn> with ({{GPUInternalErrorReason}} or undefined) |reason| for {{GPUDevice}} |device|, run
the following steps:
internal error</dfn> for {{GPUDevice}} |device|, run the following steps:

<div data-timeline=content>
[=Content timeline=] steps:

1. Let |error| be a new {{GPUInternalError}} with an appropriate error message.
1. Set |error|.{{GPUInternalError/reason}} to |reason|.
1. [$Dispatch error$] |error| to |device|.
</div>
</div>
Expand All @@ -12991,6 +12987,7 @@ of WebGPU calls, typically for debugging purposes or to make an operation more f
<script type=idl>
enum GPUErrorFilter {
"validation",
"out-of-memory",
"internal"
};

Expand All @@ -13006,11 +13003,15 @@ partial interface GPUDevice {
<dl dfn-type=enum-value dfn-for=GPUErrorFilter>
: <dfn>"validation"</dfn>
::
Indicates that the error scope catches {{GPUValidationError}}s.
Indicates that the error scope will catch a {{GPUValidationError}}.

: <dfn>"out-of-memory"</dfn>
::
Indicates that the error scope will catch a {{GPUOutOfMemoryError}}.

: <dfn>"internal"</dfn>
::
Indicates that the error scope catches {{GPUInternalError}}s.
Indicates that the error scope will catch a {{GPUInternalError}}.
</dl>

{{GPUDevice}} has the following internal slots:
Expand All @@ -13033,6 +13034,8 @@ partial interface GPUDevice {
<dl class=switch>
: {{GPUValidationError}}
:: Let |type| be "validation".
: {{GPUOutOfMemoryError}}
:: Let |type| be "out-of-memory".
: {{GPUInternalError}}
:: Let |type| be "internal".
</dl>
Expand Down

0 comments on commit 94bf9a4

Please sign in to comment.