From ee7d6db0472c8f0b863408e0a0163bc466bcb428 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Mon, 28 Nov 2022 15:13:16 +0000 Subject: [PATCH] tint: const eval of reflect builtin Bug: tint:1581 Change-Id: Ife4409ca897a5754fe6b76c650d26fd66ef5880f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111901 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Antonio Maiorano --- src/tint/intrinsics.def | 2 +- src/tint/resolver/const_eval.cc | 77 ++++++++++++++++--- src/tint/resolver/const_eval.h | 33 +++++++- src/tint/resolver/const_eval_builtin_test.cc | 55 +++++++++++++ src/tint/resolver/const_eval_test.h | 20 ++--- src/tint/resolver/intrinsic_table.inl | 6 +- .../reflect/05357e.wgsl.expected.dxc.hlsl | 2 +- .../reflect/05357e.wgsl.expected.fxc.hlsl | 2 +- .../literal/reflect/05357e.wgsl.expected.glsl | 6 +- .../literal/reflect/05357e.wgsl.expected.msl | 2 +- .../reflect/05357e.wgsl.expected.spvasm | 33 ++++---- .../reflect/310de5.wgsl.expected.dxc.hlsl | 2 +- .../literal/reflect/310de5.wgsl.expected.glsl | 6 +- .../literal/reflect/310de5.wgsl.expected.msl | 2 +- .../reflect/310de5.wgsl.expected.spvasm | 36 ++++----- .../reflect/61ca21.wgsl.expected.dxc.hlsl | 2 +- .../literal/reflect/61ca21.wgsl.expected.glsl | 6 +- .../literal/reflect/61ca21.wgsl.expected.msl | 2 +- .../reflect/61ca21.wgsl.expected.spvasm | 36 ++++----- .../builtins/gen/literal/reflect/a8baf2.wgsl | 43 +++++++++++ .../reflect/a8baf2.wgsl.expected.dxc.hlsl | 30 ++++++++ .../reflect/a8baf2.wgsl.expected.fxc.hlsl | 30 ++++++++ .../literal/reflect/a8baf2.wgsl.expected.glsl | 49 ++++++++++++ .../literal/reflect/a8baf2.wgsl.expected.msl | 33 ++++++++ .../reflect/a8baf2.wgsl.expected.spvasm | 67 ++++++++++++++++ .../literal/reflect/a8baf2.wgsl.expected.wgsl | 19 +++++ .../reflect/b61e10.wgsl.expected.dxc.hlsl | 2 +- .../reflect/b61e10.wgsl.expected.fxc.hlsl | 2 +- .../literal/reflect/b61e10.wgsl.expected.glsl | 6 +- .../literal/reflect/b61e10.wgsl.expected.msl | 2 +- .../reflect/b61e10.wgsl.expected.spvasm | 37 +++++---- .../reflect/bb15ac.wgsl.expected.dxc.hlsl | 2 +- .../literal/reflect/bb15ac.wgsl.expected.glsl | 6 +- .../literal/reflect/bb15ac.wgsl.expected.msl | 2 +- .../reflect/bb15ac.wgsl.expected.spvasm | 36 ++++----- .../builtins/gen/literal/reflect/bba2d0.wgsl | 43 +++++++++++ .../reflect/bba2d0.wgsl.expected.dxc.hlsl | 30 ++++++++ .../reflect/bba2d0.wgsl.expected.fxc.hlsl | 30 ++++++++ .../literal/reflect/bba2d0.wgsl.expected.glsl | 49 ++++++++++++ .../literal/reflect/bba2d0.wgsl.expected.msl | 33 ++++++++ .../reflect/bba2d0.wgsl.expected.spvasm | 67 ++++++++++++++++ .../literal/reflect/bba2d0.wgsl.expected.wgsl | 19 +++++ .../builtins/gen/literal/reflect/d7e210.wgsl | 43 +++++++++++ .../reflect/d7e210.wgsl.expected.dxc.hlsl | 30 ++++++++ .../reflect/d7e210.wgsl.expected.fxc.hlsl | 30 ++++++++ .../literal/reflect/d7e210.wgsl.expected.glsl | 49 ++++++++++++ .../literal/reflect/d7e210.wgsl.expected.msl | 33 ++++++++ .../reflect/d7e210.wgsl.expected.spvasm | 65 ++++++++++++++++ .../literal/reflect/d7e210.wgsl.expected.wgsl | 19 +++++ .../reflect/f47fdb.wgsl.expected.dxc.hlsl | 2 +- .../reflect/f47fdb.wgsl.expected.fxc.hlsl | 2 +- .../literal/reflect/f47fdb.wgsl.expected.glsl | 6 +- .../literal/reflect/f47fdb.wgsl.expected.msl | 2 +- .../reflect/f47fdb.wgsl.expected.spvasm | 37 +++++---- .../tint/builtins/gen/var/reflect/a8baf2.wgsl | 45 +++++++++++ .../var/reflect/a8baf2.wgsl.expected.dxc.hlsl | 30 ++++++++ .../var/reflect/a8baf2.wgsl.expected.fxc.hlsl | 30 ++++++++ .../gen/var/reflect/a8baf2.wgsl.expected.glsl | 49 ++++++++++++ .../gen/var/reflect/a8baf2.wgsl.expected.msl | 33 ++++++++ .../var/reflect/a8baf2.wgsl.expected.spvasm | 67 ++++++++++++++++ .../gen/var/reflect/a8baf2.wgsl.expected.wgsl | 21 +++++ .../tint/builtins/gen/var/reflect/bba2d0.wgsl | 45 +++++++++++ .../var/reflect/bba2d0.wgsl.expected.dxc.hlsl | 30 ++++++++ .../var/reflect/bba2d0.wgsl.expected.fxc.hlsl | 30 ++++++++ .../gen/var/reflect/bba2d0.wgsl.expected.glsl | 49 ++++++++++++ .../gen/var/reflect/bba2d0.wgsl.expected.msl | 33 ++++++++ .../var/reflect/bba2d0.wgsl.expected.spvasm | 67 ++++++++++++++++ .../gen/var/reflect/bba2d0.wgsl.expected.wgsl | 21 +++++ .../tint/builtins/gen/var/reflect/d7e210.wgsl | 45 +++++++++++ .../var/reflect/d7e210.wgsl.expected.dxc.hlsl | 30 ++++++++ .../var/reflect/d7e210.wgsl.expected.fxc.hlsl | 30 ++++++++ .../gen/var/reflect/d7e210.wgsl.expected.glsl | 49 ++++++++++++ .../gen/var/reflect/d7e210.wgsl.expected.msl | 33 ++++++++ .../var/reflect/d7e210.wgsl.expected.spvasm | 65 ++++++++++++++++ .../gen/var/reflect/d7e210.wgsl.expected.wgsl | 21 +++++ 75 files changed, 1937 insertions(+), 171 deletions(-) create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.wgsl diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 687b8e1026..efa7f4fe05 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -518,7 +518,7 @@ fn pow(vec, vec) -> vec @const fn quantizeToF16(vec) -> vec @const fn radians(T) -> T @const fn radians(vec) -> vec -fn reflect(vec, vec) -> vec +@const fn reflect(vec, vec) -> vec fn refract(vec, vec, T) -> vec @const fn reverseBits(T) -> T @const fn reverseBits(vec) -> vec diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index f1197ce8bc..95eefe045d 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1189,6 +1189,26 @@ ConstEval::Result ConstEval::Length(const Source& source, return Dispatch_fa_f32_f16(SqrtFunc(source, ty), d.Get()); } +ConstEval::Result ConstEval::Mul(const Source& source, + const sem::Type* ty, + const sem::Constant* v1, + const sem::Constant* v2) { + auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { + return Dispatch_fia_fiu32_f16(MulFunc(source, c0->Type()), c0, c1); + }; + return TransformBinaryElements(builder, ty, transform, v1, v2); +} + +ConstEval::Result ConstEval::Sub(const Source& source, + const sem::Type* ty, + const sem::Constant* v1, + const sem::Constant* v2) { + auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { + return Dispatch_fia_fiu32_f16(SubFunc(source, c0->Type()), c0, c1); + }; + return TransformBinaryElements(builder, ty, transform, v1, v2); +} + auto ConstEval::Det2Func(const Source& source, const sem::Type* elem_ty) { return [=](auto a, auto b, auto c, auto d) -> ImplResult { if (auto r = Det2(source, a, b, c, d)) { @@ -1481,21 +1501,13 @@ ConstEval::Result ConstEval::OpPlus(const sem::Type* ty, ConstEval::Result ConstEval::OpMinus(const sem::Type* ty, utils::VectorRef args, const Source& source) { - auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { - return Dispatch_fia_fiu32_f16(SubFunc(source, c0->Type()), c0, c1); - }; - - return TransformBinaryElements(builder, ty, transform, args[0], args[1]); + return Sub(source, ty, args[0], args[1]); } ConstEval::Result ConstEval::OpMultiply(const sem::Type* ty, utils::VectorRef args, const Source& source) { - auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { - return Dispatch_fia_fiu32_f16(MulFunc(source, c0->Type()), c0, c1); - }; - - return TransformBinaryElements(builder, ty, transform, args[0], args[1]); + return Mul(source, ty, args[0], args[1]); } ConstEval::Result ConstEval::OpMultiplyMatVec(const sem::Type* ty, @@ -2213,7 +2225,7 @@ ConstEval::Result ConstEval::degrees(const sem::Type* ty, ConstEval::Result ConstEval::determinant(const sem::Type* ty, utils::VectorRef args, const Source& source) { - auto calculate = [&]() -> ImplResult { + auto calculate = [&]() -> ConstEval::Result { auto* m = args[0]; auto* mat_ty = m->Type()->As(); auto me = [&](size_t r, size_t c) { return m->Index(c)->Index(r); }; @@ -2899,6 +2911,49 @@ ConstEval::Result ConstEval::radians(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0]); } +ConstEval::Result ConstEval::reflect(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto calculate = [&]() -> ConstEval::Result { + // For the incident vector e1 and surface orientation e2, returns the reflection direction + // e1 - 2 * dot(e2, e1) * e2. + auto* e1 = args[0]; + auto* e2 = args[1]; + auto* vec_ty = ty->As(); + auto* el_ty = vec_ty->type(); + + // dot(e2, e1) + auto dot_e2_e1 = Dot(source, e2, e1); + if (!dot_e2_e1) { + return utils::Failure; + } + + // 2 * dot(e2, e1) + auto mul2 = [&](auto v) -> ImplResult { + using NumberT = decltype(v); + return CreateElement(builder, source, el_ty, NumberT{NumberT{2} * v}); + }; + auto dot_e2_e1_2 = Dispatch_fa_f32_f16(mul2, dot_e2_e1.Get()); + if (!dot_e2_e1_2) { + return utils::Failure; + } + + // 2 * dot(e2, e1) * e2 + auto dot_e2_e1_2_e2 = Mul(source, ty, dot_e2_e1_2.Get(), e2); + if (!dot_e2_e1_2_e2) { + return utils::Failure; + } + + // e1 - 2 * dot(e2, e1) * e2 + return Sub(source, ty, e1, dot_e2_e1_2_e2.Get()); + }; + auto r = calculate(); + if (!r) { + AddNote("when calculating reflect", source); + } + return r; +} + ConstEval::Result ConstEval::reverseBits(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 df1db17806..1a16a79bb7 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -791,6 +791,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// reflect builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result reflect(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// reverseBits builtin /// @param ty the expression type /// @param args the input arguments @@ -1261,13 +1270,35 @@ class ConstEval { /// @returns the dot product Result Dot(const Source& source, const sem::Constant* v1, const sem::Constant* v2); - /// Return sthe length of c0 + /// Returns the length of c0 /// @param source the source location /// @param ty the return type /// @param c0 the constant to calculate the length of /// @returns the length of c0 Result Length(const Source& source, const sem::Type* ty, const sem::Constant* c0); + /// Returns the product of v1 and v2 + /// @param source the source location + /// @param ty the return type + /// @param v1 lhs value + /// @param v2 rhs value + /// @returns the product of v1 and v2 + Result Mul(const Source& source, + const sem::Type* ty, + const sem::Constant* v1, + const sem::Constant* v2); + + /// Returns the difference between v2 and v1 + /// @param source the source location + /// @param ty the return type + /// @param v1 lhs value + /// @param v2 rhs value + /// @returns the difference between v2 and v1 + Result Sub(const Source& source, + const sem::Type* ty, + const sem::Constant* v1, + const sem::Constant* v2); + ProgramBuilder& builder; }; diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 7c5d708ba2..1860886840 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1934,6 +1934,61 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(ReverseBitsCases(), // ReverseBitsCases())))); +template +std::vector ReflectCases() { + auto pos_y = Vec(T(0), T(1), T(0)); + auto neg_y = Vec(T(0), -T(1), T(0)); + auto pos_large_y = Vec(T(0), T(10000), T(0)); + auto neg_large_y = Vec(T(0), -T(10000), T(0)); + + auto cos_45 = T(0.70710678118654752440084436210485); + auto pos_xyz = Vec(cos_45, cos_45, cos_45); + + auto r = std::vector{ + C({Vec(T(1), -T(1), T(0)), pos_y}, Vec(T(1), T(1), T(0))), + C({Vec(T(24), -T(42), T(0)), pos_y}, Vec(T(24), T(42), T(0))), + // Flipping reflection vector doesn't change the result + C({Vec(T(1), -T(1), T(0)), neg_y}, Vec(T(1), T(1), T(0))), + C({Vec(T(24), -T(42), T(0)), neg_y}, Vec(T(24), T(42), T(0))), + // Parallel input and reflection vectors: result is negation of input + C({pos_y, pos_y}, neg_y), + C({neg_y, pos_y}, pos_y), + C({pos_large_y, pos_y}, neg_large_y), + C({neg_large_y, pos_y}, pos_large_y), + // Input axis vectors reflected by normalized(vec(1,1,1)) vector. + C({Vec(T(1), T(0), T(0)), pos_xyz}, Vec(T(0), -T(1), -T(1))).FloatComp(0.02), + C({Vec(T(0), T(1), T(0)), pos_xyz}, Vec(-T(1), T(0), -T(1))).FloatComp(0.02), + C({Vec(T(0), T(0), T(1)), pos_xyz}, Vec(-T(1), -T(1), T(0))).FloatComp(0.02), + C({Vec(-T(1), T(0), T(0)), pos_xyz}, Vec(T(0), T(1), T(1))).FloatComp(0.02), + C({Vec(T(0), -T(1), T(0)), pos_xyz}, Vec(T(1), T(0), T(1))).FloatComp(0.02), + C({Vec(T(0), T(0), -T(1)), pos_xyz}, Vec(T(1), T(1), T(0))).FloatComp(0.02), + }; + + auto error_msg = [](auto a, const char* op, auto b) { + return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( +12:34 note: when calculating reflect)"; + }; + ConcatInto( // + r, std::vector{ + // Overflow the dot product operation + E({Vec(T::Highest(), T::Highest(), T(0)), Vec(T(1), T(1), T(0))}, + error_msg(T::Highest(), "+", T::Highest())), + E({Vec(T::Lowest(), T::Lowest(), T(0)), Vec(T(1), T(1), T(0))}, + error_msg(T::Lowest(), "+", T::Lowest())), + }); + + return r; +} +INSTANTIATE_TEST_SUITE_P( // + Reflect, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kReflect), + testing::ValuesIn( + // ReflectCases()))); + Concat(ReflectCases(), // + ReflectCases(), // + ReflectCases())))); + template std::vector RadiansCases() { return std::vector{ diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index 0d27805ce9..42b6f92963 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -105,34 +105,34 @@ inline void CheckConstant(const sem::Constant* got_constant, auto got = std::get(got_scalar); if constexpr (std::is_same_v) { - EXPECT_EQ(got, expected); + EXPECT_EQ(got, expected) << "index: " << i; } else if constexpr (IsFloatingPoint) { if (std::isnan(expected)) { - EXPECT_TRUE(std::isnan(got)); + EXPECT_TRUE(std::isnan(got)) << "index: " << i; } else { if (flags.pos_or_neg) { got = Abs(got); } if (flags.float_compare) { if (flags.float_compare_epsilon) { - EXPECT_NEAR(got, expected, *flags.float_compare_epsilon); + EXPECT_NEAR(got, expected, *flags.float_compare_epsilon) + << "index: " << i; } else { - EXPECT_FLOAT_EQ(got, expected); + EXPECT_FLOAT_EQ(got, expected) << "index: " << i; } } else { - EXPECT_EQ(got, expected); + EXPECT_EQ(got, expected) << "index: " << i; } } } else { if (flags.pos_or_neg) { - auto got_abs = Abs(got); - EXPECT_EQ(got_abs, expected); - } else { - EXPECT_EQ(got, expected); + got = Abs(got); } + EXPECT_EQ(got, expected) << "index: " << i; + // Check that the constant's integer doesn't contain unexpected // data in the MSBs that are outside of the bit-width of T. - EXPECT_EQ(AInt(got), AInt(expected)); + EXPECT_EQ(AInt(got), AInt(expected)) << "index: " << i; } }, expected_scalar); diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index e521a9ce00..94044bfb9a 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -13698,12 +13698,12 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[626], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::reflect, }, { /* [449] */ @@ -14415,7 +14415,7 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [63] */ - /* fn reflect(vec, vec) -> vec */ + /* fn reflect(vec, vec) -> vec */ /* num overloads */ 1, /* overloads */ &kOverloads[448], }, diff --git a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.dxc.hlsl index fd73a286ea..6f444479ea 100644 --- a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_05357e() { - float4 res = reflect((1.0f).xxxx, (1.0f).xxxx); + float4 res = (-7.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.fxc.hlsl index fd73a286ea..6f444479ea 100644 --- a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reflect_05357e() { - float4 res = reflect((1.0f).xxxx, (1.0f).xxxx); + float4 res = (-7.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.glsl index 3921ef5650..d0d626386d 100644 --- a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reflect_05357e() { - vec4 res = reflect(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(-7.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reflect_05357e() { - vec4 res = reflect(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(-7.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reflect_05357e() { - vec4 res = reflect(vec4(1.0f), vec4(1.0f)); + vec4 res = vec4(-7.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.msl index 6a895d1b03..dc4902387d 100644 --- a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_05357e() { - float4 res = reflect(float4(1.0f), float4(1.0f)); + float4 res = float4(-7.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.spvasm index 2e975508d7..1270752e01 100644 --- a/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/05357e.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %float_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %reflect_05357e = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Reflect %16 %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %reflect_05357e +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %reflect_05357e OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %reflect_05357e + %26 = OpLabel + %27 = OpFunctionCall %void %reflect_05357e OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reflect_05357e + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_05357e OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.dxc.hlsl index df49cea0d3..cec687cb56 100644 --- a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_310de5() { - vector res = reflect((float16_t(1.0h)).xxxx, (float16_t(1.0h)).xxxx); + vector res = (float16_t(-7.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.glsl index 278aae3f47..50d8018339 100644 --- a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void reflect_310de5() { - f16vec4 res = reflect(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(-7.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void reflect_310de5() { - f16vec4 res = reflect(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(-7.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void reflect_310de5() { - f16vec4 res = reflect(f16vec4(1.0hf), f16vec4(1.0hf)); + f16vec4 res = f16vec4(-7.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.msl index cea7ea6fc2..ed9ddfd3b0 100644 --- a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_310de5() { - half4 res = reflect(half4(1.0h), half4(1.0h)); + half4 res = half4(-7.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.spvasm index bc8cf64e8f..1662f545d7 100644 --- a/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/310de5.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_n0x1_cp_2 = OpConstant %half -0x1.cp+2 + %16 = OpConstantComposite %v4half %half_n0x1_cp_2 %half_n0x1_cp_2 %half_n0x1_cp_2 %half_n0x1_cp_2 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reflect_310de5 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Reflect %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %reflect_310de5 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reflect_310de5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %reflect_310de5 + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_310de5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %reflect_310de5 + %32 = OpLabel + %33 = OpFunctionCall %void %reflect_310de5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.dxc.hlsl index f5e64c6190..4b9e0bd513 100644 --- a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_61ca21() { - vector res = reflect((float16_t(1.0h)).xxx, (float16_t(1.0h)).xxx); + vector res = (float16_t(-5.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.glsl index c797b566e1..2cbd2fdc6b 100644 --- a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void reflect_61ca21() { - f16vec3 res = reflect(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(-5.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void reflect_61ca21() { - f16vec3 res = reflect(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(-5.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void reflect_61ca21() { - f16vec3 res = reflect(f16vec3(1.0hf), f16vec3(1.0hf)); + f16vec3 res = f16vec3(-5.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.msl index cf8a1a60b5..fa01d980a3 100644 --- a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_61ca21() { - half3 res = reflect(half3(1.0h), half3(1.0h)); + half3 res = half3(-5.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.spvasm index 289c8ce60a..a6f0e1b38f 100644 --- a/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/61ca21.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_n0x1_4p_2 = OpConstant %half -0x1.4p+2 + %16 = OpConstantComposite %v3half %half_n0x1_4p_2 %half_n0x1_4p_2 %half_n0x1_4p_2 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reflect_61ca21 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Reflect %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %reflect_61ca21 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reflect_61ca21 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %reflect_61ca21 + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_61ca21 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %reflect_61ca21 + %32 = OpLabel + %33 = OpFunctionCall %void %reflect_61ca21 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl new file mode 100644 index 0000000000..5a3fd803a6 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.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 reflect(vec<3, fa>, vec<3, fa>) -> vec<3, fa> +fn reflect_a8baf2() { + var res = reflect(vec3(1.), vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_a8baf2(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_a8baf2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_a8baf2(); +} diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..6165f42e79 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_a8baf2() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_a8baf2(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..6165f42e79 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_a8baf2() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_a8baf2(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.glsl new file mode 100644 index 0000000000..216d4691a0 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +vec4 vertex_main() { + reflect_a8baf2(); + 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 reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +void fragment_main() { + reflect_a8baf2(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +void compute_main() { + reflect_a8baf2(); +} + +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/reflect/a8baf2.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.msl new file mode 100644 index 0000000000..32f118f1c8 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_a8baf2() { + float3 res = float3(-5.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +kernel void compute_main() { + reflect_a8baf2(); + return; +} + diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.spvasm new file mode 100644 index 0000000000..0dfefac6f9 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; 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 %reflect_a8baf2 "reflect_a8baf2" + 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 + %v3float = OpTypeVector %float 3 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_a8baf2 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_a8baf2 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_a8baf2 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_a8baf2 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.wgsl new file mode 100644 index 0000000000..4878d5f02b --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/a8baf2.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn reflect_a8baf2() { + var res = reflect(vec3(1.0), vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_a8baf2(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_a8baf2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_a8baf2(); +} diff --git a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.dxc.hlsl index 5762d11c15..90b42890d9 100644 --- a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_b61e10() { - float2 res = reflect((1.0f).xx, (1.0f).xx); + float2 res = (-3.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.fxc.hlsl index 5762d11c15..90b42890d9 100644 --- a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reflect_b61e10() { - float2 res = reflect((1.0f).xx, (1.0f).xx); + float2 res = (-3.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.glsl index 83fb3a6988..459b2e1e73 100644 --- a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reflect_b61e10() { - vec2 res = reflect(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(-3.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reflect_b61e10() { - vec2 res = reflect(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(-3.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reflect_b61e10() { - vec2 res = reflect(vec2(1.0f), vec2(1.0f)); + vec2 res = vec2(-3.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.msl index 2df9be572f..d039f0fee2 100644 --- a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_b61e10() { - float2 res = reflect(float2(1.0f), float2(1.0f)); + float2 res = float2(-3.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.spvasm index 6155906487..7f0741c9e7 100644 --- a/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/b61e10.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %reflect_b61e10 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Reflect %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reflect_b61e10 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_b61e10 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %reflect_b61e10 + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_b61e10 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %reflect_b61e10 + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_b61e10 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.dxc.hlsl index 573d3ee4b3..196943eb73 100644 --- a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_bb15ac() { - vector res = reflect((float16_t(1.0h)).xx, (float16_t(1.0h)).xx); + vector res = (float16_t(-3.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.glsl index 5e9063de32..e9b3594c99 100644 --- a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void reflect_bb15ac() { - f16vec2 res = reflect(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(-3.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void reflect_bb15ac() { - f16vec2 res = reflect(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(-3.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void reflect_bb15ac() { - f16vec2 res = reflect(f16vec2(1.0hf), f16vec2(1.0hf)); + f16vec2 res = f16vec2(-3.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.msl index a3e72b809c..dc37f9ecba 100644 --- a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_bb15ac() { - half2 res = reflect(half2(1.0h), half2(1.0h)); + half2 res = half2(-3.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.spvasm index 275c45f39b..4855d701d0 100644 --- a/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/bb15ac.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_n0x1_8p_1 = OpConstant %half -0x1.8p+1 + %16 = OpConstantComposite %v2half %half_n0x1_8p_1 %half_n0x1_8p_1 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reflect_bb15ac = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Reflect %18 %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %reflect_bb15ac +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reflect_bb15ac OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %reflect_bb15ac + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_bb15ac OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %reflect_bb15ac + %32 = OpLabel + %33 = OpFunctionCall %void %reflect_bb15ac OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl new file mode 100644 index 0000000000..53cd7f770c --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.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 reflect(vec<2, fa>, vec<2, fa>) -> vec<2, fa> +fn reflect_bba2d0() { + var res = reflect(vec2(1.), vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_bba2d0(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_bba2d0(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_bba2d0(); +} diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..7183a0dc82 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_bba2d0() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_bba2d0(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..7183a0dc82 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_bba2d0() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_bba2d0(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.glsl new file mode 100644 index 0000000000..fff1f235bc --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +vec4 vertex_main() { + reflect_bba2d0(); + 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 reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +void fragment_main() { + reflect_bba2d0(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +void compute_main() { + reflect_bba2d0(); +} + +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/reflect/bba2d0.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.msl new file mode 100644 index 0000000000..b4c3ba9b0e --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_bba2d0() { + float2 res = float2(-3.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +kernel void compute_main() { + reflect_bba2d0(); + return; +} + diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.spvasm new file mode 100644 index 0000000000..113c2c7495 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; 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 %reflect_bba2d0 "reflect_bba2d0" + 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 + %v2float = OpTypeVector %float 2 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_bba2d0 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_bba2d0 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_bba2d0 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_bba2d0 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.wgsl new file mode 100644 index 0000000000..8d1bdfdc66 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/bba2d0.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn reflect_bba2d0() { + var res = reflect(vec2(1.0), vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_bba2d0(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_bba2d0(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_bba2d0(); +} diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl new file mode 100644 index 0000000000..21dd9b34bc --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.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 reflect(vec<4, fa>, vec<4, fa>) -> vec<4, fa> +fn reflect_d7e210() { + var res = reflect(vec4(1.), vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_d7e210(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_d7e210(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_d7e210(); +} diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..9d53c4bb6b --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_d7e210() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_d7e210(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..9d53c4bb6b --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_d7e210() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_d7e210(); + return; +} diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.glsl new file mode 100644 index 0000000000..a1507a5a26 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +vec4 vertex_main() { + reflect_d7e210(); + 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 reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +void fragment_main() { + reflect_d7e210(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +void compute_main() { + reflect_d7e210(); +} + +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/reflect/d7e210.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.msl new file mode 100644 index 0000000000..e2e4cb5f40 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_d7e210() { + float4 res = float4(-7.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +kernel void compute_main() { + reflect_d7e210(); + return; +} + diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.spvasm new file mode 100644 index 0000000000..ceb4be6ac5 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; 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 %reflect_d7e210 "reflect_d7e210" + 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_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_d7e210 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %reflect_d7e210 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %reflect_d7e210 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_d7e210 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.wgsl new file mode 100644 index 0000000000..b3fe5b2b01 --- /dev/null +++ b/test/tint/builtins/gen/literal/reflect/d7e210.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn reflect_d7e210() { + var res = reflect(vec4(1.0), vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_d7e210(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_d7e210(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_d7e210(); +} diff --git a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.dxc.hlsl index a98a1fef23..0d2e5ba5a7 100644 --- a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reflect_f47fdb() { - float3 res = reflect((1.0f).xxx, (1.0f).xxx); + float3 res = (-5.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.fxc.hlsl index a98a1fef23..0d2e5ba5a7 100644 --- a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reflect_f47fdb() { - float3 res = reflect((1.0f).xxx, (1.0f).xxx); + float3 res = (-5.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.glsl index cdddcc02dc..4e2c08ef63 100644 --- a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reflect_f47fdb() { - vec3 res = reflect(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(-5.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reflect_f47fdb() { - vec3 res = reflect(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(-5.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reflect_f47fdb() { - vec3 res = reflect(vec3(1.0f), vec3(1.0f)); + vec3 res = vec3(-5.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.msl b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.msl index 36e3c60dde..6b8595d86e 100644 --- a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reflect_f47fdb() { - float3 res = reflect(float3(1.0f), float3(1.0f)); + float3 res = float3(-5.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.spvasm index 69731e22a1..4a1dc75080 100644 --- a/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reflect/f47fdb.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %reflect_f47fdb = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Reflect %17 %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reflect_f47fdb +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_f47fdb OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %reflect_f47fdb + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_f47fdb OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %reflect_f47fdb + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_f47fdb OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl new file mode 100644 index 0000000000..c2d3817c94 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.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 reflect(vec<3, fa>, vec<3, fa>) -> vec<3, fa> +fn reflect_a8baf2() { + const arg_0 = vec3(1.); + const arg_1 = vec3(1.); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_a8baf2(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_a8baf2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_a8baf2(); +} diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..6165f42e79 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_a8baf2() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_a8baf2(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..6165f42e79 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_a8baf2() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_a8baf2(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.glsl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.glsl new file mode 100644 index 0000000000..216d4691a0 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +vec4 vertex_main() { + reflect_a8baf2(); + 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 reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +void fragment_main() { + reflect_a8baf2(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_a8baf2() { + vec3 res = vec3(-5.0f); +} + +void compute_main() { + reflect_a8baf2(); +} + +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/var/reflect/a8baf2.wgsl.expected.msl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.msl new file mode 100644 index 0000000000..32f118f1c8 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_a8baf2() { + float3 res = float3(-5.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_a8baf2(); + 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() { + reflect_a8baf2(); + return; +} + +kernel void compute_main() { + reflect_a8baf2(); + return; +} + diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.spvasm b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.spvasm new file mode 100644 index 0000000000..0dfefac6f9 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; 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 %reflect_a8baf2 "reflect_a8baf2" + 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 + %v3float = OpTypeVector %float 3 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_a8baf2 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_a8baf2 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_a8baf2 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_a8baf2 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.wgsl b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.wgsl new file mode 100644 index 0000000000..2c797fa822 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/a8baf2.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn reflect_a8baf2() { + const arg_0 = vec3(1.0); + const arg_1 = vec3(1.0); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_a8baf2(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_a8baf2(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_a8baf2(); +} diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl new file mode 100644 index 0000000000..6010b5d148 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.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 reflect(vec<2, fa>, vec<2, fa>) -> vec<2, fa> +fn reflect_bba2d0() { + const arg_0 = vec2(1.); + const arg_1 = vec2(1.); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_bba2d0(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_bba2d0(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_bba2d0(); +} diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..7183a0dc82 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_bba2d0() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_bba2d0(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..7183a0dc82 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_bba2d0() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_bba2d0(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.glsl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.glsl new file mode 100644 index 0000000000..fff1f235bc --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +vec4 vertex_main() { + reflect_bba2d0(); + 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 reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +void fragment_main() { + reflect_bba2d0(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_bba2d0() { + vec2 res = vec2(-3.0f); +} + +void compute_main() { + reflect_bba2d0(); +} + +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/var/reflect/bba2d0.wgsl.expected.msl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.msl new file mode 100644 index 0000000000..b4c3ba9b0e --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_bba2d0() { + float2 res = float2(-3.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_bba2d0(); + 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() { + reflect_bba2d0(); + return; +} + +kernel void compute_main() { + reflect_bba2d0(); + return; +} + diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.spvasm b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.spvasm new file mode 100644 index 0000000000..113c2c7495 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; 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 %reflect_bba2d0 "reflect_bba2d0" + 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 + %v2float = OpTypeVector %float 2 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_bba2d0 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %reflect_bba2d0 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %reflect_bba2d0 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %reflect_bba2d0 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.wgsl b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.wgsl new file mode 100644 index 0000000000..40b6a4cabc --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/bba2d0.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn reflect_bba2d0() { + const arg_0 = vec2(1.0); + const arg_1 = vec2(1.0); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_bba2d0(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_bba2d0(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_bba2d0(); +} diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl new file mode 100644 index 0000000000..7fc7db2058 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.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 reflect(vec<4, fa>, vec<4, fa>) -> vec<4, fa> +fn reflect_d7e210() { + const arg_0 = vec4(1.); + const arg_1 = vec4(1.); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_d7e210(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_d7e210(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_d7e210(); +} diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..9d53c4bb6b --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void reflect_d7e210() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_d7e210(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..9d53c4bb6b --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void reflect_d7e210() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + reflect_d7e210(); + return; +} diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.glsl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.glsl new file mode 100644 index 0000000000..a1507a5a26 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +vec4 vertex_main() { + reflect_d7e210(); + 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 reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +void fragment_main() { + reflect_d7e210(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void reflect_d7e210() { + vec4 res = vec4(-7.0f); +} + +void compute_main() { + reflect_d7e210(); +} + +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/var/reflect/d7e210.wgsl.expected.msl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.msl new file mode 100644 index 0000000000..e2e4cb5f40 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void reflect_d7e210() { + float4 res = float4(-7.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + reflect_d7e210(); + 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() { + reflect_d7e210(); + return; +} + +kernel void compute_main() { + reflect_d7e210(); + return; +} + diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.spvasm b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.spvasm new file mode 100644 index 0000000000..ceb4be6ac5 --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; 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 %reflect_d7e210 "reflect_d7e210" + 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_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%reflect_d7e210 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %reflect_d7e210 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %reflect_d7e210 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %reflect_d7e210 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.wgsl b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.wgsl new file mode 100644 index 0000000000..102bb08bda --- /dev/null +++ b/test/tint/builtins/gen/var/reflect/d7e210.wgsl.expected.wgsl @@ -0,0 +1,21 @@ +fn reflect_d7e210() { + const arg_0 = vec4(1.0); + const arg_1 = vec4(1.0); + var res = reflect(arg_0, arg_1); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + reflect_d7e210(); + return vec4(); +} + +@fragment +fn fragment_main() { + reflect_d7e210(); +} + +@compute @workgroup_size(1) +fn compute_main() { + reflect_d7e210(); +}