Move tint::transform::Robustness to a santizier transform

There's no good reason for this to be public.
Move it into the writers, and expose a 'disable_robustness' option to
turn it off. This can be expanded to hold more fine-grain control in the
future.

Change-Id: I6ea6e54a27b2ae0fbcba5fdf45539063045cc15a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122203
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Ben Clayton
2023-03-02 20:48:48 +00:00
committed by Dawn LUCI CQ
parent 902c9e5726
commit 03de0e83ae
201 changed files with 2208 additions and 2204 deletions

View File

@@ -10,6 +10,5 @@ int4 tint_div(int4 lhs, int4 rhs) {
}
void foo() {
const int4 tint_symbol = tint_div(asint(v.Load4(0u)), (2).xxxx);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_div(asint(v.Load4(0u)), (2).xxxx)));
}

View File

@@ -10,6 +10,5 @@ int4 tint_div(int4 lhs, int4 rhs) {
}
void foo() {
const int4 tint_symbol = tint_div(asint(v.Load4(0u)), (2).xxxx);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_div(asint(v.Load4(0u)), (2).xxxx)));
}

View File

@@ -17,7 +17,6 @@ ivec4 tint_div(ivec4 lhs, ivec4 rhs) {
}
void foo() {
ivec4 tint_symbol = tint_div(v.inner.a, ivec4(2));
v.inner.a = tint_symbol;
v.inner.a = tint_div(v.inner.a, ivec4(2));
}

View File

@@ -9,8 +9,7 @@ int4 tint_div(int4 lhs, int4 rhs) {
return (lhs / select(rhs, int4(1), ((rhs == int4(0)) | ((lhs == int4((-2147483647 - 1))) & (rhs == int4(-1))))));
}
void foo(device S* const tint_symbol_1) {
int4 const tint_symbol = tint_div((*(tint_symbol_1)).a, int4(2));
(*(tint_symbol_1)).a = tint_symbol;
void foo(device S* const tint_symbol) {
(*(tint_symbol)).a = tint_div((*(tint_symbol)).a, int4(2));
}

View File

@@ -44,7 +44,7 @@
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
%41 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%42 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%unused_entry_point = OpFunction %void None %7
%10 = OpLabel
OpReturn
@@ -64,10 +64,10 @@
OpFunctionEnd
%foo = OpFunction %void None %7
%33 = OpLabel
%38 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%39 = OpLoad %v4int %38
%34 = OpFunctionCall %v4int %tint_div %39 %41
%42 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
OpStore %42 %34
%37 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%39 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%40 = OpLoad %v4int %39
%38 = OpFunctionCall %v4int %tint_div %40 %42
OpStore %37 %38
OpReturn
OpFunctionEnd

View File

@@ -16,6 +16,5 @@ int4 tint_mod(int4 lhs, int rhs) {
}
void foo() {
const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), 2);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), 2)));
}

View File

@@ -16,6 +16,5 @@ int4 tint_mod(int4 lhs, int rhs) {
}
void foo() {
const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), 2);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), 2)));
}

View File

@@ -23,7 +23,6 @@ ivec4 tint_mod(ivec4 lhs, int rhs) {
}
void foo() {
ivec4 tint_symbol = tint_mod(v.inner.a, 2);
v.inner.a = tint_symbol;
v.inner.a = tint_mod(v.inner.a, 2);
}

View File

