tint: Support @diagnostic on continuing statements

Bug: tint:1809
Change-Id: I01725dc3b5aa3a91f7a3d3b0077667a1072debce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124360
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2023-03-16 18:19:25 +00:00
committed by Dawn LUCI CQ
parent abe6db26d2
commit 498e91826e
12 changed files with 266 additions and 4 deletions

View File

@@ -0,0 +1,9 @@
@fragment
fn main(@location(0) x : f32) {
loop {
continuing @diagnostic(warning, derivative_uniformity) {
_ = dpdx(1.0);
break if x > 0.0;
}
}
}

View File

@@ -0,0 +1,28 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
struct tint_symbol_1 {
float x : TEXCOORD0;
};
void main_inner(float x) {
while (true) {
{
if ((x > 0.0f)) { break; }
}
}
}
void main(tint_symbol_1 tint_symbol) {
main_inner(tint_symbol.x);
return;
}

View File

@@ -0,0 +1,28 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
struct tint_symbol_1 {
float x : TEXCOORD0;
};
void main_inner(float x) {
while (true) {
{
if ((x > 0.0f)) { break; }
}
}
}
void main(tint_symbol_1 tint_symbol) {
main_inner(tint_symbol.x);
return;
}

View File

@@ -0,0 +1,28 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
#version 310 es
precision highp float;
layout(location = 0) in float x_1;
void tint_symbol(float x) {
while (true) {
{
if ((x > 0.0f)) { break; }
}
}
}
void main() {
tint_symbol(x_1);
return;
}

View File

@@ -0,0 +1,32 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
#include <metal_stdlib>
using namespace metal;
struct tint_symbol_2 {
float x [[user(locn0)]];
};
void tint_symbol_inner(float x) {
while (true) {
{
if ((x > 0.0f)) { break; }
}
}
}
fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) {
tint_symbol_inner(tint_symbol_1.x);
return;
}

View File

@@ -0,0 +1,55 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 21
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %x_1
OpExecutionMode %main OriginUpperLeft
OpName %x_1 "x_1"
OpName %main_inner "main_inner"
OpName %x "x"
OpName %main "main"
OpDecorate %x_1 Location 0
%float = OpTypeFloat 32
%_ptr_Input_float = OpTypePointer Input %float
%x_1 = OpVariable %_ptr_Input_float Input
%void = OpTypeVoid
%4 = OpTypeFunction %void %float
%13 = OpConstantNull %float
%bool = OpTypeBool
%16 = OpTypeFunction %void
%main_inner = OpFunction %void None %4
%x = OpFunctionParameter %float
%8 = OpLabel
OpBranch %9
%9 = OpLabel
OpLoopMerge %10 %11 None
OpBranch %12
%12 = OpLabel
OpBranch %11
%11 = OpLabel
%14 = OpFOrdGreaterThan %bool %x %13
OpBranchConditional %14 %10 %9
%10 = OpLabel
OpReturn
OpFunctionEnd
%main = OpFunction %void None %16
%18 = OpLabel
%20 = OpLoad %float %x_1
%19 = OpFunctionCall %void %main_inner %20
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,22 @@
diagnostic_filtering/loop_continuing_attribute.wgsl:5:11 warning: 'dpdx' must only be called from uniform control flow
_ = dpdx(1.0);
^^^^^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:7 note: control flow depends on possibly non-uniform value
break if x > 0.0;
^^^^^
diagnostic_filtering/loop_continuing_attribute.wgsl:6:16 note: user-defined input 'x' of 'main' may be non-uniform
break if x > 0.0;
^
@fragment
fn main(@location(0) x : f32) {
loop {
continuing @diagnostic(warning, derivative_uniformity) {
_ = dpdx(1.0);
break if (x > 0.0);
}
}
}