From 3728a505d661508aaf1c9a2757281241f0ad6582 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Mon, 28 Nov 2022 21:14:36 +0000 Subject: [PATCH] tint: const eval of refract builtin Bug: tint:1581 Change-Id: Iff64e8a680fbbc82e1f8efe2e2f8e05af8e3692c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111920 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Antonio Maiorano --- src/tint/intrinsics.def | 2 +- src/tint/resolver/const_eval.cc | 98 +++++++++++++++++++ src/tint/resolver/const_eval.h | 9 ++ src/tint/resolver/const_eval_builtin_test.cc | 90 ++++++++++++++++- src/tint/resolver/intrinsic_table.inl | 6 +- .../refract/0594ba.wgsl.expected.dxc.hlsl | 2 +- .../literal/refract/0594ba.wgsl.expected.glsl | 6 +- .../literal/refract/0594ba.wgsl.expected.msl | 2 +- .../refract/0594ba.wgsl.expected.spvasm | 36 ++++--- .../refract/570cb3.wgsl.expected.dxc.hlsl | 2 +- .../literal/refract/570cb3.wgsl.expected.glsl | 6 +- .../literal/refract/570cb3.wgsl.expected.msl | 2 +- .../refract/570cb3.wgsl.expected.spvasm | 36 ++++--- .../refract/7e02e6.wgsl.expected.dxc.hlsl | 2 +- .../refract/7e02e6.wgsl.expected.fxc.hlsl | 2 +- .../literal/refract/7e02e6.wgsl.expected.glsl | 6 +- .../literal/refract/7e02e6.wgsl.expected.msl | 2 +- .../refract/7e02e6.wgsl.expected.spvasm | 33 +++---- .../refract/8984af.wgsl.expected.dxc.hlsl | 2 +- .../literal/refract/8984af.wgsl.expected.glsl | 6 +- .../literal/refract/8984af.wgsl.expected.msl | 2 +- .../refract/8984af.wgsl.expected.spvasm | 36 ++++--- .../builtins/gen/literal/refract/8c192a.wgsl | 43 ++++++++ .../refract/8c192a.wgsl.expected.dxc.hlsl | 30 ++++++ .../refract/8c192a.wgsl.expected.fxc.hlsl | 30 ++++++ .../literal/refract/8c192a.wgsl.expected.glsl | 49 ++++++++++ .../literal/refract/8c192a.wgsl.expected.msl | 33 +++++++ .../refract/8c192a.wgsl.expected.spvasm | 65 ++++++++++++ .../literal/refract/8c192a.wgsl.expected.wgsl | 19 ++++ .../refract/cbc1d2.wgsl.expected.dxc.hlsl | 2 +- .../refract/cbc1d2.wgsl.expected.fxc.hlsl | 2 +- .../literal/refract/cbc1d2.wgsl.expected.glsl | 6 +- .../literal/refract/cbc1d2.wgsl.expected.msl | 2 +- .../refract/cbc1d2.wgsl.expected.spvasm | 37 ++++--- .../refract/cd905f.wgsl.expected.dxc.hlsl | 2 +- .../refract/cd905f.wgsl.expected.fxc.hlsl | 2 +- .../literal/refract/cd905f.wgsl.expected.glsl | 6 +- .../literal/refract/cd905f.wgsl.expected.msl | 2 +- .../refract/cd905f.wgsl.expected.spvasm | 37 ++++--- .../builtins/gen/literal/refract/cf1629.wgsl | 43 ++++++++ .../refract/cf1629.wgsl.expected.dxc.hlsl | 30 ++++++ .../refract/cf1629.wgsl.expected.fxc.hlsl | 30 ++++++ .../literal/refract/cf1629.wgsl.expected.glsl | 49 ++++++++++ .../literal/refract/cf1629.wgsl.expected.msl | 33 +++++++ .../refract/cf1629.wgsl.expected.spvasm | 67 +++++++++++++ .../literal/refract/cf1629.wgsl.expected.wgsl | 19 ++++ .../builtins/gen/literal/refract/d7569b.wgsl | 43 ++++++++ .../refract/d7569b.wgsl.expected.dxc.hlsl | 30 ++++++ .../refract/d7569b.wgsl.expected.fxc.hlsl | 30 ++++++ .../literal/refract/d7569b.wgsl.expected.glsl | 49 ++++++++++ .../literal/refract/d7569b.wgsl.expected.msl | 33 +++++++ .../refract/d7569b.wgsl.expected.spvasm | 67 +++++++++++++ .../literal/refract/d7569b.wgsl.expected.wgsl | 19 ++++ .../tint/builtins/gen/var/refract/8c192a.wgsl | 46 +++++++++ .../var/refract/8c192a.wgsl.expected.dxc.hlsl | 30 ++++++ .../var/refract/8c192a.wgsl.expected.fxc.hlsl | 30 ++++++ .../gen/var/refract/8c192a.wgsl.expected.glsl | 49 ++++++++++ .../gen/var/refract/8c192a.wgsl.expected.msl | 33 +++++++ .../var/refract/8c192a.wgsl.expected.spvasm | 65 ++++++++++++ .../gen/var/refract/8c192a.wgsl.expected.wgsl | 22 +++++ .../tint/builtins/gen/var/refract/cf1629.wgsl | 46 +++++++++ .../var/refract/cf1629.wgsl.expected.dxc.hlsl | 30 ++++++ .../var/refract/cf1629.wgsl.expected.fxc.hlsl | 30 ++++++ .../gen/var/refract/cf1629.wgsl.expected.glsl | 49 ++++++++++ .../gen/var/refract/cf1629.wgsl.expected.msl | 33 +++++++ .../var/refract/cf1629.wgsl.expected.spvasm | 67 +++++++++++++ .../gen/var/refract/cf1629.wgsl.expected.wgsl | 22 +++++ .../tint/builtins/gen/var/refract/d7569b.wgsl | 46 +++++++++ .../var/refract/d7569b.wgsl.expected.dxc.hlsl | 30 ++++++ .../var/refract/d7569b.wgsl.expected.fxc.hlsl | 30 ++++++ .../gen/var/refract/d7569b.wgsl.expected.glsl | 49 ++++++++++ .../gen/var/refract/d7569b.wgsl.expected.msl | 33 +++++++ .../var/refract/d7569b.wgsl.expected.spvasm | 67 +++++++++++++ .../gen/var/refract/d7569b.wgsl.expected.wgsl | 22 +++++ 74 files changed, 1972 insertions(+), 154 deletions(-) create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.wgsl diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index efa7f4fe05..fb75c979fb 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -519,7 +519,7 @@ fn pow(vec, vec) -> vec @const fn radians(T) -> T @const fn radians(vec) -> vec @const fn reflect(vec, vec) -> vec -fn refract(vec, vec, T) -> vec +@const fn refract(vec, vec, T) -> vec @const fn reverseBits(T) -> T @const fn reverseBits(vec) -> vec @const fn round(@test_value(3.4) T) -> T diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 95eefe045d..b7674dcd75 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -2954,6 +2954,104 @@ ConstEval::Result ConstEval::reflect(const sem::Type* ty, return r; } +ConstEval::Result ConstEval::refract(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto* vec_ty = ty->As(); + auto* el_ty = vec_ty->type(); + + auto compute_k = [&](auto e3, auto dot_e2_e1) -> ConstEval::Result { + using NumberT = decltype(e3); + // let k = 1.0 - e3 * e3 * (1.0 - dot(e2, e1) * dot(e2, e1)) + auto e3_squared = Mul(source, e3, e3); + if (!e3_squared) { + return utils::Failure; + } + auto dot_e2_e1_squared = Mul(source, dot_e2_e1, dot_e2_e1); + if (!dot_e2_e1_squared) { + return utils::Failure; + } + auto r = Sub(source, NumberT(1), dot_e2_e1_squared.Get()); + if (!r) { + return utils::Failure; + } + r = Mul(source, e3_squared.Get(), r.Get()); + if (!r) { + return utils::Failure; + } + r = Sub(source, NumberT(1), r.Get()); + if (!r) { + return utils::Failure; + } + return CreateElement(builder, source, el_ty, r.Get()); + }; + + auto compute_e2_scale = [&](auto e3, auto dot_e2_e1, auto k) -> ConstEval::Result { + // e3 * dot(e2, e1) + sqrt(k) + auto sqrt_k = Sqrt(source, k); + if (!sqrt_k) { + return utils::Failure; + } + auto r = Mul(source, e3, dot_e2_e1); + if (!r) { + return utils::Failure; + } + r = Add(source, r.Get(), sqrt_k.Get()); + if (!r) { + return utils::Failure; + } + return CreateElement(builder, source, el_ty, r.Get()); + }; + + auto calculate = [&]() -> ConstEval::Result { + auto* e1 = args[0]; + auto* e2 = args[1]; + auto* e3 = args[2]; + + // For the incident vector e1 and surface normal e2, and the ratio of indices of refraction + // e3, let k = 1.0 - e3 * e3 * (1.0 - dot(e2, e1) * dot(e2, e1)). If k < 0.0, returns the + // refraction vector 0.0, otherwise return the refraction vector e3 * e1 - (e3 * dot(e2, e1) + // + sqrt(k)) * e2. + + // dot(e2, e1) + auto dot_e2_e1 = Dot(source, e2, e1); + if (!dot_e2_e1) { + return utils::Failure; + } + + // let k = 1.0 - e3 * e3 * (1.0 - dot(e2, e1) * dot(e2, e1)) + auto k = Dispatch_fa_f32_f16(compute_k, e3, dot_e2_e1.Get()); + if (!k) { + return utils::Failure; + } + + // If k < 0.0, returns the refraction vector 0.0 + if (k.Get()->As() < 0) { + return ZeroValue(builder, ty); + } + + // Otherwise return the refraction vector e3 * e1 - (e3 * dot(e2, e1) + sqrt(k)) * e2 + auto e1_scaled = Mul(source, ty, e3, e1); + if (!e1_scaled) { + return utils::Failure; + } + auto e2_scale = Dispatch_fa_f32_f16(compute_e2_scale, e3, dot_e2_e1.Get(), k.Get()); + if (!e2_scale) { + return utils::Failure; + } + auto e2_scaled = Mul(source, ty, e2_scale.Get(), e2); + if (!e1_scaled) { + return utils::Failure; + } + return Sub(source, ty, e1_scaled.Get(), e2_scaled.Get()); + }; + auto r = calculate(); + if (!r) { + AddNote("when calculating refract", source); + } + return r; +} + ConstEval::Result ConstEval::reverseBits(const sem::Type* ty, utils::VectorRef args, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 1a16a79bb7..d92dc3fedc 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -800,6 +800,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// refract 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 refract(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// reverseBits builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 1860886840..b7f506ce15 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1983,11 +1983,91 @@ INSTANTIATE_TEST_SUITE_P( // Reflect, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kReflect), - testing::ValuesIn( - // ReflectCases()))); - Concat(ReflectCases(), // - ReflectCases(), // - ReflectCases())))); + testing::ValuesIn(Concat(ReflectCases(), // + ReflectCases(), // + ReflectCases())))); + +template +std::vector RefractCases() { + // Returns "eta" (Greek letter) that denotes the ratio of indices of refraction for the input + // and output vector angles from the normal vector. + auto eta = [](auto angle1, auto angle2) { + // Snell's law: sin(angle1) / sin(angle2) == n2 / n1 + // We want the ratio of n1 to n2, so sin(angle2) / sin(angle1) + auto angle1_rads = T(angle1) * kPi / T(180); + auto angle2_rads = T(angle2) * kPi / T(180); + return T(std::sin(angle2_rads) / std::sin(angle1_rads)); + }; + + auto zero = Vec(T(0), T(0), T(0)); + auto pos_y = Vec(T(0), T(1), T(0)); + auto neg_y = Vec(T(0), -T(1), T(0)); + auto pos_x = Vec(T(1), T(0), T(0)); + auto neg_x = Vec(-T(1), T(0), T(0)); + auto cos_45 = T(0.70710678118654752440084436210485); + auto cos_30 = T(0.86602540378443864676372317075294); + auto down_right = Vec(T(cos_45), -T(cos_45), T(0)); + auto up_right = Vec(T(cos_45), T(cos_45), T(0)); + + auto eps = 0.001; + if constexpr (std::is_same_v) { + eps = 0.1; + } + + auto r = std::vector{ + // e3 (eta) == 1, no refraction, so input is same as output + C({down_right, pos_y, Val(T(1))}, down_right), + C({neg_y, pos_y, Val(T(1))}, neg_y), + // Varying etas + C({down_right, pos_y, Val(eta(45, 45))}, down_right).FloatComp(eps), // e3 == 1 + C({down_right, pos_y, Val(eta(45, 30))}, Vec(T(0.5), -T(cos_30), T(0))).FloatComp(eps), + C({down_right, pos_y, Val(eta(45, 60))}, Vec(T(cos_30), -T(0.5), T(0))).FloatComp(eps), + C({down_right, pos_y, Val(eta(45, 90))}, Vec(T(1), T(0), T(0))).FloatComp(eps), + // Flip input and normal, same result + C({up_right, neg_y, Val(eta(45, 45))}, up_right).FloatComp(eps), // e3 == 1 + C({up_right, neg_y, Val(eta(45, 30))}, Vec(T(0.5), T(cos_30), T(0))).FloatComp(eps), + C({up_right, neg_y, Val(eta(45, 60))}, Vec(T(cos_30), T(0.5), T(0))).FloatComp(eps), + C({up_right, neg_y, Val(eta(45, 90))}, Vec(T(1), T(0), T(0))).FloatComp(eps), + // Flip only normal, result is flipped + C({down_right, neg_y, Val(eta(45, 45))}, up_right).FloatComp(eps), // e3 == 1 + C({down_right, neg_y, Val(eta(45, 30))}, Vec(T(0.5), T(cos_30), T(0))).FloatComp(eps), + C({down_right, neg_y, Val(eta(45, 60))}, Vec(T(cos_30), T(0.5), T(0))).FloatComp(eps), + C({down_right, neg_y, Val(eta(45, 90))}, Vec(T(1), T(0), T(0))).FloatComp(eps), + + // If k < 0.0, returns the refraction vector 0.0 + C({down_right, pos_y, Val(T(2))}, zero).FloatComp(eps), + + // A few more with a different normal (e2) + C({down_right, neg_x, Val(eta(45, 45))}, down_right).FloatComp(eps), // e3 == 1 + C({down_right, neg_x, Val(eta(45, 30))}, Vec(cos_30, -T(0.5), T(0))).FloatComp(eps), + C({down_right, neg_x, Val(eta(45, 60))}, Vec(T(0.5), -T(cos_30), T(0))).FloatComp(eps), + }; + + auto error_msg = [](auto a, const char* op, auto b) { + return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( +12:34 note: when calculating refract)"; + }; + ConcatInto( // + r, + std::vector{ + // Overflow the dot product operation + E({Vec(T::Highest(), T::Highest(), T(0)), Vec(T(1), T(1), T(0)), Val(T(1))}, + error_msg(T::Highest(), "+", T::Highest())), + E({Vec(T::Lowest(), T::Lowest(), T(0)), Vec(T(1), T(1), T(0)), Val(T(1))}, + error_msg(T::Lowest(), "+", T::Lowest())), + // Overflow the k^2 operation + E({down_right, pos_y, Val(T::Highest())}, error_msg(T::Highest(), "*", T::Highest())), + }); + + return r; +} +INSTANTIATE_TEST_SUITE_P( // + Refract, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kRefract), + testing::ValuesIn(Concat(RefractCases(), // + RefractCases(), // + RefractCases())))); template std::vector RadiansCases() { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 94044bfb9a..d0752daf93 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -13710,12 +13710,12 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 3, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[477], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::refract, }, { /* [450] */ @@ -14421,7 +14421,7 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [64] */ - /* fn refract(vec, vec, T) -> vec */ + /* fn refract(vec, vec, T) -> vec */ /* num overloads */ 1, /* overloads */ &kOverloads[449], }, diff --git a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.dxc.hlsl index 7e127946e2..036961cbab 100644 --- a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_0594ba() { - vector res = refract((float16_t(1.0h)).xxxx, (float16_t(1.0h)).xxxx, float16_t(1.0h)); + vector res = (float16_t(-7.0h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.glsl index c5293b5806..093b8e6f79 100644 --- a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void refract_0594ba() { - f16vec4 res = refract(f16vec4(1.0hf), f16vec4(1.0hf), 1.0hf); + f16vec4 res = f16vec4(-7.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void refract_0594ba() { - f16vec4 res = refract(f16vec4(1.0hf), f16vec4(1.0hf), 1.0hf); + f16vec4 res = f16vec4(-7.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void refract_0594ba() { - f16vec4 res = refract(f16vec4(1.0hf), f16vec4(1.0hf), 1.0hf); + f16vec4 res = f16vec4(-7.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.msl index e5623fafa0..b48045b45a 100644 --- a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_0594ba() { - half4 res = refract(half4(1.0h), half4(1.0h), 1.0h); + half4 res = half4(-7.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.spvasm index 9c59d3b03e..ce2973d971 100644 --- a/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/0594ba.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_n0x1_cp_2 = OpConstant %half -0x1.cp+2 + %16 = OpConstantComposite %v4half %half_n0x1_cp_2 %half_n0x1_cp_2 %half_n0x1_cp_2 %half_n0x1_cp_2 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %refract_0594ba = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Refract %18 %18 %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %refract_0594ba +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %refract_0594ba OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %refract_0594ba + %29 = OpLabel + %30 = OpFunctionCall %void %refract_0594ba OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %refract_0594ba + %32 = OpLabel + %33 = OpFunctionCall %void %refract_0594ba OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.dxc.hlsl index 4a35894df3..c1b787847b 100644 --- a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_570cb3() { - vector res = refract((float16_t(1.0h)).xx, (float16_t(1.0h)).xx, float16_t(1.0h)); + vector res = (float16_t(-3.0h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.glsl index b0f0ad1051..8b473a1b58 100644 --- a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void refract_570cb3() { - f16vec2 res = refract(f16vec2(1.0hf), f16vec2(1.0hf), 1.0hf); + f16vec2 res = f16vec2(-3.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void refract_570cb3() { - f16vec2 res = refract(f16vec2(1.0hf), f16vec2(1.0hf), 1.0hf); + f16vec2 res = f16vec2(-3.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void refract_570cb3() { - f16vec2 res = refract(f16vec2(1.0hf), f16vec2(1.0hf), 1.0hf); + f16vec2 res = f16vec2(-3.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.msl index 1414d82d55..77ac3c566e 100644 --- a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_570cb3() { - half2 res = refract(half2(1.0h), half2(1.0h), 1.0h); + half2 res = half2(-3.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.spvasm index 63fcc1581c..8b8e556c7b 100644 --- a/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/570cb3.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_n0x1_8p_1 = OpConstant %half -0x1.8p+1 + %16 = OpConstantComposite %v2half %half_n0x1_8p_1 %half_n0x1_8p_1 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %refract_570cb3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Refract %18 %18 %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %refract_570cb3 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %refract_570cb3 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %refract_570cb3 + %29 = OpLabel + %30 = OpFunctionCall %void %refract_570cb3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %refract_570cb3 + %32 = OpLabel + %33 = OpFunctionCall %void %refract_570cb3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.dxc.hlsl index d8c3de86a4..9a378462f3 100644 --- a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_7e02e6() { - float4 res = refract((1.0f).xxxx, (1.0f).xxxx, 1.0f); + float4 res = (-7.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.fxc.hlsl index d8c3de86a4..9a378462f3 100644 --- a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void refract_7e02e6() { - float4 res = refract((1.0f).xxxx, (1.0f).xxxx, 1.0f); + float4 res = (-7.0f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.glsl index 5c8bd1e747..7c268ccb9e 100644 --- a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void refract_7e02e6() { - vec4 res = refract(vec4(1.0f), vec4(1.0f), 1.0f); + vec4 res = vec4(-7.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void refract_7e02e6() { - vec4 res = refract(vec4(1.0f), vec4(1.0f), 1.0f); + vec4 res = vec4(-7.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void refract_7e02e6() { - vec4 res = refract(vec4(1.0f), vec4(1.0f), 1.0f); + vec4 res = vec4(-7.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.msl index a44d158caa..4d49f4743e 100644 --- a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_7e02e6() { - float4 res = refract(float4(1.0f), float4(1.0f), 1.0f); + float4 res = float4(-7.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.spvasm index 6cfa75a5d9..8c8e3ad777 100644 --- a/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/7e02e6.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %float_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %refract_7e02e6 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Refract %16 %16 %float_1 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %refract_7e02e6 +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %refract_7e02e6 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %refract_7e02e6 + %26 = OpLabel + %27 = OpFunctionCall %void %refract_7e02e6 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %refract_7e02e6 + %29 = OpLabel + %30 = OpFunctionCall %void %refract_7e02e6 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.dxc.hlsl index 5e25ebc612..1de0940b16 100644 --- a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_8984af() { - vector res = refract((float16_t(1.0h)).xxx, (float16_t(1.0h)).xxx, float16_t(1.0h)); + vector res = (float16_t(-5.0h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.glsl index 5bfbd9404d..0de3f687cc 100644 --- a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void refract_8984af() { - f16vec3 res = refract(f16vec3(1.0hf), f16vec3(1.0hf), 1.0hf); + f16vec3 res = f16vec3(-5.0hf); } vec4 vertex_main() { @@ -23,7 +23,7 @@ void main() { precision mediump float; void refract_8984af() { - f16vec3 res = refract(f16vec3(1.0hf), f16vec3(1.0hf), 1.0hf); + f16vec3 res = f16vec3(-5.0hf); } void fragment_main() { @@ -38,7 +38,7 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require void refract_8984af() { - f16vec3 res = refract(f16vec3(1.0hf), f16vec3(1.0hf), 1.0hf); + f16vec3 res = f16vec3(-5.0hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.msl index 977ac05319..9f75260036 100644 --- a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_8984af() { - half3 res = refract(half3(1.0h), half3(1.0h), 1.0h); + half3 res = half3(-5.0h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.spvasm index 7192390a09..48e5cfdc3b 100644 --- a/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/8984af.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_n0x1_4p_2 = OpConstant %half -0x1.4p+2 + %16 = OpConstantComposite %v3half %half_n0x1_4p_2 %half_n0x1_4p_2 %half_n0x1_4p_2 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %refract_8984af = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Refract %18 %18 %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %refract_8984af +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %refract_8984af OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %refract_8984af + %29 = OpLabel + %30 = OpFunctionCall %void %refract_8984af OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %refract_8984af + %32 = OpLabel + %33 = OpFunctionCall %void %refract_8984af OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl new file mode 100644 index 0000000000..bf858d6277 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.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 refract(vec<4, fa>, vec<4, fa>, fa) -> vec<4, fa> +fn refract_8c192a() { + var res = refract(vec4(1.), vec4(1.), 1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_8c192a(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_8c192a(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_8c192a(); +} diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..ad89208343 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_8c192a() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_8c192a(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..ad89208343 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_8c192a() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_8c192a(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.glsl new file mode 100644 index 0000000000..1a30d60311 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +vec4 vertex_main() { + refract_8c192a(); + 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 refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +void fragment_main() { + refract_8c192a(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +void compute_main() { + refract_8c192a(); +} + +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/refract/8c192a.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.msl new file mode 100644 index 0000000000..ec3928eb00 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_8c192a() { + float4 res = float4(-7.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +kernel void compute_main() { + refract_8c192a(); + return; +} + diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.spvasm new file mode 100644 index 0000000000..6f9326d9ba --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_8c192a "refract_8c192a" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_8c192a = 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 %refract_8c192a + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %refract_8c192a + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %refract_8c192a + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.wgsl new file mode 100644 index 0000000000..15b5d9e1de --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/8c192a.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn refract_8c192a() { + var res = refract(vec4(1.0), vec4(1.0), 1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_8c192a(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_8c192a(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_8c192a(); +} diff --git a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.dxc.hlsl index 0fa2f162aa..66e3464abd 100644 --- a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_cbc1d2() { - float3 res = refract((1.0f).xxx, (1.0f).xxx, 1.0f); + float3 res = (-5.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.fxc.hlsl index 0fa2f162aa..66e3464abd 100644 --- a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void refract_cbc1d2() { - float3 res = refract((1.0f).xxx, (1.0f).xxx, 1.0f); + float3 res = (-5.0f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.glsl index 45dc14b8f2..4190d98850 100644 --- a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void refract_cbc1d2() { - vec3 res = refract(vec3(1.0f), vec3(1.0f), 1.0f); + vec3 res = vec3(-5.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void refract_cbc1d2() { - vec3 res = refract(vec3(1.0f), vec3(1.0f), 1.0f); + vec3 res = vec3(-5.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void refract_cbc1d2() { - vec3 res = refract(vec3(1.0f), vec3(1.0f), 1.0f); + vec3 res = vec3(-5.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.msl index dbec949089..70bb4908d4 100644 --- a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_cbc1d2() { - float3 res = refract(float3(1.0f), float3(1.0f), 1.0f); + float3 res = float3(-5.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.spvasm index 5591003742..c57564da6c 100644 --- a/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/cbc1d2.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %refract_cbc1d2 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Refract %17 %17 %float_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %refract_cbc1d2 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %refract_cbc1d2 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %refract_cbc1d2 + %28 = OpLabel + %29 = OpFunctionCall %void %refract_cbc1d2 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %refract_cbc1d2 + %31 = OpLabel + %32 = OpFunctionCall %void %refract_cbc1d2 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.dxc.hlsl index ef5d9451dc..835d5c0b4f 100644 --- a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void refract_cd905f() { - float2 res = refract((1.0f).xx, (1.0f).xx, 1.0f); + float2 res = (-3.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.fxc.hlsl index ef5d9451dc..835d5c0b4f 100644 --- a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void refract_cd905f() { - float2 res = refract((1.0f).xx, (1.0f).xx, 1.0f); + float2 res = (-3.0f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.glsl index d0928e7590..a9628576f9 100644 --- a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void refract_cd905f() { - vec2 res = refract(vec2(1.0f), vec2(1.0f), 1.0f); + vec2 res = vec2(-3.0f); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void refract_cd905f() { - vec2 res = refract(vec2(1.0f), vec2(1.0f), 1.0f); + vec2 res = vec2(-3.0f); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void refract_cd905f() { - vec2 res = refract(vec2(1.0f), vec2(1.0f), 1.0f); + vec2 res = vec2(-3.0f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.msl index 1ba00a8ddb..75ac067f48 100644 --- a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void refract_cd905f() { - float2 res = refract(float2(1.0f), float2(1.0f), 1.0f); + float2 res = float2(-3.0f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.spvasm index 9a6516e697..845a4de072 100644 --- a/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/refract/cd905f.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %refract_cd905f = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Refract %17 %17 %float_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %refract_cd905f +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %refract_cd905f OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %refract_cd905f + %28 = OpLabel + %29 = OpFunctionCall %void %refract_cd905f OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %refract_cd905f + %31 = OpLabel + %32 = OpFunctionCall %void %refract_cd905f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl new file mode 100644 index 0000000000..ba0362cdcf --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.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 refract(vec<2, fa>, vec<2, fa>, fa) -> vec<2, fa> +fn refract_cf1629() { + var res = refract(vec2(1.), vec2(1.), 1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_cf1629(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_cf1629(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_cf1629(); +} diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..125f05c963 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_cf1629() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_cf1629(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..125f05c963 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_cf1629() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_cf1629(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.glsl new file mode 100644 index 0000000000..3aa71379e2 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +vec4 vertex_main() { + refract_cf1629(); + 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 refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +void fragment_main() { + refract_cf1629(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +void compute_main() { + refract_cf1629(); +} + +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/refract/cf1629.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.msl new file mode 100644 index 0000000000..b163611f26 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_cf1629() { + float2 res = float2(-3.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +kernel void compute_main() { + refract_cf1629(); + return; +} + diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.spvasm new file mode 100644 index 0000000000..ebc5b0e5eb --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_cf1629 "refract_cf1629" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_cf1629 = 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 %refract_cf1629 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %refract_cf1629 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %refract_cf1629 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.wgsl new file mode 100644 index 0000000000..546b61723b --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/cf1629.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn refract_cf1629() { + var res = refract(vec2(1.0), vec2(1.0), 1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_cf1629(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_cf1629(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_cf1629(); +} diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl new file mode 100644 index 0000000000..9a4b45acfe --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.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 refract(vec<3, fa>, vec<3, fa>, fa) -> vec<3, fa> +fn refract_d7569b() { + var res = refract(vec3(1.), vec3(1.), 1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_d7569b(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_d7569b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_d7569b(); +} diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..d46289173b --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_d7569b() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_d7569b(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..d46289173b --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_d7569b() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_d7569b(); + return; +} diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.glsl new file mode 100644 index 0000000000..c83ef7be0f --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +vec4 vertex_main() { + refract_d7569b(); + 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 refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +void fragment_main() { + refract_d7569b(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +void compute_main() { + refract_d7569b(); +} + +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/refract/d7569b.wgsl.expected.msl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.msl new file mode 100644 index 0000000000..c164d6c9b9 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_d7569b() { + float3 res = float3(-5.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +kernel void compute_main() { + refract_d7569b(); + return; +} + diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.spvasm new file mode 100644 index 0000000000..e9daaa6f24 --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_d7569b "refract_d7569b" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_d7569b = 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 %refract_d7569b + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %refract_d7569b + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %refract_d7569b + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.wgsl new file mode 100644 index 0000000000..abd4e9f58a --- /dev/null +++ b/test/tint/builtins/gen/literal/refract/d7569b.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn refract_d7569b() { + var res = refract(vec3(1.0), vec3(1.0), 1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_d7569b(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_d7569b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_d7569b(); +} diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl b/test/tint/builtins/gen/var/refract/8c192a.wgsl new file mode 100644 index 0000000000..903f0df2f5 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl @@ -0,0 +1,46 @@ +// 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 refract(vec<4, fa>, vec<4, fa>, fa) -> vec<4, fa> +fn refract_8c192a() { + const arg_0 = vec4(1.); + const arg_1 = vec4(1.); + const arg_2 = 1.; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_8c192a(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_8c192a(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_8c192a(); +} diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..ad89208343 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_8c192a() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_8c192a(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..ad89208343 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_8c192a() { + float4 res = (-7.0f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_8c192a(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.glsl b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.glsl new file mode 100644 index 0000000000..1a30d60311 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +vec4 vertex_main() { + refract_8c192a(); + 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 refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +void fragment_main() { + refract_8c192a(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_8c192a() { + vec4 res = vec4(-7.0f); +} + +void compute_main() { + refract_8c192a(); +} + +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/refract/8c192a.wgsl.expected.msl b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.msl new file mode 100644 index 0000000000..ec3928eb00 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_8c192a() { + float4 res = float4(-7.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_8c192a(); + 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() { + refract_8c192a(); + return; +} + +kernel void compute_main() { + refract_8c192a(); + return; +} + diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.spvasm b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.spvasm new file mode 100644 index 0000000000..6f9326d9ba --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_8c192a "refract_8c192a" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %float_n7 = OpConstant %float -7 + %14 = OpConstantComposite %v4float %float_n7 %float_n7 %float_n7 %float_n7 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_8c192a = 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 %refract_8c192a + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %refract_8c192a + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %refract_8c192a + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.wgsl b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.wgsl new file mode 100644 index 0000000000..ccec330b74 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/8c192a.wgsl.expected.wgsl @@ -0,0 +1,22 @@ +fn refract_8c192a() { + const arg_0 = vec4(1.0); + const arg_1 = vec4(1.0); + const arg_2 = 1.0; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_8c192a(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_8c192a(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_8c192a(); +} diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl b/test/tint/builtins/gen/var/refract/cf1629.wgsl new file mode 100644 index 0000000000..d7197e0108 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl @@ -0,0 +1,46 @@ +// 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 refract(vec<2, fa>, vec<2, fa>, fa) -> vec<2, fa> +fn refract_cf1629() { + const arg_0 = vec2(1.); + const arg_1 = vec2(1.); + const arg_2 = 1.; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_cf1629(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_cf1629(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_cf1629(); +} diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..125f05c963 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_cf1629() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_cf1629(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..125f05c963 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_cf1629() { + float2 res = (-3.0f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_cf1629(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.glsl b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.glsl new file mode 100644 index 0000000000..3aa71379e2 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +vec4 vertex_main() { + refract_cf1629(); + 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 refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +void fragment_main() { + refract_cf1629(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_cf1629() { + vec2 res = vec2(-3.0f); +} + +void compute_main() { + refract_cf1629(); +} + +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/refract/cf1629.wgsl.expected.msl b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.msl new file mode 100644 index 0000000000..b163611f26 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_cf1629() { + float2 res = float2(-3.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_cf1629(); + 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() { + refract_cf1629(); + return; +} + +kernel void compute_main() { + refract_cf1629(); + return; +} + diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.spvasm b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.spvasm new file mode 100644 index 0000000000..ebc5b0e5eb --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_cf1629 "refract_cf1629" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 + %float_n3 = OpConstant %float -3 + %15 = OpConstantComposite %v2float %float_n3 %float_n3 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_cf1629 = 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 %refract_cf1629 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %refract_cf1629 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %refract_cf1629 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.wgsl b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.wgsl new file mode 100644 index 0000000000..d31618cb2e --- /dev/null +++ b/test/tint/builtins/gen/var/refract/cf1629.wgsl.expected.wgsl @@ -0,0 +1,22 @@ +fn refract_cf1629() { + const arg_0 = vec2(1.0); + const arg_1 = vec2(1.0); + const arg_2 = 1.0; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_cf1629(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_cf1629(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_cf1629(); +} diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl b/test/tint/builtins/gen/var/refract/d7569b.wgsl new file mode 100644 index 0000000000..fe92eff24d --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl @@ -0,0 +1,46 @@ +// 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 refract(vec<3, fa>, vec<3, fa>, fa) -> vec<3, fa> +fn refract_d7569b() { + const arg_0 = vec3(1.); + const arg_1 = vec3(1.); + const arg_2 = 1.; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_d7569b(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_d7569b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_d7569b(); +} diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..d46289173b --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void refract_d7569b() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_d7569b(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..d46289173b --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void refract_d7569b() { + float3 res = (-5.0f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + refract_d7569b(); + return; +} diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.glsl b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.glsl new file mode 100644 index 0000000000..c83ef7be0f --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +vec4 vertex_main() { + refract_d7569b(); + 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 refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +void fragment_main() { + refract_d7569b(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void refract_d7569b() { + vec3 res = vec3(-5.0f); +} + +void compute_main() { + refract_d7569b(); +} + +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/refract/d7569b.wgsl.expected.msl b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.msl new file mode 100644 index 0000000000..c164d6c9b9 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void refract_d7569b() { + float3 res = float3(-5.0f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + refract_d7569b(); + 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() { + refract_d7569b(); + return; +} + +kernel void compute_main() { + refract_d7569b(); + return; +} + diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.spvasm b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.spvasm new file mode 100644 index 0000000000..e9daaa6f24 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %refract_d7569b "refract_d7569b" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 + %float_n5 = OpConstant %float -5 + %15 = OpConstantComposite %v3float %float_n5 %float_n5 %float_n5 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%refract_d7569b = 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 %refract_d7569b + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %refract_d7569b + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %refract_d7569b + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.wgsl new file mode 100644 index 0000000000..2349c31732 --- /dev/null +++ b/test/tint/builtins/gen/var/refract/d7569b.wgsl.expected.wgsl @@ -0,0 +1,22 @@ +fn refract_d7569b() { + const arg_0 = vec3(1.0); + const arg_1 = vec3(1.0); + const arg_2 = 1.0; + var res = refract(arg_0, arg_1, arg_2); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + refract_d7569b(); + return vec4(); +} + +@fragment +fn fragment_main() { + refract_d7569b(); +} + +@compute @workgroup_size(1) +fn compute_main() { + refract_d7569b(); +}