@@ -15,8 +15,7 @@ int4 tint_mod(int4 lhs, int rhs) {
}
}
void foo(device S* const tint_symbol_1) {
int4 const tint_symbol = tint_mod((*(tint_symbol_1)).a, 2);
(*(tint_symbol_1)).a = tint_symbol;
void foo(device S* const tint_symbol) {
(*(tint_symbol)).a = tint_mod((*(tint_symbol)).a, 2);
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 65
; Bound: 58
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs "lhs"
OpName %rhs "rhs"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpDecorate %v_block Block
OpMemberDecorate %v_block 0 Offset 0
@@ -33,24 +31,20 @@
%void = OpTypeVoid
%7 = OpTypeFunction %void
%11 = OpTypeFunction %v4int %v4int %int
%18 = OpConstantNull %v4int
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%19 = OpConstantNull %bool
%_ptr_Function_v4int = OpTypePointer Function %v4int
%22 = OpConstantNull %v4int
%v4bool = OpTypeVector %bool 4
%int_n2147483648 = OpConstant %int -2147483648
%28 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%23 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%int_n1 = OpConstant %int -1
%31 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%26 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%int_1 = OpConstant %int 1
%36 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%31 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4
%uint_2147483648 = OpConstant %uint 2147483648
%43 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
%45 = OpConstantNull %v4uint
%true = OpConstantTrue %bool
%38 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
%40 = OpConstantNull %v4uint
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
@@ -62,44 +56,37 @@
%lhs = OpFunctionParameter %v4int
%rhs = OpFunctionParameter %int
%15 = OpLabel
%tint_return_flag = OpVariable %_ptr_Function_bool Function %19
%tint_return_value = OpVariable %_ptr_Function_v4int Function %22
%23 = OpCompositeConstruct %v4int %rhs %rhs %rhs %rhs
%25 = OpIEqual %v4bool %23 %22
%29 = OpIEqual %v4bool %lhs %28
%32 = OpIEqual %v4bool %23 %31
%33 = OpLogicalAnd %v4bool %29 %32
%34 = OpLogicalOr %v4bool %25 %33
%24 = OpSelect %v4int %34 %36 %23
%41 = OpBitwiseOr %v4int %lhs %24
%38 = OpBitcast %v4uint %41
%44 = OpBitwiseAnd %v4uint %38 %43
%46 = OpINotEqual %v4bool %44 %45
%37 = OpAny %bool %46
OpSelectionMerge %47 None
OpBranchConditional %37 %48 %49
%48 = OpLabel
OpStore %tint_return_flag %true
%51 = OpSDiv %v4int %lhs %24
%52 = OpIMul %v4int %51 %24
%53 = OpISub %v4int %lhs %52
OpStore %tint_return_value %53
OpBranch %47
%49 = OpLabel
OpStore %tint_return_flag %true
%54 = OpSRem %v4int %lhs %24
OpStore %tint_return_value %54
OpBranch %47
%47 = OpLabel
%55 = OpLoad %v4int %tint_return_value
OpReturnValue %55
%16 = OpCompositeConstruct %v4int %rhs %rhs %rhs %rhs
%19 = OpIEqual %v4bool %16 %18
%24 = OpIEqual %v4bool %lhs %23
%27 = OpIEqual %v4bool %16 %26
%28 = OpLogicalAnd %v4bool %24 %27
%29 = OpLogicalOr %v4bool %19 %28
%17 = OpSelect %v4int %29 %31 %16
%36 = OpBitwiseOr %v4int %lhs %17
%33 = OpBitcast %v4uint %36
%39 = OpBitwiseAnd %v4uint %33 %38
%41 = OpINotEqual %v4bool %39 %40
%32 = OpAny %bool %41
OpSelectionMerge %42 None
OpBranchConditional %32 %43 %44
%43 = OpLabel
%45 = OpSDiv %v4int %lhs %17
%46 = OpIMul %v4int %45 %17
%47 = OpISub %v4int %lhs %46
OpReturnValue %47
%44 = OpLabel
%48 = OpSRem %v4int %lhs %17
OpReturnValue %48
%42 = OpLabel
OpReturnValue %18
OpFunctionEnd
%foo = OpFunction %void None %7
%57 = OpLabel
%61 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%62 = OpLoad %v4int %61
%58 = OpFunctionCall %v4int %tint_mod %62 %int_2
%64 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
OpStore %64 %58
%50 = OpLabel
%53 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%55 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%56 = OpLoad %v4int %55
%54 = OpFunctionCall %v4int %tint_mod %56 %int_2
OpStore %53 %54
OpReturn
OpFunctionEnd

View File

@@ -15,6 +15,5 @@ int4 tint_mod(int4 lhs, int4 rhs) {
}
void foo() {
const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), (2).xxxx);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), (2).xxxx)));
}

View File

@@ -15,6 +15,5 @@ int4 tint_mod(int4 lhs, int4 rhs) {
}
void foo() {
const int4 tint_symbol = tint_mod(asint(v.Load4(0u)), (2).xxxx);
v.Store4(0u, asuint(tint_symbol));
v.Store4(0u, asuint(tint_mod(asint(v.Load4(0u)), (2).xxxx)));
}

View File

@@ -22,7 +22,6 @@ ivec4 tint_mod(ivec4 lhs, ivec4 rhs) {
}
void foo() {
ivec4 tint_symbol = tint_mod(v.inner.a, ivec4(2));
v.inner.a = tint_symbol;
v.inner.a = tint_mod(v.inner.a, ivec4(2));
}

View File

