Import Tint changes from Dawn
Changes:
- bc970d479c66ec3236dac9ce21861abff2586892 [tint][fuzz] Generate `dictionary.txt` from .def files by Ben Clayton <bclayton@google.com>
- ba00f41c0e3365e638fee70983ca10ddfbe2a2ee [tint][gn] Fix naming of ClusterFuzz data files by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: bc970d479c66ec3236dac9ce21861abff2586892
Change-Id: I828b439e77e32a63108a2bbdeaf3917874889a4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/184245
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
diff --git a/src/tint/cmd/fuzz/wgsl/dictionary.txt b/src/tint/cmd/fuzz/wgsl/dictionary.txt
index 59742d7..cc0d9d3 100644
--- a/src/tint/cmd/fuzz/wgsl/dictionary.txt
+++ b/src/tint/cmd/fuzz/wgsl/dictionary.txt
@@ -1,3 +1,39 @@
+# Copyright 2024 The Dawn & Tint Authors
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+# src/tint/cmd/fuzz/wgsl/dictionary.txt.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+# Do not modify this file directly
+################################################################################
+
"!"
"!="
"%"
@@ -38,17 +74,48 @@
"^"
"^="
"_"
-"{"
-"|"
-"|="
-"||"
-"}"
-"~"
+"__atomic_compare_exchange_result"
+"__atomic_compare_exchange_result_i32"
+"__atomic_compare_exchange_result_u32"
+"__frexp_result"
+"__frexp_result_abstract"
+"__frexp_result_f16"
+"__frexp_result_f32"
+"__frexp_result_vec"
+"__frexp_result_vec2_abstract"
+"__frexp_result_vec2_f16"
+"__frexp_result_vec2_f32"
+"__frexp_result_vec3_abstract"
+"__frexp_result_vec3_f16"
+"__frexp_result_vec3_f32"
+"__frexp_result_vec4_abstract"
+"__frexp_result_vec4_f16"
+"__frexp_result_vec4_f32"
+"__in"
+"__modf_result"
+"__modf_result_abstract"
+"__modf_result_f16"
+"__modf_result_f32"
+"__modf_result_vec"
+"__modf_result_vec2_abstract"
+"__modf_result_vec2_f16"
+"__modf_result_vec2_f32"
+"__modf_result_vec3_abstract"
+"__modf_result_vec3_f16"
+"__modf_result_vec3_f32"
+"__modf_result_vec4_abstract"
+"__modf_result_vec4_f16"
+"__modf_result_vec4_f32"
+"__out"
+"__packed_vec3"
+"__point_size"
+"__tint_materialize"
"a"
"abs"
"acos"
"acosh"
-"@align"
+"alias"
+"align"
"all"
"any"
"array"
@@ -61,6 +128,8 @@
"atomic"
"atomicAdd"
"atomicAnd"
+"atomicCompareExchangeWeak"
+"atomicExchange"
"atomicLoad"
"atomicMax"
"atomicMin"
@@ -69,31 +138,35 @@
"atomicSub"
"atomicXor"
"b"
-"@binding"
+"bgra8unorm"
+"binding"
"bitcast"
+"blend_src"
"bool"
"break"
-"@builtin"
-"@builtin(frag_depth)"
-"@builtin(front_facing)"
-"@builtin(global_invocation_id)"
-"@builtin(instance_index)"
-"@builtin(local_invocation_id)"
-"@builtin(local_invocation_index)"
-"@builtin(num_workgroups)"
-"@builtin(position)"
-"@builtin(sample_index)"
-"@builtin(sample_mask)"
-"@builtin(vertex_index)"
-"@builtin(workgroup_id)"
+"builtin"
"case"
"ceil"
"center"
"centroid"
+"chromium_disable_uniformity_analysis"
+"chromium_experimental_framebuffer_fetch"
+"chromium_experimental_pixel_local"
+"chromium_experimental_push_constant"
+"chromium_experimental_subgroups"
+"chromium_internal_dual_source_blending"
+"chromium_internal_graphite"
+"chromium_internal_relaxed_uniform_layout"
+"chromium_testing_experimental"
+"chromium_testing_shipped"
+"chromium_testing_shipped_with_killswitch"
+"chromium_testing_unimplemented"
+"chromium_testing_unsafe_experimental"
"clamp"
-"@compute"
-"@const"
+"color"
+"compute"
"const"
+"const_assert"
"continue"
"continuing"
"cos"
@@ -104,7 +177,9 @@
"cross"
"default"
"degrees"
+"derivative_uniformity"
"determinant"
+"diagnostic"
"discard"
"distance"
"dot"
@@ -118,11 +193,13 @@
"dpdyFine"
"else"
"enable"
+"error"
"exp"
"exp2"
"extractBits"
"f16"
"f32"
+"fa"
"faceForward"
"fallthrough"
"false"
@@ -135,7 +212,7 @@
"for"
"fract"
"frag_depth"
-"@fragment"
+"fragment"
"frexp"
"front_facing"
"function"
@@ -144,14 +221,17 @@
"fwidthFine"
"g"
"global_invocation_id"
-"@group"
+"group"
+"handle"
"i32"
-"@id"
+"ia"
+"id"
"if"
+"info"
"insertBits"
"instance_index"
-"@interpolate"
-"@invariant"
+"interpolate"
+"invariant"
"inverseSqrt"
"ldexp"
"length"
@@ -159,46 +239,80 @@
"linear"
"local_invocation_id"
"local_invocation_index"
-"@location"
+"location"
"log"
"log2"
"loop"
+"mat"
"mat2x2"
+"mat2x2f"
+"mat2x2h"
"mat2x3"
+"mat2x3f"
+"mat2x3h"
"mat2x4"
+"mat2x4f"
+"mat2x4h"
"mat3x2"
+"mat3x2f"
+"mat3x2h"
"mat3x3"
+"mat3x3f"
+"mat3x3h"
"mat3x4"
+"mat3x4f"
+"mat3x4h"
"mat4x2"
+"mat4x2f"
+"mat4x2h"
"mat4x3"
+"mat4x3f"
+"mat4x3h"
"mat4x4"
+"mat4x4f"
+"mat4x4h"
"max"
"min"
"mix"
"modf"
+"must_use"
"normalize"
"num_workgroups"
+"off"
"override"
"pack2x16float"
"pack2x16snorm"
"pack2x16unorm"
"pack4x8snorm"
"pack4x8unorm"
+"pack4xI8"
+"pack4xI8Clamp"
+"pack4xU8"
+"pack4xU8Clamp"
+"packedVec3"
+"packed_4x8_integer_dot_product"
"perspective"
+"pixel_local"
+"pointer_composite_access"
"position"
"pow"
"private"
"ptr"
+"push_constant"
"quantizeToF16"
"r"
"r32float"
"r32sint"
"r32uint"
+"r8unorm"
"radians"
"read"
"read_write"
+"readonly_and_readwrite_storage_textures"
+"ref"
"reflect"
"refract"
+"requires"
"return"
"reverseBits"
"rg32float"
@@ -225,17 +339,36 @@
"sign"
"sin"
"sinh"
-"@size"
+"size"
"smoothstep"
"sqrt"
-"staticAssert"
"step"
"storage"
"storageBarrier"
"struct"
+"subgroupBallot"
+"subgroupBroadcast"
+"subgroup_invocation_id"
+"subgroup_size"
"switch"
"tan"
"tanh"
+"textureBarrier"
+"textureDimensions"
+"textureGather"
+"textureGatherCompare"
+"textureLoad"
+"textureNumLayers"
+"textureNumLevels"
+"textureNumSamples"
+"textureSample"
+"textureSampleBaseClampToEdge"
+"textureSampleBias"
+"textureSampleCompare"
+"textureSampleCompareLevel"
+"textureSampleGrad"
+"textureSampleLevel"
+"textureStore"
"texture_1d"
"texture_2d"
"texture_2d_array"
@@ -247,29 +380,15 @@
"texture_depth_cube"
"texture_depth_cube_array"
"texture_depth_multisampled_2d"
-"textureDimensions"
-"textureGather"
-"textureGatherCompare"
-"textureLoad"
+"texture_external"
"texture_multisampled_2d"
-"textureNumLayers"
-"textureNumLevels"
-"textureNumSamples"
-"textureSample"
-"textureSampleBias"
-"textureSampleCompare"
-"textureSampleCompareLevel"
-"textureSampleGrad"
-"textureSampleLevel"
"texture_storage_1d"
"texture_storage_2d"
"texture_storage_2d_array"
"texture_storage_3d"
-"textureStore"
"transpose"
"true"
"trunc"
-"type"
"u32"
"uniform"
"unpack2x16float"
@@ -277,20 +396,44 @@
"unpack2x16unorm"
"unpack4x8snorm"
"unpack4x8unorm"
+"unpack4xI8"
+"unpack4xU8"
+"unreachable_code"
+"unrestricted_pointer_parameters"
"var"
+"vec"
"vec2"
+"vec2f"
+"vec2h"
+"vec2i"
+"vec2u"
"vec3"
+"vec3f"
+"vec3h"
+"vec3i"
+"vec3u"
"vec4"
-"@vertex"
+"vec4f"
+"vec4h"
+"vec4i"
+"vec4u"
+"vertex"
"vertex_index"
"w"
+"warning"
"while"
"workgroup"
"workgroupBarrier"
"workgroupUniformLoad"
"workgroup_id"
-"@workgroup_size"
+"workgroup_size"
"write"
"x"
"y"
"z"
+"{"
+"|"
+"|="
+"||"
+"}"
+"~"
diff --git a/src/tint/cmd/fuzz/wgsl/dictionary.txt.tmpl b/src/tint/cmd/fuzz/wgsl/dictionary.txt.tmpl
new file mode 100644
index 0000000..5ffad37
--- /dev/null
+++ b/src/tint/cmd/fuzz/wgsl/dictionary.txt.tmpl
@@ -0,0 +1,129 @@
+{{- /*
+--------------------------------------------------------------------------------
+Template file for use with tools/src/cmd/gen to generate dictionary.txt
+
+To update the generated file, run:
+ ./tools/run gen
+
+See:
+* tools/src/cmd/gen for structures used by this template
+* https://golang.org/pkg/text/template/ for documentation on the template syntax
+--------------------------------------------------------------------------------
+*/ -}}
+
+{{- SetCommentPrefix "#" -}}
+{{- $W := LoadIntrinsics "src/tint/lang/wgsl/wgsl.def" -}}
+{{- $C := LoadIntrinsics "src/tint/lang/core/core.def" -}}
+
+{{- $tokens := List}}
+
+{{- /* ============================== Operators ============================== */ -}}
+{{- $tokens = Append $tokens
+ "!"
+ "!="
+ "%"
+ "%="
+ "&"
+ "&&"
+ "&="
+ "("
+ ")"
+ "*"
+ "*="
+ "+"
+ "++"
+ "+="
+ ","
+ "-"
+ "--"
+ "-="
+ "->"
+ "."
+ "/"
+ "/="
+ ":"
+ ";"
+ "<"
+ "<<"
+ "<<="
+ "<="
+ "="
+ "=="
+ ">"
+ ">="
+ ">>"
+ ">>="
+ "@"
+ "["
+ "]"
+ "^"
+ "^="
+ "_"
+ "{"
+ "|"
+ "|="
+ "||"
+ "}"
+ "~"
+ "alias"
+ "break"
+ "case"
+ "const"
+ "const_assert"
+ "continue"
+ "continuing"
+ "diagnostic"
+ "discard"
+ "default"
+ "else"
+ "enable"
+ "fallthrough"
+ "false"
+ "fn"
+ "for"
+ "if"
+ "let"
+ "loop"
+ "override"
+ "return"
+ "requires"
+ "struct"
+ "switch"
+ "true"
+ "var"
+ "while"
+-}}
+
+{{- /* ============================== Swizzles =============================== */ -}}
+{{- $tokens = Append $tokens
+ "x" "y" "z" "w"
+ "r" "g" "b" "a"
+-}}
+
+{{- /* ============================ Boolean values =========================== */ -}}
+{{- $tokens = Append $tokens
+ "true" "false"
+-}}
+
+{{- /* ========================== Builtin functions ========================== */ -}}
+{{- range $W.Sem.Builtins}}{{$tokens = Append $tokens .Name}}{{end -}}
+
+{{- /* ================================ Types ================================ */ -}}
+{{- range $W.Sem.Types}}{{$tokens = Append $tokens .Name}}{{end -}}
+
+{{- /* ============================= Enumerators ============================= */ -}}
+{{- range $W.Sem.Enums}}
+ {{- range .Entries}}
+ {{- $tokens = Append $tokens .Name}}
+ {{- end}}
+{{- end}}
+{{- range $C.Sem.Enums}}
+ {{- range .Entries}}
+ {{- $tokens = Append $tokens .Name}}
+ {{- end}}
+{{- end}}
+
+{{- $tokens = SortUnique $tokens}}
+
+{{- range $tokens}}"{{.}}"
+{{end -}}
diff --git a/src/tint/tint.gni b/src/tint/tint.gni
index b284b4b..bf48aae 100644
--- a/src/tint/tint.gni
+++ b/src/tint/tint.gni
@@ -164,8 +164,22 @@
}
template("tint_fuzzer_test") {
- fuzzer_test(target_name) {
- forward_variables_from(invoker, "*")
+ # fuzzer_test.gni doesn't handle targets that use 'output_name' correctly.
+ # It will build an executable with the requested name, but the ClusterFuzz
+ # data files (corpus, dictionary, options, owners, runtime_deps) will all
+ # use the target name for their output file names, and these will not be
+ # used by ClusterFuzz.
+ # To work around this, if an 'output_name' is specified, pass the
+ # 'output_name' to fuzzer_test() as the target name, then make a proxy
+ # 'target_name' group that depends on the fuzzer target.
+ if (defined(invoker.output_name)) {
+ fuzzer_name = invoker.output_name
+ } else {
+ fuzzer_name = target_name
+ }
+
+ fuzzer_test(fuzzer_name) {
+ forward_variables_from(invoker, "*", [ "output_name" ])
exclude_main = false
if (target_name == "wgsl") {
@@ -181,6 +195,13 @@
assert(false, "unsupported tint fuzzer target")
}
}
+
+ if (fuzzer_name != target_name) {
+ group(target_name) {
+ testonly = true
+ deps = [ ":${fuzzer_name}" ]
+ }
+ }
}
} else {
template("tint_fuzz_source_set") {