Skip to content

Commit fe9b7c8

Browse files
committed
Clarify most errors are not filterable
- Detectable errors will generate diagnostics. - Most diagnostics are not filterable. They can only be so if triggered by one of a few enumerated filterable triggering rules. - Fix the description of where diagnostics go if processing during shader-creaiton or pipeline-creation.
1 parent a33585c commit fe9b7c8

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

wgsl/index.bs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,18 @@ When unclear from context, this specification indicates
453453
whether failure to meet a particular requirement
454454
results in a shader-creation, pipeline-creation, or dynamic error.
455455

456-
The WebGPU specification describes the consequences of each kind of error.
457-
A WGSL program with a [=shader-creation error=] or [=pipeline-creation error=] error will not be incorporated
458-
into a [=pipeline=] and hence will not be executed.
456+
The WebGPU specification describes the consequences of each kind of error. In particular:
457+
* Detectable errors [=behavioral requirement|will=] [=triggered|trigger=] a [=diagnostic=].
458+
* A WGSL program with a [=shader-creation error=] or [=pipeline-creation error=] error will not be incorporated
459+
into a [=pipeline=] and hence will not be executed.
459460

460461
## Diagnostics ## {#diagnostics}
461462

462-
An implementation can generate [=diagnostics=] during [=shader module creation=].
463+
An implementation can generate [=diagnostics=] during [=shader module creation=] or [=pipeline creation=].
463464
A <dfn noexport>diagnostic</dfn> is a message produced by the implementation for the benefit of the application author.
464465

465-
We say a diagnostic is <dfn noexport>triggered</dfn> when a particular condition is met, known as the [=diagnostic/triggering rule=].
466+
A diagnostic is created, or <dfn noexport>triggered</dfn>, when a particular condition is met,
467+
known as the <dfn dfn-for="diagnostic">triggering rule</dfn>.
466468
The place in the source text where the condition is met, expressed as a point or range in the source text, is known as the
467469
<dfn dfn-for="diagnostic">triggering location</dfn>.
468470

@@ -483,32 +485,34 @@ The <dfn dfn-for="diagnostic">severity</dfn> of a diagnostic is one of:
483485
This is the lowest severity.
484486

