-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlykind: diagnosticsError message should be betterError message should be betterlang: WGSLWebGPU Shading LanguageWebGPU Shading LanguagenagaShader TranslatorShader Translator
Description
We currently do not support the @diagnostic(…)
attribute/diagnostic(…)
directive (AKA "diagnostic filters" in the WebGPU spec.). This is a rather complicated subsystem, but it's exciting to have robust management of diagnostics in WGSL a la Rust. An example of how this is used from the spec.:
EXAMPLE: Global diagnostic filter for derivative uniformity
diagnostic(off,derivative_uniformity); var<private> d: f32; fn helper() -> vec4<f32> { if (d < 0.5) { // The derivative_uniformity diagnostic is disabled here // by the global diagnostic filter. return textureSample(t,s,vec2(0,0)); } else { // The derivative_uniformity diagnostic is set to 'warning' severity. @diagnostic(warning,derivative_uniformity) { return textureSample(t,s,vec2(0,0)); } } return vec4(0.0); }
Relevant part of the spec.: Diagnostics, section 2.3
An initial implementation of this should include the derivative_uniformity
rule, as the only current example of filterable trigger rules that can be managed per the spec.
Parse paths that we need to support to be spec.-compliant:
- Directive: WGSL: Implement
diagnostic(…);
directives andderivative_uniformity
triggering rule #6148 - Attributes placements (pasted from the spec.):
- Beginning of a compound statement.
- Beginning of a function declaration: feat(wgsl-in): parse
diagnostic(…)
attributes onfn
s #6353 - Beginning of an
if
statement. - Beginning of a
switch statement
. - Beginning of a
switch_body
. - Beginning of a
loop
statement. - Beginning of a
while
statement. - Beginning of a
for
statement. - Immediately before the opening brace ('{') of the loop body of a loop, while, or for loop.
- Beginning of a
continuing_compound_statement
.
Metadata
Metadata
Assignees
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlykind: diagnosticsError message should be betterError message should be betterlang: WGSLWebGPU Shading LanguageWebGPU Shading LanguagenagaShader TranslatorShader Translator
Type
Projects
Status
Done