From 69c2c34326e09ced925cea219e3e5da22f42d1bb Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 23 Nov 2022 18:21:38 +0000 Subject: [PATCH] tint: Implement const-eval of frexp() Also add abstract overloads. Bug: tint:1581 Fixed: tint:1768 Change-Id: Icda465e0cfe960b77823c2135f0cfe8f82ed394f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111441 Kokoro: Kokoro Reviewed-by: Antonio Maiorano Reviewed-by: Dan Sinclair Commit-Queue: Ben Clayton --- src/tint/intrinsics.def | 4 +- src/tint/resolver/builtin_test.cc | 50 +----- src/tint/resolver/const_eval.cc | 73 ++++++++ src/tint/resolver/const_eval.h | 9 + src/tint/resolver/const_eval_builtin_test.cc | 56 ++++++ src/tint/resolver/intrinsic_table.cc | 78 ++++++-- src/tint/resolver/intrinsic_table.inl | 12 +- src/tint/resolver/materialize_test.cc | 88 ++++++++++ .../glsl/generator_impl_builtin_test.cc | 160 ++++++++++++++--- .../hlsl/generator_impl_builtin_test.cc | 157 ++++++++++++++--- .../writer/msl/generator_impl_builtin_test.cc | 141 ++++++++++++--- src/tint/writer/spirv/builder_builtin_test.cc | 166 +++++++++++++----- .../tint/bug/tint/1757.wgsl.expected.dxc.hlsl | 9 +- .../tint/bug/tint/1757.wgsl.expected.fxc.hlsl | 9 +- test/tint/bug/tint/1757.wgsl.expected.glsl | 8 +- test/tint/bug/tint/1757.wgsl.expected.msl | 8 +- test/tint/bug/tint/1757.wgsl.expected.spvasm | 10 +- .../builtins/frexp.wgsl.expected.dxc.hlsl | 9 +- .../builtins/frexp.wgsl.expected.fxc.hlsl | 9 +- test/tint/builtins/frexp.wgsl.expected.glsl | 8 +- test/tint/builtins/frexp.wgsl.expected.msl | 8 +- test/tint/builtins/frexp.wgsl.expected.spvasm | 10 +- test/tint/builtins/frexp/scalar/const.wgsl | 7 + .../frexp/scalar/const.wgsl.expected.dxc.hlsl | 11 ++ .../frexp/scalar/const.wgsl.expected.fxc.hlsl | 11 ++ .../frexp/scalar/const.wgsl.expected.glsl | 19 ++ .../frexp/scalar/const.wgsl.expected.msl | 15 ++ .../frexp/scalar/const.wgsl.expected.spvasm | 29 +++ .../frexp/scalar/const.wgsl.expected.wgsl | 7 + .../builtins/frexp/scalar/const_members.wgsl | 7 + .../const_members.wgsl.expected.dxc.hlsl | 12 ++ .../const_members.wgsl.expected.fxc.hlsl | 12 ++ .../scalar/const_members.wgsl.expected.glsl | 20 +++ .../scalar/const_members.wgsl.expected.msl | 16 ++ .../scalar/const_members.wgsl.expected.spvasm | 20 +++ .../scalar/const_members.wgsl.expected.wgsl | 7 + test/tint/builtins/frexp/scalar/mixed.wgsl | 10 ++ .../frexp/scalar/mixed.wgsl.expected.dxc.hlsl | 22 +++ .../frexp/scalar/mixed.wgsl.expected.fxc.hlsl | 22 +++ .../frexp/scalar/mixed.wgsl.expected.glsl | 28 +++ .../frexp/scalar/mixed.wgsl.expected.msl | 24 +++ .../frexp/scalar/mixed.wgsl.expected.spvasm | 46 +++++ .../frexp/scalar/mixed.wgsl.expected.wgsl | 10 ++ test/tint/builtins/frexp/scalar/runtime.wgsl | 7 + .../scalar/runtime.wgsl.expected.dxc.hlsl | 19 ++ .../scalar/runtime.wgsl.expected.fxc.hlsl | 19 ++ .../frexp/scalar/runtime.wgsl.expected.glsl | 26 +++ .../frexp/scalar/runtime.wgsl.expected.msl | 22 +++ .../frexp/scalar/runtime.wgsl.expected.spvasm | 29 +++ .../frexp/scalar/runtime.wgsl.expected.wgsl | 7 + test/tint/builtins/frexp/vector/const.wgsl | 7 + .../frexp/vector/const.wgsl.expected.dxc.hlsl | 11 ++ .../frexp/vector/const.wgsl.expected.fxc.hlsl | 11 ++ .../frexp/vector/const.wgsl.expected.glsl | 19 ++ .../frexp/vector/const.wgsl.expected.msl | 15 ++ .../frexp/vector/const.wgsl.expected.spvasm | 35 ++++ .../frexp/vector/const.wgsl.expected.wgsl | 7 + .../builtins/frexp/vector/const_members.wgsl | 7 + .../const_members.wgsl.expected.dxc.hlsl | 12 ++ .../const_members.wgsl.expected.fxc.hlsl | 12 ++ .../vector/const_members.wgsl.expected.glsl | 20 +++ .../vector/const_members.wgsl.expected.msl | 16 ++ .../vector/const_members.wgsl.expected.spvasm | 26 +++ .../vector/const_members.wgsl.expected.wgsl | 7 + test/tint/builtins/frexp/vector/mixed.wgsl | 10 ++ .../frexp/vector/mixed.wgsl.expected.dxc.hlsl | 22 +++ .../frexp/vector/mixed.wgsl.expected.fxc.hlsl | 22 +++ .../frexp/vector/mixed.wgsl.expected.glsl | 28 +++ .../frexp/vector/mixed.wgsl.expected.msl | 24 +++ .../frexp/vector/mixed.wgsl.expected.spvasm | 54 ++++++ .../frexp/vector/mixed.wgsl.expected.wgsl | 10 ++ test/tint/builtins/frexp/vector/runtime.wgsl | 7 + .../vector/runtime.wgsl.expected.dxc.hlsl | 19 ++ .../vector/runtime.wgsl.expected.fxc.hlsl | 19 ++ .../frexp/vector/runtime.wgsl.expected.glsl | 26 +++ .../frexp/vector/runtime.wgsl.expected.msl | 22 +++ .../frexp/vector/runtime.wgsl.expected.spvasm | 33 ++++ .../frexp/vector/runtime.wgsl.expected.wgsl | 7 + .../builtins/gen/literal/frexp/34bbfb.wgsl | 43 +++++ .../frexp/34bbfb.wgsl.expected.dxc.hlsl | 34 ++++ .../frexp/34bbfb.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/frexp/34bbfb.wgsl.expected.glsl | 67 +++++++ .../literal/frexp/34bbfb.wgsl.expected.msl | 38 ++++ .../literal/frexp/34bbfb.wgsl.expected.spvasm | 77 ++++++++ .../literal/frexp/34bbfb.wgsl.expected.wgsl | 19 ++ .../frexp/3dd21e.wgsl.expected.dxc.hlsl | 9 +- .../literal/frexp/3dd21e.wgsl.expected.glsl | 24 +-- .../literal/frexp/3dd21e.wgsl.expected.msl | 8 +- .../literal/frexp/3dd21e.wgsl.expected.spvasm | 39 ++-- .../frexp/4b2200.wgsl.expected.dxc.hlsl | 9 +- .../frexp/4b2200.wgsl.expected.fxc.hlsl | 9 +- .../literal/frexp/4b2200.wgsl.expected.glsl | 24 +-- .../literal/frexp/4b2200.wgsl.expected.msl | 8 +- .../literal/frexp/4b2200.wgsl.expected.spvasm | 19 +- .../frexp/5257dd.wgsl.expected.dxc.hlsl | 9 +- .../literal/frexp/5257dd.wgsl.expected.glsl | 24 +-- .../literal/frexp/5257dd.wgsl.expected.msl | 8 +- .../literal/frexp/5257dd.wgsl.expected.spvasm | 8 +- .../frexp/5f47bf.wgsl.expected.dxc.hlsl | 9 +- .../literal/frexp/5f47bf.wgsl.expected.glsl | 24 +-- .../literal/frexp/5f47bf.wgsl.expected.msl | 8 +- .../literal/frexp/5f47bf.wgsl.expected.spvasm | 39 ++-- .../builtins/gen/literal/frexp/6fb3ad.wgsl | 43 +++++ .../frexp/6fb3ad.wgsl.expected.dxc.hlsl | 34 ++++ .../frexp/6fb3ad.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/frexp/6fb3ad.wgsl.expected.glsl | 67 +++++++ .../literal/frexp/6fb3ad.wgsl.expected.msl | 38 ++++ .../literal/frexp/6fb3ad.wgsl.expected.spvasm | 78 ++++++++ .../literal/frexp/6fb3ad.wgsl.expected.wgsl | 19 ++ .../frexp/77af93.wgsl.expected.dxc.hlsl | 9 +- .../frexp/77af93.wgsl.expected.fxc.hlsl | 9 +- .../literal/frexp/77af93.wgsl.expected.glsl | 24 +-- .../literal/frexp/77af93.wgsl.expected.msl | 8 +- .../literal/frexp/77af93.wgsl.expected.spvasm | 40 +++-- .../frexp/979800.wgsl.expected.dxc.hlsl | 9 +- .../frexp/979800.wgsl.expected.fxc.hlsl | 9 +- .../literal/frexp/979800.wgsl.expected.glsl | 24 +-- .../literal/frexp/979800.wgsl.expected.msl | 8 +- .../literal/frexp/979800.wgsl.expected.spvasm | 40 +++-- .../frexp/ae4a66.wgsl.expected.dxc.hlsl | 9 +- .../literal/frexp/ae4a66.wgsl.expected.glsl | 24 +-- .../literal/frexp/ae4a66.wgsl.expected.msl | 8 +- .../literal/frexp/ae4a66.wgsl.expected.spvasm | 39 ++-- .../builtins/gen/literal/frexp/bee870.wgsl | 43 +++++ .../frexp/bee870.wgsl.expected.dxc.hlsl | 34 ++++ .../frexp/bee870.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/frexp/bee870.wgsl.expected.glsl | 67 +++++++ .../literal/frexp/bee870.wgsl.expected.msl | 38 ++++ .../literal/frexp/bee870.wgsl.expected.spvasm | 74 ++++++++ .../literal/frexp/bee870.wgsl.expected.wgsl | 19 ++ .../builtins/gen/literal/frexp/bf45ae.wgsl | 43 +++++ .../frexp/bf45ae.wgsl.expected.dxc.hlsl | 34 ++++ .../frexp/bf45ae.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/frexp/bf45ae.wgsl.expected.glsl | 67 +++++++ .../literal/frexp/bf45ae.wgsl.expected.msl | 38 ++++ .../literal/frexp/bf45ae.wgsl.expected.spvasm | 78 ++++++++ .../literal/frexp/bf45ae.wgsl.expected.wgsl | 19 ++ .../frexp/eb2421.wgsl.expected.dxc.hlsl | 9 +- .../frexp/eb2421.wgsl.expected.fxc.hlsl | 9 +- .../literal/frexp/eb2421.wgsl.expected.glsl | 24 +-- .../literal/frexp/eb2421.wgsl.expected.msl | 8 +- .../literal/frexp/eb2421.wgsl.expected.spvasm | 40 +++-- .../modf/68d8ee.wgsl.expected.dxc.hlsl | 34 ++++ .../modf/68d8ee.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/modf/68d8ee.wgsl.expected.glsl | 67 +++++++ .../gen/literal/modf/68d8ee.wgsl.expected.msl | 38 ++++ .../literal/modf/68d8ee.wgsl.expected.spvasm | 76 ++++++++ .../literal/modf/68d8ee.wgsl.expected.wgsl | 19 ++ .../modf/732aa6.wgsl.expected.dxc.hlsl | 34 ++++ .../modf/732aa6.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/modf/732aa6.wgsl.expected.glsl | 67 +++++++ .../gen/literal/modf/732aa6.wgsl.expected.msl | 38 ++++ .../literal/modf/732aa6.wgsl.expected.spvasm | 76 ++++++++ .../literal/modf/732aa6.wgsl.expected.wgsl | 19 ++ .../modf/c15f48.wgsl.expected.dxc.hlsl | 34 ++++ .../modf/c15f48.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/modf/c15f48.wgsl.expected.glsl | 67 +++++++ .../gen/literal/modf/c15f48.wgsl.expected.msl | 38 ++++ .../literal/modf/c15f48.wgsl.expected.spvasm | 73 ++++++++ .../literal/modf/c15f48.wgsl.expected.wgsl | 19 ++ .../modf/f3d1f9.wgsl.expected.dxc.hlsl | 34 ++++ .../modf/f3d1f9.wgsl.expected.fxc.hlsl | 34 ++++ .../literal/modf/f3d1f9.wgsl.expected.glsl | 67 +++++++ .../gen/literal/modf/f3d1f9.wgsl.expected.msl | 38 ++++ .../literal/modf/f3d1f9.wgsl.expected.spvasm | 75 ++++++++ .../literal/modf/f3d1f9.wgsl.expected.wgsl | 19 ++ test/tint/builtins/gen/var/frexp/34bbfb.wgsl | 44 +++++ .../var/frexp/34bbfb.wgsl.expected.dxc.hlsl | 34 ++++ .../var/frexp/34bbfb.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/frexp/34bbfb.wgsl.expected.glsl | 67 +++++++ .../gen/var/frexp/34bbfb.wgsl.expected.msl | 38 ++++ .../gen/var/frexp/34bbfb.wgsl.expected.spvasm | 77 ++++++++ .../gen/var/frexp/34bbfb.wgsl.expected.wgsl | 20 +++ test/tint/builtins/gen/var/frexp/6fb3ad.wgsl | 44 +++++ .../var/frexp/6fb3ad.wgsl.expected.dxc.hlsl | 34 ++++ .../var/frexp/6fb3ad.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/frexp/6fb3ad.wgsl.expected.glsl | 67 +++++++ .../gen/var/frexp/6fb3ad.wgsl.expected.msl | 38 ++++ .../gen/var/frexp/6fb3ad.wgsl.expected.spvasm | 78 ++++++++ .../gen/var/frexp/6fb3ad.wgsl.expected.wgsl | 20 +++ test/tint/builtins/gen/var/frexp/bee870.wgsl | 44 +++++ .../var/frexp/bee870.wgsl.expected.dxc.hlsl | 34 ++++ .../var/frexp/bee870.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/frexp/bee870.wgsl.expected.glsl | 67 +++++++ .../gen/var/frexp/bee870.wgsl.expected.msl | 38 ++++ .../gen/var/frexp/bee870.wgsl.expected.spvasm | 74 ++++++++ .../gen/var/frexp/bee870.wgsl.expected.wgsl | 20 +++ test/tint/builtins/gen/var/frexp/bf45ae.wgsl | 44 +++++ .../var/frexp/bf45ae.wgsl.expected.dxc.hlsl | 34 ++++ .../var/frexp/bf45ae.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/frexp/bf45ae.wgsl.expected.glsl | 67 +++++++ .../gen/var/frexp/bf45ae.wgsl.expected.msl | 38 ++++ .../gen/var/frexp/bf45ae.wgsl.expected.spvasm | 78 ++++++++ .../gen/var/frexp/bf45ae.wgsl.expected.wgsl | 20 +++ .../var/modf/68d8ee.wgsl.expected.dxc.hlsl | 34 ++++ .../var/modf/68d8ee.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/modf/68d8ee.wgsl.expected.glsl | 67 +++++++ .../gen/var/modf/68d8ee.wgsl.expected.msl | 38 ++++ .../gen/var/modf/68d8ee.wgsl.expected.spvasm | 76 ++++++++ .../gen/var/modf/68d8ee.wgsl.expected.wgsl | 20 +++ .../var/modf/732aa6.wgsl.expected.dxc.hlsl | 34 ++++ .../var/modf/732aa6.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/modf/732aa6.wgsl.expected.glsl | 67 +++++++ .../gen/var/modf/732aa6.wgsl.expected.msl | 38 ++++ .../gen/var/modf/732aa6.wgsl.expected.spvasm | 76 ++++++++ .../gen/var/modf/732aa6.wgsl.expected.wgsl | 20 +++ .../var/modf/c15f48.wgsl.expected.dxc.hlsl | 34 ++++ .../var/modf/c15f48.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/modf/c15f48.wgsl.expected.glsl | 67 +++++++ .../gen/var/modf/c15f48.wgsl.expected.msl | 38 ++++ .../gen/var/modf/c15f48.wgsl.expected.spvasm | 73 ++++++++ .../gen/var/modf/c15f48.wgsl.expected.wgsl | 20 +++ .../var/modf/f3d1f9.wgsl.expected.dxc.hlsl | 34 ++++ .../var/modf/f3d1f9.wgsl.expected.fxc.hlsl | 34 ++++ .../gen/var/modf/f3d1f9.wgsl.expected.glsl | 67 +++++++ .../gen/var/modf/f3d1f9.wgsl.expected.msl | 38 ++++ .../gen/var/modf/f3d1f9.wgsl.expected.spvasm | 75 ++++++++ .../gen/var/modf/f3d1f9.wgsl.expected.wgsl | 20 +++ 218 files changed, 6625 insertions(+), 719 deletions(-) create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/scalar/const.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/scalar/const_members.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/scalar/mixed.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/scalar/runtime.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/vector/const.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/vector/const_members.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/vector/mixed.wgsl.expected.wgsl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.glsl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.msl create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.spvasm create mode 100644 test/tint/builtins/frexp/vector/runtime.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.wgsl diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 9b429198d7..6c17ec6111 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -477,8 +477,8 @@ fn fma(T, T, T) -> T fn fma(vec, vec, vec) -> vec fn fract(T) -> T fn fract(vec) -> vec -fn frexp(T) -> __frexp_result -fn frexp(vec) -> __frexp_result_vec +@const fn frexp(T) -> __frexp_result +@const fn frexp(vec) -> __frexp_result_vec @stage("fragment") fn fwidth(f32) -> f32 @stage("fragment") fn fwidth(vec) -> vec @stage("fragment") fn fwidthCoarse(f32) -> f32 diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 7e371f4323..07ade34acb 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -1079,54 +1079,8 @@ TEST_F(ResolverBuiltinFloatTest, Frexp_Error_FirstParamInt) { R"(error: no matching call to frexp(i32, ptr) 2 candidate functions: - frexp(T) -> __frexp_result_T where: T is f32 or f16 - frexp(vecN) -> __frexp_result_vecN_T where: T is f32 or f16 -)"); -} - -TEST_F(ResolverBuiltinFloatTest, Frexp_Error_SecondParamFloatPtr) { - GlobalVar("v", ty.f32(), ast::AddressSpace::kWorkgroup); - auto* call = Call("frexp", 1_f, AddressOf("v")); - WrapInFunction(call); - - EXPECT_FALSE(r()->Resolve()); - - EXPECT_EQ(r()->error(), - R"(error: no matching call to frexp(f32, ptr) - -2 candidate functions: - frexp(T) -> __frexp_result_T where: T is f32 or f16 - frexp(vecN) -> __frexp_result_vecN_T where: T is f32 or f16 -)"); -} - -TEST_F(ResolverBuiltinFloatTest, Frexp_Error_SecondParamNotAPointer) { - auto* call = Call("frexp", 1_f, 1_i); - WrapInFunction(call); - - EXPECT_FALSE(r()->Resolve()); - - EXPECT_EQ(r()->error(), R"(error: no matching call to frexp(f32, i32) - -2 candidate functions: - frexp(T) -> __frexp_result_T where: T is f32 or f16 - frexp(vecN) -> __frexp_result_vecN_T where: T is f32 or f16 -)"); -} - -TEST_F(ResolverBuiltinFloatTest, Frexp_Error_VectorSizesDontMatch) { - GlobalVar("v", ty.vec4(), ast::AddressSpace::kWorkgroup); - auto* call = Call("frexp", vec2(1_f, 2_f), AddressOf("v")); - WrapInFunction(call); - - EXPECT_FALSE(r()->Resolve()); - - EXPECT_EQ(r()->error(), - R"(error: no matching call to frexp(vec2, ptr, read_write>) - -2 candidate functions: - frexp(T) -> __frexp_result_T where: T is f32 or f16 - frexp(vecN) -> __frexp_result_vecN_T where: T is f32 or f16 + frexp(T) -> __frexp_result_T where: T is abstract-float, f32 or f16 + frexp(vecN) -> __frexp_result_vecN_T where: T is abstract-float, f32 or f16 )"); } diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 4b365fe770..b0595f2c15 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -2219,6 +2219,79 @@ ConstEval::Result ConstEval::floor(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0]); } +ConstEval::Result ConstEval::frexp(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto* arg = args[0]; + + struct FractExp { + ImplResult fract; + ImplResult exp; + }; + + auto scalar = [&](const sem::Constant* s) { + int exp = 0; + double fract = std::frexp(s->As(), &exp); + return Switch( + s->Type(), + [&](const sem::F32*) { + return FractExp{ + CreateElement(builder, source, builder.create(), f32(fract)), + CreateElement(builder, source, builder.create(), i32(exp)), + }; + }, + [&](const sem::F16*) { + return FractExp{ + CreateElement(builder, source, builder.create(), f16(fract)), + CreateElement(builder, source, builder.create(), i32(exp)), + }; + }, + [&](const sem::AbstractFloat*) { + return FractExp{ + CreateElement(builder, source, builder.create(), + AFloat(fract)), + CreateElement(builder, source, builder.create(), AInt(exp)), + }; + }, + [&](Default) { + TINT_ICE(Resolver, builder.Diagnostics()) + << "unhandled element type for frexp() const-eval: " + << builder.FriendlyName(s->Type()); + return FractExp{utils::Failure, utils::Failure}; + }); + }; + + if (auto* vec = arg->Type()->As()) { + utils::Vector fract_els; + utils::Vector exp_els; + for (uint32_t i = 0; i < vec->Width(); i++) { + auto fe = scalar(arg->Index(i)); + if (!fe.fract || !fe.exp) { + return utils::Failure; + } + fract_els.Push(fe.fract.Get()); + exp_els.Push(fe.exp.Get()); + } + auto fract_ty = builder.create(fract_els[0]->Type(), vec->Width()); + auto exp_ty = builder.create(exp_els[0]->Type(), vec->Width()); + return CreateComposite(builder, ty, + utils::Vector{ + CreateComposite(builder, fract_ty, std::move(fract_els)), + CreateComposite(builder, exp_ty, std::move(exp_els)), + }); + } else { + auto fe = scalar(arg); + if (!fe.fract || !fe.exp) { + return utils::Failure; + } + return CreateComposite(builder, ty, + utils::Vector{ + fe.fract.Get(), + fe.exp.Get(), + }); + } +} + ConstEval::Result ConstEval::insertBits(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 4b3bb5405f..60407297c7 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -610,6 +610,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// frexp builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location + /// @return the result value, or null if the value cannot be calculated + Result frexp(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// insertBits 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 70a5bc82d5..c2880779ce 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -968,6 +968,62 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(FloorCases(), // FloorCases(), FloorCases())))); +template +std::vector FrexpCases() { + using F = T; // fract type + using E = std::conditional_t, AInt, i32>; // exp type + + auto cases = std::vector{ + // Scalar tests + // in fract exp + C({T(-3.5)}, {F(-0.875), E(2)}), // + C({T(-3.0)}, {F(-0.750), E(2)}), // + C({T(-2.5)}, {F(-0.625), E(2)}), // + C({T(-2.0)}, {F(-0.500), E(2)}), // + C({T(-1.5)}, {F(-0.750), E(1)}), // + C({T(-1.0)}, {F(-0.500), E(1)}), // + C({T(+0.0)}, {F(+0.000), E(0)}), // + C({T(+1.0)}, {F(+0.500), E(1)}), // + C({T(+1.5)}, {F(+0.750), E(1)}), // + C({T(+2.0)}, {F(+0.500), E(2)}), // + C({T(+2.5)}, {F(+0.625), E(2)}), // + C({T(+3.0)}, {F(+0.750), E(2)}), // + C({T(+3.5)}, {F(+0.875), E(2)}), // + + // Vector tests + // in fract exp + C({Vec(T(-2.5), T(+1.0))}, {Vec(F(-0.625), F(+0.500)), Vec(E(2), E(1))}), + C({Vec(T(+3.5), T(-2.5))}, {Vec(F(+0.875), F(-0.625)), Vec(E(2), E(2))}), + }; + + ConcatIntoIf>(cases, std::vector{ + C({T::Highest()}, {F(0x0.ffep0), E(16)}), // + C({T::Lowest()}, {F(-0x0.ffep0), E(16)}), // + C({T::Smallest()}, {F(0.5), E(-13)}), // + }); + + ConcatIntoIf>(cases, + std::vector{ + C({T::Highest()}, {F(0x0.ffffffp0), E(128)}), // + C({T::Lowest()}, {F(-0x0.ffffffp0), E(128)}), // + C({T::Smallest()}, {F(0.5), E(-125)}), // + }); + + ConcatIntoIf>( + cases, std::vector{ + C({T::Highest()}, {F(0x0.fffffffffffff8p0), E(1024)}), // + C({T::Lowest()}, {F(-0x0.fffffffffffff8p0), E(1024)}), // + C({T::Smallest()}, {F(0.5), E(-1021)}), // + }); + return cases; +} +INSTANTIATE_TEST_SUITE_P( // + Frexp, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kFrexp), + testing::ValuesIn(Concat(FrexpCases(), // + FrexpCases(), // + FrexpCases())))); template std::vector InsertBitsCases() { diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 2fa6feb585..6e7e4f8a79 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -855,6 +855,7 @@ const sem::Struct* build_modf_result(MatchState& state, const sem::Type* el) { return nullptr; }); } + const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const sem::Type* el) { auto prefix = "__modf_result_vec" + std::to_string(n.Value()); auto build_f32 = [&] { @@ -883,27 +884,70 @@ const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const sem return nullptr; }); } + const sem::Struct* build_frexp_result(MatchState& state, const sem::Type* el) { - std::string display_name; - if (el->Is()) { - display_name = "__frexp_result_f16"; - } else { - display_name = "__frexp_result"; - } - auto* i32 = state.builder.create(); - return build_struct(state.builder, display_name, {{"fract", el}, {"exp", i32}}); + auto build_f32 = [&] { + auto* f = state.builder.create(); + auto* i = state.builder.create(); + return build_struct(state.builder, "__frexp_result", {{"fract", f}, {"exp", i}}); + }; + auto build_f16 = [&] { + auto* f = state.builder.create(); + auto* i = state.builder.create(); + return build_struct(state.builder, "__frexp_result_f16", {{"fract", f}, {"exp", i}}); + }; + + return Switch( + el, // + [&](const sem::F32*) { return build_f32(); }, // + [&](const sem::F16*) { return build_f16(); }, // + [&](const sem::AbstractFloat*) { + auto* i = state.builder.create(); + auto* abstract = + build_struct(state.builder, "__frexp_result_abstract", {{"fract", el}, {"exp", i}}); + abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()}); + return abstract; + }, + [&](Default) { + TINT_ICE(Resolver, state.builder.Diagnostics()) + << "unhandled frexp type: " << state.builder.FriendlyName(el); + return nullptr; + }); } + const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const sem::Type* el) { - std::string display_name; - if (el->Is()) { - display_name = "__frexp_result_vec" + std::to_string(n.Value()) + "_f16"; - } else { - display_name = "__frexp_result_vec" + std::to_string(n.Value()); - } - auto* vec = state.builder.create(el, n.Value()); - auto* vec_i32 = state.builder.create(state.builder.create(), n.Value()); - return build_struct(state.builder, display_name, {{"fract", vec}, {"exp", vec_i32}}); + auto prefix = "__frexp_result_vec" + std::to_string(n.Value()); + auto build_f32 = [&] { + auto* f = state.builder.create(state.builder.create(), n.Value()); + auto* e = state.builder.create(state.builder.create(), n.Value()); + return build_struct(state.builder, prefix, {{"fract", f}, {"exp", e}}); + }; + auto build_f16 = [&] { + auto* f = state.builder.create(state.builder.create(), n.Value()); + auto* e = state.builder.create(state.builder.create(), n.Value()); + return build_struct(state.builder, prefix + "_f16", {{"fract", f}, {"exp", e}}); + }; + + return Switch( + el, // + [&](const sem::F32*) { return build_f32(); }, // + [&](const sem::F16*) { return build_f16(); }, // + [&](const sem::AbstractFloat*) { + auto* f = state.builder.create(el, n.Value()); + auto* e = state.builder.create(state.builder.create(), + n.Value()); + auto* abstract = + build_struct(state.builder, prefix + "_abstract", {{"fract", f}, {"exp", e}}); + abstract->SetConcreteTypes(utils::Vector{build_f32(), build_f16()}); + return abstract; + }, + [&](Default) { + TINT_ICE(Resolver, state.builder.Diagnostics()) + << "unhandled frexp type: " << state.builder.FriendlyName(el); + return nullptr; + }); } + const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const sem::Type* ty) { return build_struct( state.builder, diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 1c54749f2f..ee79ab1363 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12558,24 +12558,24 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[862], /* return matcher indices */ &kMatcherIndices[104], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::frexp, }, { /* [354] */ /* num parameters */ 1, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[26], + /* template types */ &kTemplateTypes[23], /* template numbers */ &kTemplateNumbers[4], /* parameters */ &kParameters[863], /* return matcher indices */ &kMatcherIndices[39], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::frexp, }, { /* [355] */ @@ -14259,8 +14259,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [40] */ - /* fn frexp(T) -> __frexp_result */ - /* fn frexp(vec) -> __frexp_result_vec */ + /* fn frexp(T) -> __frexp_result */ + /* fn frexp(vec) -> __frexp_result_vec */ /* num overloads */ 2, /* overloads */ &kOverloads[353], }, diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index 074c4dba47..be8d400ff6 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -1320,6 +1320,94 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) { abstract_str->Members()[0]->Type()->As()->type()->Is()); } +TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) { + // var v = frexp(1); + auto* call = Call("frexp", 1_a); + WrapInFunction(Decl(Var("v", call))); + ASSERT_TRUE(r()->Resolve()) << r()->error(); + auto* sem = Sem().Get(call); + ASSERT_TRUE(sem->Is()); + auto* materialize = sem->As(); + ASSERT_TRUE(materialize->Type()->Is()); + auto* concrete_str = materialize->Type()->As(); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(materialize->Expr()->Type()->Is()); + auto* abstract_str = materialize->Expr()->Type()->As(); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); +} + +TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) { + // var v = frexp(vec2(1)); + auto* call = Call("frexp", Construct(ty.vec2(nullptr), 1_a)); + WrapInFunction(Decl(Var("v", call))); + ASSERT_TRUE(r()->Resolve()) << r()->error(); + auto* sem = Sem().Get(call); + ASSERT_TRUE(sem->Is()); + auto* materialize = sem->As(); + ASSERT_TRUE(materialize->Type()->Is()); + auto* concrete_str = materialize->Type()->As(); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); + ASSERT_TRUE(materialize->Expr()->Type()->Is()); + auto* abstract_str = materialize->Expr()->Type()->As(); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE( + abstract_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE( + abstract_str->Members()[1]->Type()->As()->type()->Is()); +} + +TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) { + // var v = frexp(1_h); // v is __frexp_result_f16 + // v = frexp(1); // __frexp_result_f16 <- __frexp_result_abstract + Enable(ast::Extension::kF16); + auto* call = Call("frexp", 1_a); + WrapInFunction(Decl(Var("v", Call("frexp", 1_h))), // + Assign("v", call)); + ASSERT_TRUE(r()->Resolve()) << r()->error(); + auto* sem = Sem().Get(call); + ASSERT_TRUE(sem->Is()); + auto* materialize = sem->As(); + ASSERT_TRUE(materialize->Type()->Is()); + auto* concrete_str = materialize->Type()->As(); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(materialize->Expr()->Type()->Is()); + auto* abstract_str = materialize->Expr()->Type()->As(); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(abstract_str->Members()[1]->Type()->Is()); +} + +TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) { + // var v = frexp(vec2(1_h)); // v is __frexp_result_vec2_f16 + // v = frexp(vec2(1)); // __frexp_result_vec2_f16 <- __frexp_result_vec2_abstract + Enable(ast::Extension::kF16); + auto* call = Call("frexp", Construct(ty.vec2(nullptr), 1_a)); + WrapInFunction(Decl(Var("v", Call("frexp", Construct(ty.vec2(nullptr), 1_h)))), + Assign("v", call)); + ASSERT_TRUE(r()->Resolve()) << r()->error(); + auto* sem = Sem().Get(call); + ASSERT_TRUE(sem->Is()); + auto* materialize = sem->As(); + ASSERT_TRUE(materialize->Type()->Is()); + auto* concrete_str = materialize->Type()->As(); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); + ASSERT_TRUE(materialize->Expr()->Type()->Is()); + auto* abstract_str = materialize->Expr()->Type()->As(); + ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); + ASSERT_TRUE( + abstract_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE( + abstract_str->Members()[1]->Type()->As()->type()->Is()); +} + } // namespace materialize_abstract_structure } // namespace diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc index 7d0a72e44e..cd33dccca1 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc @@ -668,9 +668,9 @@ void main() { )"); } -TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Scalar_f32) { - auto* call = Call("frexp", 1_f); - WrapInFunction(CallStmt(call)); +TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) { + WrapInFunction(Var("f", Expr(1_f)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -690,7 +690,8 @@ frexp_result tint_frexp(float param_0) { void test_function() { - tint_frexp(1.0f); + float f = 1.0f; + frexp_result v = tint_frexp(f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -701,11 +702,11 @@ void main() { )"); } -TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Scalar_f16) { +TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", 1_h); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(1_h)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -726,7 +727,8 @@ frexp_result_f16 tint_frexp(float16_t param_0) { void test_function() { - tint_frexp(1.0hf); + float16_t f = 1.0hf; + frexp_result_f16 v = tint_frexp(f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -737,9 +739,9 @@ void main() { )"); } -TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Vector_f32) { - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); +TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) { + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -759,7 +761,8 @@ frexp_result_vec3 tint_frexp(vec3 param_0) { void test_function() { - tint_frexp(vec3(0.0f)); + vec3 f = vec3(0.0f); + frexp_result_vec3 v = tint_frexp(f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -770,11 +773,11 @@ void main() { )"); } -TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Vector_f16) { +TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -795,7 +798,118 @@ frexp_result_vec3_f16 tint_frexp(f16vec3 param_0) { void test_function() { - tint_frexp(f16vec3(0.0hf)); + f16vec3 f = f16vec3(0.0hf); + frexp_result_vec3_f16 v = tint_frexp(f); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + test_function(); + return; +} +)"); +} + +TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", 1_f)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void test_function() { + frexp_result v = frexp_result(0.5f, 1); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + test_function(); + return; +} +)"); +} + +TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", 1_h)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#version 310 es +#extension GL_AMD_gpu_shader_half_float : require + +struct frexp_result_f16 { + float16_t fract; + int exp; +}; + + +void test_function() { + frexp_result_f16 v = frexp_result_f16(0.5hf, 1); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + test_function(); + return; +} +)"); +} + +TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#version 310 es + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void test_function() { + frexp_result_vec3 v = frexp_result_vec3(vec3(0.0f), ivec3(0)); +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + test_function(); + return; +} +)"); +} + +TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#version 310 es +#extension GL_AMD_gpu_shader_half_float : require + +struct frexp_result_vec3_f16 { + f16vec3 fract; + ivec3 exp; +}; + + +void test_function() { + frexp_result_vec3_f16 v = frexp_result_vec3_f16(f16vec3(0.0hf), ivec3(0)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -815,20 +929,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { ASSERT_TRUE(gen.Generate()) << gen.error(); EXPECT_EQ(gen.result(), R"(#version 310 es -struct frexp_result { - float fract; - int exp; -}; - -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - - void test_function() { - float tint_symbol = tint_frexp(1.0f).fract; + float tint_symbol = 0.5f; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc index 3e9b16973a..a17c3cbf49 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -572,7 +572,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, NonInitializer_Modf_Vector_f32) { Decl(Var("v", Call("modf", vec3(1.5_f, 2.5_f, 3.5_f)))), // Now assign 'v' again with another modf call. // This requires generating a temporary variable for the struct initializer. - Assign("v", Call("modf", vec3(4.5_f, 5.5_f, 6.5_f)))); + Assign("v", Call("modf", vec3(4.5_a, 5.5_a, 6.5_a)))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -591,9 +591,9 @@ void test_function() { )"); } -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Scalar_f32) { - auto* call = Call("frexp", 1_f); - WrapInFunction(CallStmt(call)); +TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) { + WrapInFunction(Var("f", Expr(1_f)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -611,17 +611,18 @@ frexp_result tint_frexp(float param_0) { [numthreads(1, 1, 1)] void test_function() { - tint_frexp(1.0f); + float f = 1.0f; + frexp_result v = tint_frexp(f); return; } )"); } -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Scalar_f16) { +TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", 1_h); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(1_h)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -639,15 +640,16 @@ frexp_result_f16 tint_frexp(float16_t param_0) { [numthreads(1, 1, 1)] void test_function() { - tint_frexp(float16_t(1.0h)); + float16_t f = float16_t(1.0h); + frexp_result_f16 v = tint_frexp(f); return; } )"); } -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Vector_f32) { - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); +TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) { + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -665,17 +667,18 @@ frexp_result_vec3 tint_frexp(float3 param_0) { [numthreads(1, 1, 1)] void test_function() { - tint_frexp((0.0f).xxx); + float3 f = (0.0f).xxx; + frexp_result_vec3 v = tint_frexp(f); return; } )"); } -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Vector_f16) { +TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -693,15 +696,15 @@ frexp_result_vec3_f16 tint_frexp(vector param_0) { [numthreads(1, 1, 1)] void test_function() { - tint_frexp((float16_t(0.0h)).xxx); + vector f = (float16_t(0.0h)).xxx; + frexp_result_vec3_f16 v = tint_frexp(f); return; } )"); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { - WrapInFunction(MemberAccessor(Call("frexp", 1_f), "sig")); +TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", 1_f)))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -710,16 +713,114 @@ TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - [numthreads(1, 1, 1)] void test_function() { - const float tint_symbol = tint_frexp(1.0f).fract; + const frexp_result v = {0.5f, 1}; + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", 1_h)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct frexp_result_f16 { + float16_t fract; + int exp; +}; +[numthreads(1, 1, 1)] +void test_function() { + const frexp_result_f16 v = {float16_t(0.5h), 1}; + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +[numthreads(1, 1, 1)] +void test_function() { + const frexp_result_vec3 v = (frexp_result_vec3)0; + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f16 { + vector fract; + int3 exp; +}; +[numthreads(1, 1, 1)] +void test_function() { + const frexp_result_vec3_f16 v = (frexp_result_vec3_f16)0; + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, NonInitializer_Frexp_Vector_f32) { + WrapInFunction( + // Declare a variable with the result of a frexp call. + // This is required to infer the 'var' type. + Decl(Var("v", Call("frexp", vec3(1.5_f, 2.5_f, 3.5_f)))), + // Now assign 'v' again with another frexp call. + // This requires generating a temporary variable for the struct initializer. + Assign("v", Call("frexp", vec3(4.5_a, 5.5_a, 6.5_a)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +[numthreads(1, 1, 1)] +void test_function() { + frexp_result_vec3 v = {float3(0.75f, 0.625f, 0.875f), int3(1, 2, 2)}; + const frexp_result_vec3 c = {float3(0.5625f, 0.6875f, 0.8125f), (3).xxx}; + v = c; + return; +} +)"); +} + +// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over +TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Sig_Deprecation) { + WrapInFunction(Var("v", Call("frexp", 1_f)), // + MemberAccessor("v", "sig")); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct frexp_result { + float fract; + int exp; +}; +[numthreads(1, 1, 1)] +void test_function() { + frexp_result v = {0.5f, 1}; + const float tint_symbol = v.fract; return; } )"); diff --git a/src/tint/writer/msl/generator_impl_builtin_test.cc b/src/tint/writer/msl/generator_impl_builtin_test.cc index c611d6b368..7d000b1619 100644 --- a/src/tint/writer/msl/generator_impl_builtin_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_test.cc @@ -621,9 +621,9 @@ kernel void test_function() { )"); } -TEST_F(MslGeneratorImplTest, Frexp_Scalar_f32) { - auto* call = Call("frexp", 1_f); - WrapInFunction(CallStmt(call)); +TEST_F(MslGeneratorImplTest, Runtime_Frexp_Scalar_f32) { + WrapInFunction(Var("f", Expr(1_f)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -643,18 +643,19 @@ frexp_result tint_frexp(float param_0) { } kernel void test_function() { - tint_frexp(1.0f); + float f = 1.0f; + frexp_result v = tint_frexp(f); return; } )"); } -TEST_F(MslGeneratorImplTest, Frexp_Scalar_f16) { +TEST_F(MslGeneratorImplTest, Runtime_Frexp_Scalar_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", 1_h); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(1_h)), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -674,16 +675,17 @@ frexp_result_f16 tint_frexp(half param_0) { } kernel void test_function() { - tint_frexp(1.0h); + half f = 1.0h; + frexp_result_f16 v = tint_frexp(f); return; } )"); } -TEST_F(MslGeneratorImplTest, Frexp_Vector_f32) { - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); +TEST_F(MslGeneratorImplTest, Runtime_Frexp_Vector_f32) { + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -703,18 +705,19 @@ frexp_result_vec3 tint_frexp(float3 param_0) { } kernel void test_function() { - tint_frexp(float3(0.0f)); + float3 f = float3(0.0f); + frexp_result_vec3 v = tint_frexp(f); return; } )"); } -TEST_F(MslGeneratorImplTest, Frexp_Vector_f16) { +TEST_F(MslGeneratorImplTest, Runtime_Frexp_Vector_f16) { Enable(ast::Extension::kF16); - auto* call = Call("frexp", vec3()); - WrapInFunction(CallStmt(call)); + WrapInFunction(Var("f", Expr(vec3())), // + Var("v", Call("frexp", "f"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -734,7 +737,100 @@ frexp_result_vec3_f16 tint_frexp(half3 param_0) { } kernel void test_function() { - tint_frexp(half3(0.0h)); + half3 f = half3(0.0h); + frexp_result_vec3_f16 v = tint_frexp(f); + return; +} + +)"); +} + +TEST_F(MslGeneratorImplTest, Const_Frexp_Scalar_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", 1_f)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +kernel void test_function() { + frexp_result const v = frexp_result{.fract=0.5f, .exp=1}; + return; +} + +)"); +} + +TEST_F(MslGeneratorImplTest, Const_Frexp_Scalar_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", 1_h)))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#include + +using namespace metal; + +struct frexp_result_f16 { + half fract; + int exp; +}; +kernel void test_function() { + frexp_result_f16 const v = frexp_result_f16{.fract=0.5h, .exp=1}; + return; +} + +)"); +} + +TEST_F(MslGeneratorImplTest, Const_Frexp_Vector_f32) { + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#include + +using namespace metal; + +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +kernel void test_function() { + frexp_result_vec3 const v = frexp_result_vec3{}; + return; +} + +)"); +} + +TEST_F(MslGeneratorImplTest, Const_Frexp_Vector_f16) { + Enable(ast::Extension::kF16); + + WrapInFunction(Decl(Let("v", Call("frexp", vec3())))); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(#include + +using namespace metal; + +struct frexp_result_vec3_f16 { + half3 fract; + int3 exp; +}; +kernel void test_function() { + frexp_result_vec3_f16 const v = frexp_result_vec3_f16{}; return; } @@ -751,19 +847,8 @@ TEST_F(MslGeneratorImplTest, Frexp_Sig_Deprecation) { EXPECT_EQ(gen.result(), R"(#include using namespace metal; - -struct frexp_result { - float fract; - int exp; -}; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - kernel void test_function() { - float const tint_symbol = tint_frexp(1.0f).fract; + float const tint_symbol = 0.5f; return; } diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index c0995e840d..e08912253f 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -1834,7 +1834,7 @@ OpFunctionEnd Validate(b); } -TEST_F(BuiltinBuilderTest, Call_Frexp_f32) { +TEST_F(BuiltinBuilderTest, Runtime_Call_Frexp_f32) { auto* vec = Var("vec", vec2(1_f, 2_f)); auto* expr = Call("frexp", vec); Func("a_func", utils::Empty, ty.void_(), @@ -1888,7 +1888,7 @@ OpFunctionEnd Validate(b); } -TEST_F(BuiltinBuilderTest, Call_Frexp_f16) { +TEST_F(BuiltinBuilderTest, Runtime_Call_Frexp_f16) { Enable(ast::Extension::kF16); auto* vec = Var("vec", vec2(1_h, 2_h)); @@ -1948,15 +1948,10 @@ OpFunctionEnd Validate(b); } -// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over -TEST_F(BuiltinBuilderTest, Frexp_Sig_Deprecation) { - WrapInFunction(MemberAccessor(Call("frexp", 1_f), "sig")); - - auto* vec = Var("vec", vec2(1_f, 2_f)); +TEST_F(BuiltinBuilderTest, Const_Call_Frexp_f32) { Func("a_func", utils::Empty, ty.void_(), utils::Vector{ - Decl(vec), - Decl(Let("s", MemberAccessor(Call("frexp", vec), "sig"))), + CallStmt(Call("frexp", vec2(1_f, 2_f))), }, utils::Vector{ Stage(ast::PipelineStage::kFragment), @@ -1967,51 +1962,134 @@ TEST_F(BuiltinBuilderTest, Frexp_Sig_Deprecation) { ASSERT_TRUE(b.Build()) << b.error(); auto got = DumpBuilder(b); auto* expect = R"(OpCapability Shader -%9 = OpExtInstImport "GLSL.std.450" +%11 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpEntryPoint Fragment %12 "a_func" -OpExecutionMode %3 LocalSize 1 1 1 -OpExecutionMode %12 OriginUpperLeft -OpName %3 "test_function" -OpName %6 "__frexp_result" +OpEntryPoint Fragment %3 "a_func" +OpExecutionMode %3 OriginUpperLeft +OpName %3 "a_func" +OpName %6 "__frexp_result_vec2" OpMemberName %6 0 "fract" OpMemberName %6 1 "exp" -OpName %12 "a_func" -OpName %17 "vec" -OpName %21 "__frexp_result_vec2" -OpMemberName %21 0 "fract" -OpMemberName %21 1 "exp" OpMemberDecorate %6 0 Offset 0 -OpMemberDecorate %6 1 Offset 4 -OpMemberDecorate %21 0 Offset 0 -OpMemberDecorate %21 1 Offset 8 +OpMemberDecorate %6 1 Offset 8 %2 = OpTypeVoid %1 = OpTypeFunction %2 -%7 = OpTypeFloat 32 -%8 = OpTypeInt 32 1 -%6 = OpTypeStruct %7 %8 -%10 = OpConstant %7 1 -%14 = OpTypeVector %7 2 -%15 = OpConstant %7 2 -%16 = OpConstantComposite %14 %10 %15 -%18 = OpTypePointer Function %14 -%19 = OpConstantNull %14 -%22 = OpTypeVector %8 2 -%21 = OpTypeStruct %14 %22 +%8 = OpTypeFloat 32 +%7 = OpTypeVector %8 2 +%10 = OpTypeInt 32 1 +%9 = OpTypeVector %10 2 +%6 = OpTypeStruct %7 %9 +%12 = OpConstant %8 1 +%13 = OpConstant %8 2 +%14 = OpConstantComposite %7 %12 %13 %3 = OpFunction %2 None %1 %4 = OpLabel -%5 = OpExtInst %6 %9 FrexpStruct %10 -%11 = OpCompositeExtract %7 %5 0 +%5 = OpExtInst %6 %11 FrexpStruct %14 OpReturn OpFunctionEnd -%12 = OpFunction %2 None %1 -%13 = OpLabel -%17 = OpVariable %18 Function %19 -OpStore %17 %16 -%23 = OpLoad %14 %17 -%20 = OpExtInst %21 %9 FrexpStruct %23 -%24 = OpCompositeExtract %14 %20 0 +)"; + EXPECT_EQ(expect, got); + + Validate(b); +} + +TEST_F(BuiltinBuilderTest, Const_Call_Frexp_f16) { + Enable(ast::Extension::kF16); + + Func("a_func", utils::Empty, ty.void_(), + utils::Vector{ + CallStmt(Call("frexp", vec2(1_h, 2_h))), + }, + utils::Vector{ + Stage(ast::PipelineStage::kFragment), + }); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + auto got = DumpBuilder(b); + auto* expect = R"(OpCapability Shader +OpCapability Float16 +OpCapability UniformAndStorageBuffer16BitAccess +OpCapability StorageBuffer16BitAccess +OpCapability StorageInputOutput16 +%11 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %3 "a_func" +OpExecutionMode %3 OriginUpperLeft +OpName %3 "a_func" +OpName %6 "__frexp_result_vec2_f16" +OpMemberName %6 0 "fract" +OpMemberName %6 1 "exp" +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 8 +%2 = OpTypeVoid +%1 = OpTypeFunction %2 +%8 = OpTypeFloat 16 +%7 = OpTypeVector %8 2 +%10 = OpTypeInt 32 1 +%9 = OpTypeVector %10 2 +%6 = OpTypeStruct %7 %9 +%12 = OpConstant %8 0x1p+0 +%13 = OpConstant %8 0x1p+1 +%14 = OpConstantComposite %7 %12 %13 +%3 = OpFunction %2 None %1 +%4 = OpLabel +%5 = OpExtInst %6 %11 FrexpStruct %14 +OpReturn +OpFunctionEnd +)"; + EXPECT_EQ(expect, got); + + Validate(b); +} + +// TODO(crbug.com/tint/1757): Remove once deprecation period for `frexp().sig` is over +TEST_F(BuiltinBuilderTest, Frexp_Sig_Deprecation) { + Func("a_func", utils::Empty, ty.void_(), + utils::Vector{ + Decl(Var("vec", vec2(1_f, 2_f))), + Decl(Let("s", MemberAccessor(Call("frexp", "vec"), "sig"))), + }, + utils::Vector{ + Stage(ast::PipelineStage::kFragment), + }); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + auto got = DumpBuilder(b); + auto* expect = R"(OpCapability Shader +%17 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %3 "a_func" +OpExecutionMode %3 OriginUpperLeft +OpName %3 "a_func" +OpName %10 "vec" +OpName %14 "__frexp_result_vec2" +OpMemberName %14 0 "fract" +OpMemberName %14 1 "exp" +OpMemberDecorate %14 0 Offset 0 +OpMemberDecorate %14 1 Offset 8 +%2 = OpTypeVoid +%1 = OpTypeFunction %2 +%6 = OpTypeFloat 32 +%5 = OpTypeVector %6 2 +%7 = OpConstant %6 1 +%8 = OpConstant %6 2 +%9 = OpConstantComposite %5 %7 %8 +%11 = OpTypePointer Function %5 +%12 = OpConstantNull %5 +%16 = OpTypeInt 32 1 +%15 = OpTypeVector %16 2 +%14 = OpTypeStruct %5 %15 +%3 = OpFunction %2 None %1 +%4 = OpLabel +%10 = OpVariable %11 Function %12 +OpStore %10 %9 +%18 = OpLoad %5 %10 +%13 = OpExtInst %14 %17 FrexpStruct %18 +%19 = OpCompositeExtract %5 %13 0 OpReturn OpFunctionEnd )"; diff --git a/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl index 1e0655fadf..895420b5a6 100644 --- a/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/1757.wgsl.expected.dxc.hlsl @@ -6,16 +6,9 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - [numthreads(1, 1, 1)] void main() { - const frexp_result res = tint_frexp(1.230000019f); + const frexp_result res = {0.61500001f, 1}; const int exp = res.exp; const float sig = res.fract; return; diff --git a/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl index 1e0655fadf..895420b5a6 100644 --- a/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/1757.wgsl.expected.fxc.hlsl @@ -6,16 +6,9 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - [numthreads(1, 1, 1)] void main() { - const frexp_result res = tint_frexp(1.230000019f); + const frexp_result res = {0.61500001f, 1}; const int exp = res.exp; const float sig = res.fract; return; diff --git a/test/tint/bug/tint/1757.wgsl.expected.glsl b/test/tint/bug/tint/1757.wgsl.expected.glsl index e6efd68c0a..e6ff7ca09e 100644 --- a/test/tint/bug/tint/1757.wgsl.expected.glsl +++ b/test/tint/bug/tint/1757.wgsl.expected.glsl @@ -9,15 +9,9 @@ struct frexp_result { int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void tint_symbol() { - frexp_result res = tint_frexp(1.230000019f); + frexp_result res = frexp_result(0.61500001f, 1); int tint_symbol_1 = res.exp; float sig = res.fract; } diff --git a/test/tint/bug/tint/1757.wgsl.expected.msl b/test/tint/bug/tint/1757.wgsl.expected.msl index 8196ef61e0..0d960e71f8 100644 --- a/test/tint/bug/tint/1757.wgsl.expected.msl +++ b/test/tint/bug/tint/1757.wgsl.expected.msl @@ -10,14 +10,8 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - kernel void tint_symbol() { - frexp_result const res = tint_frexp(1.230000019f); + frexp_result const res = frexp_result{.fract=0.61500001f, .exp=1}; int const exp = res.exp; float const sig = res.fract; return; diff --git a/test/tint/bug/tint/1757.wgsl.expected.spvasm b/test/tint/bug/tint/1757.wgsl.expected.spvasm index 4116852a64..79b00c0b40 100644 --- a/test/tint/bug/tint/1757.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1757.wgsl.expected.spvasm @@ -8,7 +8,6 @@ bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has b ; Bound: 13 ; Schema: 0 OpCapability Shader - %9 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -23,11 +22,12 @@ bug/tint/1757.wgsl:6:25 warning: use of deprecated language feature: 'sig' has b %float = OpTypeFloat 32 %int = OpTypeInt 32 1 %__frexp_result = OpTypeStruct %float %int -%float_1_23000002 = OpConstant %float 1.23000002 +%float_0_61500001 = OpConstant %float 0.61500001 + %int_1 = OpConstant %int 1 + %10 = OpConstantComposite %__frexp_result %float_0_61500001 %int_1 %main = OpFunction %void None %1 %4 = OpLabel - %5 = OpExtInst %__frexp_result %9 FrexpStruct %float_1_23000002 - %11 = OpCompositeExtract %int %5 1 - %12 = OpCompositeExtract %float %5 0 + %11 = OpCompositeExtract %int %10 1 + %12 = OpCompositeExtract %float %10 0 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/frexp.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp.wgsl.expected.dxc.hlsl index 5737415683..3e21c7ff63 100644 --- a/test/tint/builtins/frexp.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/frexp.wgsl.expected.dxc.hlsl @@ -2,16 +2,9 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - [numthreads(1, 1, 1)] void main() { - const frexp_result res = tint_frexp(1.230000019f); + const frexp_result res = {0.61500001f, 1}; const int exp = res.exp; const float fract = res.fract; return; diff --git a/test/tint/builtins/frexp.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp.wgsl.expected.fxc.hlsl index 5737415683..3e21c7ff63 100644 --- a/test/tint/builtins/frexp.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/frexp.wgsl.expected.fxc.hlsl @@ -2,16 +2,9 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - [numthreads(1, 1, 1)] void main() { - const frexp_result res = tint_frexp(1.230000019f); + const frexp_result res = {0.61500001f, 1}; const int exp = res.exp; const float fract = res.fract; return; diff --git a/test/tint/builtins/frexp.wgsl.expected.glsl b/test/tint/builtins/frexp.wgsl.expected.glsl index 08ae34daab..d1244477f6 100644 --- a/test/tint/builtins/frexp.wgsl.expected.glsl +++ b/test/tint/builtins/frexp.wgsl.expected.glsl @@ -5,15 +5,9 @@ struct frexp_result { int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void tint_symbol() { - frexp_result res = tint_frexp(1.230000019f); + frexp_result res = frexp_result(0.61500001f, 1); int tint_symbol_1 = res.exp; float tint_symbol_2 = res.fract; } diff --git a/test/tint/builtins/frexp.wgsl.expected.msl b/test/tint/builtins/frexp.wgsl.expected.msl index 59dd29ce7b..1bce450398 100644 --- a/test/tint/builtins/frexp.wgsl.expected.msl +++ b/test/tint/builtins/frexp.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - kernel void tint_symbol() { - frexp_result const res = tint_frexp(1.230000019f); + frexp_result const res = frexp_result{.fract=0.61500001f, .exp=1}; int const exp = res.exp; float const fract = res.fract; return; diff --git a/test/tint/builtins/frexp.wgsl.expected.spvasm b/test/tint/builtins/frexp.wgsl.expected.spvasm index 8828159968..69cdd2f9a6 100644 --- a/test/tint/builtins/frexp.wgsl.expected.spvasm +++ b/test/tint/builtins/frexp.wgsl.expected.spvasm @@ -4,7 +4,6 @@ ; Bound: 13 ; Schema: 0 OpCapability Shader - %9 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -19,11 +18,12 @@ %float = OpTypeFloat 32 %int = OpTypeInt 32 1 %__frexp_result = OpTypeStruct %float %int -%float_1_23000002 = OpConstant %float 1.23000002 +%float_0_61500001 = OpConstant %float 0.61500001 + %int_1 = OpConstant %int 1 + %10 = OpConstantComposite %__frexp_result %float_0_61500001 %int_1 %main = OpFunction %void None %1 %4 = OpLabel - %5 = OpExtInst %__frexp_result %9 FrexpStruct %float_1_23000002 - %11 = OpCompositeExtract %int %5 1 - %12 = OpCompositeExtract %float %5 0 + %11 = OpCompositeExtract %int %10 1 + %12 = OpCompositeExtract %float %10 0 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/frexp/scalar/const.wgsl b/test/tint/builtins/frexp/scalar/const.wgsl new file mode 100644 index 0000000000..e4ea5556f2 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = 1.25; + let res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/scalar/const.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..f14cccd0dd --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.dxc.hlsl @@ -0,0 +1,11 @@ +struct frexp_result { + float fract; + int exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result res = {0.625f, 1}; + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/scalar/const.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..f14cccd0dd --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.fxc.hlsl @@ -0,0 +1,11 @@ +struct frexp_result { + float fract; + int exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result res = {0.625f, 1}; + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.glsl b/test/tint/builtins/frexp/scalar/const.wgsl.expected.glsl new file mode 100644 index 0000000000..ec8ca7c78a --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.glsl @@ -0,0 +1,19 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void tint_symbol() { + frexp_result res = frexp_result(0.625f, 1); + float tint_symbol_2 = res.fract; + int tint_symbol_3 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.msl b/test/tint/builtins/frexp/scalar/const.wgsl.expected.msl new file mode 100644 index 0000000000..f0dcbcf08a --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.msl @@ -0,0 +1,15 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +kernel void tint_symbol() { + frexp_result const res = frexp_result{.fract=0.625f, .exp=1}; + float const fract = res.fract; + int const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.spvasm b/test/tint/builtins/frexp/scalar/const.wgsl.expected.spvasm new file mode 100644 index 0000000000..541d342609 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.spvasm @@ -0,0 +1,29 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 13 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result "__frexp_result" + OpMemberName %__frexp_result 0 "fract" + OpMemberName %__frexp_result 1 "exp" + OpMemberDecorate %__frexp_result 0 Offset 0 + OpMemberDecorate %__frexp_result 1 Offset 4 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %int = OpTypeInt 32 1 +%__frexp_result = OpTypeStruct %float %int +%float_0_625 = OpConstant %float 0.625 + %int_1 = OpConstant %int 1 + %10 = OpConstantComposite %__frexp_result %float_0_625 %int_1 + %main = OpFunction %void None %1 + %4 = OpLabel + %11 = OpCompositeExtract %float %10 0 + %12 = OpCompositeExtract %int %10 1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/scalar/const.wgsl.expected.wgsl b/test/tint/builtins/frexp/scalar/const.wgsl.expected.wgsl new file mode 100644 index 0000000000..281cc002d0 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = 1.25; + let res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl b/test/tint/builtins/frexp/scalar/const_members.wgsl new file mode 100644 index 0000000000..1d61cac726 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = 1.25; + const res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..19792b6a9c --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl @@ -0,0 +1,12 @@ +struct frexp_result { + float fract; + int exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result tint_symbol_1 = {0.625f, 1}; + const float fract = tint_symbol_1.fract; + const frexp_result tint_symbol_2 = {0.625f, 1}; + const int exp = tint_symbol_2.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..19792b6a9c --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl @@ -0,0 +1,12 @@ +struct frexp_result { + float fract; + int exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result tint_symbol_1 = {0.625f, 1}; + const float fract = tint_symbol_1.fract; + const frexp_result tint_symbol_2 = {0.625f, 1}; + const int exp = tint_symbol_2.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl new file mode 100644 index 0000000000..6667f5f411 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl @@ -0,0 +1,20 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void tint_symbol() { + frexp_result tint_symbol_4 = frexp_result(0.625f, 1); + float tint_symbol_2 = tint_symbol_4.fract; + frexp_result tint_symbol_5 = frexp_result(0.625f, 1); + int tint_symbol_3 = tint_symbol_5.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl new file mode 100644 index 0000000000..c2d6c144e8 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl @@ -0,0 +1,16 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +kernel void tint_symbol() { + frexp_result const tint_symbol_1 = frexp_result{.fract=0.625f, .exp=1}; + float const fract = tint_symbol_1.fract; + frexp_result const tint_symbol_2 = frexp_result{.fract=0.625f, .exp=1}; + int const exp = tint_symbol_2.exp; + return; +} + diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.spvasm b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.spvasm new file mode 100644 index 0000000000..a8c2cb1cac --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.spvasm @@ -0,0 +1,20 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 9 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 +%float_0_625 = OpConstant %float 0.625 + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 + %main = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.wgsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.wgsl new file mode 100644 index 0000000000..94a6b90a1d --- /dev/null +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = 1.25; + const res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl b/test/tint/builtins/frexp/scalar/mixed.wgsl new file mode 100644 index 0000000000..18049a42c4 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl @@ -0,0 +1,10 @@ +@compute @workgroup_size(1) +fn main() { + const const_in = 1.25; + let runtime_in = 1.25; + var res = frexp(const_in); + res = frexp(runtime_in); + res = frexp(const_in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b1dc653279 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.dxc.hlsl @@ -0,0 +1,22 @@ +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + float exp; + float fract = frexp(param_0, exp); + frexp_result result = {fract, int(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float runtime_in = 1.25f; + frexp_result res = {0.625f, 1}; + res = tint_frexp(runtime_in); + const frexp_result c = {0.625f, 1}; + res = c; + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b1dc653279 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.fxc.hlsl @@ -0,0 +1,22 @@ +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + float exp; + float fract = frexp(param_0, exp); + frexp_result result = {fract, int(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float runtime_in = 1.25f; + frexp_result res = {0.625f, 1}; + res = tint_frexp(runtime_in); + const frexp_result c = {0.625f, 1}; + res = c; + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.glsl b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.glsl new file mode 100644 index 0000000000..cd9010d1a0 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.glsl @@ -0,0 +1,28 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + +frexp_result tint_frexp(float param_0) { + frexp_result result; + result.fract = frexp(param_0, result.exp); + return result; +} + + +void tint_symbol() { + float runtime_in = 1.25f; + frexp_result res = frexp_result(0.625f, 1); + res = tint_frexp(runtime_in); + res = frexp_result(0.625f, 1); + float tint_symbol_1 = res.fract; + int tint_symbol_2 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.msl b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.msl new file mode 100644 index 0000000000..029f4e2376 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.msl @@ -0,0 +1,24 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + frexp_result result; + result.fract = frexp(param_0, result.exp); + return result; +} + +kernel void tint_symbol() { + float const runtime_in = 1.25f; + frexp_result res = frexp_result{.fract=0.625f, .exp=1}; + res = tint_frexp(runtime_in); + res = frexp_result{.fract=0.625f, .exp=1}; + float const fract = res.fract; + int const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.spvasm b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.spvasm new file mode 100644 index 0000000000..d87b2436f2 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.spvasm @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + %16 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result "__frexp_result" + OpMemberName %__frexp_result 0 "fract" + OpMemberName %__frexp_result 1 "exp" + OpName %res "res" + OpMemberDecorate %__frexp_result 0 Offset 0 + OpMemberDecorate %__frexp_result 1 Offset 4 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %float_1_25 = OpConstant %float 1.25 + %int = OpTypeInt 32 1 +%__frexp_result = OpTypeStruct %float %int +%float_0_625 = OpConstant %float 0.625 + %int_1 = OpConstant %int 1 + %11 = OpConstantComposite %__frexp_result %float_0_625 %int_1 +%_ptr_Function___frexp_result = OpTypePointer Function %__frexp_result + %14 = OpConstantNull %__frexp_result + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_float = OpTypePointer Function %float + %uint_1 = OpConstant %uint 1 +%_ptr_Function_int = OpTypePointer Function %int + %main = OpFunction %void None %1 + %4 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result Function %14 + OpStore %res %11 + %15 = OpExtInst %__frexp_result %16 FrexpStruct %float_1_25 + OpStore %res %15 + OpStore %res %11 + %20 = OpAccessChain %_ptr_Function_float %res %uint_0 + %21 = OpLoad %float %20 + %24 = OpAccessChain %_ptr_Function_int %res %uint_1 + %25 = OpLoad %int %24 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.wgsl b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.wgsl new file mode 100644 index 0000000000..c46880d04f --- /dev/null +++ b/test/tint/builtins/frexp/scalar/mixed.wgsl.expected.wgsl @@ -0,0 +1,10 @@ +@compute @workgroup_size(1) +fn main() { + const const_in = 1.25; + let runtime_in = 1.25; + var res = frexp(const_in); + res = frexp(runtime_in); + res = frexp(const_in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl b/test/tint/builtins/frexp/scalar/runtime.wgsl new file mode 100644 index 0000000000..fdf9b45edc --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + let in = 1.25; + let res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..3f6cc5043f --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.dxc.hlsl @@ -0,0 +1,19 @@ +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + float exp; + float fract = frexp(param_0, exp); + frexp_result result = {fract, int(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float tint_symbol = 1.25f; + const frexp_result res = tint_frexp(tint_symbol); + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..3f6cc5043f --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.fxc.hlsl @@ -0,0 +1,19 @@ +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + float exp; + float fract = frexp(param_0, exp); + frexp_result result = {fract, int(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float tint_symbol = 1.25f; + const frexp_result res = tint_frexp(tint_symbol); + const float fract = res.fract; + const int exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.glsl b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.glsl new file mode 100644 index 0000000000..4e3c642732 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.glsl @@ -0,0 +1,26 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + +frexp_result tint_frexp(float param_0) { + frexp_result result; + result.fract = frexp(param_0, result.exp); + return result; +} + + +void tint_symbol() { + float tint_symbol_1 = 1.25f; + frexp_result res = tint_frexp(tint_symbol_1); + float tint_symbol_2 = res.fract; + int tint_symbol_3 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.msl b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.msl new file mode 100644 index 0000000000..97eff80335 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.msl @@ -0,0 +1,22 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +frexp_result tint_frexp(float param_0) { + frexp_result result; + result.fract = frexp(param_0, result.exp); + return result; +} + +kernel void tint_symbol() { + float const in = 1.25f; + frexp_result const res = tint_frexp(in); + float const fract = res.fract; + int const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.spvasm b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.spvasm new file mode 100644 index 0000000000..cf7a5cec67 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.spvasm @@ -0,0 +1,29 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 13 +; Schema: 0 + OpCapability Shader + %10 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result "__frexp_result" + OpMemberName %__frexp_result 0 "fract" + OpMemberName %__frexp_result 1 "exp" + OpMemberDecorate %__frexp_result 0 Offset 0 + OpMemberDecorate %__frexp_result 1 Offset 4 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %float_1_25 = OpConstant %float 1.25 + %int = OpTypeInt 32 1 +%__frexp_result = OpTypeStruct %float %int + %main = OpFunction %void None %1 + %4 = OpLabel + %7 = OpExtInst %__frexp_result %10 FrexpStruct %float_1_25 + %11 = OpCompositeExtract %float %7 0 + %12 = OpCompositeExtract %int %7 1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.wgsl b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.wgsl new file mode 100644 index 0000000000..300cf788f3 --- /dev/null +++ b/test/tint/builtins/frexp/scalar/runtime.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + let in = 1.25; + let res = frexp(in); + let fract : f32 = res.fract; + let exp : i32 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/const.wgsl b/test/tint/builtins/frexp/vector/const.wgsl new file mode 100644 index 0000000000..eb44c9643f --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = vec2(1.25, 3.75); + let res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/vector/const.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..8bba86f638 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.dxc.hlsl @@ -0,0 +1,11 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result_vec2 res = {float2(0.625f, 0.9375f), int2(1, 2)}; + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/vector/const.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..8bba86f638 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.fxc.hlsl @@ -0,0 +1,11 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result_vec2 res = {float2(0.625f, 0.9375f), int2(1, 2)}; + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.glsl b/test/tint/builtins/frexp/vector/const.wgsl.expected.glsl new file mode 100644 index 0000000000..1bf02abdc3 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.glsl @@ -0,0 +1,19 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void tint_symbol() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.625f, 0.9375f), ivec2(1, 2)); + vec2 tint_symbol_2 = res.fract; + ivec2 tint_symbol_3 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.msl b/test/tint/builtins/frexp/vector/const.wgsl.expected.msl new file mode 100644 index 0000000000..fb5dd60078 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.msl @@ -0,0 +1,15 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +kernel void tint_symbol() { + frexp_result_vec2 const res = frexp_result_vec2{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; + float2 const fract = res.fract; + int2 const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.spvasm b/test/tint/builtins/frexp/vector/const.wgsl.expected.spvasm new file mode 100644 index 0000000000..50a68f25b0 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.spvasm @@ -0,0 +1,35 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result_vec2 "__frexp_result_vec2" + OpMemberName %__frexp_result_vec2 0 "fract" + OpMemberName %__frexp_result_vec2 1 "exp" + OpMemberDecorate %__frexp_result_vec2 0 Offset 0 + OpMemberDecorate %__frexp_result_vec2 1 Offset 8 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 +%__frexp_result_vec2 = OpTypeStruct %v2float %v2int +%float_0_625 = OpConstant %float 0.625 +%float_0_9375 = OpConstant %float 0.9375 + %12 = OpConstantComposite %v2float %float_0_625 %float_0_9375 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %15 = OpConstantComposite %v2int %int_1 %int_2 + %16 = OpConstantComposite %__frexp_result_vec2 %12 %15 + %main = OpFunction %void None %1 + %4 = OpLabel + %17 = OpCompositeExtract %v2float %16 0 + %18 = OpCompositeExtract %v2int %16 1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/vector/const.wgsl.expected.wgsl b/test/tint/builtins/frexp/vector/const.wgsl.expected.wgsl new file mode 100644 index 0000000000..71a7f5285b --- /dev/null +++ b/test/tint/builtins/frexp/vector/const.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = vec2(1.25, 3.75); + let res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl b/test/tint/builtins/frexp/vector/const_members.wgsl new file mode 100644 index 0000000000..71375c5406 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = vec2(1.25, 3.75); + const res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b3c80eb9e8 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl @@ -0,0 +1,12 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result_vec2 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)}; + const float2 fract = tint_symbol_1.fract; + const frexp_result_vec2 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)}; + const int2 exp = tint_symbol_2.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b3c80eb9e8 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl @@ -0,0 +1,12 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +[numthreads(1, 1, 1)] +void main() { + const frexp_result_vec2 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)}; + const float2 fract = tint_symbol_1.fract; + const frexp_result_vec2 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)}; + const int2 exp = tint_symbol_2.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl new file mode 100644 index 0000000000..ae073aba73 --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl @@ -0,0 +1,20 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void tint_symbol() { + frexp_result_vec2 tint_symbol_4 = frexp_result_vec2(vec2(0.625f, 0.9375f), ivec2(1, 2)); + vec2 tint_symbol_2 = tint_symbol_4.fract; + frexp_result_vec2 tint_symbol_5 = frexp_result_vec2(vec2(0.625f, 0.9375f), ivec2(1, 2)); + ivec2 tint_symbol_3 = tint_symbol_5.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl new file mode 100644 index 0000000000..bf9777227f --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl @@ -0,0 +1,16 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +kernel void tint_symbol() { + frexp_result_vec2 const tint_symbol_1 = frexp_result_vec2{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; + float2 const fract = tint_symbol_1.fract; + frexp_result_vec2 const tint_symbol_2 = frexp_result_vec2{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; + int2 const exp = tint_symbol_2.exp; + return; +} + diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.spvasm b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.spvasm new file mode 100644 index 0000000000..4a729e88fb --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.spvasm @@ -0,0 +1,26 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 15 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 +%float_0_625 = OpConstant %float 0.625 +%float_0_9375 = OpConstant %float 0.9375 + %9 = OpConstantComposite %v2float %float_0_625 %float_0_9375 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %14 = OpConstantComposite %v2int %int_1 %int_2 + %main = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.wgsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.wgsl new file mode 100644 index 0000000000..1cb2f7fb3b --- /dev/null +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + const in = vec2(1.25, 3.75); + const res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl b/test/tint/builtins/frexp/vector/mixed.wgsl new file mode 100644 index 0000000000..edf19277b7 --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl @@ -0,0 +1,10 @@ +@compute @workgroup_size(1) +fn main() { + const const_in = vec2(1.25, 3.75); + let runtime_in = vec2(1.25, 3.75); + var res = frexp(const_in); + res = frexp(runtime_in); + res = frexp(const_in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..7d6adb33f9 --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.dxc.hlsl @@ -0,0 +1,22 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + float2 exp; + float2 fract = frexp(param_0, exp); + frexp_result_vec2 result = {fract, int2(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float2 runtime_in = float2(1.25f, 3.75f); + frexp_result_vec2 res = {float2(0.625f, 0.9375f), int2(1, 2)}; + res = tint_frexp(runtime_in); + const frexp_result_vec2 c = {float2(0.625f, 0.9375f), int2(1, 2)}; + res = c; + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..7d6adb33f9 --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.fxc.hlsl @@ -0,0 +1,22 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + float2 exp; + float2 fract = frexp(param_0, exp); + frexp_result_vec2 result = {fract, int2(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float2 runtime_in = float2(1.25f, 3.75f); + frexp_result_vec2 res = {float2(0.625f, 0.9375f), int2(1, 2)}; + res = tint_frexp(runtime_in); + const frexp_result_vec2 c = {float2(0.625f, 0.9375f), int2(1, 2)}; + res = c; + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.glsl b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.glsl new file mode 100644 index 0000000000..82d9710d7d --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.glsl @@ -0,0 +1,28 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + +frexp_result_vec2 tint_frexp(vec2 param_0) { + frexp_result_vec2 result; + result.fract = frexp(param_0, result.exp); + return result; +} + + +void tint_symbol() { + vec2 runtime_in = vec2(1.25f, 3.75f); + frexp_result_vec2 res = frexp_result_vec2(vec2(0.625f, 0.9375f), ivec2(1, 2)); + res = tint_frexp(runtime_in); + res = frexp_result_vec2(vec2(0.625f, 0.9375f), ivec2(1, 2)); + vec2 tint_symbol_1 = res.fract; + ivec2 tint_symbol_2 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.msl b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.msl new file mode 100644 index 0000000000..aba51abf72 --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.msl @@ -0,0 +1,24 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + frexp_result_vec2 result; + result.fract = frexp(param_0, result.exp); + return result; +} + +kernel void tint_symbol() { + float2 const runtime_in = float2(1.25f, 3.75f); + frexp_result_vec2 res = frexp_result_vec2{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; + res = tint_frexp(runtime_in); + res = frexp_result_vec2{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; + float2 const fract = res.fract; + int2 const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.spvasm b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.spvasm new file mode 100644 index 0000000000..2b45647589 --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.spvasm @@ -0,0 +1,54 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 34 +; Schema: 0 + OpCapability Shader + %24 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result_vec2 "__frexp_result_vec2" + OpMemberName %__frexp_result_vec2 0 "fract" + OpMemberName %__frexp_result_vec2 1 "exp" + OpName %res "res" + OpMemberDecorate %__frexp_result_vec2 0 Offset 0 + OpMemberDecorate %__frexp_result_vec2 1 Offset 8 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %float_1_25 = OpConstant %float 1.25 + %float_3_75 = OpConstant %float 3.75 + %9 = OpConstantComposite %v2float %float_1_25 %float_3_75 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 +%__frexp_result_vec2 = OpTypeStruct %v2float %v2int +%float_0_625 = OpConstant %float 0.625 +%float_0_9375 = OpConstant %float 0.9375 + %15 = OpConstantComposite %v2float %float_0_625 %float_0_9375 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %18 = OpConstantComposite %v2int %int_1 %int_2 + %19 = OpConstantComposite %__frexp_result_vec2 %15 %18 +%_ptr_Function___frexp_result_vec2 = OpTypePointer Function %__frexp_result_vec2 + %22 = OpConstantNull %__frexp_result_vec2 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %uint_1 = OpConstant %uint 1 +%_ptr_Function_v2int = OpTypePointer Function %v2int + %main = OpFunction %void None %1 + %4 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec2 Function %22 + OpStore %res %19 + %23 = OpExtInst %__frexp_result_vec2 %24 FrexpStruct %9 + OpStore %res %23 + OpStore %res %19 + %28 = OpAccessChain %_ptr_Function_v2float %res %uint_0 + %29 = OpLoad %v2float %28 + %32 = OpAccessChain %_ptr_Function_v2int %res %uint_1 + %33 = OpLoad %v2int %32 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/vector/mixed.wgsl.expected.wgsl b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.wgsl new file mode 100644 index 0000000000..cf570ada0e --- /dev/null +++ b/test/tint/builtins/frexp/vector/mixed.wgsl.expected.wgsl @@ -0,0 +1,10 @@ +@compute @workgroup_size(1) +fn main() { + const const_in = vec2(1.25, 3.75); + let runtime_in = vec2(1.25, 3.75); + var res = frexp(const_in); + res = frexp(runtime_in); + res = frexp(const_in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl b/test/tint/builtins/frexp/vector/runtime.wgsl new file mode 100644 index 0000000000..bb595dddcf --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + let in = vec2(1.25, 3.75); + let res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..ea744b6f53 --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.dxc.hlsl @@ -0,0 +1,19 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + float2 exp; + float2 fract = frexp(param_0, exp); + frexp_result_vec2 result = {fract, int2(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float2 tint_symbol = float2(1.25f, 3.75f); + const frexp_result_vec2 res = tint_frexp(tint_symbol); + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..ea744b6f53 --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.fxc.hlsl @@ -0,0 +1,19 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + float2 exp; + float2 fract = frexp(param_0, exp); + frexp_result_vec2 result = {fract, int2(exp)}; + return result; +} + +[numthreads(1, 1, 1)] +void main() { + const float2 tint_symbol = float2(1.25f, 3.75f); + const frexp_result_vec2 res = tint_frexp(tint_symbol); + const float2 fract = res.fract; + const int2 exp = res.exp; + return; +} diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.glsl b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.glsl new file mode 100644 index 0000000000..ded971f5d5 --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.glsl @@ -0,0 +1,26 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + +frexp_result_vec2 tint_frexp(vec2 param_0) { + frexp_result_vec2 result; + result.fract = frexp(param_0, result.exp); + return result; +} + + +void tint_symbol() { + vec2 tint_symbol_1 = vec2(1.25f, 3.75f); + frexp_result_vec2 res = tint_frexp(tint_symbol_1); + vec2 tint_symbol_2 = res.fract; + ivec2 tint_symbol_3 = res.exp; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() { + tint_symbol(); + return; +} diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.msl b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.msl new file mode 100644 index 0000000000..30cf6ccfdb --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.msl @@ -0,0 +1,22 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +frexp_result_vec2 tint_frexp(float2 param_0) { + frexp_result_vec2 result; + result.fract = frexp(param_0, result.exp); + return result; +} + +kernel void tint_symbol() { + float2 const in = float2(1.25f, 3.75f); + frexp_result_vec2 const res = tint_frexp(in); + float2 const fract = res.fract; + int2 const exp = res.exp; + return; +} + diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.spvasm b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.spvasm new file mode 100644 index 0000000000..8541b98ff9 --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.spvasm @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 17 +; Schema: 0 + OpCapability Shader + %14 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %__frexp_result_vec2 "__frexp_result_vec2" + OpMemberName %__frexp_result_vec2 0 "fract" + OpMemberName %__frexp_result_vec2 1 "exp" + OpMemberDecorate %__frexp_result_vec2 0 Offset 0 + OpMemberDecorate %__frexp_result_vec2 1 Offset 8 + %void = OpTypeVoid + %1 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %float_1_25 = OpConstant %float 1.25 + %float_3_75 = OpConstant %float 3.75 + %9 = OpConstantComposite %v2float %float_1_25 %float_3_75 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 +%__frexp_result_vec2 = OpTypeStruct %v2float %v2int + %main = OpFunction %void None %1 + %4 = OpLabel + %10 = OpExtInst %__frexp_result_vec2 %14 FrexpStruct %9 + %15 = OpCompositeExtract %v2float %10 0 + %16 = OpCompositeExtract %v2int %10 1 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/frexp/vector/runtime.wgsl.expected.wgsl b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.wgsl new file mode 100644 index 0000000000..2665db35a9 --- /dev/null +++ b/test/tint/builtins/frexp/vector/runtime.wgsl.expected.wgsl @@ -0,0 +1,7 @@ +@compute @workgroup_size(1) +fn main() { + let in = vec2(1.25, 3.75); + let res = frexp(in); + let fract : vec2 = res.fract; + let exp : vec2 = res.exp; +} diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl new file mode 100644 index 0000000000..c6e393adf7 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.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 frexp(vec<4, fa>) -> __frexp_result_vec<4, fa> +fn frexp_34bbfb() { + var res = frexp(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_34bbfb(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_34bbfb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_34bbfb(); +} diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..f0571de9e9 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_34bbfb(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..f0571de9e9 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_34bbfb(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.glsl new file mode 100644 index 0000000000..b05fb00df0 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +vec4 vertex_main() { + frexp_34bbfb(); + 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; + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +void fragment_main() { + frexp_34bbfb(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +void compute_main() { + frexp_34bbfb(); +} + +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/frexp/34bbfb.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.msl new file mode 100644 index 0000000000..1a5b65264c --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4{.fract=float4(0.5f), .exp=int4(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +kernel void compute_main() { + frexp_34bbfb(); + return; +} + diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.spvasm new file mode 100644 index 0000000000..146a713a22 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.spvasm @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 38 +; 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 %frexp_34bbfb "frexp_34bbfb" + OpName %__frexp_result_vec4 "__frexp_result_vec4" + OpMemberName %__frexp_result_vec4 0 "fract" + OpMemberName %__frexp_result_vec4 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec4 0 Offset 0 + OpMemberDecorate %__frexp_result_vec4 1 Offset 16 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 +%__frexp_result_vec4 = OpTypeStruct %v4float %v4int + %float_0_5 = OpConstant %float 0.5 + %17 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %19 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %20 = OpConstantComposite %__frexp_result_vec4 %17 %19 +%_ptr_Function___frexp_result_vec4 = OpTypePointer Function %__frexp_result_vec4 + %23 = OpConstantNull %__frexp_result_vec4 + %24 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_34bbfb = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec4 Function %23 + OpStore %res %20 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %24 + %26 = OpLabel + %27 = OpFunctionCall %void %frexp_34bbfb + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %30 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_34bbfb + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %36 = OpLabel + %37 = OpFunctionCall %void %frexp_34bbfb + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.wgsl new file mode 100644 index 0000000000..809d0bd89a --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/34bbfb.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn frexp_34bbfb() { + var res = frexp(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_34bbfb(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_34bbfb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_34bbfb(); +} diff --git a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.dxc.hlsl index 7c8df2fcaf..38aad8c756 100644 --- a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec4_f16 { vector fract; int4 exp; }; -frexp_result_vec4_f16 tint_frexp(vector param_0) { - vector exp; - vector fract = frexp(param_0, exp); - frexp_result_vec4_f16 result = {fract, int4(exp)}; - return result; -} - void frexp_3dd21e() { - frexp_result_vec4_f16 res = tint_frexp((float16_t(1.0h)).xxxx); + frexp_result_vec4_f16 res = {(float16_t(0.5h)).xxxx, (1).xxxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.glsl index a84c5d2431..273b5569e5 100644 --- a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.glsl @@ -6,15 +6,9 @@ struct frexp_result_vec4_f16 { ivec4 exp; }; -frexp_result_vec4_f16 tint_frexp(f16vec4 param_0) { - frexp_result_vec4_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_3dd21e() { - frexp_result_vec4_f16 res = tint_frexp(f16vec4(1.0hf)); + frexp_result_vec4_f16 res = frexp_result_vec4_f16(f16vec4(0.5hf), ivec4(1)); } vec4 vertex_main() { @@ -39,15 +33,9 @@ struct frexp_result_vec4_f16 { ivec4 exp; }; -frexp_result_vec4_f16 tint_frexp(f16vec4 param_0) { - frexp_result_vec4_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_3dd21e() { - frexp_result_vec4_f16 res = tint_frexp(f16vec4(1.0hf)); + frexp_result_vec4_f16 res = frexp_result_vec4_f16(f16vec4(0.5hf), ivec4(1)); } void fragment_main() { @@ -66,15 +54,9 @@ struct frexp_result_vec4_f16 { ivec4 exp; }; -frexp_result_vec4_f16 tint_frexp(f16vec4 param_0) { - frexp_result_vec4_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_3dd21e() { - frexp_result_vec4_f16 res = tint_frexp(f16vec4(1.0hf)); + frexp_result_vec4_f16 res = frexp_result_vec4_f16(f16vec4(0.5hf), ivec4(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.msl index 2ea4018ac1..c5b011cb1f 100644 --- a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec4_f16 { half4 fract; int4 exp; }; -frexp_result_vec4_f16 tint_frexp(half4 param_0) { - frexp_result_vec4_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_3dd21e() { - frexp_result_vec4_f16 res = tint_frexp(half4(1.0h)); + frexp_result_vec4_f16 res = frexp_result_vec4_f16{.fract=half4(0.5h), .exp=int4(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.spvasm index 7e70b1253a..1edb7a714f 100644 --- a/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/3dd21e.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 40 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %19 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -45,38 +44,40 @@ %int = OpTypeInt 32 1 %v4int = OpTypeVector %int 4 %__frexp_result_vec4_f16 = OpTypeStruct %v4half %v4int -%half_0x1p_0 = OpConstant %half 0x1p+0 - %21 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1pn1 = OpConstant %half 0x1p-1 + %19 = OpConstantComposite %v4half %half_0x1pn1 %half_0x1pn1 %half_0x1pn1 %half_0x1pn1 + %int_1 = OpConstant %int 1 + %21 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %22 = OpConstantComposite %__frexp_result_vec4_f16 %19 %21 %_ptr_Function___frexp_result_vec4_f16 = OpTypePointer Function %__frexp_result_vec4_f16 - %24 = OpConstantNull %__frexp_result_vec4_f16 - %25 = OpTypeFunction %v4float + %25 = OpConstantNull %__frexp_result_vec4_f16 + %26 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %frexp_3dd21e = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec4_f16 Function %24 - %13 = OpExtInst %__frexp_result_vec4_f16 %19 FrexpStruct %21 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec4_f16 Function %25 + OpStore %res %22 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %25 - %27 = OpLabel - %28 = OpFunctionCall %void %frexp_3dd21e +%vertex_main_inner = OpFunction %v4float None %26 + %28 = OpLabel + %29 = OpFunctionCall %void %frexp_3dd21e OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %31 + %31 = OpLabel + %32 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %32 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %frexp_3dd21e + %35 = OpLabel + %36 = OpFunctionCall %void %frexp_3dd21e OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %37 = OpLabel - %38 = OpFunctionCall %void %frexp_3dd21e + %38 = OpLabel + %39 = OpFunctionCall %void %frexp_3dd21e OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.dxc.hlsl index 8737fe5188..31de0eb3be 100644 --- a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = {0.5f, 1}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.fxc.hlsl index 8737fe5188..31de0eb3be 100644 --- a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.fxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - float exp; - float fract = frexp(param_0, exp); - frexp_result result = {fract, int(exp)}; - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = {0.5f, 1}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.glsl index 2e58875392..f5a158d46e 100644 --- a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.glsl @@ -5,15 +5,9 @@ struct frexp_result { int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = frexp_result(0.5f, 1); } vec4 vertex_main() { @@ -37,15 +31,9 @@ struct frexp_result { int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = frexp_result(0.5f, 1); } void fragment_main() { @@ -63,15 +51,9 @@ struct frexp_result { int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = frexp_result(0.5f, 1); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.msl index b979b5d97b..1fa65d3258 100644 --- a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result { float fract; int exp; }; -frexp_result tint_frexp(float param_0) { - frexp_result result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_4b2200() { - frexp_result res = tint_frexp(1.0f); + frexp_result res = frexp_result{.fract=0.5f, .exp=1}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.spvasm index e67480b890..2b4eb35176 100644 --- a/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/4b2200.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 35 ; Schema: 0 OpCapability Shader - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -38,15 +37,17 @@ %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %__frexp_result = OpTypeStruct %float %int - %float_1 = OpConstant %float 1 + %float_0_5 = OpConstant %float 0.5 + %int_1 = OpConstant %int 1 + %17 = OpConstantComposite %__frexp_result %float_0_5 %int_1 %_ptr_Function___frexp_result = OpTypePointer Function %__frexp_result %20 = OpConstantNull %__frexp_result %21 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %frexp_4b2200 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function___frexp_result Function %20 - %13 = OpExtInst %__frexp_result %16 FrexpStruct %float_1 - OpStore %res %13 + OpStore %res %17 OpReturn OpFunctionEnd %vertex_main_inner = OpFunction %v4float None %21 @@ -62,12 +63,12 @@ OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %frexp_4b2200 + %30 = OpLabel + %31 = OpFunctionCall %void %frexp_4b2200 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %frexp_4b2200 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_4b2200 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.dxc.hlsl index abe82bcd45..09b1676e72 100644 --- a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_f16 { float16_t fract; int exp; }; -frexp_result_f16 tint_frexp(float16_t param_0) { - float16_t exp; - float16_t fract = frexp(param_0, exp); - frexp_result_f16 result = {fract, int(exp)}; - return result; -} - void frexp_5257dd() { - frexp_result_f16 res = tint_frexp(float16_t(1.0h)); + frexp_result_f16 res = {float16_t(0.5h), 1}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.glsl index 226b7cc45e..eae6d647cd 100644 --- a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.glsl @@ -6,15 +6,9 @@ struct frexp_result_f16 { int exp; }; -frexp_result_f16 tint_frexp(float16_t param_0) { - frexp_result_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5257dd() { - frexp_result_f16 res = tint_frexp(1.0hf); + frexp_result_f16 res = frexp_result_f16(0.5hf, 1); } vec4 vertex_main() { @@ -39,15 +33,9 @@ struct frexp_result_f16 { int exp; }; -frexp_result_f16 tint_frexp(float16_t param_0) { - frexp_result_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5257dd() { - frexp_result_f16 res = tint_frexp(1.0hf); + frexp_result_f16 res = frexp_result_f16(0.5hf, 1); } void fragment_main() { @@ -66,15 +54,9 @@ struct frexp_result_f16 { int exp; }; -frexp_result_f16 tint_frexp(float16_t param_0) { - frexp_result_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5257dd() { - frexp_result_f16 res = tint_frexp(1.0hf); + frexp_result_f16 res = frexp_result_f16(0.5hf, 1); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.msl index 404e632dd5..06dbf4111a 100644 --- a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_f16 { half fract; int exp; }; -frexp_result_f16 tint_frexp(half param_0) { - frexp_result_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5257dd() { - frexp_result_f16 res = tint_frexp(1.0h); + frexp_result_f16 res = frexp_result_f16{.fract=0.5h, .exp=1}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.spvasm index c750b75710..3c9f0f48fe 100644 --- a/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/5257dd.wgsl.expected.spvasm @@ -8,7 +8,6 @@ OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %17 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -43,7 +42,9 @@ %half = OpTypeFloat 16 %int = OpTypeInt 32 1 %__frexp_result_f16 = OpTypeStruct %half %int -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1pn1 = OpConstant %half 0x1p-1 + %int_1 = OpConstant %int 1 + %18 = OpConstantComposite %__frexp_result_f16 %half_0x1pn1 %int_1 %_ptr_Function___frexp_result_f16 = OpTypePointer Function %__frexp_result_f16 %21 = OpConstantNull %__frexp_result_f16 %22 = OpTypeFunction %v4float @@ -51,8 +52,7 @@ %frexp_5257dd = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function___frexp_result_f16 Function %21 - %13 = OpExtInst %__frexp_result_f16 %17 FrexpStruct %half_0x1p_0 - OpStore %res %13 + OpStore %res %18 OpReturn OpFunctionEnd %vertex_main_inner = OpFunction %v4float None %22 diff --git a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.dxc.hlsl index 059e50c5d1..3244bf1191 100644 --- a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec2_f16 { vector fract; int2 exp; }; -frexp_result_vec2_f16 tint_frexp(vector param_0) { - vector exp; - vector fract = frexp(param_0, exp); - frexp_result_vec2_f16 result = {fract, int2(exp)}; - return result; -} - void frexp_5f47bf() { - frexp_result_vec2_f16 res = tint_frexp((float16_t(1.0h)).xx); + frexp_result_vec2_f16 res = {(float16_t(0.5h)).xx, (1).xx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.glsl index 4b44bc9629..6c074b6458 100644 --- a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.glsl @@ -6,15 +6,9 @@ struct frexp_result_vec2_f16 { ivec2 exp; }; -frexp_result_vec2_f16 tint_frexp(f16vec2 param_0) { - frexp_result_vec2_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5f47bf() { - frexp_result_vec2_f16 res = tint_frexp(f16vec2(1.0hf)); + frexp_result_vec2_f16 res = frexp_result_vec2_f16(f16vec2(0.5hf), ivec2(1)); } vec4 vertex_main() { @@ -39,15 +33,9 @@ struct frexp_result_vec2_f16 { ivec2 exp; }; -frexp_result_vec2_f16 tint_frexp(f16vec2 param_0) { - frexp_result_vec2_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5f47bf() { - frexp_result_vec2_f16 res = tint_frexp(f16vec2(1.0hf)); + frexp_result_vec2_f16 res = frexp_result_vec2_f16(f16vec2(0.5hf), ivec2(1)); } void fragment_main() { @@ -66,15 +54,9 @@ struct frexp_result_vec2_f16 { ivec2 exp; }; -frexp_result_vec2_f16 tint_frexp(f16vec2 param_0) { - frexp_result_vec2_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5f47bf() { - frexp_result_vec2_f16 res = tint_frexp(f16vec2(1.0hf)); + frexp_result_vec2_f16 res = frexp_result_vec2_f16(f16vec2(0.5hf), ivec2(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.msl index 942cd07e8c..de30665747 100644 --- a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec2_f16 { half2 fract; int2 exp; }; -frexp_result_vec2_f16 tint_frexp(half2 param_0) { - frexp_result_vec2_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_5f47bf() { - frexp_result_vec2_f16 res = tint_frexp(half2(1.0h)); + frexp_result_vec2_f16 res = frexp_result_vec2_f16{.fract=half2(0.5h), .exp=int2(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.spvasm index 6c21824625..b6ccbe0e41 100644 --- a/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/5f47bf.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 40 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %19 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -45,38 +44,40 @@ %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 %__frexp_result_vec2_f16 = OpTypeStruct %v2half %v2int -%half_0x1p_0 = OpConstant %half 0x1p+0 - %21 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1pn1 = OpConstant %half 0x1p-1 + %19 = OpConstantComposite %v2half %half_0x1pn1 %half_0x1pn1 + %int_1 = OpConstant %int 1 + %21 = OpConstantComposite %v2int %int_1 %int_1 + %22 = OpConstantComposite %__frexp_result_vec2_f16 %19 %21 %_ptr_Function___frexp_result_vec2_f16 = OpTypePointer Function %__frexp_result_vec2_f16 - %24 = OpConstantNull %__frexp_result_vec2_f16 - %25 = OpTypeFunction %v4float + %25 = OpConstantNull %__frexp_result_vec2_f16 + %26 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %frexp_5f47bf = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec2_f16 Function %24 - %13 = OpExtInst %__frexp_result_vec2_f16 %19 FrexpStruct %21 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec2_f16 Function %25 + OpStore %res %22 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %25 - %27 = OpLabel - %28 = OpFunctionCall %void %frexp_5f47bf +%vertex_main_inner = OpFunction %v4float None %26 + %28 = OpLabel + %29 = OpFunctionCall %void %frexp_5f47bf OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %31 + %31 = OpLabel + %32 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %32 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %frexp_5f47bf + %35 = OpLabel + %36 = OpFunctionCall %void %frexp_5f47bf OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %37 = OpLabel - %38 = OpFunctionCall %void %frexp_5f47bf + %38 = OpLabel + %39 = OpFunctionCall %void %frexp_5f47bf OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl new file mode 100644 index 0000000000..5b10ae9cd0 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.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 frexp(vec<2, fa>) -> __frexp_result_vec<2, fa> +fn frexp_6fb3ad() { + var res = frexp(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_6fb3ad(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_6fb3ad(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_6fb3ad(); +} diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cc4ff35f4e --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_6fb3ad(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cc4ff35f4e --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_6fb3ad(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.glsl new file mode 100644 index 0000000000..e5ecc96e34 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +vec4 vertex_main() { + frexp_6fb3ad(); + 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; + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +void fragment_main() { + frexp_6fb3ad(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +void compute_main() { + frexp_6fb3ad(); +} + +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/frexp/6fb3ad.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.msl new file mode 100644 index 0000000000..5356433678 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2{.fract=float2(0.5f), .exp=int2(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +kernel void compute_main() { + frexp_6fb3ad(); + return; +} + diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.spvasm new file mode 100644 index 0000000000..1d03915ce0 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.spvasm @@ -0,0 +1,78 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 39 +; 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 %frexp_6fb3ad "frexp_6fb3ad" + OpName %__frexp_result_vec2 "__frexp_result_vec2" + OpMemberName %__frexp_result_vec2 0 "fract" + OpMemberName %__frexp_result_vec2 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec2 0 Offset 0 + OpMemberDecorate %__frexp_result_vec2 1 Offset 8 + %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 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 +%__frexp_result_vec2 = OpTypeStruct %v2float %v2int + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v2int %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec2 %18 %20 +%_ptr_Function___frexp_result_vec2 = OpTypePointer Function %__frexp_result_vec2 + %24 = OpConstantNull %__frexp_result_vec2 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_6fb3ad = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec2 Function %24 + OpStore %res %21 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_6fb3ad + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_6fb3ad + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_6fb3ad + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.wgsl new file mode 100644 index 0000000000..472008bd2f --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/6fb3ad.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn frexp_6fb3ad() { + var res = frexp(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_6fb3ad(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_6fb3ad(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_6fb3ad(); +} diff --git a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.dxc.hlsl index edc72cbb7f..9305a1e516 100644 --- a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec4 { float4 fract; int4 exp; }; -frexp_result_vec4 tint_frexp(float4 param_0) { - float4 exp; - float4 fract = frexp(param_0, exp); - frexp_result_vec4 result = {fract, int4(exp)}; - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp((1.0f).xxxx); + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.fxc.hlsl index edc72cbb7f..9305a1e516 100644 --- a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.fxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec4 { float4 fract; int4 exp; }; -frexp_result_vec4 tint_frexp(float4 param_0) { - float4 exp; - float4 fract = frexp(param_0, exp); - frexp_result_vec4 result = {fract, int4(exp)}; - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp((1.0f).xxxx); + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.glsl index f346a3fd2f..5361fab131 100644 --- a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.glsl @@ -5,15 +5,9 @@ struct frexp_result_vec4 { ivec4 exp; }; -frexp_result_vec4 tint_frexp(vec4 param_0) { - frexp_result_vec4 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp(vec4(1.0f)); + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); } vec4 vertex_main() { @@ -37,15 +31,9 @@ struct frexp_result_vec4 { ivec4 exp; }; -frexp_result_vec4 tint_frexp(vec4 param_0) { - frexp_result_vec4 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp(vec4(1.0f)); + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); } void fragment_main() { @@ -63,15 +51,9 @@ struct frexp_result_vec4 { ivec4 exp; }; -frexp_result_vec4 tint_frexp(vec4 param_0) { - frexp_result_vec4 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp(vec4(1.0f)); + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.msl index ebe3fb6b4b..448b11867e 100644 --- a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec4 { float4 fract; int4 exp; }; -frexp_result_vec4 tint_frexp(float4 param_0) { - frexp_result_vec4 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_77af93() { - frexp_result_vec4 res = tint_frexp(float4(1.0f)); + frexp_result_vec4 res = frexp_result_vec4{.fract=float4(0.5f), .exp=int4(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.spvasm index 5c18e0211a..5ee24673da 100644 --- a/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/77af93.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 38 ; Schema: 0 OpCapability Shader - %17 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -39,37 +38,40 @@ %int = OpTypeInt 32 1 %v4int = OpTypeVector %int 4 %__frexp_result_vec4 = OpTypeStruct %v4float %v4int - %float_1 = OpConstant %float 1 - %19 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %float_0_5 = OpConstant %float 0.5 + %17 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %19 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %20 = OpConstantComposite %__frexp_result_vec4 %17 %19 %_ptr_Function___frexp_result_vec4 = OpTypePointer Function %__frexp_result_vec4 - %22 = OpConstantNull %__frexp_result_vec4 - %23 = OpTypeFunction %v4float + %23 = OpConstantNull %__frexp_result_vec4 + %24 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %frexp_77af93 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec4 Function %22 - %13 = OpExtInst %__frexp_result_vec4 %17 FrexpStruct %19 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec4 Function %23 + OpStore %res %20 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %23 - %25 = OpLabel - %26 = OpFunctionCall %void %frexp_77af93 +%vertex_main_inner = OpFunction %v4float None %24 + %26 = OpLabel + %27 = OpFunctionCall %void %frexp_77af93 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %29 + %29 = OpLabel + %30 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %30 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %frexp_77af93 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_77af93 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %frexp_77af93 + %36 = OpLabel + %37 = OpFunctionCall %void %frexp_77af93 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.dxc.hlsl index 5638db7b5a..3952e5e157 100644 --- a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec3 { float3 fract; int3 exp; }; -frexp_result_vec3 tint_frexp(float3 param_0) { - float3 exp; - float3 fract = frexp(param_0, exp); - frexp_result_vec3 result = {fract, int3(exp)}; - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp((1.0f).xxx); + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.fxc.hlsl index 5638db7b5a..3952e5e157 100644 --- a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.fxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec3 { float3 fract; int3 exp; }; -frexp_result_vec3 tint_frexp(float3 param_0) { - float3 exp; - float3 fract = frexp(param_0, exp); - frexp_result_vec3 result = {fract, int3(exp)}; - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp((1.0f).xxx); + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.glsl index 815df55c59..0e99f61b76 100644 --- a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.glsl @@ -5,15 +5,9 @@ struct frexp_result_vec3 { ivec3 exp; }; -frexp_result_vec3 tint_frexp(vec3 param_0) { - frexp_result_vec3 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp(vec3(1.0f)); + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); } vec4 vertex_main() { @@ -37,15 +31,9 @@ struct frexp_result_vec3 { ivec3 exp; }; -frexp_result_vec3 tint_frexp(vec3 param_0) { - frexp_result_vec3 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp(vec3(1.0f)); + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); } void fragment_main() { @@ -63,15 +51,9 @@ struct frexp_result_vec3 { ivec3 exp; }; -frexp_result_vec3 tint_frexp(vec3 param_0) { - frexp_result_vec3 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp(vec3(1.0f)); + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.msl index dfd3a1c323..5dbe0f6a84 100644 --- a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec3 { float3 fract; int3 exp; }; -frexp_result_vec3 tint_frexp(float3 param_0) { - frexp_result_vec3 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_979800() { - frexp_result_vec3 res = tint_frexp(float3(1.0f)); + frexp_result_vec3 res = frexp_result_vec3{.fract=float3(0.5f), .exp=int3(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.spvasm index 78eb763a4d..82afd21806 100644 --- a/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/979800.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 37 +; Bound: 39 ; Schema: 0 OpCapability Shader - %18 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -40,37 +39,40 @@ %int = OpTypeInt 32 1 %v3int = OpTypeVector %int 3 %__frexp_result_vec3 = OpTypeStruct %v3float %v3int - %float_1 = OpConstant %float 1 - %20 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec3 %18 %20 %_ptr_Function___frexp_result_vec3 = OpTypePointer Function %__frexp_result_vec3 - %23 = OpConstantNull %__frexp_result_vec3 - %24 = OpTypeFunction %v4float + %24 = OpConstantNull %__frexp_result_vec3 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %frexp_979800 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec3 Function %23 - %13 = OpExtInst %__frexp_result_vec3 %18 FrexpStruct %20 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec3 Function %24 + OpStore %res %21 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %24 - %26 = OpLabel - %27 = OpFunctionCall %void %frexp_979800 +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_979800 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %30 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %frexp_979800 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_979800 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %35 = OpLabel - %36 = OpFunctionCall %void %frexp_979800 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_979800 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.dxc.hlsl index 1ae9ade94e..e64f0fea5b 100644 --- a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec3_f16 { vector fract; int3 exp; }; -frexp_result_vec3_f16 tint_frexp(vector param_0) { - vector exp; - vector fract = frexp(param_0, exp); - frexp_result_vec3_f16 result = {fract, int3(exp)}; - return result; -} - void frexp_ae4a66() { - frexp_result_vec3_f16 res = tint_frexp((float16_t(1.0h)).xxx); + frexp_result_vec3_f16 res = {(float16_t(0.5h)).xxx, (1).xxx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.glsl index d5d3e9b83e..fecb412736 100644 --- a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.glsl @@ -6,15 +6,9 @@ struct frexp_result_vec3_f16 { ivec3 exp; }; -frexp_result_vec3_f16 tint_frexp(f16vec3 param_0) { - frexp_result_vec3_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_ae4a66() { - frexp_result_vec3_f16 res = tint_frexp(f16vec3(1.0hf)); + frexp_result_vec3_f16 res = frexp_result_vec3_f16(f16vec3(0.5hf), ivec3(1)); } vec4 vertex_main() { @@ -39,15 +33,9 @@ struct frexp_result_vec3_f16 { ivec3 exp; }; -frexp_result_vec3_f16 tint_frexp(f16vec3 param_0) { - frexp_result_vec3_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_ae4a66() { - frexp_result_vec3_f16 res = tint_frexp(f16vec3(1.0hf)); + frexp_result_vec3_f16 res = frexp_result_vec3_f16(f16vec3(0.5hf), ivec3(1)); } void fragment_main() { @@ -66,15 +54,9 @@ struct frexp_result_vec3_f16 { ivec3 exp; }; -frexp_result_vec3_f16 tint_frexp(f16vec3 param_0) { - frexp_result_vec3_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_ae4a66() { - frexp_result_vec3_f16 res = tint_frexp(f16vec3(1.0hf)); + frexp_result_vec3_f16 res = frexp_result_vec3_f16(f16vec3(0.5hf), ivec3(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.msl index 140dcd8cb5..16c1374ef9 100644 --- a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec3_f16 { half3 fract; int3 exp; }; -frexp_result_vec3_f16 tint_frexp(half3 param_0) { - frexp_result_vec3_f16 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_ae4a66() { - frexp_result_vec3_f16 res = tint_frexp(half3(1.0h)); + frexp_result_vec3_f16 res = frexp_result_vec3_f16{.fract=half3(0.5h), .exp=int3(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.spvasm index f483930968..af26946a8f 100644 --- a/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/ae4a66.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 39 +; Bound: 40 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %19 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -45,38 +44,40 @@ %int = OpTypeInt 32 1 %v3int = OpTypeVector %int 3 %__frexp_result_vec3_f16 = OpTypeStruct %v3half %v3int -%half_0x1p_0 = OpConstant %half 0x1p+0 - %21 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1pn1 = OpConstant %half 0x1p-1 + %19 = OpConstantComposite %v3half %half_0x1pn1 %half_0x1pn1 %half_0x1pn1 + %int_1 = OpConstant %int 1 + %21 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %22 = OpConstantComposite %__frexp_result_vec3_f16 %19 %21 %_ptr_Function___frexp_result_vec3_f16 = OpTypePointer Function %__frexp_result_vec3_f16 - %24 = OpConstantNull %__frexp_result_vec3_f16 - %25 = OpTypeFunction %v4float + %25 = OpConstantNull %__frexp_result_vec3_f16 + %26 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %frexp_ae4a66 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec3_f16 Function %24 - %13 = OpExtInst %__frexp_result_vec3_f16 %19 FrexpStruct %21 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec3_f16 Function %25 + OpStore %res %22 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %25 - %27 = OpLabel - %28 = OpFunctionCall %void %frexp_ae4a66 +%vertex_main_inner = OpFunction %v4float None %26 + %28 = OpLabel + %29 = OpFunctionCall %void %frexp_ae4a66 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %31 + %31 = OpLabel + %32 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %32 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %frexp_ae4a66 + %35 = OpLabel + %36 = OpFunctionCall %void %frexp_ae4a66 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %37 = OpLabel - %38 = OpFunctionCall %void %frexp_ae4a66 + %38 = OpLabel + %39 = OpFunctionCall %void %frexp_ae4a66 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl new file mode 100644 index 0000000000..62bdbc6553 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.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 frexp(fa) -> __frexp_result +fn frexp_bee870() { + var res = frexp(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bee870(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bee870(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bee870(); +} diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..efbe069e1a --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = {0.5f, 1}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bee870(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..efbe069e1a --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = {0.5f, 1}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bee870(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.glsl new file mode 100644 index 0000000000..0e94ee2321 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +vec4 vertex_main() { + frexp_bee870(); + 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; + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +void fragment_main() { + frexp_bee870(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +void compute_main() { + frexp_bee870(); +} + +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/frexp/bee870.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.msl new file mode 100644 index 0000000000..8c2107d088 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = frexp_result{.fract=0.5f, .exp=1}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +kernel void compute_main() { + frexp_bee870(); + return; +} + diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.spvasm new file mode 100644 index 0000000000..b2675a6b78 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.spvasm @@ -0,0 +1,74 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 35 +; 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 %frexp_bee870 "frexp_bee870" + OpName %__frexp_result "__frexp_result" + OpMemberName %__frexp_result 0 "fract" + OpMemberName %__frexp_result 1 "exp" + 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 + OpMemberDecorate %__frexp_result 0 Offset 0 + OpMemberDecorate %__frexp_result 1 Offset 4 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%__frexp_result = OpTypeStruct %float %int + %float_0_5 = OpConstant %float 0.5 + %int_1 = OpConstant %int 1 + %17 = OpConstantComposite %__frexp_result %float_0_5 %int_1 +%_ptr_Function___frexp_result = OpTypePointer Function %__frexp_result + %20 = OpConstantNull %__frexp_result + %21 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_bee870 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result Function %20 + OpStore %res %17 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %21 + %23 = OpLabel + %24 = OpFunctionCall %void %frexp_bee870 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %27 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %frexp_bee870 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_bee870 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.wgsl new file mode 100644 index 0000000000..b3e97d48a1 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bee870.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn frexp_bee870() { + var res = frexp(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bee870(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bee870(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bee870(); +} diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl new file mode 100644 index 0000000000..87876d682d --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.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 frexp(vec<3, fa>) -> __frexp_result_vec<3, fa> +fn frexp_bf45ae() { + var res = frexp(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bf45ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bf45ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bf45ae(); +} diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..c896f2bd82 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bf45ae(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..c896f2bd82 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bf45ae(); + return; +} diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.glsl new file mode 100644 index 0000000000..f7f382e426 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +vec4 vertex_main() { + frexp_bf45ae(); + 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; + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +void fragment_main() { + frexp_bf45ae(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +void compute_main() { + frexp_bf45ae(); +} + +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/frexp/bf45ae.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.msl new file mode 100644 index 0000000000..6bbab1134a --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3{.fract=float3(0.5f), .exp=int3(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +kernel void compute_main() { + frexp_bf45ae(); + return; +} + diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.spvasm new file mode 100644 index 0000000000..28459bc1c2 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.spvasm @@ -0,0 +1,78 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 39 +; 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 %frexp_bf45ae "frexp_bf45ae" + OpName %__frexp_result_vec3 "__frexp_result_vec3" + OpMemberName %__frexp_result_vec3 0 "fract" + OpMemberName %__frexp_result_vec3 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec3 0 Offset 0 + OpMemberDecorate %__frexp_result_vec3 1 Offset 16 + %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 + %int = OpTypeInt 32 1 + %v3int = OpTypeVector %int 3 +%__frexp_result_vec3 = OpTypeStruct %v3float %v3int + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec3 %18 %20 +%_ptr_Function___frexp_result_vec3 = OpTypePointer Function %__frexp_result_vec3 + %24 = OpConstantNull %__frexp_result_vec3 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_bf45ae = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec3 Function %24 + OpStore %res %21 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_bf45ae + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_bf45ae + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_bf45ae + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.wgsl new file mode 100644 index 0000000000..9cfa8bd1a2 --- /dev/null +++ b/test/tint/builtins/gen/literal/frexp/bf45ae.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn frexp_bf45ae() { + var res = frexp(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bf45ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bf45ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bf45ae(); +} diff --git a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.dxc.hlsl index 3e7f4736a0..f0e207cb02 100644 --- a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.dxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec2 { float2 fract; int2 exp; }; -frexp_result_vec2 tint_frexp(float2 param_0) { - float2 exp; - float2 fract = frexp(param_0, exp); - frexp_result_vec2 result = {fract, int2(exp)}; - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp((1.0f).xx); + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.fxc.hlsl index 3e7f4736a0..f0e207cb02 100644 --- a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.fxc.hlsl @@ -2,15 +2,8 @@ struct frexp_result_vec2 { float2 fract; int2 exp; }; -frexp_result_vec2 tint_frexp(float2 param_0) { - float2 exp; - float2 fract = frexp(param_0, exp); - frexp_result_vec2 result = {fract, int2(exp)}; - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp((1.0f).xx); + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.glsl b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.glsl index 67638a713b..0495b8a656 100644 --- a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.glsl @@ -5,15 +5,9 @@ struct frexp_result_vec2 { ivec2 exp; }; -frexp_result_vec2 tint_frexp(vec2 param_0) { - frexp_result_vec2 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp(vec2(1.0f)); + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); } vec4 vertex_main() { @@ -37,15 +31,9 @@ struct frexp_result_vec2 { ivec2 exp; }; -frexp_result_vec2 tint_frexp(vec2 param_0) { - frexp_result_vec2 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp(vec2(1.0f)); + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); } void fragment_main() { @@ -63,15 +51,9 @@ struct frexp_result_vec2 { ivec2 exp; }; -frexp_result_vec2 tint_frexp(vec2 param_0) { - frexp_result_vec2 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp(vec2(1.0f)); + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.msl b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.msl index 47f93350f7..d920b46fd6 100644 --- a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.msl @@ -6,14 +6,8 @@ struct frexp_result_vec2 { float2 fract; int2 exp; }; -frexp_result_vec2 tint_frexp(float2 param_0) { - frexp_result_vec2 result; - result.fract = frexp(param_0, result.exp); - return result; -} - void frexp_eb2421() { - frexp_result_vec2 res = tint_frexp(float2(1.0f)); + frexp_result_vec2 res = frexp_result_vec2{.fract=float2(0.5f), .exp=int2(1)}; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.spvasm index 812b9e1acc..29a867929d 100644 --- a/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/frexp/eb2421.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 37 +; Bound: 39 ; Schema: 0 OpCapability Shader - %18 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -40,37 +39,40 @@ %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 %__frexp_result_vec2 = OpTypeStruct %v2float %v2int - %float_1 = OpConstant %float 1 - %20 = OpConstantComposite %v2float %float_1 %float_1 + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v2int %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec2 %18 %20 %_ptr_Function___frexp_result_vec2 = OpTypePointer Function %__frexp_result_vec2 - %23 = OpConstantNull %__frexp_result_vec2 - %24 = OpTypeFunction %v4float + %24 = OpConstantNull %__frexp_result_vec2 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %frexp_eb2421 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function___frexp_result_vec2 Function %23 - %13 = OpExtInst %__frexp_result_vec2 %18 FrexpStruct %20 - OpStore %res %13 + %res = OpVariable %_ptr_Function___frexp_result_vec2 Function %24 + OpStore %res %21 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %24 - %26 = OpLabel - %27 = OpFunctionCall %void %frexp_eb2421 +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_eb2421 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %30 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %frexp_eb2421 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_eb2421 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %35 = OpLabel - %36 = OpFunctionCall %void %frexp_eb2421 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_eb2421 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a09bda3527 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = {(-0.5f).xxx, (-1.0f).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_68d8ee(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a09bda3527 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = {(-0.5f).xxx, (-1.0f).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_68d8ee(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.glsl b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.glsl new file mode 100644 index 0000000000..24140f3c3c --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +vec4 vertex_main() { + modf_68d8ee(); + 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; + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +void fragment_main() { + modf_68d8ee(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +void compute_main() { + modf_68d8ee(); +} + +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/modf/68d8ee.wgsl.expected.msl b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.msl new file mode 100644 index 0000000000..d24f9fdfbc --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3{.fract=float3(-0.5f), .whole=float3(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +kernel void compute_main() { + modf_68d8ee(); + return; +} + diff --git a/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.spvasm new file mode 100644 index 0000000000..e08886d658 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.spvasm @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 37 +; 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 %modf_68d8ee "modf_68d8ee" + OpName %__modf_result_vec3 "__modf_result_vec3" + OpMemberName %__modf_result_vec3 0 "fract" + OpMemberName %__modf_result_vec3 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec3 0 Offset 0 + OpMemberDecorate %__modf_result_vec3 1 Offset 16 + %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 +%__modf_result_vec3 = OpTypeStruct %v3float %v3float + %float_n0_5 = OpConstant %float -0.5 + %16 = OpConstantComposite %v3float %float_n0_5 %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %18 = OpConstantComposite %v3float %float_n1 %float_n1 %float_n1 + %19 = OpConstantComposite %__modf_result_vec3 %16 %18 +%_ptr_Function___modf_result_vec3 = OpTypePointer Function %__modf_result_vec3 + %22 = OpConstantNull %__modf_result_vec3 + %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_68d8ee = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec3 Function %22 + OpStore %res %19 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %23 + %25 = OpLabel + %26 = OpFunctionCall %void %modf_68d8ee + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %29 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_68d8ee + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %35 = OpLabel + %36 = OpFunctionCall %void %modf_68d8ee + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.wgsl new file mode 100644 index 0000000000..0c6f535c20 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/68d8ee.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn modf_68d8ee() { + var res = modf(vec3(-(1.5))); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_68d8ee(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_68d8ee(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_68d8ee(); +} diff --git a/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..348870d617 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = {(-0.5f).xx, (-1.0f).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_732aa6(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..348870d617 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = {(-0.5f).xx, (-1.0f).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_732aa6(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.glsl new file mode 100644 index 0000000000..0695a32cf2 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +vec4 vertex_main() { + modf_732aa6(); + 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; + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +void fragment_main() { + modf_732aa6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +void compute_main() { + modf_732aa6(); +} + +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/modf/732aa6.wgsl.expected.msl b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.msl new file mode 100644 index 0000000000..dcb1f40e5c --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2{.fract=float2(-0.5f), .whole=float2(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +kernel void compute_main() { + modf_732aa6(); + return; +} + diff --git a/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.spvasm new file mode 100644 index 0000000000..28a7da48fb --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.spvasm @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 37 +; 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 %modf_732aa6 "modf_732aa6" + OpName %__modf_result_vec2 "__modf_result_vec2" + OpMemberName %__modf_result_vec2 0 "fract" + OpMemberName %__modf_result_vec2 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec2 0 Offset 0 + OpMemberDecorate %__modf_result_vec2 1 Offset 8 + %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 +%__modf_result_vec2 = OpTypeStruct %v2float %v2float + %float_n0_5 = OpConstant %float -0.5 + %16 = OpConstantComposite %v2float %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %18 = OpConstantComposite %v2float %float_n1 %float_n1 + %19 = OpConstantComposite %__modf_result_vec2 %16 %18 +%_ptr_Function___modf_result_vec2 = OpTypePointer Function %__modf_result_vec2 + %22 = OpConstantNull %__modf_result_vec2 + %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_732aa6 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec2 Function %22 + OpStore %res %19 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %23 + %25 = OpLabel + %26 = OpFunctionCall %void %modf_732aa6 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %29 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_732aa6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %35 = OpLabel + %36 = OpFunctionCall %void %modf_732aa6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.wgsl new file mode 100644 index 0000000000..a3fd30eb73 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/732aa6.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn modf_732aa6() { + var res = modf(vec2(-(1.5))); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_732aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_732aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_732aa6(); +} diff --git a/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..15c5b1148f --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = {-0.5f, -1.0f}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_c15f48(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..15c5b1148f --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = {-0.5f, -1.0f}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_c15f48(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.glsl b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.glsl new file mode 100644 index 0000000000..3c6410fc87 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +vec4 vertex_main() { + modf_c15f48(); + 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; + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +void fragment_main() { + modf_c15f48(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +void compute_main() { + modf_c15f48(); +} + +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/modf/c15f48.wgsl.expected.msl b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.msl new file mode 100644 index 0000000000..676ddc126e --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = modf_result{.fract=-0.5f, .whole=-1.0f}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +kernel void compute_main() { + modf_c15f48(); + return; +} + diff --git a/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.spvasm new file mode 100644 index 0000000000..c18f9c6824 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.spvasm @@ -0,0 +1,73 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 34 +; 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 %modf_c15f48 "modf_c15f48" + OpName %__modf_result "__modf_result" + OpMemberName %__modf_result 0 "fract" + OpMemberName %__modf_result 1 "whole" + 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 + OpMemberDecorate %__modf_result 0 Offset 0 + OpMemberDecorate %__modf_result 1 Offset 4 + %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 +%__modf_result = OpTypeStruct %float %float + %float_n0_5 = OpConstant %float -0.5 + %float_n1 = OpConstant %float -1 + %16 = OpConstantComposite %__modf_result %float_n0_5 %float_n1 +%_ptr_Function___modf_result = OpTypePointer Function %__modf_result + %19 = OpConstantNull %__modf_result + %20 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_c15f48 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result Function %19 + OpStore %res %16 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %modf_c15f48 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %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 + %29 = OpLabel + %30 = OpFunctionCall %void %modf_c15f48 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_c15f48 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.wgsl new file mode 100644 index 0000000000..3efab9a88a --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/c15f48.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn modf_c15f48() { + var res = modf(-(1.5)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_c15f48(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_c15f48(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_c15f48(); +} diff --git a/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..e72d03c511 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = {(-0.5f).xxxx, (-1.0f).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_f3d1f9(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..e72d03c511 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = {(-0.5f).xxxx, (-1.0f).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_f3d1f9(); + return; +} diff --git a/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.glsl new file mode 100644 index 0000000000..3f2277d6f1 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +vec4 vertex_main() { + modf_f3d1f9(); + 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; + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +void fragment_main() { + modf_f3d1f9(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +void compute_main() { + modf_f3d1f9(); +} + +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/modf/f3d1f9.wgsl.expected.msl b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.msl new file mode 100644 index 0000000000..087677aedf --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4{.fract=float4(-0.5f), .whole=float4(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +kernel void compute_main() { + modf_f3d1f9(); + return; +} + diff --git a/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.spvasm new file mode 100644 index 0000000000..629b8a5454 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.spvasm @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 36 +; 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 %modf_f3d1f9 "modf_f3d1f9" + OpName %__modf_result_vec4 "__modf_result_vec4" + OpMemberName %__modf_result_vec4 0 "fract" + OpMemberName %__modf_result_vec4 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec4 0 Offset 0 + OpMemberDecorate %__modf_result_vec4 1 Offset 16 + %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 +%__modf_result_vec4 = OpTypeStruct %v4float %v4float + %float_n0_5 = OpConstant %float -0.5 + %15 = OpConstantComposite %v4float %float_n0_5 %float_n0_5 %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %17 = OpConstantComposite %v4float %float_n1 %float_n1 %float_n1 %float_n1 + %18 = OpConstantComposite %__modf_result_vec4 %15 %17 +%_ptr_Function___modf_result_vec4 = OpTypePointer Function %__modf_result_vec4 + %21 = OpConstantNull %__modf_result_vec4 + %22 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_f3d1f9 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec4 Function %21 + OpStore %res %18 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %22 + %24 = OpLabel + %25 = OpFunctionCall %void %modf_f3d1f9 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %28 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %modf_f3d1f9 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %modf_f3d1f9 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.wgsl new file mode 100644 index 0000000000..1bc789e168 --- /dev/null +++ b/test/tint/builtins/gen/literal/modf/f3d1f9.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn modf_f3d1f9() { + var res = modf(vec4(-(1.5))); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_f3d1f9(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_f3d1f9(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_f3d1f9(); +} diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl new file mode 100644 index 0000000000..5a57803e18 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl @@ -0,0 +1,44 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn frexp(vec<4, fa>) -> __frexp_result_vec<4, fa> +fn frexp_34bbfb() { + const arg_0 = vec4(1.); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_34bbfb(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_34bbfb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_34bbfb(); +} diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..f0571de9e9 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_34bbfb(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..f0571de9e9 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = {(0.5f).xxxx, (1).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_34bbfb(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.glsl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.glsl new file mode 100644 index 0000000000..b05fb00df0 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +vec4 vertex_main() { + frexp_34bbfb(); + 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; + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +void fragment_main() { + frexp_34bbfb(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec4 { + vec4 fract; + ivec4 exp; +}; + + +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4(vec4(0.5f), ivec4(1)); +} + +void compute_main() { + frexp_34bbfb(); +} + +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/frexp/34bbfb.wgsl.expected.msl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.msl new file mode 100644 index 0000000000..1a5b65264c --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec4 { + float4 fract; + int4 exp; +}; +void frexp_34bbfb() { + frexp_result_vec4 res = frexp_result_vec4{.fract=float4(0.5f), .exp=int4(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_34bbfb(); + 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() { + frexp_34bbfb(); + return; +} + +kernel void compute_main() { + frexp_34bbfb(); + return; +} + diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.spvasm b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.spvasm new file mode 100644 index 0000000000..146a713a22 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.spvasm @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 38 +; 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 %frexp_34bbfb "frexp_34bbfb" + OpName %__frexp_result_vec4 "__frexp_result_vec4" + OpMemberName %__frexp_result_vec4 0 "fract" + OpMemberName %__frexp_result_vec4 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec4 0 Offset 0 + OpMemberDecorate %__frexp_result_vec4 1 Offset 16 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %v4int = OpTypeVector %int 4 +%__frexp_result_vec4 = OpTypeStruct %v4float %v4int + %float_0_5 = OpConstant %float 0.5 + %17 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %19 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %20 = OpConstantComposite %__frexp_result_vec4 %17 %19 +%_ptr_Function___frexp_result_vec4 = OpTypePointer Function %__frexp_result_vec4 + %23 = OpConstantNull %__frexp_result_vec4 + %24 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_34bbfb = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec4 Function %23 + OpStore %res %20 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %24 + %26 = OpLabel + %27 = OpFunctionCall %void %frexp_34bbfb + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %30 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_34bbfb + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %36 = OpLabel + %37 = OpFunctionCall %void %frexp_34bbfb + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.wgsl b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.wgsl new file mode 100644 index 0000000000..cb64b2b691 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/34bbfb.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn frexp_34bbfb() { + const arg_0 = vec4(1.0); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_34bbfb(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_34bbfb(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_34bbfb(); +} diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl new file mode 100644 index 0000000000..a7805698c3 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl @@ -0,0 +1,44 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn frexp(vec<2, fa>) -> __frexp_result_vec<2, fa> +fn frexp_6fb3ad() { + const arg_0 = vec2(1.); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_6fb3ad(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_6fb3ad(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_6fb3ad(); +} diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cc4ff35f4e --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_6fb3ad(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cc4ff35f4e --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = {(0.5f).xx, (1).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_6fb3ad(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.glsl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.glsl new file mode 100644 index 0000000000..e5ecc96e34 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +vec4 vertex_main() { + frexp_6fb3ad(); + 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; + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +void fragment_main() { + frexp_6fb3ad(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec2 { + vec2 fract; + ivec2 exp; +}; + + +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2(vec2(0.5f), ivec2(1)); +} + +void compute_main() { + frexp_6fb3ad(); +} + +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/frexp/6fb3ad.wgsl.expected.msl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.msl new file mode 100644 index 0000000000..5356433678 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec2 { + float2 fract; + int2 exp; +}; +void frexp_6fb3ad() { + frexp_result_vec2 res = frexp_result_vec2{.fract=float2(0.5f), .exp=int2(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_6fb3ad(); + 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() { + frexp_6fb3ad(); + return; +} + +kernel void compute_main() { + frexp_6fb3ad(); + return; +} + diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.spvasm b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.spvasm new file mode 100644 index 0000000000..1d03915ce0 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.spvasm @@ -0,0 +1,78 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 39 +; 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 %frexp_6fb3ad "frexp_6fb3ad" + OpName %__frexp_result_vec2 "__frexp_result_vec2" + OpMemberName %__frexp_result_vec2 0 "fract" + OpMemberName %__frexp_result_vec2 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec2 0 Offset 0 + OpMemberDecorate %__frexp_result_vec2 1 Offset 8 + %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 + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 +%__frexp_result_vec2 = OpTypeStruct %v2float %v2int + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v2int %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec2 %18 %20 +%_ptr_Function___frexp_result_vec2 = OpTypePointer Function %__frexp_result_vec2 + %24 = OpConstantNull %__frexp_result_vec2 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_6fb3ad = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec2 Function %24 + OpStore %res %21 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_6fb3ad + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_6fb3ad + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_6fb3ad + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.wgsl b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.wgsl new file mode 100644 index 0000000000..208d085793 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/6fb3ad.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn frexp_6fb3ad() { + const arg_0 = vec2(1.0); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_6fb3ad(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_6fb3ad(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_6fb3ad(); +} diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl b/test/tint/builtins/gen/var/frexp/bee870.wgsl new file mode 100644 index 0000000000..9d01b83ee8 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl @@ -0,0 +1,44 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn frexp(fa) -> __frexp_result +fn frexp_bee870() { + const arg_0 = 1.; + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bee870(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bee870(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bee870(); +} diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..efbe069e1a --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = {0.5f, 1}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bee870(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..efbe069e1a --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = {0.5f, 1}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bee870(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.glsl b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.glsl new file mode 100644 index 0000000000..0e94ee2321 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +vec4 vertex_main() { + frexp_bee870(); + 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; + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +void fragment_main() { + frexp_bee870(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result { + float fract; + int exp; +}; + + +void frexp_bee870() { + frexp_result res = frexp_result(0.5f, 1); +} + +void compute_main() { + frexp_bee870(); +} + +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/frexp/bee870.wgsl.expected.msl b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.msl new file mode 100644 index 0000000000..8c2107d088 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result { + float fract; + int exp; +}; +void frexp_bee870() { + frexp_result res = frexp_result{.fract=0.5f, .exp=1}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_bee870(); + 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() { + frexp_bee870(); + return; +} + +kernel void compute_main() { + frexp_bee870(); + return; +} + diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.spvasm b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.spvasm new file mode 100644 index 0000000000..b2675a6b78 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.spvasm @@ -0,0 +1,74 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 35 +; 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 %frexp_bee870 "frexp_bee870" + OpName %__frexp_result "__frexp_result" + OpMemberName %__frexp_result 0 "fract" + OpMemberName %__frexp_result 1 "exp" + 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 + OpMemberDecorate %__frexp_result 0 Offset 0 + OpMemberDecorate %__frexp_result 1 Offset 4 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%__frexp_result = OpTypeStruct %float %int + %float_0_5 = OpConstant %float 0.5 + %int_1 = OpConstant %int 1 + %17 = OpConstantComposite %__frexp_result %float_0_5 %int_1 +%_ptr_Function___frexp_result = OpTypePointer Function %__frexp_result + %20 = OpConstantNull %__frexp_result + %21 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_bee870 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result Function %20 + OpStore %res %17 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %21 + %23 = OpLabel + %24 = OpFunctionCall %void %frexp_bee870 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %27 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %frexp_bee870 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %33 = OpLabel + %34 = OpFunctionCall %void %frexp_bee870 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.wgsl b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.wgsl new file mode 100644 index 0000000000..79bda2b898 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bee870.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn frexp_bee870() { + const arg_0 = 1.0; + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bee870(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bee870(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bee870(); +} diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl new file mode 100644 index 0000000000..c7477ac3af --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl @@ -0,0 +1,44 @@ +// Copyright 2022 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////////////////////////////////////////////// +// File generated by tools/src/cmd/gen +// using the template: +// test/tint/builtins/gen/gen.wgsl.tmpl +// +// Do not modify this file directly +//////////////////////////////////////////////////////////////////////////////// + + +// fn frexp(vec<3, fa>) -> __frexp_result_vec<3, fa> +fn frexp_bf45ae() { + const arg_0 = vec3(1.); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bf45ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bf45ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bf45ae(); +} diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..c896f2bd82 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bf45ae(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..c896f2bd82 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = {(0.5f).xxx, (1).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + frexp_bf45ae(); + return; +} diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.glsl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.glsl new file mode 100644 index 0000000000..f7f382e426 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +vec4 vertex_main() { + frexp_bf45ae(); + 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; + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +void fragment_main() { + frexp_bf45ae(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct frexp_result_vec3 { + vec3 fract; + ivec3 exp; +}; + + +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3(vec3(0.5f), ivec3(1)); +} + +void compute_main() { + frexp_bf45ae(); +} + +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/frexp/bf45ae.wgsl.expected.msl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.msl new file mode 100644 index 0000000000..6bbab1134a --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct frexp_result_vec3 { + float3 fract; + int3 exp; +}; +void frexp_bf45ae() { + frexp_result_vec3 res = frexp_result_vec3{.fract=float3(0.5f), .exp=int3(1)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + frexp_bf45ae(); + 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() { + frexp_bf45ae(); + return; +} + +kernel void compute_main() { + frexp_bf45ae(); + return; +} + diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.spvasm b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.spvasm new file mode 100644 index 0000000000..28459bc1c2 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.spvasm @@ -0,0 +1,78 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 39 +; 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 %frexp_bf45ae "frexp_bf45ae" + OpName %__frexp_result_vec3 "__frexp_result_vec3" + OpMemberName %__frexp_result_vec3 0 "fract" + OpMemberName %__frexp_result_vec3 1 "exp" + 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 + OpMemberDecorate %__frexp_result_vec3 0 Offset 0 + OpMemberDecorate %__frexp_result_vec3 1 Offset 16 + %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 + %int = OpTypeInt 32 1 + %v3int = OpTypeVector %int 3 +%__frexp_result_vec3 = OpTypeStruct %v3float %v3int + %float_0_5 = OpConstant %float 0.5 + %18 = OpConstantComposite %v3float %float_0_5 %float_0_5 %float_0_5 + %int_1 = OpConstant %int 1 + %20 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %21 = OpConstantComposite %__frexp_result_vec3 %18 %20 +%_ptr_Function___frexp_result_vec3 = OpTypePointer Function %__frexp_result_vec3 + %24 = OpConstantNull %__frexp_result_vec3 + %25 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%frexp_bf45ae = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___frexp_result_vec3 Function %24 + OpStore %res %21 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %25 + %27 = OpLabel + %28 = OpFunctionCall %void %frexp_bf45ae + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %31 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %frexp_bf45ae + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %37 = OpLabel + %38 = OpFunctionCall %void %frexp_bf45ae + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.wgsl b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.wgsl new file mode 100644 index 0000000000..0cd674da03 --- /dev/null +++ b/test/tint/builtins/gen/var/frexp/bf45ae.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn frexp_bf45ae() { + const arg_0 = vec3(1.0); + var res = frexp(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + frexp_bf45ae(); + return vec4(); +} + +@fragment +fn fragment_main() { + frexp_bf45ae(); +} + +@compute @workgroup_size(1) +fn compute_main() { + frexp_bf45ae(); +} diff --git a/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a09bda3527 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = {(-0.5f).xxx, (-1.0f).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_68d8ee(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a09bda3527 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = {(-0.5f).xxx, (-1.0f).xxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_68d8ee(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.glsl b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.glsl new file mode 100644 index 0000000000..24140f3c3c --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +vec4 vertex_main() { + modf_68d8ee(); + 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; + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +void fragment_main() { + modf_68d8ee(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec3 { + vec3 fract; + vec3 whole; +}; + + +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3(vec3(-0.5f), vec3(-1.0f)); +} + +void compute_main() { + modf_68d8ee(); +} + +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/modf/68d8ee.wgsl.expected.msl b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.msl new file mode 100644 index 0000000000..d24f9fdfbc --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec3 { + float3 fract; + float3 whole; +}; +void modf_68d8ee() { + modf_result_vec3 res = modf_result_vec3{.fract=float3(-0.5f), .whole=float3(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_68d8ee(); + 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() { + modf_68d8ee(); + return; +} + +kernel void compute_main() { + modf_68d8ee(); + return; +} + diff --git a/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.spvasm b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.spvasm new file mode 100644 index 0000000000..e08886d658 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.spvasm @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 37 +; 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 %modf_68d8ee "modf_68d8ee" + OpName %__modf_result_vec3 "__modf_result_vec3" + OpMemberName %__modf_result_vec3 0 "fract" + OpMemberName %__modf_result_vec3 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec3 0 Offset 0 + OpMemberDecorate %__modf_result_vec3 1 Offset 16 + %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 +%__modf_result_vec3 = OpTypeStruct %v3float %v3float + %float_n0_5 = OpConstant %float -0.5 + %16 = OpConstantComposite %v3float %float_n0_5 %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %18 = OpConstantComposite %v3float %float_n1 %float_n1 %float_n1 + %19 = OpConstantComposite %__modf_result_vec3 %16 %18 +%_ptr_Function___modf_result_vec3 = OpTypePointer Function %__modf_result_vec3 + %22 = OpConstantNull %__modf_result_vec3 + %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_68d8ee = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec3 Function %22 + OpStore %res %19 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %23 + %25 = OpLabel + %26 = OpFunctionCall %void %modf_68d8ee + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %29 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_68d8ee + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %35 = OpLabel + %36 = OpFunctionCall %void %modf_68d8ee + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.wgsl b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.wgsl new file mode 100644 index 0000000000..c62b099626 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/68d8ee.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn modf_68d8ee() { + const arg_0 = vec3(-(1.5)); + var res = modf(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_68d8ee(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_68d8ee(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_68d8ee(); +} diff --git a/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..348870d617 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = {(-0.5f).xx, (-1.0f).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_732aa6(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..348870d617 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = {(-0.5f).xx, (-1.0f).xx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_732aa6(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.glsl b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.glsl new file mode 100644 index 0000000000..0695a32cf2 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +vec4 vertex_main() { + modf_732aa6(); + 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; + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +void fragment_main() { + modf_732aa6(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec2 { + vec2 fract; + vec2 whole; +}; + + +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2(vec2(-0.5f), vec2(-1.0f)); +} + +void compute_main() { + modf_732aa6(); +} + +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/modf/732aa6.wgsl.expected.msl b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.msl new file mode 100644 index 0000000000..dcb1f40e5c --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec2 { + float2 fract; + float2 whole; +}; +void modf_732aa6() { + modf_result_vec2 res = modf_result_vec2{.fract=float2(-0.5f), .whole=float2(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_732aa6(); + 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() { + modf_732aa6(); + return; +} + +kernel void compute_main() { + modf_732aa6(); + return; +} + diff --git a/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.spvasm new file mode 100644 index 0000000000..28a7da48fb --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.spvasm @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 37 +; 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 %modf_732aa6 "modf_732aa6" + OpName %__modf_result_vec2 "__modf_result_vec2" + OpMemberName %__modf_result_vec2 0 "fract" + OpMemberName %__modf_result_vec2 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec2 0 Offset 0 + OpMemberDecorate %__modf_result_vec2 1 Offset 8 + %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 +%__modf_result_vec2 = OpTypeStruct %v2float %v2float + %float_n0_5 = OpConstant %float -0.5 + %16 = OpConstantComposite %v2float %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %18 = OpConstantComposite %v2float %float_n1 %float_n1 + %19 = OpConstantComposite %__modf_result_vec2 %16 %18 +%_ptr_Function___modf_result_vec2 = OpTypePointer Function %__modf_result_vec2 + %22 = OpConstantNull %__modf_result_vec2 + %23 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_732aa6 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec2 Function %22 + OpStore %res %19 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %23 + %25 = OpLabel + %26 = OpFunctionCall %void %modf_732aa6 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %29 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_732aa6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %35 = OpLabel + %36 = OpFunctionCall %void %modf_732aa6 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.wgsl b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.wgsl new file mode 100644 index 0000000000..e1b0b3e69f --- /dev/null +++ b/test/tint/builtins/gen/var/modf/732aa6.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn modf_732aa6() { + const arg_0 = vec2(-(1.5)); + var res = modf(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_732aa6(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_732aa6(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_732aa6(); +} diff --git a/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..15c5b1148f --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = {-0.5f, -1.0f}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_c15f48(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..15c5b1148f --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = {-0.5f, -1.0f}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_c15f48(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.glsl b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.glsl new file mode 100644 index 0000000000..3c6410fc87 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +vec4 vertex_main() { + modf_c15f48(); + 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; + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +void fragment_main() { + modf_c15f48(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result { + float fract; + float whole; +}; + + +void modf_c15f48() { + modf_result res = modf_result(-0.5f, -1.0f); +} + +void compute_main() { + modf_c15f48(); +} + +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/modf/c15f48.wgsl.expected.msl b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.msl new file mode 100644 index 0000000000..676ddc126e --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result { + float fract; + float whole; +}; +void modf_c15f48() { + modf_result res = modf_result{.fract=-0.5f, .whole=-1.0f}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_c15f48(); + 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() { + modf_c15f48(); + return; +} + +kernel void compute_main() { + modf_c15f48(); + return; +} + diff --git a/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.spvasm b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.spvasm new file mode 100644 index 0000000000..c18f9c6824 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.spvasm @@ -0,0 +1,73 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 34 +; 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 %modf_c15f48 "modf_c15f48" + OpName %__modf_result "__modf_result" + OpMemberName %__modf_result 0 "fract" + OpMemberName %__modf_result 1 "whole" + 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 + OpMemberDecorate %__modf_result 0 Offset 0 + OpMemberDecorate %__modf_result 1 Offset 4 + %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 +%__modf_result = OpTypeStruct %float %float + %float_n0_5 = OpConstant %float -0.5 + %float_n1 = OpConstant %float -1 + %16 = OpConstantComposite %__modf_result %float_n0_5 %float_n1 +%_ptr_Function___modf_result = OpTypePointer Function %__modf_result + %19 = OpConstantNull %__modf_result + %20 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_c15f48 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result Function %19 + OpStore %res %16 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %modf_c15f48 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %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 + %29 = OpLabel + %30 = OpFunctionCall %void %modf_c15f48 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %modf_c15f48 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.wgsl b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.wgsl new file mode 100644 index 0000000000..b343662fd7 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/c15f48.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn modf_c15f48() { + const arg_0 = -(1.5); + var res = modf(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_c15f48(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_c15f48(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_c15f48(); +} diff --git a/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..e72d03c511 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.dxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = {(-0.5f).xxxx, (-1.0f).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_f3d1f9(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..e72d03c511 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.fxc.hlsl @@ -0,0 +1,34 @@ +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = {(-0.5f).xxxx, (-1.0f).xxxx}; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + modf_f3d1f9(); + return; +} diff --git a/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.glsl b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.glsl new file mode 100644 index 0000000000..3f2277d6f1 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.glsl @@ -0,0 +1,67 @@ +#version 310 es + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +vec4 vertex_main() { + modf_f3d1f9(); + 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; + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +void fragment_main() { + modf_f3d1f9(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +struct modf_result_vec4 { + vec4 fract; + vec4 whole; +}; + + +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4(vec4(-0.5f), vec4(-1.0f)); +} + +void compute_main() { + modf_f3d1f9(); +} + +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/modf/f3d1f9.wgsl.expected.msl b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.msl new file mode 100644 index 0000000000..087677aedf --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.msl @@ -0,0 +1,38 @@ +#include + +using namespace metal; + +struct modf_result_vec4 { + float4 fract; + float4 whole; +}; +void modf_f3d1f9() { + modf_result_vec4 res = modf_result_vec4{.fract=float4(-0.5f), .whole=float4(-1.0f)}; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + modf_f3d1f9(); + 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() { + modf_f3d1f9(); + return; +} + +kernel void compute_main() { + modf_f3d1f9(); + return; +} + diff --git a/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.spvasm b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.spvasm new file mode 100644 index 0000000000..629b8a5454 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.spvasm @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 36 +; 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 %modf_f3d1f9 "modf_f3d1f9" + OpName %__modf_result_vec4 "__modf_result_vec4" + OpMemberName %__modf_result_vec4 0 "fract" + OpMemberName %__modf_result_vec4 1 "whole" + 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 + OpMemberDecorate %__modf_result_vec4 0 Offset 0 + OpMemberDecorate %__modf_result_vec4 1 Offset 16 + %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 +%__modf_result_vec4 = OpTypeStruct %v4float %v4float + %float_n0_5 = OpConstant %float -0.5 + %15 = OpConstantComposite %v4float %float_n0_5 %float_n0_5 %float_n0_5 %float_n0_5 + %float_n1 = OpConstant %float -1 + %17 = OpConstantComposite %v4float %float_n1 %float_n1 %float_n1 %float_n1 + %18 = OpConstantComposite %__modf_result_vec4 %15 %17 +%_ptr_Function___modf_result_vec4 = OpTypePointer Function %__modf_result_vec4 + %21 = OpConstantNull %__modf_result_vec4 + %22 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%modf_f3d1f9 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function___modf_result_vec4 Function %21 + OpStore %res %18 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %22 + %24 = OpLabel + %25 = OpFunctionCall %void %modf_f3d1f9 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %28 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %modf_f3d1f9 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %34 = OpLabel + %35 = OpFunctionCall %void %modf_f3d1f9 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.wgsl b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.wgsl new file mode 100644 index 0000000000..a40cbe8396 --- /dev/null +++ b/test/tint/builtins/gen/var/modf/f3d1f9.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn modf_f3d1f9() { + const arg_0 = vec4(-(1.5)); + var res = modf(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + modf_f3d1f9(); + return vec4(); +} + +@fragment +fn fragment_main() { + modf_f3d1f9(); +} + +@compute @workgroup_size(1) +fn compute_main() { + modf_f3d1f9(); +}