diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 7a18e17b96..f2b4d7e650 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -445,7 +445,7 @@ fn arrayLength(ptr, A>) -> u32 fn determinant(mat) -> T fn distance(T, T) -> T fn distance(vec, vec) -> T -fn dot(vec, vec) -> T +@const fn dot(vec, vec) -> T fn dot4I8Packed(u32, u32) -> i32 fn dot4U8Packed(u32, u32) -> u32 @stage("fragment") fn dpdx(f32) -> f32 diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 0de24114bc..9fc6090c9c 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -2062,7 +2062,7 @@ TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) { R"(error: no matching call to dot(f32, f32) 1 candidate function: - dot(vecN, vecN) -> T where: T is f32, i32, u32 or f16 + dot(vecN, vecN) -> T where: T is abstract-float, abstract-int, f32, i32, u32 or f16 )"); } diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 9275ef32c4..28e100ea1f 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1969,6 +1969,36 @@ ConstEval::Result ConstEval::degrees(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0]); } +ConstEval::Result ConstEval::dot(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto calculate = [&]() -> ImplResult { + auto* v1 = args[0]; + auto* v2 = args[1]; + auto* vec_ty = v1->Type()->As(); + switch (vec_ty->Width()) { + case 2: + return Dispatch_fia_fiu32_f16(Dot2Func(source, ty), v1->Index(0), v1->Index(1), + v2->Index(0), v2->Index(1)); + case 3: + return Dispatch_fia_fiu32_f16(Dot3Func(source, ty), v1->Index(0), v1->Index(1), + v1->Index(2), v2->Index(0), v2->Index(1), + v2->Index(2)); + case 4: + return Dispatch_fia_fiu32_f16(Dot4Func(source, ty), v1->Index(0), v1->Index(1), + v1->Index(2), v1->Index(3), v2->Index(0), + v2->Index(1), v2->Index(2), v2->Index(3)); + } + TINT_ICE(Resolver, builder.Diagnostics()) << "Expected scalar or vector"; + return utils::Failure; + }; + auto r = calculate(); + if (!r) { + AddNote("when calculating dot", source); + } + return r; +} + ConstEval::Result ConstEval::extractBits(const sem::Type* ty, utils::VectorRef args, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 5e2a97f44b..cb1babd1d2 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -539,7 +539,6 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// degrees builtin /// @param ty the expression type /// @param args the input arguments /// @param source the source location of the conversion @@ -548,6 +547,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// dot builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location + /// @return the result value, or null if the value cannot be calculated + Result dot(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// extractBits builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 1bf0bd095c..7fbdf30e38 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -792,10 +792,60 @@ INSTANTIATE_TEST_SUITE_P( // ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kCross), testing::ValuesIn(Concat(CrossCases(), // - CrossCases(), - CrossCases(), // + CrossCases(), // CrossCases())))); +template +std::vector DotCases() { + auto r = std::vector{ + C({Vec(T(0), T(0)), Vec(T(0), T(0))}, Val(T(0))), + C({Vec(T(0), T(0), T(0)), Vec(T(0), T(0), T(0))}, Val(T(0))), + C({Vec(T(0), T(0), T(0), T(0)), Vec(T(0), T(0), T(0), T(0))}, Val(T(0))), + C({Vec(T(1), T(2), T(3), T(4)), Vec(T(5), T(6), T(7), T(8))}, Val(T(70))), + + C({Vec(T(1), T(1)), Vec(T(1), T(1))}, Val(T(2))), + C({Vec(T(1), T(2)), Vec(T(2), T(1))}, Val(T(4))), + C({Vec(T(2), T(2)), Vec(T(2), T(2))}, Val(T(8))), + + C({Vec(T::Highest(), T::Highest()), Vec(T(1), T(0))}, Val(T::Highest())), + C({Vec(T::Lowest(), T::Lowest()), Vec(T(1), T(0))}, Val(T::Lowest())), + }; + + if constexpr (IsAbstract || IsFloatingPoint) { + auto error_msg = [](auto a, const char* op, auto b) { + return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( +12:34 note: when calculating dot)"; + }; + ConcatInto( // + r, std::vector{ + E({Vec(T::Highest(), T::Highest()), Vec(T(1), T(1))}, + error_msg(T::Highest(), "+", T::Highest())), + E({Vec(T::Lowest(), T::Lowest()), Vec(T(1), T(1))}, + error_msg(T::Lowest(), "+", T::Lowest())), + }); + } else { + // Overflow is not an error for concrete integrals + ConcatInto( // + r, std::vector{ + C({Vec(T::Highest(), T::Highest()), Vec(T(1), T(1))}, + Val(Add(T::Highest(), T::Highest()))), + C({Vec(T::Lowest(), T::Lowest()), Vec(T(1), T(1))}, + Val(Add(T::Lowest(), T::Lowest()))), + }); + } + return r; +} +INSTANTIATE_TEST_SUITE_P( // + Dot, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kDot), + testing::ValuesIn(Concat(DotCases(), // + DotCases(), // + DotCases(), // + DotCases(), // + DotCases(), // + DotCases())))); + template std::vector FirstLeadingBitCases() { using B = BitValues; diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index c2e12bc4f4..cccbf769e4 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -107,6 +107,19 @@ inline constexpr Number Mul(Number v1, Number v2) { } TINT_END_DISABLE_WARNING(CONSTANT_OVERFLOW); +TINT_BEGIN_DISABLE_WARNING(CONSTANT_OVERFLOW); +template +inline constexpr Number Add(Number v1, Number v2) { + if constexpr (std::is_integral_v && std::is_signed_v) { + // For signed integrals, avoid C++ UB by adding as unsigned + using UT = std::make_unsigned_t; + return static_cast>(static_cast(v1) + static_cast(v2)); + } else { + return static_cast>(v1 + v2); + } +} +TINT_END_DISABLE_WARNING(CONSTANT_OVERFLOW); + // Concats any number of std::vectors template [[nodiscard]] inline auto Concat(Vec&& v1, Vecs&&... vs) { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 9e768623c0..91ff68c329 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -8209,22 +8209,22 @@ constexpr TemplateTypeInfo kTemplateTypes[] = { { /* [27] */ /* name */ "T", - /* matcher index */ 65, + /* matcher index */ 52, }, { /* [28] */ /* name */ "T", - /* matcher index */ 52, + /* matcher index */ 64, }, { /* [29] */ /* name */ "T", - /* matcher index */ 64, + /* matcher index */ 60, }, { /* [30] */ /* name */ "T", - /* matcher index */ 60, + /* matcher index */ 65, }, { /* [31] */ @@ -8838,7 +8838,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[982], /* return matcher indices */ &kMatcherIndices[130], @@ -8850,7 +8850,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[983], /* return matcher indices */ &kMatcherIndices[130], @@ -8862,7 +8862,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 4, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[427], /* return matcher indices */ &kMatcherIndices[130], @@ -8874,7 +8874,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[576], /* return matcher indices */ &kMatcherIndices[130], @@ -8886,7 +8886,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[579], /* return matcher indices */ &kMatcherIndices[130], @@ -8898,7 +8898,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[582], /* return matcher indices */ &kMatcherIndices[130], @@ -8910,7 +8910,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[792], /* return matcher indices */ &kMatcherIndices[130], @@ -8922,7 +8922,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[794], /* return matcher indices */ &kMatcherIndices[130], @@ -8934,7 +8934,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[796], /* return matcher indices */ &kMatcherIndices[130], @@ -9474,7 +9474,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[975], /* return matcher indices */ &kMatcherIndices[102], @@ -9486,7 +9486,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[976], /* return matcher indices */ &kMatcherIndices[102], @@ -9498,7 +9498,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[573], /* return matcher indices */ &kMatcherIndices[102], @@ -9510,7 +9510,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[788], /* return matcher indices */ &kMatcherIndices[102], @@ -9522,7 +9522,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[790], /* return matcher indices */ &kMatcherIndices[102], @@ -9942,7 +9942,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[968], /* return matcher indices */ &kMatcherIndices[150], @@ -9954,7 +9954,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[969], /* return matcher indices */ &kMatcherIndices[150], @@ -9966,7 +9966,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[786], /* return matcher indices */ &kMatcherIndices[150], @@ -11322,7 +11322,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[30], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[718], /* return matcher indices */ &kMatcherIndices[3], @@ -11334,7 +11334,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[30], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[720], /* return matcher indices */ &kMatcherIndices[30], @@ -11346,7 +11346,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[30], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[722], /* return matcher indices */ &kMatcherIndices[30], @@ -11358,7 +11358,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[30], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[724], /* return matcher indices */ &kMatcherIndices[30], @@ -11394,7 +11394,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[734], /* return matcher indices */ &kMatcherIndices[3], @@ -11406,7 +11406,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[736], /* return matcher indices */ &kMatcherIndices[30], @@ -11442,7 +11442,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[742], /* return matcher indices */ &kMatcherIndices[3], @@ -11454,7 +11454,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[744], /* return matcher indices */ &kMatcherIndices[30], @@ -11550,7 +11550,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[480], /* return matcher indices */ &kMatcherIndices[3], @@ -11562,7 +11562,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[483], /* return matcher indices */ &kMatcherIndices[30], @@ -11574,7 +11574,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[486], /* return matcher indices */ &kMatcherIndices[30], @@ -13302,7 +13302,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[954], /* return matcher indices */ &kMatcherIndices[3], @@ -13314,7 +13314,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[955], /* return matcher indices */ &kMatcherIndices[30], @@ -13326,7 +13326,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[30], + /* template types */ &kTemplateTypes[29], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[956], /* return matcher indices */ &kMatcherIndices[3], @@ -13338,7 +13338,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[30], + /* template types */ &kTemplateTypes[29], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[957], /* return matcher indices */ &kMatcherIndices[30], @@ -13350,7 +13350,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[726], /* return matcher indices */ &kMatcherIndices[3], @@ -13362,7 +13362,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[29], + /* template types */ &kTemplateTypes[28], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[728], /* return matcher indices */ &kMatcherIndices[30], @@ -13374,7 +13374,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[750], /* return matcher indices */ &kMatcherIndices[35], @@ -13386,7 +13386,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[752], /* return matcher indices */ &kMatcherIndices[33], @@ -13398,7 +13398,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[754], /* return matcher indices */ &kMatcherIndices[35], @@ -13410,7 +13410,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[28], + /* template types */ &kTemplateTypes[27], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[756], /* return matcher indices */ &kMatcherIndices[33], @@ -13506,7 +13506,7 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[30], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[772], /* return matcher indices */ &kMatcherIndices[33], @@ -13578,12 +13578,12 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[27], + /* template types */ &kTemplateTypes[22], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[604], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::dot, }, { /* [439] */ @@ -14137,7 +14137,7 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [22] */ - /* fn dot(vec, vec) -> T */ + /* fn dot(vec, vec) -> T */ /* num overloads */ 1, /* overloads */ &kOverloads[438], }, diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl new file mode 100644 index 0000000000..1be3d72eab --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<4, fa>, vec<4, fa>) -> fa +fn dot_08eb56() { + var res = dot(vec4(1.), vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_08eb56(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_08eb56(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_08eb56(); +} diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..c4e18defe0 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_08eb56() { + float res = 4.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_08eb56(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_08eb56(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_08eb56(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..c4e18defe0 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_08eb56() { + float res = 4.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_08eb56(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_08eb56(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_08eb56(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.glsl new file mode 100644 index 0000000000..fde4529cc8 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_08eb56() { + float res = 4.0f; +} + +vec4 vertex_main() { + dot_08eb56(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_08eb56() { + float res = 4.0f; +} + +void fragment_main() { + dot_08eb56(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_08eb56() { + float res = 4.0f; +} + +void compute_main() { + dot_08eb56(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.msl new file mode 100644 index 0000000000..a442896500 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_08eb56() { + float res = 4.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_08eb56(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_08eb56(); + return; +} + +kernel void compute_main() { + dot_08eb56(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.spvasm new file mode 100644 index 0000000000..e5558a9921 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_08eb56 "dot_08eb56" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_4 = OpConstant %float 4 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_08eb56 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_4 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_08eb56 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %dot_08eb56 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %dot_08eb56 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.wgsl new file mode 100644 index 0000000000..1d86506dd6 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/08eb56.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_08eb56() { + var res = dot(vec4(1.0), vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_08eb56(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_08eb56(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_08eb56(); +} diff --git a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.dxc.hlsl index ddbdbd46ec..f8d8fff458 100644 --- a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_0c577b() { - float res = dot((1.0f).xxxx, (1.0f).xxxx); + float res = 4.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.fxc.hlsl index ddbdbd46ec..f8d8fff458 100644 --- a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_0c577b() { - float res = dot((1.0f).xxxx, (1.0f).xxxx); + float res = 4.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.glsl index bc4518f455..df20f2860f 100644 --- a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void dot_0c577b() { - float res = dot(vec4(1.0f), vec4(1.0f)); + float res = 4.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void dot_0c577b() { - float res = dot(vec4(1.0f), vec4(1.0f)); + float res = 4.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void dot_0c577b() { - float res = dot(vec4(1.0f), vec4(1.0f)); + float res = 4.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.msl index f4501c00b8..041a650e5f 100644 --- a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_0c577b() { - float res = dot(float4(1.0f), float4(1.0f)); + float res = 4.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.spvasm index b64095ef36..b814ca884d 100644 --- a/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/0c577b.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,36 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %15 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %float_4 = OpConstant %float 4 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %dot_0c577b = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpDot %float %15 %15 - OpStore %res %13 + OpStore %res %float_4 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %dot_0c577b +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_0c577b OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %dot_0c577b + %25 = OpLabel + %26 = OpFunctionCall %void %dot_0c577b OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %dot_0c577b + %28 = OpLabel + %29 = OpFunctionCall %void %dot_0c577b OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl new file mode 100644 index 0000000000..2673e84eb5 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<2, fa>, vec<2, fa>) -> fa +fn dot_0d2c2e() { + var res = dot(vec2(1.), vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_0d2c2e(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_0d2c2e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_0d2c2e(); +} diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..46e88b59a7 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_0d2c2e() { + float res = 2.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_0d2c2e(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_0d2c2e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_0d2c2e(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..46e88b59a7 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_0d2c2e() { + float res = 2.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_0d2c2e(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_0d2c2e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_0d2c2e(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.glsl new file mode 100644 index 0000000000..56f8ba0b58 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_0d2c2e() { + float res = 2.0f; +} + +vec4 vertex_main() { + dot_0d2c2e(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_0d2c2e() { + float res = 2.0f; +} + +void fragment_main() { + dot_0d2c2e(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_0d2c2e() { + float res = 2.0f; +} + +void compute_main() { + dot_0d2c2e(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.msl new file mode 100644 index 0000000000..9e750d456b --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_0d2c2e() { + float res = 2.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_0d2c2e(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_0d2c2e(); + return; +} + +kernel void compute_main() { + dot_0d2c2e(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.spvasm new file mode 100644 index 0000000000..bb94b746e0 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_0d2c2e "dot_0d2c2e" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_2 = OpConstant %float 2 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_0d2c2e = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_2 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_0d2c2e + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %dot_0d2c2e + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %dot_0d2c2e + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.wgsl new file mode 100644 index 0000000000..fbae591aee --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/0d2c2e.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_0d2c2e() { + var res = dot(vec2(1.0), vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_0d2c2e(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_0d2c2e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_0d2c2e(); +} diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl new file mode 100644 index 0000000000..b59b695f8c --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<2, ia>, vec<2, ia>) -> ia +fn dot_14bc63() { + var res = dot(vec2(1), vec2(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_14bc63(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_14bc63(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_14bc63(); +} diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..77562dcaa4 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_14bc63() { + int res = 2; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_14bc63(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_14bc63(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_14bc63(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..77562dcaa4 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_14bc63() { + int res = 2; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_14bc63(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_14bc63(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_14bc63(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.glsl new file mode 100644 index 0000000000..ee013411ac --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_14bc63() { + int res = 2; +} + +vec4 vertex_main() { + dot_14bc63(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_14bc63() { + int res = 2; +} + +void fragment_main() { + dot_14bc63(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_14bc63() { + int res = 2; +} + +void compute_main() { + dot_14bc63(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.msl new file mode 100644 index 0000000000..6f2f467507 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_14bc63() { + int res = 2; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_14bc63(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_14bc63(); + return; +} + +kernel void compute_main() { + dot_14bc63(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.spvasm new file mode 100644 index 0000000000..f454100a91 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_14bc63 "dot_14bc63" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_2 = OpConstant %int 2 +%_ptr_Function_int = OpTypePointer Function %int + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_14bc63 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_2 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_14bc63 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_14bc63 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %dot_14bc63 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.wgsl new file mode 100644 index 0000000000..c124ead5d8 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/14bc63.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_14bc63() { + var res = dot(vec2(1), vec2(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_14bc63(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_14bc63(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_14bc63(); +} diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl new file mode 100644 index 0000000000..8720932c9b --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<3, fa>, vec<3, fa>) -> fa +fn dot_5a4c8f() { + var res = dot(vec3(1.), vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_5a4c8f(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_5a4c8f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_5a4c8f(); +} diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b6e6077f2e --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_5a4c8f() { + float res = 3.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_5a4c8f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_5a4c8f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_5a4c8f(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b6e6077f2e --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_5a4c8f() { + float res = 3.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_5a4c8f(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_5a4c8f(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_5a4c8f(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.glsl new file mode 100644 index 0000000000..bf3a69a043 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_5a4c8f() { + float res = 3.0f; +} + +vec4 vertex_main() { + dot_5a4c8f(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_5a4c8f() { + float res = 3.0f; +} + +void fragment_main() { + dot_5a4c8f(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_5a4c8f() { + float res = 3.0f; +} + +void compute_main() { + dot_5a4c8f(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.msl new file mode 100644 index 0000000000..e3ba3f5d74 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_5a4c8f() { + float res = 3.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_5a4c8f(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_5a4c8f(); + return; +} + +kernel void compute_main() { + dot_5a4c8f(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.spvasm new file mode 100644 index 0000000000..e212ecb1d7 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_5a4c8f "dot_5a4c8f" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_3 = OpConstant %float 3 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_5a4c8f = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_3 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_5a4c8f + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %dot_5a4c8f + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %dot_5a4c8f + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.wgsl new file mode 100644 index 0000000000..022f0e2e19 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/5a4c8f.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_5a4c8f() { + var res = dot(vec3(1.0), vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_5a4c8f(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_5a4c8f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_5a4c8f(); +} diff --git a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.dxc.hlsl index cd0f853b12..734a719ca3 100644 --- a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_7548a0() { - uint res = dot((1u).xxx, (1u).xxx); + uint res = 3u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.fxc.hlsl index cd0f853b12..734a719ca3 100644 --- a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_7548a0() { - uint res = dot((1u).xxx, (1u).xxx); + uint res = 3u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.glsl index 6b184f8f5d..7011d7e7d2 100644 --- a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -uint tint_int_dot(uvec3 a, uvec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_7548a0() { - uint res = tint_int_dot(uvec3(1u), uvec3(1u)); + uint res = 3u; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -uint tint_int_dot(uvec3 a, uvec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_7548a0() { - uint res = tint_int_dot(uvec3(1u), uvec3(1u)); + uint res = 3u; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -uint tint_int_dot(uvec3 a, uvec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_7548a0() { - uint res = tint_int_dot(uvec3(1u), uvec3(1u)); + uint res = 3u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.msl index 47aee0ff3c..3261b2e2a2 100644 --- a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot3(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} void dot_7548a0() { - uint res = tint_dot3(uint3(1u), uint3(1u)); + uint res = 3u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.spvasm index 2043848f40..27b387a960 100644 --- a/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/7548a0.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 45 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,49 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %v3uint = OpTypeVector %uint 3 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 + %uint_3 = OpConstant %uint 3 %_ptr_Function_uint = OpTypePointer Function %uint - %30 = OpConstantNull %uint - %31 = OpTypeFunction %v4float + %17 = OpConstantNull %uint + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_7548a0 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_uint Function %30 - %18 = OpCompositeExtract %uint %17 0 - %19 = OpCompositeExtract %uint %17 0 - %20 = OpIMul %uint %18 %19 - %21 = OpCompositeExtract %uint %17 1 - %22 = OpCompositeExtract %uint %17 1 - %23 = OpIMul %uint %21 %22 - %24 = OpIAdd %uint %20 %23 - %25 = OpCompositeExtract %uint %17 2 - %26 = OpCompositeExtract %uint %17 2 - %27 = OpIMul %uint %25 %26 - %13 = OpIAdd %uint %24 %27 - OpStore %res %13 + %res = OpVariable %_ptr_Function_uint Function %17 + OpStore %res %uint_3 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %31 - %33 = OpLabel - %34 = OpFunctionCall %void %dot_7548a0 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_7548a0 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %36 = OpLabel - %37 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %37 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %40 = OpLabel - %41 = OpFunctionCall %void %dot_7548a0 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_7548a0 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %43 = OpLabel - %44 = OpFunctionCall %void %dot_7548a0 + %30 = OpLabel + %31 = OpFunctionCall %void %dot_7548a0 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.dxc.hlsl index 4e4cbb5ed8..47e8b07100 100644 --- a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_883f0e() { - float res = dot((1.0f).xx, (1.0f).xx); + float res = 2.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.fxc.hlsl index 4e4cbb5ed8..47e8b07100 100644 --- a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_883f0e() { - float res = dot((1.0f).xx, (1.0f).xx); + float res = 2.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.glsl index 6ab33ae703..226cf9ac38 100644 --- a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void dot_883f0e() { - float res = dot(vec2(1.0f), vec2(1.0f)); + float res = 2.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void dot_883f0e() { - float res = dot(vec2(1.0f), vec2(1.0f)); + float res = 2.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void dot_883f0e() { - float res = dot(vec2(1.0f), vec2(1.0f)); + float res = 2.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.msl index 44510c4a7c..0f63f30686 100644 --- a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_883f0e() { - float res = dot(float2(1.0f), float2(1.0f)); + float res = 2.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.spvasm index e1cf73c227..e178ced2c6 100644 --- a/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/883f0e.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,37 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v2float %float_1 %float_1 + %float_2 = OpConstant %float 2 %_ptr_Function_float = OpTypePointer Function %float - %19 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %dot_883f0e = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpDot %float %16 %16 - OpStore %res %13 + OpStore %res %float_2 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %dot_883f0e +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_883f0e OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %dot_883f0e + %25 = OpLabel + %26 = OpFunctionCall %void %dot_883f0e OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %dot_883f0e + %28 = OpLabel + %29 = OpFunctionCall %void %dot_883f0e OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.dxc.hlsl index 45e55deba0..ae4d81528a 100644 --- a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_8e40f1() { - float16_t res = dot((float16_t(1.0h)).xxx, (float16_t(1.0h)).xxx); + float16_t res = float16_t(3.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.glsl index 069a38d69f..8f5eca676f 100644 --- a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void dot_8e40f1() { - float16_t res = dot(f16vec3(1.0hf), f16vec3(1.0hf)); + float16_t res = 3.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void dot_8e40f1() { - float16_t res = dot(f16vec3(1.0hf), f16vec3(1.0hf)); + float16_t res = 3.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void dot_8e40f1() { - float16_t res = dot(f16vec3(1.0hf), f16vec3(1.0hf)); + float16_t res = 3.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.msl index 9299636cf2..48288512c3 100644 --- a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_8e40f1() { - half res = dot(half3(1.0h), half3(1.0h)); + half res = 3.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.spvasm index 005fa5a7ff..f1e3db83e9 100644 --- a/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/8e40f1.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -35,39 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 - %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %17 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_8p_1 = OpConstant %half 0x1.8p+1 %_ptr_Function_half = OpTypePointer Function %half - %20 = OpConstantNull %half - %21 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_8e40f1 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %20 - %13 = OpDot %half %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1_8p_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %dot_8e40f1 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_8e40f1 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_8e40f1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %30 = OpLabel %31 = OpFunctionCall %void %dot_8e40f1 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %dot_8e40f1 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.dxc.hlsl index 9237756a2e..598ea1ab7c 100644 --- a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_97c7ee() { - uint res = dot((1u).xx, (1u).xx); + uint res = 2u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.fxc.hlsl index 9237756a2e..598ea1ab7c 100644 --- a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_97c7ee() { - uint res = dot((1u).xx, (1u).xx); + uint res = 2u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.glsl index c61da39599..eca1297e52 100644 --- a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -uint tint_int_dot(uvec2 a, uvec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_97c7ee() { - uint res = tint_int_dot(uvec2(1u), uvec2(1u)); + uint res = 2u; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -uint tint_int_dot(uvec2 a, uvec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_97c7ee() { - uint res = tint_int_dot(uvec2(1u), uvec2(1u)); + uint res = 2u; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -uint tint_int_dot(uvec2 a, uvec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_97c7ee() { - uint res = tint_int_dot(uvec2(1u), uvec2(1u)); + uint res = 2u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.msl index 6565bb85a4..e329edd9ea 100644 --- a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot2(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1]; -} void dot_97c7ee() { - uint res = tint_dot2(uint2(1u), uint2(1u)); + uint res = 2u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.spvasm index 079b868089..384a3d7eb0 100644 --- a/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/97c7ee.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 41 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,45 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %v2uint = OpTypeVector %uint 2 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v2uint %uint_1 %uint_1 + %uint_2 = OpConstant %uint 2 %_ptr_Function_uint = OpTypePointer Function %uint - %26 = OpConstantNull %uint - %27 = OpTypeFunction %v4float + %17 = OpConstantNull %uint + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_97c7ee = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_uint Function %26 - %18 = OpCompositeExtract %uint %17 0 - %19 = OpCompositeExtract %uint %17 0 - %20 = OpIMul %uint %18 %19 - %21 = OpCompositeExtract %uint %17 1 - %22 = OpCompositeExtract %uint %17 1 - %23 = OpIMul %uint %21 %22 - %13 = OpIAdd %uint %20 %23 - OpStore %res %13 + %res = OpVariable %_ptr_Function_uint Function %17 + OpStore %res %uint_2 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %27 - %29 = OpLabel - %30 = OpFunctionCall %void %dot_97c7ee +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_97c7ee OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %33 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %36 = OpLabel - %37 = OpFunctionCall %void %dot_97c7ee + %27 = OpLabel + %28 = OpFunctionCall %void %dot_97c7ee OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %39 = OpLabel - %40 = OpFunctionCall %void %dot_97c7ee + %30 = OpLabel + %31 = OpFunctionCall %void %dot_97c7ee OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.dxc.hlsl index 6a9325cd1b..08f1cddf17 100644 --- a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_ba4246() { - float res = dot((1.0f).xxx, (1.0f).xxx); + float res = 3.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.fxc.hlsl index 6a9325cd1b..08f1cddf17 100644 --- a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_ba4246() { - float res = dot((1.0f).xxx, (1.0f).xxx); + float res = 3.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.glsl index 101b193471..95e9397ef2 100644 --- a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void dot_ba4246() { - float res = dot(vec3(1.0f), vec3(1.0f)); + float res = 3.0f; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void dot_ba4246() { - float res = dot(vec3(1.0f), vec3(1.0f)); + float res = 3.0f; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void dot_ba4246() { - float res = dot(vec3(1.0f), vec3(1.0f)); + float res = 3.0f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.msl index be8c5ad201..e127cecc98 100644 --- a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_ba4246() { - float res = dot(float3(1.0f), float3(1.0f)); + float res = 3.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.spvasm index 3ab148083f..948070e55c 100644 --- a/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/ba4246.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,37 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %float_3 = OpConstant %float 3 %_ptr_Function_float = OpTypePointer Function %float - %19 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %dot_ba4246 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpDot %float %16 %16 - OpStore %res %13 + OpStore %res %float_3 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %dot_ba4246 +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %dot_ba4246 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %dot_ba4246 + %25 = OpLabel + %26 = OpFunctionCall %void %dot_ba4246 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %dot_ba4246 + %28 = OpLabel + %29 = OpFunctionCall %void %dot_ba4246 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl new file mode 100644 index 0000000000..b2409c4b81 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<3, ia>, vec<3, ia>) -> ia +fn dot_c11efe() { + var res = dot(vec3(1), vec3(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_c11efe(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_c11efe(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_c11efe(); +} diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..c35aa55dbd --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_c11efe() { + int res = 3; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_c11efe(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_c11efe(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_c11efe(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..c35aa55dbd --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_c11efe() { + int res = 3; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_c11efe(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_c11efe(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_c11efe(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.glsl new file mode 100644 index 0000000000..0a21a3d4e8 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_c11efe() { + int res = 3; +} + +vec4 vertex_main() { + dot_c11efe(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_c11efe() { + int res = 3; +} + +void fragment_main() { + dot_c11efe(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_c11efe() { + int res = 3; +} + +void compute_main() { + dot_c11efe(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.msl new file mode 100644 index 0000000000..a177d81004 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_c11efe() { + int res = 3; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_c11efe(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_c11efe(); + return; +} + +kernel void compute_main() { + dot_c11efe(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.spvasm new file mode 100644 index 0000000000..d2fdf7d9dd --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_c11efe "dot_c11efe" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_3 = OpConstant %int 3 +%_ptr_Function_int = OpTypePointer Function %int + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_c11efe = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_3 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_c11efe + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_c11efe + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %dot_c11efe + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.wgsl new file mode 100644 index 0000000000..c9ace21e25 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/c11efe.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_c11efe() { + var res = dot(vec3(1), vec3(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_c11efe(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_c11efe(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_c11efe(); +} diff --git a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.dxc.hlsl index 75f9749f95..546135b93d 100644 --- a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_cd5a04() { - float16_t res = dot((float16_t(1.0h)).xx, (float16_t(1.0h)).xx); + float16_t res = float16_t(2.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.glsl index e49873a002..a9e34ca216 100644 --- a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void dot_cd5a04() { - float16_t res = dot(f16vec2(1.0hf), f16vec2(1.0hf)); + float16_t res = 2.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void dot_cd5a04() { - float16_t res = dot(f16vec2(1.0hf), f16vec2(1.0hf)); + float16_t res = 2.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void dot_cd5a04() { - float16_t res = dot(f16vec2(1.0hf), f16vec2(1.0hf)); + float16_t res = 2.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.msl index 01e75626d8..e21392720a 100644 --- a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_cd5a04() { - half res = dot(half2(1.0h), half2(1.0h)); + half res = 2.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.spvasm index 0d140a4df9..5baab994df 100644 --- a/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/cd5a04.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -35,39 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 - %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %17 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1p_1 = OpConstant %half 0x1p+1 %_ptr_Function_half = OpTypePointer Function %half - %20 = OpConstantNull %half - %21 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_cd5a04 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %20 - %13 = OpDot %half %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1p_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %dot_cd5a04 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_cd5a04 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_cd5a04 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %30 = OpLabel %31 = OpFunctionCall %void %dot_cd5a04 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %dot_cd5a04 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.dxc.hlsl index fd310339d1..9ab6fe7b6f 100644 --- a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_d0d179() { - float16_t res = dot((float16_t(1.0h)).xxxx, (float16_t(1.0h)).xxxx); + float16_t res = float16_t(4.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.glsl index c48a12d9aa..7654968f14 100644 --- a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void dot_d0d179() { - float16_t res = dot(f16vec4(1.0hf), f16vec4(1.0hf)); + float16_t res = 4.0hf; } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void dot_d0d179() { - float16_t res = dot(f16vec4(1.0hf), f16vec4(1.0hf)); + float16_t res = 4.0hf; } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void dot_d0d179() { - float16_t res = dot(f16vec4(1.0hf), f16vec4(1.0hf)); + float16_t res = 4.0hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.msl index 1110c66efe..82091e5a27 100644 --- a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void dot_d0d179() { - half res = dot(half4(1.0h), half4(1.0h)); + half res = 4.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.spvasm index b465609419..b6182ebac5 100644 --- a/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/d0d179.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -35,39 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 - %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %17 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1p_2 = OpConstant %half 0x1p+2 %_ptr_Function_half = OpTypePointer Function %half - %20 = OpConstantNull %half - %21 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_d0d179 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %20 - %13 = OpDot %half %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1p_2 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %dot_d0d179 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_d0d179 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_d0d179 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 %30 = OpLabel %31 = OpFunctionCall %void %dot_d0d179 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %dot_d0d179 - OpReturn - OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.dxc.hlsl index 65c2053d80..d6f5c4b65d 100644 --- a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_e994c7() { - uint res = dot((1u).xxxx, (1u).xxxx); + uint res = 4u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.fxc.hlsl index 65c2053d80..d6f5c4b65d 100644 --- a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_e994c7() { - uint res = dot((1u).xxxx, (1u).xxxx); + uint res = 4u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.glsl index c430e32a7e..7254b26c23 100644 --- a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -uint tint_int_dot(uvec4 a, uvec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_e994c7() { - uint res = tint_int_dot(uvec4(1u), uvec4(1u)); + uint res = 4u; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -uint tint_int_dot(uvec4 a, uvec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_e994c7() { - uint res = tint_int_dot(uvec4(1u), uvec4(1u)); + uint res = 4u; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -uint tint_int_dot(uvec4 a, uvec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_e994c7() { - uint res = tint_int_dot(uvec4(1u), uvec4(1u)); + uint res = 4u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.msl index 1939acd798..f748a3cece 100644 --- a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot4(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} void dot_e994c7() { - uint res = tint_dot4(uint4(1u), uint4(1u)); + uint res = 4u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.spvasm index 8a993d8681..1c5c49761f 100644 --- a/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/e994c7.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 49 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,53 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %v4uint = OpTypeVector %uint 4 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 + %uint_4 = OpConstant %uint 4 %_ptr_Function_uint = OpTypePointer Function %uint - %34 = OpConstantNull %uint - %35 = OpTypeFunction %v4float + %17 = OpConstantNull %uint + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_e994c7 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_uint Function %34 - %18 = OpCompositeExtract %uint %17 0 - %19 = OpCompositeExtract %uint %17 0 - %20 = OpIMul %uint %18 %19 - %21 = OpCompositeExtract %uint %17 1 - %22 = OpCompositeExtract %uint %17 1 - %23 = OpIMul %uint %21 %22 - %24 = OpIAdd %uint %20 %23 - %25 = OpCompositeExtract %uint %17 2 - %26 = OpCompositeExtract %uint %17 2 - %27 = OpIMul %uint %25 %26 - %28 = OpIAdd %uint %24 %27 - %29 = OpCompositeExtract %uint %17 3 - %30 = OpCompositeExtract %uint %17 3 - %31 = OpIMul %uint %29 %30 - %13 = OpIAdd %uint %28 %31 - OpStore %res %13 + %res = OpVariable %_ptr_Function_uint Function %17 + OpStore %res %uint_4 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %35 - %37 = OpLabel - %38 = OpFunctionCall %void %dot_e994c7 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_e994c7 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %40 = OpLabel - %41 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %41 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %44 = OpLabel - %45 = OpFunctionCall %void %dot_e994c7 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_e994c7 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %47 = OpLabel - %48 = OpFunctionCall %void %dot_e994c7 + %30 = OpLabel + %31 = OpFunctionCall %void %dot_e994c7 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl new file mode 100644 index 0000000000..527f7fc416 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl @@ -0,0 +1,43 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<4, ia>, vec<4, ia>) -> ia +fn dot_eb9fbf() { + var res = dot(vec4(1), vec4(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_eb9fbf(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_eb9fbf(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_eb9fbf(); +} diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..348af30d9d --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void dot_eb9fbf() { + int res = 4; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_eb9fbf(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_eb9fbf(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_eb9fbf(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..348af30d9d --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void dot_eb9fbf() { + int res = 4; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + dot_eb9fbf(); + return (0.0f).xxxx; +} + +tint_symbol vertex_main() { + const float4 inner_result = vertex_main_inner(); + tint_symbol wrapper_result = (tint_symbol)0; + wrapper_result.value = inner_result; + return wrapper_result; +} + +void fragment_main() { + dot_eb9fbf(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + dot_eb9fbf(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.glsl new file mode 100644 index 0000000000..a10a6391d9 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void dot_eb9fbf() { + int res = 4; +} + +vec4 vertex_main() { + dot_eb9fbf(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void dot_eb9fbf() { + int res = 4; +} + +void fragment_main() { + dot_eb9fbf(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void dot_eb9fbf() { + int res = 4; +} + +void compute_main() { + dot_eb9fbf(); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + compute_main(); + return; +} diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.msl new file mode 100644 index 0000000000..32967417e6 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void dot_eb9fbf() { + int res = 4; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + dot_eb9fbf(); + return float4(0.0f); +} + +vertex tint_symbol vertex_main() { + float4 const inner_result = vertex_main_inner(); + tint_symbol wrapper_result = {}; + wrapper_result.value = inner_result; + return wrapper_result; +} + +fragment void fragment_main() { + dot_eb9fbf(); + return; +} + +kernel void compute_main() { + dot_eb9fbf(); + return; +} + diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.spvasm new file mode 100644 index 0000000000..de51f60b62 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %dot_eb9fbf "dot_eb9fbf" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_4 = OpConstant %int 4 +%_ptr_Function_int = OpTypePointer Function %int + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 + %dot_eb9fbf = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_4 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_eb9fbf + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %dot_eb9fbf + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %dot_eb9fbf + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.wgsl new file mode 100644 index 0000000000..85209cec76 --- /dev/null +++ b/test/tint/builtins/gen/literal/dot/eb9fbf.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn dot_eb9fbf() { + var res = dot(vec4(1), vec4(1)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_eb9fbf(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_eb9fbf(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_eb9fbf(); +} diff --git a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.dxc.hlsl index 570b419f4a..dfaf584086 100644 --- a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_ef6b1d() { - int res = dot((1).xxxx, (1).xxxx); + int res = 4; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.fxc.hlsl index 570b419f4a..dfaf584086 100644 --- a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_ef6b1d() { - int res = dot((1).xxxx, (1).xxxx); + int res = 4; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.glsl index a6ec4b0080..c3359d511f 100644 --- a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -int tint_int_dot(ivec4 a, ivec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_ef6b1d() { - int res = tint_int_dot(ivec4(1), ivec4(1)); + int res = 4; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -int tint_int_dot(ivec4 a, ivec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_ef6b1d() { - int res = tint_int_dot(ivec4(1), ivec4(1)); + int res = 4; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -int tint_int_dot(ivec4 a, ivec4 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} - void dot_ef6b1d() { - int res = tint_int_dot(ivec4(1), ivec4(1)); + int res = 4; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.msl index e5e2f0777c..ee2bc3cb0b 100644 --- a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot4(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]; -} void dot_ef6b1d() { - int res = tint_dot4(int4(1), int4(1)); + int res = 4; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.spvasm index 3d8c3fb78c..afe822c584 100644 --- a/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/ef6b1d.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 49 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,53 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int = OpTypeInt 32 1 - %v4int = OpTypeVector %int 4 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %int_4 = OpConstant %int 4 %_ptr_Function_int = OpTypePointer Function %int - %34 = OpConstantNull %int - %35 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_ef6b1d = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_int Function %34 - %18 = OpCompositeExtract %int %17 0 - %19 = OpCompositeExtract %int %17 0 - %20 = OpIMul %int %18 %19 - %21 = OpCompositeExtract %int %17 1 - %22 = OpCompositeExtract %int %17 1 - %23 = OpIMul %int %21 %22 - %24 = OpIAdd %int %20 %23 - %25 = OpCompositeExtract %int %17 2 - %26 = OpCompositeExtract %int %17 2 - %27 = OpIMul %int %25 %26 - %28 = OpIAdd %int %24 %27 - %29 = OpCompositeExtract %int %17 3 - %30 = OpCompositeExtract %int %17 3 - %31 = OpIMul %int %29 %30 - %13 = OpIAdd %int %28 %31 - OpStore %res %13 + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_4 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %35 - %37 = OpLabel - %38 = OpFunctionCall %void %dot_ef6b1d +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_ef6b1d OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %40 = OpLabel - %41 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %41 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %44 = OpLabel - %45 = OpFunctionCall %void %dot_ef6b1d + %27 = OpLabel + %28 = OpFunctionCall %void %dot_ef6b1d OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %47 = OpLabel - %48 = OpFunctionCall %void %dot_ef6b1d + %30 = OpLabel + %31 = OpFunctionCall %void %dot_ef6b1d OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.dxc.hlsl index b3fde1321e..7454ee26eb 100644 --- a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_f1312c() { - int res = dot((1).xxx, (1).xxx); + int res = 3; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.fxc.hlsl index b3fde1321e..7454ee26eb 100644 --- a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_f1312c() { - int res = dot((1).xxx, (1).xxx); + int res = 3; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.glsl index 907adba6f9..e076417c2b 100644 --- a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -int tint_int_dot(ivec3 a, ivec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_f1312c() { - int res = tint_int_dot(ivec3(1), ivec3(1)); + int res = 3; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -int tint_int_dot(ivec3 a, ivec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_f1312c() { - int res = tint_int_dot(ivec3(1), ivec3(1)); + int res = 3; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -int tint_int_dot(ivec3 a, ivec3 b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - void dot_f1312c() { - int res = tint_int_dot(ivec3(1), ivec3(1)); + int res = 3; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.msl index 5de6c94d43..b5181d53d5 100644 --- a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot3(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} void dot_f1312c() { - int res = tint_dot3(int3(1), int3(1)); + int res = 3; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.spvasm index 121718d184..1cd4a1cbef 100644 --- a/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/f1312c.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 45 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,49 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int = OpTypeInt 32 1 - %v3int = OpTypeVector %int 3 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %int_3 = OpConstant %int 3 %_ptr_Function_int = OpTypePointer Function %int - %30 = OpConstantNull %int - %31 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_f1312c = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_int Function %30 - %18 = OpCompositeExtract %int %17 0 - %19 = OpCompositeExtract %int %17 0 - %20 = OpIMul %int %18 %19 - %21 = OpCompositeExtract %int %17 1 - %22 = OpCompositeExtract %int %17 1 - %23 = OpIMul %int %21 %22 - %24 = OpIAdd %int %20 %23 - %25 = OpCompositeExtract %int %17 2 - %26 = OpCompositeExtract %int %17 2 - %27 = OpIMul %int %25 %26 - %13 = OpIAdd %int %24 %27 - OpStore %res %13 + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_3 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %31 - %33 = OpLabel - %34 = OpFunctionCall %void %dot_f1312c +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_f1312c OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %36 = OpLabel - %37 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %37 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %40 = OpLabel - %41 = OpFunctionCall %void %dot_f1312c + %27 = OpLabel + %28 = OpFunctionCall %void %dot_f1312c OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %43 = OpLabel - %44 = OpFunctionCall %void %dot_f1312c + %30 = OpLabel + %31 = OpFunctionCall %void %dot_f1312c OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.dxc.hlsl index 8df1600626..ab81427ea8 100644 --- a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void dot_fc5f7c() { - int res = dot((1).xx, (1).xx); + int res = 2; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.fxc.hlsl index 8df1600626..ab81427ea8 100644 --- a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void dot_fc5f7c() { - int res = dot((1).xx, (1).xx); + int res = 2; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.glsl index 9801dc592c..d570992d70 100644 --- a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.glsl @@ -1,11 +1,7 @@ #version 310 es -int tint_int_dot(ivec2 a, ivec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_fc5f7c() { - int res = tint_int_dot(ivec2(1), ivec2(1)); + int res = 2; } vec4 vertex_main() { @@ -24,12 +20,8 @@ void main() { #version 310 es precision mediump float; -int tint_int_dot(ivec2 a, ivec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_fc5f7c() { - int res = tint_int_dot(ivec2(1), ivec2(1)); + int res = 2; } void fragment_main() { @@ -42,12 +34,8 @@ void main() { } #version 310 es -int tint_int_dot(ivec2 a, ivec2 b) { - return a[0]*b[0] + a[1]*b[1]; -} - void dot_fc5f7c() { - int res = tint_int_dot(ivec2(1), ivec2(1)); + int res = 2; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.msl b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.msl index 6fbcb2ba11..45314730ff 100644 --- a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -template -T tint_dot2(vec a, vec b) { - return a[0]*b[0] + a[1]*b[1]; -} void dot_fc5f7c() { - int res = tint_dot2(int2(1), int2(1)); + int res = 2; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.spvasm index ea9acb45f5..f62845fb15 100644 --- a/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/dot/fc5f7c.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 41 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,45 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int = OpTypeInt 32 1 - %v2int = OpTypeVector %int 2 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v2int %int_1 %int_1 + %int_2 = OpConstant %int 2 %_ptr_Function_int = OpTypePointer Function %int - %26 = OpConstantNull %int - %27 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %dot_fc5f7c = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_int Function %26 - %18 = OpCompositeExtract %int %17 0 - %19 = OpCompositeExtract %int %17 0 - %20 = OpIMul %int %18 %19 - %21 = OpCompositeExtract %int %17 1 - %22 = OpCompositeExtract %int %17 1 - %23 = OpIMul %int %21 %22 - %13 = OpIAdd %int %20 %23 - OpStore %res %13 + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_2 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %27 - %29 = OpLabel - %30 = OpFunctionCall %void %dot_fc5f7c +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %dot_fc5f7c OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %33 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %36 = OpLabel - %37 = OpFunctionCall %void %dot_fc5f7c + %27 = OpLabel + %28 = OpFunctionCall %void %dot_fc5f7c OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %39 = OpLabel - %40 = OpFunctionCall %void %dot_fc5f7c + %30 = OpLabel + %31 = OpFunctionCall %void %dot_fc5f7c OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/dot/08eb56.wgsl b/test/tint/builtins/gen/var/dot/08eb56.wgsl new file mode 100644 index 0000000000..950d853099 --- /dev/null +++ b/test/tint/builtins/gen/var/dot/08eb56.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<4, fa>, vec<4, fa>) -> fa +fn dot_08eb56() { + const arg_0 = vec4(1.); + const arg_1 = vec4(1.); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_08eb56(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_08eb56(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_08eb56(); +} diff --git a/test/tint/builtins/gen/var/dot/0d2c2e.wgsl b/test/tint/builtins/gen/var/dot/0d2c2e.wgsl new file mode 100644 index 0000000000..5c444c5dbb --- /dev/null +++ b/test/tint/builtins/gen/var/dot/0d2c2e.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<2, fa>, vec<2, fa>) -> fa +fn dot_0d2c2e() { + const arg_0 = vec2(1.); + const arg_1 = vec2(1.); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_0d2c2e(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_0d2c2e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_0d2c2e(); +} diff --git a/test/tint/builtins/gen/var/dot/14bc63.wgsl b/test/tint/builtins/gen/var/dot/14bc63.wgsl new file mode 100644 index 0000000000..c90dd8e680 --- /dev/null +++ b/test/tint/builtins/gen/var/dot/14bc63.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<2, ia>, vec<2, ia>) -> ia +fn dot_14bc63() { + const arg_0 = vec2(1); + const arg_1 = vec2(1); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_14bc63(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_14bc63(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_14bc63(); +} diff --git a/test/tint/builtins/gen/var/dot/5a4c8f.wgsl b/test/tint/builtins/gen/var/dot/5a4c8f.wgsl new file mode 100644 index 0000000000..c20c848eb9 --- /dev/null +++ b/test/tint/builtins/gen/var/dot/5a4c8f.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<3, fa>, vec<3, fa>) -> fa +fn dot_5a4c8f() { + const arg_0 = vec3(1.); + const arg_1 = vec3(1.); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_5a4c8f(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_5a4c8f(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_5a4c8f(); +} diff --git a/test/tint/builtins/gen/var/dot/c11efe.wgsl b/test/tint/builtins/gen/var/dot/c11efe.wgsl new file mode 100644 index 0000000000..3b6ba52364 --- /dev/null +++ b/test/tint/builtins/gen/var/dot/c11efe.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<3, ia>, vec<3, ia>) -> ia +fn dot_c11efe() { + const arg_0 = vec3(1); + const arg_1 = vec3(1); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_c11efe(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_c11efe(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_c11efe(); +} diff --git a/test/tint/builtins/gen/var/dot/eb9fbf.wgsl b/test/tint/builtins/gen/var/dot/eb9fbf.wgsl new file mode 100644 index 0000000000..27e1ae9114 --- /dev/null +++ b/test/tint/builtins/gen/var/dot/eb9fbf.wgsl @@ -0,0 +1,45 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn dot(vec<4, ia>, vec<4, ia>) -> ia +fn dot_eb9fbf() { + const arg_0 = vec4(1); + const arg_1 = vec4(1); + var res = dot(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + dot_eb9fbf(); + return vec4(); +} + +@fragment +fn fragment_main() { + dot_eb9fbf(); +} + +@compute @workgroup_size(1) +fn compute_main() { + dot_eb9fbf(); +}