485487
Triggered diagnostics [=behavioral requirement|will=] be processed as follows:
486-
1. If a [=shader-creation error=] occurs independently of diagnostic processing, then all diagnostics may be discarded.
487-
2. For each diagnostic *D*, find the [=diagnostic filter=]
488+
1. For each diagnostic *D*, find the [=diagnostic filter=]
488489
with the smallest [=affected range=] that contains D's [=diagnostic/triggering location=], and which has the same [=diagnostic/triggering rule=].
489490
* If such a rule exists, apply it to *D*. This may discard *D* or change *D*'s [=diagnostic/severity=].
490491
* Otherwise *D* remains unchanged.
491-
3. If at least one remaining diagnostic has [=severity/error=] severity, then:
492+
2. If at least one remaining diagnostic has [=severity/error=] severity, then:
492493
* Other diagnostics *may* be discarded, including other diagnostics with [=severity/error=] severity.
493494
* A [=program error=] is generated.
494495
* The error is a [=shader-creation error=] if the diagnostic was triggered at [=shader module creation=] time.
495-
In this case, all remaining diagnostics are collected and made available to the application via the
496-
[[WebgPU#dom-gpucompilationinfo-messages|messages]] member of the [[WebGPU#gpucompilationinfo|WebGPU GPUCompilationInfo]] object.
497496
* The error is a [=pipeline-creation error=] if the diagnostic was triggered at [=pipeline creation=] time.
497+
3. If processing during [=shader module creation=] time, the remaining diagnostics populate the
498+
[[WebgPU#dom-gpucompilationinfo-messages|messages]] member of the
499+
[[WebGPU#gpucompilationinfo|WebGPU GPUCompilationInfo]] object.
500+
4. If processing during [=pipeline creation=], the [=severity/error=] diagnostics are reported
501+
in the nearest enclosing [[WebGPU#gpu-error-scope|WebGPU GPU errorr scope]].
502+
Issue: TODO: Adjust for [#3682](https://github.com/gpuweb/gpuweb/issues/3682).
498503

499-
Issue: TODO: Adjust for https://github.com/gpuweb/gpuweb/issues/3682
504+
Note: The rules allow an implementation to stop processing a WGSL program as soon as an error is detected.
500505

501-
Note: The rules allow an implementation to stop processing a WGSL program as soon as it encounters an error.
506+
### Filterable Triggering Rules ### {#filterable-triggering-rules}
502507

503-
### Diagnostic Triggering Rules ### {#diagnostic-triggering-rules}
504-
505-
A <dfn dfn-for="diagnostic">triggering rule</dfn> is condition on a source program that, when met, causes a [=diagnostic=] to be generated.
506-
The following table defines the standard triggering rules.
508+
Most [=diagnostics=] are unconditionally reported to the WebGPU application.
509+
Some kinds of diagnostics can be [[#diagnostic-filtering|filtered]], in part by naming their [=diagnostic/triggering rule=].
510+
The following table lists the standard set of triggering rules that can be filtered.
507511

508512
<table class='data'>
509513
<caption>Diagnostic triggering rules defined in WGSL</caption>
510514
<thead>
511-
<tr><th>Triggering rule<th>Default Severity<th>Triggering Location<th>Description
515+
<tr><th>Filterable Triggering Rule<th>Default Severity<th>Triggering Location<th>Description
512516
</thead>
513517

514518
<tr>
@@ -526,7 +530,8 @@ The following table defines the standard triggering rules.
526530
See [[#uniformity]].
527531
</table>
528532

529-
An implementation may support triggering rules not specified here, provided they are spelled differently from the standard triggering rules.
533+
An implementation may support filtering triggering rules not specified here,
534+
provided they are spelled differently from the standard triggering rules.
530535
A [=diagnostic filter=] with an unrecognized [=diagnostic/triggering rule=] [=behavioral requirement|will=] be ignored.
531536

532537
Future versions of this specification may remove a particular rule or weaken its default severity
@@ -536,7 +541,7 @@ After such a change to the specification, previously valid programs would remain
536541

537542
### Diagnostic Filtering ### {#diagnostic-filtering}
538543

539-
Once a [=diagnostic=] is [=triggered=], WGSL provides filtering mechanisms to discard the diagnostic, or to modify its severity.
544+
Once a [=diagnostic=] with a filterable [=diagnostic/triggering rule=] is [=triggered=], WGSL provides mechanisms to discard the diagnostic, or to modify its severity.
540545

541546
A <dfn noexport>diagnostic filter</dfn> *DF* has three parameters:
542547
* *AR*: a range of source text known as the <dfn noexport>affected range</dfn>
@@ -556,6 +561,8 @@ A range diagnostic filter is specified as a `@diagnostic` [=attribute=] immediat
556561
* When specified as one of the attributes immediately preceding a [=syntax/call_phrase=],
557562
the [=affected range=] is the entire phrase (e.g. including the function call arguments).
558563

564+
Issue: [#3689](https://github.com/gpuweb/gpuweb/issues/3689) Refine range diagnostic filters: where they can be applied, and associated affected ranges.
565+
559566
<div class='example wgsl global-scope' heading='Range diagnostic filter on texture sampling'>
560567
<xmp highlight='rust'>
561568
var<private> d: f32;
@@ -575,7 +582,7 @@ A range diagnostic filter is specified as a `@diagnostic` [=attribute=] immediat
575582
</div>
576583

577584
A <dfn noexport>global diagnostic filter</dfn> is a diagnostic filter whose [=affected range=] is the whole WGSL program.
578-
It is a [=directive=], thus appearing before any module-scope declarations.
585+
It is a [=directive=], thus appearing before any [=module-scope=] declarations.
579586
It is spelled like the attribute form, but without the leading `@` (U+0040) codepoint, and with a terminating semicolon.
580587

581588
<div class='example wgsl global-scope' heading='Global diagnostic filter for derivative uniformity'>

0 commit comments

Comments
 (0)