@@ -14,8 +14,7 @@ int4 tint_mod(int4 lhs, int4 rhs) {
}
}
void foo(device S* const tint_symbol_1) {
int4 const tint_symbol = tint_mod((*(tint_symbol_1)).a, int4(2));
(*(tint_symbol_1)).a = tint_symbol;
void foo(device S* const tint_symbol) {
(*(tint_symbol)).a = tint_mod((*(tint_symbol)).a, int4(2));
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 65
; Bound: 58
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -16,8 +16,6 @@
OpName %tint_mod "tint_mod"
OpName %lhs "lhs"
OpName %rhs "rhs"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %foo "foo"
OpDecorate %v_block Block
OpMemberDecorate %v_block 0 Offset 0
@@ -33,28 +31,24 @@
%void = OpTypeVoid
%7 = OpTypeFunction %void
%11 = OpTypeFunction %v4int %v4int %v4int
%17 = OpConstantNull %v4int
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%19 = OpConstantNull %bool
%_ptr_Function_v4int = OpTypePointer Function %v4int
%22 = OpConstantNull %v4int
%v4bool = OpTypeVector %bool 4
%int_n2147483648 = OpConstant %int -2147483648
%27 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%22 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648
%int_n1 = OpConstant %int -1
%30 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%25 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1
%int_1 = OpConstant %int 1
%35 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%30 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4
%uint_2147483648 = OpConstant %uint 2147483648
%42 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
%44 = OpConstantNull %v4uint
%true = OpConstantTrue %bool
%37 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648
%39 = OpConstantNull %v4uint
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int
%int_2 = OpConstant %int 2
%63 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%57 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2
%unused_entry_point = OpFunction %void None %7
%10 = OpLabel
OpReturn
@@ -63,43 +57,36 @@
%lhs = OpFunctionParameter %v4int
%rhs = OpFunctionParameter %v4int
%15 = OpLabel
%tint_return_flag = OpVariable %_ptr_Function_bool Function %19
%tint_return_value = OpVariable %_ptr_Function_v4int Function %22
%24 = OpIEqual %v4bool %rhs %22
%28 = OpIEqual %v4bool %lhs %27
%31 = OpIEqual %v4bool %rhs %30
%32 = OpLogicalAnd %v4bool %28 %31
%33 = OpLogicalOr %v4bool %24 %32
%23 = OpSelect %v4int %33 %35 %rhs
%40 = OpBitwiseOr %v4int %lhs %23
%37 = OpBitcast %v4uint %40
%43 = OpBitwiseAnd %v4uint %37 %42
%45 = OpINotEqual %v4bool %43 %44
%36 = OpAny %bool %45
OpSelectionMerge %46 None
OpBranchConditional %36 %47 %48
%47 = OpLabel
OpStore %tint_return_flag %true
%50 = OpSDiv %v4int %lhs %23
%51 = OpIMul %v4int %50 %23
%52 = OpISub %v4int %lhs %51
OpStore %tint_return_value %52
OpBranch %46
%48 = OpLabel
OpStore %tint_return_flag %true
%53 = OpSRem %v4int %lhs %23
OpStore %tint_return_value %53
OpBranch %46
%46 = OpLabel
%54 = OpLoad %v4int %tint_return_value
OpReturnValue %54
%18 = OpIEqual %v4bool %rhs %17
%23 = OpIEqual %v4bool %lhs %22
%26 = OpIEqual %v4bool %rhs %25
%27 = OpLogicalAnd %v4bool %23 %26
%28 = OpLogicalOr %v4bool %18 %27
%16 = OpSelect %v4int %28 %30 %rhs
%35 = OpBitwiseOr %v4int %lhs %16
%32 = OpBitcast %v4uint %35
%38 = OpBitwiseAnd %v4uint %32 %37
%40 = OpINotEqual %v4bool %38 %39
%31 = OpAny %bool %40
OpSelectionMerge %41 None
OpBranchConditional %31 %42 %43
%42 = OpLabel
%44 = OpSDiv %v4int %lhs %16
%45 = OpIMul %v4int %44 %16
%46 = OpISub %v4int %lhs %45
OpReturnValue %46
%43 = OpLabel
%47 = OpSRem %v4int %lhs %16
OpReturnValue %47
%41 = OpLabel
OpReturnValue %17
OpFunctionEnd
%foo = OpFunction %void None %7
%56 = OpLabel
%60 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%61 = OpLoad %v4int %60
%57 = OpFunctionCall %v4int %tint_mod %61 %63
%64 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
OpStore %64 %57
%49 = OpLabel
%52 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%54 = OpAccessChain %_ptr_StorageBuffer_v4int %v %uint_0 %uint_0
%55 = OpLoad %v4int %54
%53 = OpFunctionCall %v4int %tint_mod %55 %57
OpStore %52 %53
OpReturn
OpFunctionEnd