From 91ed6f7289a4a5f070538facc6e3445ad16b2810 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 27 Oct 2022 16:41:44 +0000 Subject: [PATCH] Add const-eval for `saturate`. This CL adds const-eval for the `saturate` builtin. Bug: tint:1581 Change-Id: I3729ea5b381b04b73bbe1bc8e03e5ce65c27e082 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107362 Kokoro: Kokoro Reviewed-by: Antonio Maiorano Commit-Queue: Dan Sinclair --- src/tint/intrinsics.def | 4 +- src/tint/resolver/const_eval.cc | 14 ++++ src/tint/resolver/const_eval.h | 9 +++ src/tint/resolver/const_eval_builtin_test.cc | 25 +++++++ src/tint/resolver/intrinsic_table.inl | 12 ++-- src/tint/transform/builtin_polyfill_test.cc | 44 ------------- .../builtins/gen/literal/saturate/270da5.wgsl | 2 +- .../saturate/270da5.wgsl.expected.dxc.hlsl | 2 +- .../saturate/270da5.wgsl.expected.fxc.hlsl | 2 +- .../saturate/270da5.wgsl.expected.glsl | 6 +- .../literal/saturate/270da5.wgsl.expected.msl | 2 +- .../saturate/270da5.wgsl.expected.spvasm | 27 ++++---- .../saturate/270da5.wgsl.expected.wgsl | 2 +- .../saturate/462535.wgsl.expected.dxc.hlsl | 2 +- .../literal/saturate/462535.wgsl.expected.msl | 2 +- .../builtins/gen/literal/saturate/4ed8d7.wgsl | 43 ++++++++++++ .../saturate/4ed8d7.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/4ed8d7.wgsl.expected.fxc.hlsl | 30 +++++++++ .../saturate/4ed8d7.wgsl.expected.glsl | 49 ++++++++++++++ .../literal/saturate/4ed8d7.wgsl.expected.msl | 33 ++++++++++ .../saturate/4ed8d7.wgsl.expected.spvasm | 64 ++++++++++++++++++ .../saturate/4ed8d7.wgsl.expected.wgsl | 19 ++++++ .../builtins/gen/literal/saturate/51567f.wgsl | 2 +- .../saturate/51567f.wgsl.expected.dxc.hlsl | 2 +- .../saturate/51567f.wgsl.expected.fxc.hlsl | 2 +- .../saturate/51567f.wgsl.expected.glsl | 6 +- .../literal/saturate/51567f.wgsl.expected.msl | 2 +- .../saturate/51567f.wgsl.expected.spvasm | 28 ++++---- .../saturate/51567f.wgsl.expected.wgsl | 2 +- .../builtins/gen/literal/saturate/6bcddf.wgsl | 2 +- .../saturate/6bcddf.wgsl.expected.dxc.hlsl | 2 +- .../saturate/6bcddf.wgsl.expected.fxc.hlsl | 2 +- .../saturate/6bcddf.wgsl.expected.glsl | 6 +- .../literal/saturate/6bcddf.wgsl.expected.msl | 2 +- .../saturate/6bcddf.wgsl.expected.spvasm | 28 ++++---- .../saturate/6bcddf.wgsl.expected.wgsl | 2 +- .../builtins/gen/literal/saturate/78b37c.wgsl | 43 ++++++++++++ .../saturate/78b37c.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/78b37c.wgsl.expected.fxc.hlsl | 30 +++++++++ .../saturate/78b37c.wgsl.expected.glsl | 49 ++++++++++++++ .../literal/saturate/78b37c.wgsl.expected.msl | 33 ++++++++++ .../saturate/78b37c.wgsl.expected.spvasm | 63 ++++++++++++++++++ .../saturate/78b37c.wgsl.expected.wgsl | 19 ++++++ .../builtins/gen/literal/saturate/a5b571.wgsl | 2 +- .../saturate/a5b571.wgsl.expected.dxc.hlsl | 2 +- .../saturate/a5b571.wgsl.expected.fxc.hlsl | 2 +- .../saturate/a5b571.wgsl.expected.glsl | 6 +- .../literal/saturate/a5b571.wgsl.expected.msl | 2 +- .../saturate/a5b571.wgsl.expected.spvasm | 28 ++++---- .../saturate/a5b571.wgsl.expected.wgsl | 2 +- .../saturate/cd2028.wgsl.expected.dxc.hlsl | 2 +- .../literal/saturate/cd2028.wgsl.expected.msl | 2 +- .../builtins/gen/literal/saturate/d55822.wgsl | 43 ++++++++++++ .../saturate/d55822.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/d55822.wgsl.expected.fxc.hlsl | 30 +++++++++ .../saturate/d55822.wgsl.expected.glsl | 49 ++++++++++++++ .../literal/saturate/d55822.wgsl.expected.msl | 33 ++++++++++ .../saturate/d55822.wgsl.expected.spvasm | 66 +++++++++++++++++++ .../saturate/d55822.wgsl.expected.wgsl | 19 ++++++ .../saturate/dcde71.wgsl.expected.dxc.hlsl | 2 +- .../literal/saturate/dcde71.wgsl.expected.msl | 2 +- .../builtins/gen/literal/saturate/e40fb6.wgsl | 43 ++++++++++++ .../saturate/e40fb6.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/e40fb6.wgsl.expected.fxc.hlsl | 30 +++++++++ .../saturate/e40fb6.wgsl.expected.glsl | 49 ++++++++++++++ .../literal/saturate/e40fb6.wgsl.expected.msl | 33 ++++++++++ .../saturate/e40fb6.wgsl.expected.spvasm | 66 +++++++++++++++++++ .../saturate/e40fb6.wgsl.expected.wgsl | 19 ++++++ .../saturate/e8df56.wgsl.expected.dxc.hlsl | 2 +- .../literal/saturate/e8df56.wgsl.expected.msl | 2 +- .../builtins/gen/var/saturate/270da5.wgsl | 2 +- .../saturate/270da5.wgsl.expected.dxc.hlsl | 2 +- .../saturate/270da5.wgsl.expected.fxc.hlsl | 2 +- .../var/saturate/270da5.wgsl.expected.glsl | 6 +- .../gen/var/saturate/270da5.wgsl.expected.msl | 2 +- .../var/saturate/270da5.wgsl.expected.spvasm | 33 +++++----- .../var/saturate/270da5.wgsl.expected.wgsl | 2 +- .../builtins/gen/var/saturate/4ed8d7.wgsl | 44 +++++++++++++ .../saturate/4ed8d7.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/4ed8d7.wgsl.expected.fxc.hlsl | 30 +++++++++ .../var/saturate/4ed8d7.wgsl.expected.glsl | 49 ++++++++++++++ .../gen/var/saturate/4ed8d7.wgsl.expected.msl | 33 ++++++++++ .../var/saturate/4ed8d7.wgsl.expected.spvasm | 64 ++++++++++++++++++ .../var/saturate/4ed8d7.wgsl.expected.wgsl | 20 ++++++ .../builtins/gen/var/saturate/51567f.wgsl | 2 +- .../saturate/51567f.wgsl.expected.dxc.hlsl | 2 +- .../saturate/51567f.wgsl.expected.fxc.hlsl | 2 +- .../var/saturate/51567f.wgsl.expected.glsl | 6 +- .../gen/var/saturate/51567f.wgsl.expected.msl | 2 +- .../var/saturate/51567f.wgsl.expected.spvasm | 34 +++++----- .../var/saturate/51567f.wgsl.expected.wgsl | 2 +- .../builtins/gen/var/saturate/6bcddf.wgsl | 2 +- .../saturate/6bcddf.wgsl.expected.dxc.hlsl | 2 +- .../saturate/6bcddf.wgsl.expected.fxc.hlsl | 2 +- .../var/saturate/6bcddf.wgsl.expected.glsl | 6 +- .../gen/var/saturate/6bcddf.wgsl.expected.msl | 2 +- .../var/saturate/6bcddf.wgsl.expected.spvasm | 34 +++++----- .../var/saturate/6bcddf.wgsl.expected.wgsl | 2 +- .../builtins/gen/var/saturate/78b37c.wgsl | 44 +++++++++++++ .../saturate/78b37c.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/78b37c.wgsl.expected.fxc.hlsl | 30 +++++++++ .../var/saturate/78b37c.wgsl.expected.glsl | 49 ++++++++++++++ .../gen/var/saturate/78b37c.wgsl.expected.msl | 33 ++++++++++ .../var/saturate/78b37c.wgsl.expected.spvasm | 63 ++++++++++++++++++ .../var/saturate/78b37c.wgsl.expected.wgsl | 20 ++++++ .../builtins/gen/var/saturate/a5b571.wgsl | 2 +- .../saturate/a5b571.wgsl.expected.dxc.hlsl | 2 +- .../saturate/a5b571.wgsl.expected.fxc.hlsl | 2 +- .../var/saturate/a5b571.wgsl.expected.glsl | 6 +- .../gen/var/saturate/a5b571.wgsl.expected.msl | 2 +- .../var/saturate/a5b571.wgsl.expected.spvasm | 34 +++++----- .../var/saturate/a5b571.wgsl.expected.wgsl | 2 +- .../builtins/gen/var/saturate/d55822.wgsl | 44 +++++++++++++ .../saturate/d55822.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/d55822.wgsl.expected.fxc.hlsl | 30 +++++++++ .../var/saturate/d55822.wgsl.expected.glsl | 49 ++++++++++++++ .../gen/var/saturate/d55822.wgsl.expected.msl | 33 ++++++++++ .../var/saturate/d55822.wgsl.expected.spvasm | 66 +++++++++++++++++++ .../var/saturate/d55822.wgsl.expected.wgsl | 20 ++++++ .../builtins/gen/var/saturate/e40fb6.wgsl | 44 +++++++++++++ .../saturate/e40fb6.wgsl.expected.dxc.hlsl | 30 +++++++++ .../saturate/e40fb6.wgsl.expected.fxc.hlsl | 30 +++++++++ .../var/saturate/e40fb6.wgsl.expected.glsl | 49 ++++++++++++++ .../gen/var/saturate/e40fb6.wgsl.expected.msl | 33 ++++++++++ .../var/saturate/e40fb6.wgsl.expected.spvasm | 66 +++++++++++++++++++ .../var/saturate/e40fb6.wgsl.expected.wgsl | 20 ++++++ 126 files changed, 2416 insertions(+), 240 deletions(-) create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 01dd50179d..90766ccdca 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -522,8 +522,8 @@ fn reverseBits(T) -> T fn reverseBits(vec) -> vec fn round(T) -> T fn round(vec) -> vec -fn saturate(T) -> T -fn saturate(vec) -> vec +@const fn saturate(@test_value(2) T) -> T +@const fn saturate(@test_value(2) vec) -> vec @const("select_bool") fn select(T, T, bool) -> T @const("select_bool") fn select(vec, vec, bool) -> vec @const("select_boolvec") fn select(vec, vec, vec) -> vec diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 1d0d333a21..de29bc3d5d 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1616,6 +1616,20 @@ ConstEval::Result ConstEval::clamp(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0], args[1], args[2]); } +ConstEval::Result ConstEval::saturate(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto e) { + using NumberT = decltype(e); + return CreateElement(builder, c0->Type(), + NumberT(std::min(std::max(e, NumberT(0.0)), NumberT(1.0)))); + }; + return Dispatch_fia_fiu32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::select_bool(const sem::Type* ty, utils::VectorRef args, const Source&) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 425b524d54..cffdcca9c5 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -431,6 +431,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// saturate 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 saturate(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// select builtin with single bool third arg /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index c35099e4c6..09e73da0e5 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -460,6 +460,31 @@ INSTANTIATE_TEST_SUITE_P( // ClampCases(), ClampCases())))); +template +std::vector SaturateCases() { + return { + C({T(0)}, T(0)), + C({T(1)}, T(1)), + C({T::Lowest()}, T(0)), + C({T::Highest()}, T(1)), + + // Vector tests + C({Vec(T(0), T(0))}, // + Vec(T(0), T(0))), // + C({Vec(T(1), T(1))}, // + Vec(T(1), T(1))), // + C({Vec(T::Lowest(), T(0), T::Highest())}, // + Vec(T(0), T(0), T(1))), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Saturate, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kSaturate), + testing::ValuesIn(Concat(SaturateCases(), // + SaturateCases(), + SaturateCases())))); + template std::vector SelectCases() { return { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 785cce1b47..826307dc33 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12407,24 +12407,24 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[902], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::saturate, }, { /* [341] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[25], + /* template types */ &kTemplateTypes[24], /* template numbers */ &kTemplateNumbers[5], /* parameters */ &kParameters[903], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::saturate, }, { /* [342] */ @@ -14427,8 +14427,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [66] */ - /* fn saturate(T) -> T */ - /* fn saturate(vec) -> vec */ + /* fn saturate(@test_value(2) T) -> T */ + /* fn saturate(@test_value(2) vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[340], }, diff --git a/src/tint/transform/builtin_polyfill_test.cc b/src/tint/transform/builtin_polyfill_test.cc index 40059ca25e..dc76eb01ba 100644 --- a/src/tint/transform/builtin_polyfill_test.cc +++ b/src/tint/transform/builtin_polyfill_test.cc @@ -1435,28 +1435,6 @@ fn f() { EXPECT_EQ(expect, str(got)); } -TEST_F(BuiltinPolyfillTest, Saturate_f32_from_abstract_float) { - auto* src = R"( -fn f() { - let r : f32 = saturate(0.5); -} -)"; - - auto* expect = R"( -fn tint_saturate(v : f32) -> f32 { - return clamp(v, f32(0), f32(1)); -} - -fn f() { - let r : f32 = tint_saturate(0.5); -} -)"; - - auto got = Run(src, polyfillSaturate()); - - EXPECT_EQ(expect, str(got)); -} - TEST_F(BuiltinPolyfillTest, Saturate_f16) { auto* src = R"( enable f16; @@ -1505,28 +1483,6 @@ fn f() { EXPECT_EQ(expect, str(got)); } -TEST_F(BuiltinPolyfillTest, Saturate_vec3_f32_from_abstract_float) { - auto* src = R"( -fn f() { - let r : vec3 = saturate(vec3(0.5)); -} -)"; - - auto* expect = R"( -fn tint_saturate(v : vec3) -> vec3 { - return clamp(v, vec3(0), vec3(1)); -} - -fn f() { - let r : vec3 = tint_saturate(vec3(0.5)); -} -)"; - - auto got = Run(src, polyfillSaturate()); - - EXPECT_EQ(expect, str(got)); -} - TEST_F(BuiltinPolyfillTest, Saturate_vec3_f16) { auto* src = R"( enable f16; diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl index 2ec5cec1a8..263c53d17b 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl @@ -23,7 +23,7 @@ // fn saturate(f32) -> f32 fn saturate_270da5() { - var res: f32 = saturate(1.f); + var res: f32 = saturate(2.f); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl index 6d8db4ca81..ea2aa83845 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_270da5() { - float res = saturate(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl index 6d8db4ca81..ea2aa83845 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_270da5() { - float res = saturate(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl index f9313c7ffd..99d917d4b9 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl @@ -5,7 +5,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float res = tint_saturate(1.0f); + float res = tint_saturate(2.0f); } vec4 vertex_main() { @@ -29,7 +29,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float res = tint_saturate(1.0f); + float res = tint_saturate(2.0f); } void fragment_main() { @@ -47,7 +47,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float res = tint_saturate(1.0f); + float res = tint_saturate(2.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl index 1b6a3dcd25..5d05accd91 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_270da5() { - float res = saturate(1.0f); + float res = 1.0f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm index 4eea101a4f..47550a299e 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 37 ; Schema: 0 OpCapability Shader %14 = OpExtInstImport "GLSL.std.450" @@ -35,8 +35,9 @@ %float_1 = OpConstant %float 1 %void = OpTypeVoid %16 = OpTypeFunction %void + %float_2 = OpConstant %float 2 %_ptr_Function_float = OpTypePointer Function %float - %23 = OpTypeFunction %v4float + %24 = OpTypeFunction %v4float %tint_saturate = OpFunction %float None %9 %v = OpFunctionParameter %float %12 = OpLabel @@ -46,29 +47,29 @@ %saturate_270da5 = OpFunction %void None %16 %19 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %20 = OpFunctionCall %float %tint_saturate %float_1 + %20 = OpFunctionCall %float %tint_saturate %float_2 OpStore %res %20 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %23 - %25 = OpLabel - %26 = OpFunctionCall %void %saturate_270da5 +%vertex_main_inner = OpFunction %v4float None %24 + %26 = OpLabel + %27 = OpFunctionCall %void %saturate_270da5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %16 - %28 = OpLabel - %29 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %29 + %29 = OpLabel + %30 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %30 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %16 - %31 = OpLabel - %32 = OpFunctionCall %void %saturate_270da5 + %32 = OpLabel + %33 = OpFunctionCall %void %saturate_270da5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %16 - %34 = OpLabel - %35 = OpFunctionCall %void %saturate_270da5 + %35 = OpLabel + %36 = OpFunctionCall %void %saturate_270da5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl index dc2a36a6f3..006c87108a 100644 --- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_270da5() { - var res : f32 = saturate(1.0f); + var res : f32 = saturate(2.0f); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl index cd2602f6e1..23800c3e64 100644 --- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_462535() { - vector res = saturate((float16_t(0.0h)).xxx); + vector res = (float16_t(0.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl index 52dd6d5351..35014be5fd 100644 --- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_462535() { - half3 res = saturate(half3(0.0h)); + half3 res = half3(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl new file mode 100644 index 0000000000..d730ec4de2 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.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 saturate(vec<4, fa>) -> vec<4, fa> +fn saturate_4ed8d7() { + var res = saturate(vec4(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_4ed8d7(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_4ed8d7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_4ed8d7(); +} diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..6bafa64342 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_4ed8d7() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_4ed8d7(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..6bafa64342 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_4ed8d7() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_4ed8d7(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl new file mode 100644 index 0000000000..e6bfa97a24 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + saturate_4ed8d7(); + 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 saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + saturate_4ed8d7(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + saturate_4ed8d7(); +} + +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/saturate/4ed8d7.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.msl new file mode 100644 index 0000000000..f6dfde6a3d --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_4ed8d7() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +kernel void compute_main() { + saturate_4ed8d7(); + return; +} + diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm new file mode 100644 index 0000000000..91bfee1c0f --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_4ed8d7 "saturate_4ed8d7" + 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_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float +%saturate_4ed8d7 = 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 %saturate_4ed8d7 + 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 + %25 = OpLabel + %26 = OpFunctionCall %void %saturate_4ed8d7 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %saturate_4ed8d7 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl new file mode 100644 index 0000000000..4ef920788c --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn saturate_4ed8d7() { + var res = saturate(vec4(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_4ed8d7(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_4ed8d7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_4ed8d7(); +} diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl index 3cfebefea1..23daad5908 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<2, f32>) -> vec<2, f32> fn saturate_51567f() { - var res: vec2 = saturate(vec2(1.f)); + var res: vec2 = saturate(vec2(2.f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl index 4110251af1..8d8a7de6d4 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_51567f() { - float2 res = saturate((1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl index 4110251af1..8d8a7de6d4 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_51567f() { - float2 res = saturate((1.0f).xx); + float2 res = (1.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl index 2646c1f434..8b4840ef0e 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 res = tint_saturate(vec2(1.0f)); + vec2 res = tint_saturate(vec2(2.0f)); } vec4 vertex_main() { @@ -29,7 +29,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 res = tint_saturate(vec2(1.0f)); + vec2 res = tint_saturate(vec2(2.0f)); } void fragment_main() { @@ -47,7 +47,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 res = tint_saturate(vec2(1.0f)); + vec2 res = tint_saturate(vec2(2.0f)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl index d3d4e00bba..aa4854a0ff 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_51567f() { - float2 res = saturate(float2(1.0f)); + float2 res = float2(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm index 46f1ae9f3d..563368c3d2 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 41 ; Schema: 0 OpCapability Shader %15 = OpExtInstImport "GLSL.std.450" @@ -38,8 +38,10 @@ %18 = OpConstantComposite %v2float %float_1 %float_1 %void = OpTypeVoid %19 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %25 = OpConstantComposite %v2float %float_2 %float_2 %_ptr_Function_v2float = OpTypePointer Function %v2float - %26 = OpTypeFunction %v4float + %28 = OpTypeFunction %v4float %tint_saturate = OpFunction %v2float None %9 %v = OpFunctionParameter %v2float %13 = OpLabel @@ -49,29 +51,29 @@ %saturate_51567f = OpFunction %void None %19 %22 = OpLabel %res = OpVariable %_ptr_Function_v2float Function %16 - %23 = OpFunctionCall %v2float %tint_saturate %18 + %23 = OpFunctionCall %v2float %tint_saturate %25 OpStore %res %23 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %26 - %28 = OpLabel - %29 = OpFunctionCall %void %saturate_51567f +%vertex_main_inner = OpFunction %v4float None %28 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_51567f OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %19 - %31 = OpLabel - %32 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %32 + %33 = OpLabel + %34 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %34 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %19 - %34 = OpLabel - %35 = OpFunctionCall %void %saturate_51567f + %36 = OpLabel + %37 = OpFunctionCall %void %saturate_51567f OpReturn OpFunctionEnd %compute_main = OpFunction %void None %19 - %37 = OpLabel - %38 = OpFunctionCall %void %saturate_51567f + %39 = OpLabel + %40 = OpFunctionCall %void %saturate_51567f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl index e22d067860..f81f727d4a 100644 --- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_51567f() { - var res : vec2 = saturate(vec2(1.0f)); + var res : vec2 = saturate(vec2(2.0f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl index 0c3e1f8821..da4ce4b13c 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<3, f32>) -> vec<3, f32> fn saturate_6bcddf() { - var res: vec3 = saturate(vec3(1.f)); + var res: vec3 = saturate(vec3(2.f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl index ada840b2bc..444b45a01c 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_6bcddf() { - float3 res = saturate((1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl index ada840b2bc..444b45a01c 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_6bcddf() { - float3 res = saturate((1.0f).xxx); + float3 res = (1.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl index 301fd1c0d2..c5ca265474 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 res = tint_saturate(vec3(1.0f)); + vec3 res = tint_saturate(vec3(2.0f)); } vec4 vertex_main() { @@ -29,7 +29,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 res = tint_saturate(vec3(1.0f)); + vec3 res = tint_saturate(vec3(2.0f)); } void fragment_main() { @@ -47,7 +47,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 res = tint_saturate(vec3(1.0f)); + vec3 res = tint_saturate(vec3(2.0f)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl index 1a54ff0ac8..0cf7e3f115 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_6bcddf() { - float3 res = saturate(float3(1.0f)); + float3 res = float3(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm index bd381f1284..5559bd2a6f 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 41 ; Schema: 0 OpCapability Shader %15 = OpExtInstImport "GLSL.std.450" @@ -38,8 +38,10 @@ %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %void = OpTypeVoid %19 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %25 = OpConstantComposite %v3float %float_2 %float_2 %float_2 %_ptr_Function_v3float = OpTypePointer Function %v3float - %26 = OpTypeFunction %v4float + %28 = OpTypeFunction %v4float %tint_saturate = OpFunction %v3float None %9 %v = OpFunctionParameter %v3float %13 = OpLabel @@ -49,29 +51,29 @@ %saturate_6bcddf = OpFunction %void None %19 %22 = OpLabel %res = OpVariable %_ptr_Function_v3float Function %16 - %23 = OpFunctionCall %v3float %tint_saturate %18 + %23 = OpFunctionCall %v3float %tint_saturate %25 OpStore %res %23 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %26 - %28 = OpLabel - %29 = OpFunctionCall %void %saturate_6bcddf +%vertex_main_inner = OpFunction %v4float None %28 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_6bcddf OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %19 - %31 = OpLabel - %32 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %32 + %33 = OpLabel + %34 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %34 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %19 - %34 = OpLabel - %35 = OpFunctionCall %void %saturate_6bcddf + %36 = OpLabel + %37 = OpFunctionCall %void %saturate_6bcddf OpReturn OpFunctionEnd %compute_main = OpFunction %void None %19 - %37 = OpLabel - %38 = OpFunctionCall %void %saturate_6bcddf + %39 = OpLabel + %40 = OpFunctionCall %void %saturate_6bcddf OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl index b85b66e5c3..c4c3a615a0 100644 --- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_6bcddf() { - var res : vec3 = saturate(vec3(1.0f)); + var res : vec3 = saturate(vec3(2.0f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl new file mode 100644 index 0000000000..4ac82c167f --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.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 saturate(fa) -> fa +fn saturate_78b37c() { + var res = saturate(2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_78b37c(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_78b37c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_78b37c(); +} diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..68051b6550 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_78b37c(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..68051b6550 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_78b37c(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl new file mode 100644 index 0000000000..e660571b79 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_78b37c() { + float res = 1.0f; +} + +vec4 vertex_main() { + saturate_78b37c(); + 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 saturate_78b37c() { + float res = 1.0f; +} + +void fragment_main() { + saturate_78b37c(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_78b37c() { + float res = 1.0f; +} + +void compute_main() { + saturate_78b37c(); +} + +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/saturate/78b37c.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.msl new file mode 100644 index 0000000000..4619ba033c --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +kernel void compute_main() { + saturate_78b37c(); + return; +} + diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm new file mode 100644 index 0000000000..5b55286cd8 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm @@ -0,0 +1,63 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; 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 %saturate_78b37c "saturate_78b37c" + 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_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float +%saturate_78b37c = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %saturate_78b37c + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %saturate_78b37c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_78b37c + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl new file mode 100644 index 0000000000..43b22f6e3e --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn saturate_78b37c() { + var res = saturate(2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_78b37c(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_78b37c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_78b37c(); +} diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl index 57683f29ce..984d4cb575 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<4, f32>) -> vec<4, f32> fn saturate_a5b571() { - var res: vec4 = saturate(vec4(1.f)); + var res: vec4 = saturate(vec4(2.f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl index 2f85096dde..66b0b04acb 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_a5b571() { - float4 res = saturate((1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl index 2f85096dde..66b0b04acb 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_a5b571() { - float4 res = saturate((1.0f).xxxx); + float4 res = (1.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl index 6d2ba76a47..5ef994c25f 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 res = tint_saturate(vec4(1.0f)); + vec4 res = tint_saturate(vec4(2.0f)); } vec4 vertex_main() { @@ -29,7 +29,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 res = tint_saturate(vec4(1.0f)); + vec4 res = tint_saturate(vec4(2.0f)); } void fragment_main() { @@ -47,7 +47,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 res = tint_saturate(vec4(1.0f)); + vec4 res = tint_saturate(vec4(2.0f)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl index 6f1af61fb0..48e0fda871 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_a5b571() { - float4 res = saturate(float4(1.0f)); + float4 res = float4(1.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm index 741b8450d3..cc9e8d8cb4 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 37 +; Bound: 39 ; Schema: 0 OpCapability Shader %14 = OpExtInstImport "GLSL.std.450" @@ -36,8 +36,10 @@ %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %void = OpTypeVoid %17 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 %_ptr_Function_v4float = OpTypePointer Function %v4float - %24 = OpTypeFunction %v4float + %26 = OpTypeFunction %v4float %tint_saturate = OpFunction %v4float None %9 %v = OpFunctionParameter %v4float %12 = OpLabel @@ -47,29 +49,29 @@ %saturate_a5b571 = OpFunction %void None %17 %20 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %21 = OpFunctionCall %v4float %tint_saturate %16 + %21 = OpFunctionCall %v4float %tint_saturate %23 OpStore %res %21 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %24 - %26 = OpLabel - %27 = OpFunctionCall %void %saturate_a5b571 +%vertex_main_inner = OpFunction %v4float None %26 + %28 = OpLabel + %29 = OpFunctionCall %void %saturate_a5b571 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %17 - %29 = OpLabel - %30 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %30 + %31 = OpLabel + %32 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %32 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %17 - %32 = OpLabel - %33 = OpFunctionCall %void %saturate_a5b571 + %34 = OpLabel + %35 = OpFunctionCall %void %saturate_a5b571 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %17 - %35 = OpLabel - %36 = OpFunctionCall %void %saturate_a5b571 + %37 = OpLabel + %38 = OpFunctionCall %void %saturate_a5b571 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl index afba14c2fb..79a7572751 100644 --- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_a5b571() { - var res : vec4 = saturate(vec4(1.0f)); + var res : vec4 = saturate(vec4(2.0f)); } @vertex diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl index 6f7e98ff57..97f10e9ed7 100644 --- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_cd2028() { - vector res = saturate((float16_t(0.0h)).xx); + vector res = (float16_t(0.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl index 9f9ad52a46..0f23c028b6 100644 --- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_cd2028() { - half2 res = saturate(half2(0.0h)); + half2 res = half2(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl new file mode 100644 index 0000000000..4ed8e48d2e --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.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 saturate(vec<3, fa>) -> vec<3, fa> +fn saturate_d55822() { + var res = saturate(vec3(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_d55822(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_d55822(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_d55822(); +} diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..8121744dbd --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_d55822() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_d55822(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..8121744dbd --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_d55822() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_d55822(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl new file mode 100644 index 0000000000..499d4888c8 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_d55822() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + saturate_d55822(); + 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 saturate_d55822() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + saturate_d55822(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_d55822() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + saturate_d55822(); +} + +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/saturate/d55822.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.msl new file mode 100644 index 0000000000..40857e4975 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_d55822() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +kernel void compute_main() { + saturate_d55822(); + return; +} + diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm new file mode 100644 index 0000000000..575588da9e --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_d55822 "saturate_d55822" + 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_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float +%saturate_d55822 = 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 %saturate_d55822 + 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 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_d55822 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_d55822 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl new file mode 100644 index 0000000000..98847ccd81 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn saturate_d55822() { + var res = saturate(vec3(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_d55822(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_d55822(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_d55822(); +} diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl index 2520f59f75..23cb2324cd 100644 --- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_dcde71() { - vector res = saturate((float16_t(0.0h)).xxxx); + vector res = (float16_t(0.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl index 6bc8bf1842..3dc22678f7 100644 --- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_dcde71() { - half4 res = saturate(half4(0.0h)); + half4 res = half4(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl new file mode 100644 index 0000000000..f1e6275a0a --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.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 saturate(vec<2, fa>) -> vec<2, fa> +fn saturate_e40fb6() { + var res = saturate(vec2(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_e40fb6(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_e40fb6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_e40fb6(); +} diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1c81096c00 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_e40fb6() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_e40fb6(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1c81096c00 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_e40fb6() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_e40fb6(); + return; +} diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl new file mode 100644 index 0000000000..950837f6b2 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + saturate_e40fb6(); + 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 saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + saturate_e40fb6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + saturate_e40fb6(); +} + +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/saturate/e40fb6.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.msl new file mode 100644 index 0000000000..0bb65cea9a --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_e40fb6() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +kernel void compute_main() { + saturate_e40fb6(); + return; +} + diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm new file mode 100644 index 0000000000..770937a67f --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_e40fb6 "saturate_e40fb6" + 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_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float +%saturate_e40fb6 = 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 %saturate_e40fb6 + 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 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_e40fb6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_e40fb6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl new file mode 100644 index 0000000000..b20c99eff3 --- /dev/null +++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn saturate_e40fb6() { + var res = saturate(vec2(2)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_e40fb6(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_e40fb6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_e40fb6(); +} diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl index 661deaae47..61c28d8329 100644 --- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_e8df56() { - float16_t res = saturate(float16_t(0.0h)); + float16_t res = float16_t(0.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl index a2205c0b3a..0219c63434 100644 --- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_e8df56() { - half res = saturate(0.0h); + half res = 0.0h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl index 8b20b3d440..84fe79dfa2 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl @@ -23,7 +23,7 @@ // fn saturate(f32) -> f32 fn saturate_270da5() { - var arg_0 = 1.f; + var arg_0 = 2.f; var res: f32 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl index 91ab7830d7..1695ed7550 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl index 91ab7830d7..1695ed7550 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl index 83d9130c32..7a37078104 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl @@ -5,7 +5,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = tint_saturate(arg_0); } @@ -30,7 +30,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = tint_saturate(arg_0); } @@ -49,7 +49,7 @@ float tint_saturate(float v) { } void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = tint_saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl index f0d57ed48f..4d4aa56ff5 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_270da5() { - float arg_0 = 1.0f; + float arg_0 = 2.0f; float res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm index 3524423448..abfdea7d26 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 38 +; Bound: 39 ; Schema: 0 OpCapability Shader %14 = OpExtInstImport "GLSL.std.450" @@ -36,8 +36,9 @@ %float_1 = OpConstant %float 1 %void = OpTypeVoid %16 = OpTypeFunction %void + %float_2 = OpConstant %float 2 %_ptr_Function_float = OpTypePointer Function %float - %25 = OpTypeFunction %v4float + %26 = OpTypeFunction %v4float %tint_saturate = OpFunction %float None %9 %v = OpFunctionParameter %float %12 = OpLabel @@ -48,31 +49,31 @@ %19 = OpLabel %arg_0 = OpVariable %_ptr_Function_float Function %8 %res = OpVariable %_ptr_Function_float Function %8 - OpStore %arg_0 %float_1 - %23 = OpLoad %float %arg_0 - %22 = OpFunctionCall %float %tint_saturate %23 - OpStore %res %22 + OpStore %arg_0 %float_2 + %24 = OpLoad %float %arg_0 + %23 = OpFunctionCall %float %tint_saturate %24 + OpStore %res %23 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %25 - %27 = OpLabel - %28 = OpFunctionCall %void %saturate_270da5 +%vertex_main_inner = OpFunction %v4float None %26 + %28 = OpLabel + %29 = OpFunctionCall %void %saturate_270da5 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %16 - %30 = OpLabel - %31 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %31 + %31 = OpLabel + %32 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %32 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %16 - %33 = OpLabel - %34 = OpFunctionCall %void %saturate_270da5 + %34 = OpLabel + %35 = OpFunctionCall %void %saturate_270da5 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %16 - %36 = OpLabel - %37 = OpFunctionCall %void %saturate_270da5 + %37 = OpLabel + %38 = OpFunctionCall %void %saturate_270da5 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl index 8a4117e557..4012b51231 100644 --- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_270da5() { - var arg_0 = 1.0f; + var arg_0 = 2.0f; var res : f32 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl new file mode 100644 index 0000000000..ceb990442f --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl @@ -0,0 +1,44 @@ +// 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 saturate(vec<4, fa>) -> vec<4, fa> +fn saturate_4ed8d7() { + const arg_0 = vec4(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_4ed8d7(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_4ed8d7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_4ed8d7(); +} diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..6bafa64342 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_4ed8d7() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_4ed8d7(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..6bafa64342 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_4ed8d7() { + float4 res = (1.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_4ed8d7(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl new file mode 100644 index 0000000000..e6bfa97a24 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +vec4 vertex_main() { + saturate_4ed8d7(); + 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 saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +void fragment_main() { + saturate_4ed8d7(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_4ed8d7() { + vec4 res = vec4(1.0f); +} + +void compute_main() { + saturate_4ed8d7(); +} + +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/saturate/4ed8d7.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.msl new file mode 100644 index 0000000000..f6dfde6a3d --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_4ed8d7() { + float4 res = float4(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_4ed8d7(); + 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() { + saturate_4ed8d7(); + return; +} + +kernel void compute_main() { + saturate_4ed8d7(); + return; +} + diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm new file mode 100644 index 0000000000..91bfee1c0f --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_4ed8d7 "saturate_4ed8d7" + 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_1 = OpConstant %float 1 + %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float +%saturate_4ed8d7 = 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 %saturate_4ed8d7 + 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 + %25 = OpLabel + %26 = OpFunctionCall %void %saturate_4ed8d7 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %saturate_4ed8d7 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl new file mode 100644 index 0000000000..c5f28e825b --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn saturate_4ed8d7() { + const arg_0 = vec4(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_4ed8d7(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_4ed8d7(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_4ed8d7(); +} diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl index a63ec45639..8479f085e6 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<2, f32>) -> vec<2, f32> fn saturate_51567f() { - var arg_0 = vec2(1.f); + var arg_0 = vec2(2.f); var res: vec2 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl index bfa6819997..1f653130db 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_51567f() { - float2 arg_0 = (1.0f).xx; + float2 arg_0 = (2.0f).xx; float2 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl index bfa6819997..1f653130db 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_51567f() { - float2 arg_0 = (1.0f).xx; + float2 arg_0 = (2.0f).xx; float2 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl index d833b9ff41..fb43f00eba 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(2.0f); vec2 res = tint_saturate(arg_0); } @@ -30,7 +30,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(2.0f); vec2 res = tint_saturate(arg_0); } @@ -49,7 +49,7 @@ vec2 tint_saturate(vec2 v) { } void saturate_51567f() { - vec2 arg_0 = vec2(1.0f); + vec2 arg_0 = vec2(2.0f); vec2 res = tint_saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl index 78cac489aa..e21f23d2b8 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_51567f() { - float2 arg_0 = float2(1.0f); + float2 arg_0 = float2(2.0f); float2 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm index b81fab6bc3..968e7e7a1c 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 41 +; Bound: 43 ; Schema: 0 OpCapability Shader %15 = OpExtInstImport "GLSL.std.450" @@ -39,8 +39,10 @@ %18 = OpConstantComposite %v2float %float_1 %float_1 %void = OpTypeVoid %19 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %24 = OpConstantComposite %v2float %float_2 %float_2 %_ptr_Function_v2float = OpTypePointer Function %v2float - %28 = OpTypeFunction %v4float + %30 = OpTypeFunction %v4float %tint_saturate = OpFunction %v2float None %9 %v = OpFunctionParameter %v2float %13 = OpLabel @@ -51,31 +53,31 @@ %22 = OpLabel %arg_0 = OpVariable %_ptr_Function_v2float Function %16 %res = OpVariable %_ptr_Function_v2float Function %16 - OpStore %arg_0 %18 - %26 = OpLoad %v2float %arg_0 - %25 = OpFunctionCall %v2float %tint_saturate %26 - OpStore %res %25 + OpStore %arg_0 %24 + %28 = OpLoad %v2float %arg_0 + %27 = OpFunctionCall %v2float %tint_saturate %28 + OpStore %res %27 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %28 - %30 = OpLabel - %31 = OpFunctionCall %void %saturate_51567f +%vertex_main_inner = OpFunction %v4float None %30 + %32 = OpLabel + %33 = OpFunctionCall %void %saturate_51567f OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %19 - %33 = OpLabel - %34 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %34 + %35 = OpLabel + %36 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %36 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %19 - %36 = OpLabel - %37 = OpFunctionCall %void %saturate_51567f + %38 = OpLabel + %39 = OpFunctionCall %void %saturate_51567f OpReturn OpFunctionEnd %compute_main = OpFunction %void None %19 - %39 = OpLabel - %40 = OpFunctionCall %void %saturate_51567f + %41 = OpLabel + %42 = OpFunctionCall %void %saturate_51567f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl index a860d888b4..86689581e1 100644 --- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_51567f() { - var arg_0 = vec2(1.0f); + var arg_0 = vec2(2.0f); var res : vec2 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl index 4887b30f41..ddd305cf82 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<3, f32>) -> vec<3, f32> fn saturate_6bcddf() { - var arg_0 = vec3(1.f); + var arg_0 = vec3(2.f); var res: vec3 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl index d787b33a58..80587b0efa 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_6bcddf() { - float3 arg_0 = (1.0f).xxx; + float3 arg_0 = (2.0f).xxx; float3 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl index d787b33a58..80587b0efa 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_6bcddf() { - float3 arg_0 = (1.0f).xxx; + float3 arg_0 = (2.0f).xxx; float3 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl index 1371097eaf..a797e125b3 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(2.0f); vec3 res = tint_saturate(arg_0); } @@ -30,7 +30,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(2.0f); vec3 res = tint_saturate(arg_0); } @@ -49,7 +49,7 @@ vec3 tint_saturate(vec3 v) { } void saturate_6bcddf() { - vec3 arg_0 = vec3(1.0f); + vec3 arg_0 = vec3(2.0f); vec3 res = tint_saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl index 328dfcc62e..8aa26cff9d 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_6bcddf() { - float3 arg_0 = float3(1.0f); + float3 arg_0 = float3(2.0f); float3 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm index ff3726e423..1d5b452379 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 41 +; Bound: 43 ; Schema: 0 OpCapability Shader %15 = OpExtInstImport "GLSL.std.450" @@ -39,8 +39,10 @@ %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %void = OpTypeVoid %19 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %24 = OpConstantComposite %v3float %float_2 %float_2 %float_2 %_ptr_Function_v3float = OpTypePointer Function %v3float - %28 = OpTypeFunction %v4float + %30 = OpTypeFunction %v4float %tint_saturate = OpFunction %v3float None %9 %v = OpFunctionParameter %v3float %13 = OpLabel @@ -51,31 +53,31 @@ %22 = OpLabel %arg_0 = OpVariable %_ptr_Function_v3float Function %16 %res = OpVariable %_ptr_Function_v3float Function %16 - OpStore %arg_0 %18 - %26 = OpLoad %v3float %arg_0 - %25 = OpFunctionCall %v3float %tint_saturate %26 - OpStore %res %25 + OpStore %arg_0 %24 + %28 = OpLoad %v3float %arg_0 + %27 = OpFunctionCall %v3float %tint_saturate %28 + OpStore %res %27 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %28 - %30 = OpLabel - %31 = OpFunctionCall %void %saturate_6bcddf +%vertex_main_inner = OpFunction %v4float None %30 + %32 = OpLabel + %33 = OpFunctionCall %void %saturate_6bcddf OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %19 - %33 = OpLabel - %34 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %34 + %35 = OpLabel + %36 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %36 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %19 - %36 = OpLabel - %37 = OpFunctionCall %void %saturate_6bcddf + %38 = OpLabel + %39 = OpFunctionCall %void %saturate_6bcddf OpReturn OpFunctionEnd %compute_main = OpFunction %void None %19 - %39 = OpLabel - %40 = OpFunctionCall %void %saturate_6bcddf + %41 = OpLabel + %42 = OpFunctionCall %void %saturate_6bcddf OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl index 81b2bc1dc1..e34311a36c 100644 --- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_6bcddf() { - var arg_0 = vec3(1.0f); + var arg_0 = vec3(2.0f); var res : vec3 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl new file mode 100644 index 0000000000..ab9e1179fa --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl @@ -0,0 +1,44 @@ +// 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 saturate(fa) -> fa +fn saturate_78b37c() { + const arg_0 = 2; + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_78b37c(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_78b37c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_78b37c(); +} diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..68051b6550 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_78b37c(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..68051b6550 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_78b37c(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl new file mode 100644 index 0000000000..e660571b79 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_78b37c() { + float res = 1.0f; +} + +vec4 vertex_main() { + saturate_78b37c(); + 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 saturate_78b37c() { + float res = 1.0f; +} + +void fragment_main() { + saturate_78b37c(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_78b37c() { + float res = 1.0f; +} + +void compute_main() { + saturate_78b37c(); +} + +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/saturate/78b37c.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.msl new file mode 100644 index 0000000000..4619ba033c --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_78b37c() { + float res = 1.0f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_78b37c(); + 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() { + saturate_78b37c(); + return; +} + +kernel void compute_main() { + saturate_78b37c(); + return; +} + diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm new file mode 100644 index 0000000000..5b55286cd8 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm @@ -0,0 +1,63 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; 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 %saturate_78b37c "saturate_78b37c" + 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_1 = OpConstant %float 1 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float +%saturate_78b37c = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_1 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %saturate_78b37c + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %void %saturate_78b37c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_78b37c + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl new file mode 100644 index 0000000000..a12f95efa6 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn saturate_78b37c() { + const arg_0 = 2; + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_78b37c(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_78b37c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_78b37c(); +} diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl index 12221dc222..b8265af5d6 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl @@ -23,7 +23,7 @@ // fn saturate(vec<4, f32>) -> vec<4, f32> fn saturate_a5b571() { - var arg_0 = vec4(1.f); + var arg_0 = vec4(2.f); var res: vec4 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl index 3bd74c04c6..ab8cf8544c 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void saturate_a5b571() { - float4 arg_0 = (1.0f).xxxx; + float4 arg_0 = (2.0f).xxxx; float4 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl index 3bd74c04c6..ab8cf8544c 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void saturate_a5b571() { - float4 arg_0 = (1.0f).xxxx; + float4 arg_0 = (2.0f).xxxx; float4 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl index f90dc80bca..89b06afc84 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl @@ -5,7 +5,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(2.0f); vec4 res = tint_saturate(arg_0); } @@ -30,7 +30,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(2.0f); vec4 res = tint_saturate(arg_0); } @@ -49,7 +49,7 @@ vec4 tint_saturate(vec4 v) { } void saturate_a5b571() { - vec4 arg_0 = vec4(1.0f); + vec4 arg_0 = vec4(2.0f); vec4 res = tint_saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl index dc1a9739ff..24f08fdcdd 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void saturate_a5b571() { - float4 arg_0 = float4(1.0f); + float4 arg_0 = float4(2.0f); float4 res = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm index 9b995382ae..866662ffa4 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 41 ; Schema: 0 OpCapability Shader %14 = OpExtInstImport "GLSL.std.450" @@ -37,8 +37,10 @@ %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %void = OpTypeVoid %17 = OpTypeFunction %void + %float_2 = OpConstant %float 2 + %22 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 %_ptr_Function_v4float = OpTypePointer Function %v4float - %26 = OpTypeFunction %v4float + %28 = OpTypeFunction %v4float %tint_saturate = OpFunction %v4float None %9 %v = OpFunctionParameter %v4float %12 = OpLabel @@ -49,31 +51,31 @@ %20 = OpLabel %arg_0 = OpVariable %_ptr_Function_v4float Function %5 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_0 %16 - %24 = OpLoad %v4float %arg_0 - %23 = OpFunctionCall %v4float %tint_saturate %24 - OpStore %res %23 + OpStore %arg_0 %22 + %26 = OpLoad %v4float %arg_0 + %25 = OpFunctionCall %v4float %tint_saturate %26 + OpStore %res %25 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %26 - %28 = OpLabel - %29 = OpFunctionCall %void %saturate_a5b571 +%vertex_main_inner = OpFunction %v4float None %28 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_a5b571 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %17 - %31 = OpLabel - %32 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %32 + %33 = OpLabel + %34 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %34 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %17 - %34 = OpLabel - %35 = OpFunctionCall %void %saturate_a5b571 + %36 = OpLabel + %37 = OpFunctionCall %void %saturate_a5b571 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %17 - %37 = OpLabel - %38 = OpFunctionCall %void %saturate_a5b571 + %39 = OpLabel + %40 = OpFunctionCall %void %saturate_a5b571 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl index 671c764789..db30eba7b3 100644 --- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl +++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl @@ -1,5 +1,5 @@ fn saturate_a5b571() { - var arg_0 = vec4(1.0f); + var arg_0 = vec4(2.0f); var res : vec4 = saturate(arg_0); } diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl new file mode 100644 index 0000000000..2a419d42ad --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl @@ -0,0 +1,44 @@ +// 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 saturate(vec<3, fa>) -> vec<3, fa> +fn saturate_d55822() { + const arg_0 = vec3(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_d55822(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_d55822(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_d55822(); +} diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..8121744dbd --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_d55822() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_d55822(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..8121744dbd --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_d55822() { + float3 res = (1.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_d55822(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl new file mode 100644 index 0000000000..499d4888c8 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_d55822() { + vec3 res = vec3(1.0f); +} + +vec4 vertex_main() { + saturate_d55822(); + 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 saturate_d55822() { + vec3 res = vec3(1.0f); +} + +void fragment_main() { + saturate_d55822(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_d55822() { + vec3 res = vec3(1.0f); +} + +void compute_main() { + saturate_d55822(); +} + +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/saturate/d55822.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.msl new file mode 100644 index 0000000000..40857e4975 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_d55822() { + float3 res = float3(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_d55822(); + 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() { + saturate_d55822(); + return; +} + +kernel void compute_main() { + saturate_d55822(); + return; +} + diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm new file mode 100644 index 0000000000..575588da9e --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_d55822 "saturate_d55822" + 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_1 = OpConstant %float 1 + %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float +%saturate_d55822 = 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 %saturate_d55822 + 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 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_d55822 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_d55822 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl new file mode 100644 index 0000000000..ba4c8788db --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn saturate_d55822() { + const arg_0 = vec3(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_d55822(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_d55822(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_d55822(); +} diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl new file mode 100644 index 0000000000..a0e9e913ea --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl @@ -0,0 +1,44 @@ +// 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 saturate(vec<2, fa>) -> vec<2, fa> +fn saturate_e40fb6() { + const arg_0 = vec2(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_e40fb6(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_e40fb6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_e40fb6(); +} diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..1c81096c00 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void saturate_e40fb6() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_e40fb6(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..1c81096c00 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void saturate_e40fb6() { + float2 res = (1.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + saturate_e40fb6(); + return; +} diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl new file mode 100644 index 0000000000..950837f6b2 --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +vec4 vertex_main() { + saturate_e40fb6(); + 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 saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +void fragment_main() { + saturate_e40fb6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void saturate_e40fb6() { + vec2 res = vec2(1.0f); +} + +void compute_main() { + saturate_e40fb6(); +} + +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/saturate/e40fb6.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.msl new file mode 100644 index 0000000000..0bb65cea9a --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void saturate_e40fb6() { + float2 res = float2(1.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + saturate_e40fb6(); + 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() { + saturate_e40fb6(); + return; +} + +kernel void compute_main() { + saturate_e40fb6(); + return; +} + diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm new file mode 100644 index 0000000000..770937a67f --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %saturate_e40fb6 "saturate_e40fb6" + 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_1 = OpConstant %float 1 + %15 = OpConstantComposite %v2float %float_1 %float_1 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float +%saturate_e40fb6 = 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 %saturate_e40fb6 + 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 + %27 = OpLabel + %28 = OpFunctionCall %void %saturate_e40fb6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %saturate_e40fb6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl new file mode 100644 index 0000000000..2cf5cdd1dc --- /dev/null +++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn saturate_e40fb6() { + const arg_0 = vec2(2); + var res = saturate(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + saturate_e40fb6(); + return vec4(); +} + +@fragment +fn fragment_main() { + saturate_e40fb6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + saturate_e40fb6(); +}