From efe9c49819a61ba2d43ba6618bd043380e5a97f9 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 21 Nov 2022 18:00:01 +0000 Subject: [PATCH] Add const-eval for `degrees` and `radians` This CL adds const-eval for `degrees` and `radians`. Bug: tint:1581 Change-Id: I7f00e2b1e5ab7c8e895680a6b75b9531dac31f5a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110601 Commit-Queue: Dan Sinclair Kokoro: Kokoro Reviewed-by: Antonio Maiorano --- src/tint/intrinsics.def | 8 +- src/tint/number.h | 3 + src/tint/resolver/const_eval.cc | 52 +++++++++++ src/tint/resolver/const_eval.h | 18 ++++ src/tint/resolver/const_eval_builtin_test.cc | 86 +++++++++++++++++++ src/tint/resolver/const_eval_test.h | 3 - src/tint/resolver/intrinsic_table.inl | 24 +++--- .../degrees/0d170c.wgsl.expected.dxc.hlsl | 6 +- .../degrees/0d170c.wgsl.expected.fxc.hlsl | 6 +- .../literal/degrees/0d170c.wgsl.expected.glsl | 21 +---- .../literal/degrees/0d170c.wgsl.expected.msl | 7 +- .../degrees/0d170c.wgsl.expected.spvasm | 33 ++++--- .../degrees/1ad5df.wgsl.expected.dxc.hlsl | 6 +- .../degrees/1ad5df.wgsl.expected.fxc.hlsl | 6 +- .../literal/degrees/1ad5df.wgsl.expected.glsl | 21 +---- .../literal/degrees/1ad5df.wgsl.expected.msl | 7 +- .../degrees/1ad5df.wgsl.expected.spvasm | 37 ++++---- .../degrees/2af623.wgsl.expected.dxc.hlsl | 6 +- .../degrees/2af623.wgsl.expected.fxc.hlsl | 6 +- .../literal/degrees/2af623.wgsl.expected.glsl | 21 +---- .../literal/degrees/2af623.wgsl.expected.msl | 7 +- .../degrees/2af623.wgsl.expected.spvasm | 37 ++++---- .../degrees/3055d3.wgsl.expected.dxc.hlsl | 6 +- .../literal/degrees/3055d3.wgsl.expected.glsl | 21 +---- .../literal/degrees/3055d3.wgsl.expected.msl | 7 +- .../degrees/3055d3.wgsl.expected.spvasm | 36 ++++---- .../degrees/51f705.wgsl.expected.dxc.hlsl | 6 +- .../degrees/51f705.wgsl.expected.fxc.hlsl | 6 +- .../literal/degrees/51f705.wgsl.expected.glsl | 21 +---- .../literal/degrees/51f705.wgsl.expected.msl | 7 +- .../degrees/51f705.wgsl.expected.spvasm | 31 ++++--- .../degrees/5e9805.wgsl.expected.dxc.hlsl | 6 +- .../literal/degrees/5e9805.wgsl.expected.glsl | 21 +---- .../literal/degrees/5e9805.wgsl.expected.msl | 7 +- .../degrees/5e9805.wgsl.expected.spvasm | 34 ++++---- .../builtins/gen/literal/degrees/810467.wgsl | 43 ++++++++++ .../degrees/810467.wgsl.expected.dxc.hlsl | 30 +++++++ .../degrees/810467.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/degrees/810467.wgsl.expected.glsl | 49 +++++++++++ .../literal/degrees/810467.wgsl.expected.msl | 33 +++++++ .../degrees/810467.wgsl.expected.spvasm | 67 +++++++++++++++ .../literal/degrees/810467.wgsl.expected.wgsl | 19 ++++ .../builtins/gen/literal/degrees/c0880c.wgsl | 43 ++++++++++ .../degrees/c0880c.wgsl.expected.dxc.hlsl | 30 +++++++ .../degrees/c0880c.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/degrees/c0880c.wgsl.expected.glsl | 49 +++++++++++ .../literal/degrees/c0880c.wgsl.expected.msl | 33 +++++++ .../degrees/c0880c.wgsl.expected.spvasm | 67 +++++++++++++++ .../literal/degrees/c0880c.wgsl.expected.wgsl | 19 ++++ .../builtins/gen/literal/degrees/d43a49.wgsl | 43 ++++++++++ .../degrees/d43a49.wgsl.expected.dxc.hlsl | 30 +++++++ .../degrees/d43a49.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/degrees/d43a49.wgsl.expected.glsl | 49 +++++++++++ .../literal/degrees/d43a49.wgsl.expected.msl | 33 +++++++ .../degrees/d43a49.wgsl.expected.spvasm | 65 ++++++++++++++ .../literal/degrees/d43a49.wgsl.expected.wgsl | 19 ++++ .../degrees/dfe8f4.wgsl.expected.dxc.hlsl | 6 +- .../literal/degrees/dfe8f4.wgsl.expected.glsl | 21 +---- .../literal/degrees/dfe8f4.wgsl.expected.msl | 7 +- .../degrees/dfe8f4.wgsl.expected.spvasm | 36 ++++---- .../degrees/f59715.wgsl.expected.dxc.hlsl | 6 +- .../literal/degrees/f59715.wgsl.expected.glsl | 21 +---- .../literal/degrees/f59715.wgsl.expected.msl | 7 +- .../degrees/f59715.wgsl.expected.spvasm | 36 ++++---- .../builtins/gen/literal/degrees/fafa7e.wgsl | 43 ++++++++++ .../degrees/fafa7e.wgsl.expected.dxc.hlsl | 30 +++++++ .../degrees/fafa7e.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/degrees/fafa7e.wgsl.expected.glsl | 49 +++++++++++ .../literal/degrees/fafa7e.wgsl.expected.msl | 33 +++++++ .../degrees/fafa7e.wgsl.expected.spvasm | 64 ++++++++++++++ .../literal/degrees/fafa7e.wgsl.expected.wgsl | 19 ++++ .../radians/09b7fc.wgsl.expected.dxc.hlsl | 6 +- .../radians/09b7fc.wgsl.expected.fxc.hlsl | 6 +- .../literal/radians/09b7fc.wgsl.expected.glsl | 21 +---- .../literal/radians/09b7fc.wgsl.expected.msl | 7 +- .../radians/09b7fc.wgsl.expected.spvasm | 33 ++++--- .../radians/208fd9.wgsl.expected.dxc.hlsl | 6 +- .../literal/radians/208fd9.wgsl.expected.glsl | 21 +---- .../literal/radians/208fd9.wgsl.expected.msl | 7 +- .../radians/208fd9.wgsl.expected.spvasm | 34 ++++---- .../builtins/gen/literal/radians/379214.wgsl | 43 ++++++++++ .../radians/379214.wgsl.expected.dxc.hlsl | 30 +++++++ .../radians/379214.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/radians/379214.wgsl.expected.glsl | 49 +++++++++++ .../literal/radians/379214.wgsl.expected.msl | 33 +++++++ .../radians/379214.wgsl.expected.spvasm | 67 +++++++++++++++ .../literal/radians/379214.wgsl.expected.wgsl | 19 ++++ .../builtins/gen/literal/radians/44a9f8.wgsl | 43 ++++++++++ .../radians/44a9f8.wgsl.expected.dxc.hlsl | 30 +++++++ .../radians/44a9f8.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/radians/44a9f8.wgsl.expected.glsl | 49 +++++++++++ .../literal/radians/44a9f8.wgsl.expected.msl | 33 +++++++ .../radians/44a9f8.wgsl.expected.spvasm | 67 +++++++++++++++ .../literal/radians/44a9f8.wgsl.expected.wgsl | 19 ++++ .../radians/44f20b.wgsl.expected.dxc.hlsl | 6 +- .../literal/radians/44f20b.wgsl.expected.glsl | 21 +---- .../literal/radians/44f20b.wgsl.expected.msl | 7 +- .../radians/44f20b.wgsl.expected.spvasm | 36 ++++---- .../builtins/gen/literal/radians/524a91.wgsl | 43 ++++++++++ .../radians/524a91.wgsl.expected.dxc.hlsl | 30 +++++++ .../radians/524a91.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/radians/524a91.wgsl.expected.glsl | 49 +++++++++++ .../literal/radians/524a91.wgsl.expected.msl | 33 +++++++ .../radians/524a91.wgsl.expected.spvasm | 65 ++++++++++++++ .../literal/radians/524a91.wgsl.expected.wgsl | 19 ++++ .../radians/61687a.wgsl.expected.dxc.hlsl | 6 +- .../radians/61687a.wgsl.expected.fxc.hlsl | 6 +- .../literal/radians/61687a.wgsl.expected.glsl | 21 +---- .../literal/radians/61687a.wgsl.expected.msl | 7 +- .../radians/61687a.wgsl.expected.spvasm | 37 ++++---- .../radians/6b0ff2.wgsl.expected.dxc.hlsl | 6 +- .../radians/6b0ff2.wgsl.expected.fxc.hlsl | 6 +- .../literal/radians/6b0ff2.wgsl.expected.glsl | 21 +---- .../literal/radians/6b0ff2.wgsl.expected.msl | 7 +- .../radians/6b0ff2.wgsl.expected.spvasm | 31 ++++--- .../radians/7ea4c7.wgsl.expected.dxc.hlsl | 6 +- .../literal/radians/7ea4c7.wgsl.expected.glsl | 21 +---- .../literal/radians/7ea4c7.wgsl.expected.msl | 7 +- .../radians/7ea4c7.wgsl.expected.spvasm | 36 ++++---- .../builtins/gen/literal/radians/bff231.wgsl | 43 ++++++++++ .../radians/bff231.wgsl.expected.dxc.hlsl | 30 +++++++ .../radians/bff231.wgsl.expected.fxc.hlsl | 30 +++++++ .../literal/radians/bff231.wgsl.expected.glsl | 49 +++++++++++ .../literal/radians/bff231.wgsl.expected.msl | 33 +++++++ .../radians/bff231.wgsl.expected.spvasm | 64 ++++++++++++++ .../literal/radians/bff231.wgsl.expected.wgsl | 19 ++++ .../radians/f96258.wgsl.expected.dxc.hlsl | 6 +- .../radians/f96258.wgsl.expected.fxc.hlsl | 6 +- .../literal/radians/f96258.wgsl.expected.glsl | 21 +---- .../literal/radians/f96258.wgsl.expected.msl | 7 +- .../radians/f96258.wgsl.expected.spvasm | 37 ++++---- .../radians/fbacf0.wgsl.expected.dxc.hlsl | 6 +- .../literal/radians/fbacf0.wgsl.expected.glsl | 21 +---- .../literal/radians/fbacf0.wgsl.expected.msl | 7 +- .../radians/fbacf0.wgsl.expected.spvasm | 36 ++++---- .../tint/builtins/gen/var/degrees/810467.wgsl | 44 ++++++++++ .../var/degrees/810467.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/degrees/810467.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/degrees/810467.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/degrees/810467.wgsl.expected.msl | 33 +++++++ .../var/degrees/810467.wgsl.expected.spvasm | 67 +++++++++++++++ .../gen/var/degrees/810467.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/degrees/c0880c.wgsl | 44 ++++++++++ .../var/degrees/c0880c.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/degrees/c0880c.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/degrees/c0880c.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/degrees/c0880c.wgsl.expected.msl | 33 +++++++ .../var/degrees/c0880c.wgsl.expected.spvasm | 67 +++++++++++++++ .../gen/var/degrees/c0880c.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/degrees/d43a49.wgsl | 44 ++++++++++ .../var/degrees/d43a49.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/degrees/d43a49.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/degrees/d43a49.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/degrees/d43a49.wgsl.expected.msl | 33 +++++++ .../var/degrees/d43a49.wgsl.expected.spvasm | 65 ++++++++++++++ .../gen/var/degrees/d43a49.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/degrees/fafa7e.wgsl | 44 ++++++++++ .../var/degrees/fafa7e.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/degrees/fafa7e.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/degrees/fafa7e.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/degrees/fafa7e.wgsl.expected.msl | 33 +++++++ .../var/degrees/fafa7e.wgsl.expected.spvasm | 64 ++++++++++++++ .../gen/var/degrees/fafa7e.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/radians/379214.wgsl | 44 ++++++++++ .../var/radians/379214.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/radians/379214.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/radians/379214.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/radians/379214.wgsl.expected.msl | 33 +++++++ .../var/radians/379214.wgsl.expected.spvasm | 67 +++++++++++++++ .../gen/var/radians/379214.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/radians/44a9f8.wgsl | 44 ++++++++++ .../var/radians/44a9f8.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/radians/44a9f8.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/radians/44a9f8.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/radians/44a9f8.wgsl.expected.msl | 33 +++++++ .../var/radians/44a9f8.wgsl.expected.spvasm | 67 +++++++++++++++ .../gen/var/radians/44a9f8.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/radians/524a91.wgsl | 44 ++++++++++ .../var/radians/524a91.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/radians/524a91.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/radians/524a91.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/radians/524a91.wgsl.expected.msl | 33 +++++++ .../var/radians/524a91.wgsl.expected.spvasm | 65 ++++++++++++++ .../gen/var/radians/524a91.wgsl.expected.wgsl | 20 +++++ .../tint/builtins/gen/var/radians/bff231.wgsl | 44 ++++++++++ .../var/radians/bff231.wgsl.expected.dxc.hlsl | 30 +++++++ .../var/radians/bff231.wgsl.expected.fxc.hlsl | 30 +++++++ .../gen/var/radians/bff231.wgsl.expected.glsl | 49 +++++++++++ .../gen/var/radians/bff231.wgsl.expected.msl | 33 +++++++ .../var/radians/bff231.wgsl.expected.spvasm | 64 ++++++++++++++ .../gen/var/radians/bff231.wgsl.expected.wgsl | 20 +++++ test/tint/builtins/repeated_use.wgsl | 36 +++++--- .../repeated_use.wgsl.expected.dxc.hlsl | 36 +++++--- .../repeated_use.wgsl.expected.fxc.hlsl | 36 +++++--- .../builtins/repeated_use.wgsl.expected.glsl | 36 +++++--- .../builtins/repeated_use.wgsl.expected.msl | 36 +++++--- .../repeated_use.wgsl.expected.spvasm | 44 +++++----- .../builtins/repeated_use.wgsl.expected.wgsl | 36 +++++--- 198 files changed, 5029 insertions(+), 909 deletions(-) create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/radians/379214.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/degrees/810467.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/radians/379214.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/radians/524a91.wgsl.expected.wgsl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.dxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.fxc.hlsl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.glsl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.msl create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.spvasm create mode 100644 test/tint/builtins/gen/var/radians/bff231.wgsl.expected.wgsl diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 7d51d76dd0..7a18e17b96 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -440,8 +440,8 @@ fn arrayLength(ptr, A>) -> u32 @const fn countTrailingZeros(T) -> T @const fn countTrailingZeros(vec) -> vec @const fn cross(vec3, vec3) -> vec3 -fn degrees(T) -> T -fn degrees(vec) -> vec +@const fn degrees(T) -> T +@const fn degrees(vec) -> vec fn determinant(mat) -> T fn distance(T, T) -> T fn distance(vec, vec) -> T @@ -516,8 +516,8 @@ fn pow(T, T) -> T fn pow(vec, vec) -> vec @const fn quantizeToF16(f32) -> f32 @const fn quantizeToF16(vec) -> vec -fn radians(T) -> T -fn radians(vec) -> vec +@const fn radians(T) -> T +@const fn radians(vec) -> vec fn reflect(vec, vec) -> vec fn refract(vec, vec, T) -> vec @const fn reverseBits(T) -> T diff --git a/src/tint/number.h b/src/tint/number.h index 4fa6ed7c2e..dc6668976e 100644 --- a/src/tint/number.h +++ b/src/tint/number.h @@ -274,6 +274,9 @@ using f32 = Number; /// However since C++ don't have native binary16 type, the value is stored as float. using f16 = Number; +template >* = nullptr> +inline const auto kPi = T(UnwrapNumber(3.14159265358979323846)); + /// True iff T is an abstract number type template constexpr bool IsAbstract = std::is_same_v || std::is_same_v; diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 13ca03887b..f75481c9d9 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1954,6 +1954,32 @@ ConstEval::Result ConstEval::cross(const sem::Type* ty, utils::Vector{x.Get(), y.Get(), z.Get()}); } +ConstEval::Result ConstEval::degrees(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto e) -> ImplResult { + using NumberT = decltype(e); + using T = UnwrapNumber; + + auto pi = kPi; + auto scale = Div(source, NumberT(180), NumberT(pi)); + if (!scale) { + AddNote("when calculating degrees", source); + return utils::Failure; + } + auto result = Mul(source, e, scale.Get()); + if (!result) { + AddNote("when calculating degrees", source); + return utils::Failure; + } + return CreateElement(builder, source, c0->Type(), result.Get()); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::extractBits(const sem::Type* ty, utils::VectorRef args, const Source& source) { @@ -2267,6 +2293,32 @@ ConstEval::Result ConstEval::pack4x8unorm(const sem::Type* ty, return CreateElement(builder, source, ty, ret); } +ConstEval::Result ConstEval::radians(const sem::Type* ty, + utils::VectorRef args, + const Source& source) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto e) -> ImplResult { + using NumberT = decltype(e); + using T = UnwrapNumber; + + auto pi = kPi; + auto scale = Div(source, NumberT(pi), NumberT(180)); + if (!scale) { + AddNote("when calculating radians", source); + return utils::Failure; + } + auto result = Mul(source, e, scale.Get()); + if (!result) { + AddNote("when calculating radians", source); + return utils::Failure; + } + return CreateElement(builder, source, c0->Type(), result.Get()); + }; + return Dispatch_fa_f32_f16(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::reverseBits(const sem::Type* ty, utils::VectorRef args, const Source& source) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 73274a1596..5e2a97f44b 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -539,6 +539,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// degrees builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result degrees(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// extractBits builtin /// @param ty the expression type /// @param args the input arguments @@ -647,6 +656,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// radians builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result radians(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// reverseBits builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 4b0ff0b92f..1bf0bd095c 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -993,6 +993,57 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(InsertBitsCases(), // InsertBitsCases())))); +template +std::vector DegreesAFloatCases() { + return std::vector{ + C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(0.698132)}, T(40)).FloatComp(), // + C({-T(1.5708)}, -T(90.000214)).FloatComp(), // + C({T(1.5708)}, T(90.000214)).FloatComp(), // + C({T(6.28319)}, T(360.00027)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + DegreesAFloat, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kDegrees), + testing::ValuesIn(DegreesAFloatCases()))); + +template +std::vector DegreesF32Cases() { + return std::vector{ + C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(0.698132)}, T(40)).FloatComp(), // + C({-T(1.5708)}, -T(90.000206)).FloatComp(), // + C({T(1.5708)}, T(90.000206)).FloatComp(), // + C({T(6.28319)}, T(360.00024)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + DegreesF32, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kDegrees), + testing::ValuesIn(DegreesF32Cases()))); + +template +std::vector DegreesF16Cases() { + return std::vector{ + C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(0.698132)}, T(39.96875)).FloatComp(), // + C({-T(1.5708)}, -T(89.9375)).FloatComp(), // + C({T(1.5708)}, T(89.9375)).FloatComp(), // + C({T(6.28319)}, T(359.75)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + DegreesF16, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kDegrees), + testing::ValuesIn(DegreesF16Cases()))); + template std::vector ExtractBitsCases() { using UT = Number>>; @@ -1275,6 +1326,41 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(ReverseBitsCases(), // ReverseBitsCases())))); +template +std::vector RadiansCases() { + return std::vector{ + C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(40)}, T(0.69813168)).FloatComp(), // + C({-T(90)}, -T(1.5707964)).FloatComp(), // + C({T(90)}, T(1.5707964)).FloatComp(), // + C({T(360)}, T(6.2831855)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + Radians, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kRadians), + testing::ValuesIn(Concat(RadiansCases(), // + RadiansCases())))); + +template +std::vector RadiansF16Cases() { + return std::vector{ + C({T(0)}, T(0)), // + C({-T(0)}, -T(0)), // + C({T(40)}, T(0.69726562)).FloatComp(), // + C({-T(90)}, -T(1.5693359)).FloatComp(), // + C({T(90)}, T(1.5693359)).FloatComp(), // + C({T(360)}, T(6.2773438)).FloatComp(), + }; +} +INSTANTIATE_TEST_SUITE_P( // + RadiansF16, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kRadians), + testing::ValuesIn(RadiansF16Cases()))); + template std::vector RoundCases() { std::vector cases = { diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index 0cedf25a10..c2e12bc4f4 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -26,9 +26,6 @@ namespace tint::resolver { -template -inline const auto kPi = T(UnwrapNumber(3.14159265358979323846)); - template inline const auto kPiOver2 = T(UnwrapNumber(1.57079632679489661923)); diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 3b0b88d0d6..9e768623c0 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12174,24 +12174,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[835], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::degrees, }, { /* [322] */ /* 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[836], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::degrees, }, { /* [323] */ @@ -12918,24 +12918,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[888], /* return matcher indices */ &kMatcherIndices[3], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::radians, }, { /* [384] */ /* 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[889], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::radians, }, { /* [385] */ @@ -14117,8 +14117,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [19] */ - /* fn degrees(T) -> T */ - /* fn degrees(vec) -> vec */ + /* fn degrees(T) -> T */ + /* fn degrees(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[321], }, @@ -14408,8 +14408,8 @@ constexpr IntrinsicInfo kBuiltins[] = { }, { /* [62] */ - /* fn radians(T) -> T */ - /* fn radians(vec) -> vec */ + /* fn radians(T) -> T */ + /* fn radians(vec) -> vec */ /* num overloads */ 2, /* overloads */ &kOverloads[383], }, diff --git a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.dxc.hlsl index 2cd2296e5c..63b2df2baa 100644 --- a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float4 tint_degrees(float4 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_0d170c() { - float4 res = tint_degrees((1.0f).xxxx); + float4 res = (57.295776367f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.fxc.hlsl index 2cd2296e5c..63b2df2baa 100644 --- a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float4 tint_degrees(float4 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_0d170c() { - float4 res = tint_degrees((1.0f).xxxx); + float4 res = (57.295776367f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.glsl index 542dec0b01..4269efe339 100644 --- a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec4 tint_degrees(vec4 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_0d170c() { - vec4 res = tint_degrees(vec4(1.0f)); + vec4 res = vec4(57.295776367f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec4 tint_degrees(vec4 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_0d170c() { - vec4 res = tint_degrees(vec4(1.0f)); + vec4 res = vec4(57.295776367f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec4 tint_degrees(vec4 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_0d170c() { - vec4 res = tint_degrees(vec4(1.0f)); + vec4 res = vec4(57.295776367f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.msl index 8dc825c600..ef0d58a717 100644 --- a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float4 tint_degrees(float4 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_0d170c() { - float4 res = tint_degrees(float4(1.0f)); + float4 res = float4(57.295776367f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.spvasm index 738ca27315..ba056b9f8c 100644 --- a/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/0d170c.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%float_57_2957764 = OpConstant %float 57.2957764 + %14 = OpConstantComposite %v4float %float_57_2957764 %float_57_2957764 %float_57_2957764 %float_57_2957764 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %degrees_0d170c = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Degrees %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %degrees_0d170c +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %degrees_0d170c OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %degrees_0d170c + %26 = OpLabel + %27 = OpFunctionCall %void %degrees_0d170c OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %degrees_0d170c + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_0d170c OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.dxc.hlsl index f8315be982..cbe65831d8 100644 --- a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float2 tint_degrees(float2 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_1ad5df() { - float2 res = tint_degrees((1.0f).xx); + float2 res = (57.295776367f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.fxc.hlsl index f8315be982..cbe65831d8 100644 --- a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float2 tint_degrees(float2 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_1ad5df() { - float2 res = tint_degrees((1.0f).xx); + float2 res = (57.295776367f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.glsl index b3dfe33c21..8640b147ae 100644 --- a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec2 tint_degrees(vec2 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_1ad5df() { - vec2 res = tint_degrees(vec2(1.0f)); + vec2 res = vec2(57.295776367f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec2 tint_degrees(vec2 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_1ad5df() { - vec2 res = tint_degrees(vec2(1.0f)); + vec2 res = vec2(57.295776367f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec2 tint_degrees(vec2 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_1ad5df() { - vec2 res = tint_degrees(vec2(1.0f)); + vec2 res = vec2(57.295776367f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.msl index e46d2ff6e5..4af91d1cfd 100644 --- a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float2 tint_degrees(float2 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_1ad5df() { - float2 res = tint_degrees(float2(1.0f)); + float2 res = float2(57.295776367f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.spvasm index 573f04d66c..9c5c485b45 100644 --- a/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/1ad5df.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 +%float_57_2957764 = OpConstant %float 57.2957764 + %15 = OpConstantComposite %v2float %float_57_2957764 %float_57_2957764 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %degrees_1ad5df = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Degrees %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %degrees_1ad5df +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_1ad5df OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %degrees_1ad5df + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_1ad5df OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %degrees_1ad5df + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_1ad5df OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.dxc.hlsl index 292fa3a209..fa9e27882b 100644 --- a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float3 tint_degrees(float3 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_2af623() { - float3 res = tint_degrees((1.0f).xxx); + float3 res = (57.295776367f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.fxc.hlsl index 292fa3a209..fa9e27882b 100644 --- a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float3 tint_degrees(float3 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_2af623() { - float3 res = tint_degrees((1.0f).xxx); + float3 res = (57.295776367f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.glsl index fa064b924f..08b51eecfc 100644 --- a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec3 tint_degrees(vec3 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_2af623() { - vec3 res = tint_degrees(vec3(1.0f)); + vec3 res = vec3(57.295776367f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec3 tint_degrees(vec3 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_2af623() { - vec3 res = tint_degrees(vec3(1.0f)); + vec3 res = vec3(57.295776367f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec3 tint_degrees(vec3 param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_2af623() { - vec3 res = tint_degrees(vec3(1.0f)); + vec3 res = vec3(57.295776367f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.msl index 4874bbb432..4da3b352cd 100644 --- a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float3 tint_degrees(float3 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_2af623() { - float3 res = tint_degrees(float3(1.0f)); + float3 res = float3(57.295776367f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.spvasm index 160a383197..b692ad7f58 100644 --- a/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/2af623.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%float_57_2957764 = OpConstant %float 57.2957764 + %15 = OpConstantComposite %v3float %float_57_2957764 %float_57_2957764 %float_57_2957764 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %degrees_2af623 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Degrees %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %degrees_2af623 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_2af623 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %degrees_2af623 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_2af623 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %degrees_2af623 + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_2af623 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.dxc.hlsl index ff572fdde1..3ec4e92758 100644 --- a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_degrees(vector param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_3055d3() { - vector res = tint_degrees((float16_t(1.0h)).xxxx); + vector res = (float16_t(57.3125h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.glsl index b9788e1936..182025462e 100644 --- a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec4 tint_degrees(f16vec4 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_3055d3() { - f16vec4 res = tint_degrees(f16vec4(1.0hf)); + f16vec4 res = f16vec4(57.3125hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec4 tint_degrees(f16vec4 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_3055d3() { - f16vec4 res = tint_degrees(f16vec4(1.0hf)); + f16vec4 res = f16vec4(57.3125hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec4 tint_degrees(f16vec4 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_3055d3() { - f16vec4 res = tint_degrees(f16vec4(1.0hf)); + f16vec4 res = f16vec4(57.3125hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.msl index e9fe3c7e14..dbbd5200e4 100644 --- a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half4 tint_degrees(half4 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_3055d3() { - half4 res = tint_degrees(half4(1.0h)); + half4 res = half4(57.3125h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.spvasm index 171e19c7ca..ba293b3807 100644 --- a/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/3055d3.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_ca8p_5 = OpConstant %half 0x1.ca8p+5 + %16 = OpConstantComposite %v4half %half_0x1_ca8p_5 %half_0x1_ca8p_5 %half_0x1_ca8p_5 %half_0x1_ca8p_5 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %degrees_3055d3 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Degrees %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %degrees_3055d3 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %degrees_3055d3 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %degrees_3055d3 + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_3055d3 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %degrees_3055d3 + %32 = OpLabel + %33 = OpFunctionCall %void %degrees_3055d3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.dxc.hlsl index feab0fbc91..360efa4611 100644 --- a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.fxc.hlsl index feab0fbc91..360efa4611 100644 --- a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.glsl index 3357c9e108..a9b22b4c7f 100644 --- a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865f; -} - - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.msl index 6c29fa0a17..6ff8e8594b 100644 --- a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float tint_degrees(float param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_51f705() { - float res = tint_degrees(1.0f); + float res = 57.295776367f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.spvasm index 84e3e975d4..9c98fce9d3 100644 --- a/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/51f705.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 30 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,35 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 +%float_57_2957764 = OpConstant %float 57.2957764 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %degrees_51f705 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Degrees %float_1 - OpStore %res %13 + OpStore %res %float_57_2957764 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %degrees_51f705 +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %degrees_51f705 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %degrees_51f705 + %25 = OpLabel + %26 = OpFunctionCall %void %degrees_51f705 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %degrees_51f705 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_51f705 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.dxc.hlsl index 930472f282..eff605b0a3 100644 --- a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float16_t tint_degrees(float16_t param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_5e9805() { - float16_t res = tint_degrees(float16_t(1.0h)); + float16_t res = float16_t(57.3125h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.glsl index 3042f4c218..1ef9dcf232 100644 --- a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -float16_t tint_degrees(float16_t param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_5e9805() { - float16_t res = tint_degrees(1.0hf); + float16_t res = 57.3125hf; } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -float16_t tint_degrees(float16_t param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_5e9805() { - float16_t res = tint_degrees(1.0hf); + float16_t res = 57.3125hf; } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -float16_t tint_degrees(float16_t param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_5e9805() { - float16_t res = tint_degrees(1.0hf); + float16_t res = 57.3125hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.msl index 280c0bca1d..8a940209aa 100644 --- a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half tint_degrees(half param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_5e9805() { - half res = tint_degrees(1.0h); + half res = 57.3125h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.spvasm index 9a33ca6b02..a942b16cfd 100644 --- a/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/5e9805.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1_ca8p_5 = OpConstant %half 0x1.ca8p+5 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %degrees_5e9805 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Degrees %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1_ca8p_5 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %degrees_5e9805 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %degrees_5e9805 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %degrees_5e9805 + %27 = OpLabel + %28 = OpFunctionCall %void %degrees_5e9805 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %degrees_5e9805 + %30 = OpLabel + %31 = OpFunctionCall %void %degrees_5e9805 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl b/test/tint/builtins/gen/literal/degrees/810467.wgsl new file mode 100644 index 0000000000..f3a288ebd5 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.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 degrees(vec<2, fa>) -> vec<2, fa> +fn degrees_810467() { + var res = degrees(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_810467(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_810467(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_810467(); +} diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..eb0415dd4b --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_810467() { + float2 res = (57.295780182f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_810467(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..eb0415dd4b --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_810467() { + float2 res = (57.295780182f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_810467(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.glsl new file mode 100644 index 0000000000..cee6770316 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +vec4 vertex_main() { + degrees_810467(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +void fragment_main() { + degrees_810467(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +void compute_main() { + degrees_810467(); +} + +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/degrees/810467.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.msl new file mode 100644 index 0000000000..26fdf6d5f2 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_810467() { + float2 res = float2(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +kernel void compute_main() { + degrees_810467(); + return; +} + diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.spvasm new file mode 100644 index 0000000000..2f16f05b7d --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_810467 "degrees_810467" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_57_2957802 = OpConstant %float 57.2957802 + %15 = OpConstantComposite %v2float %float_57_2957802 %float_57_2957802 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_810467 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_810467 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_810467 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_810467 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.wgsl new file mode 100644 index 0000000000..f485b44b5a --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/810467.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn degrees_810467() { + var res = degrees(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_810467(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_810467(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_810467(); +} diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl new file mode 100644 index 0000000000..168ddabe8e --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.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 degrees(vec<3, fa>) -> vec<3, fa> +fn degrees_c0880c() { + var res = degrees(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_c0880c(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_c0880c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_c0880c(); +} diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..78013a9c61 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_c0880c() { + float3 res = (57.295780182f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_c0880c(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..78013a9c61 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_c0880c() { + float3 res = (57.295780182f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_c0880c(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.glsl new file mode 100644 index 0000000000..ad03188570 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +vec4 vertex_main() { + degrees_c0880c(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +void fragment_main() { + degrees_c0880c(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +void compute_main() { + degrees_c0880c(); +} + +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/degrees/c0880c.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.msl new file mode 100644 index 0000000000..4b019e90f2 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_c0880c() { + float3 res = float3(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +kernel void compute_main() { + degrees_c0880c(); + return; +} + diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.spvasm new file mode 100644 index 0000000000..7fe5c7398c --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_c0880c "degrees_c0880c" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_57_2957802 = OpConstant %float 57.2957802 + %15 = OpConstantComposite %v3float %float_57_2957802 %float_57_2957802 %float_57_2957802 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_c0880c = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_c0880c + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_c0880c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_c0880c + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.wgsl new file mode 100644 index 0000000000..56b77bedb7 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/c0880c.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn degrees_c0880c() { + var res = degrees(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_c0880c(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_c0880c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_c0880c(); +} diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl new file mode 100644 index 0000000000..591aa5e963 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.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 degrees(vec<4, fa>) -> vec<4, fa> +fn degrees_d43a49() { + var res = degrees(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_d43a49(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_d43a49(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_d43a49(); +} diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0ea5685f9b --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_d43a49() { + float4 res = (57.295780182f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_d43a49(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0ea5685f9b --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_d43a49() { + float4 res = (57.295780182f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_d43a49(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.glsl new file mode 100644 index 0000000000..893f790649 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +vec4 vertex_main() { + degrees_d43a49(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +void fragment_main() { + degrees_d43a49(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +void compute_main() { + degrees_d43a49(); +} + +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/degrees/d43a49.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.msl new file mode 100644 index 0000000000..adddeb0d13 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_d43a49() { + float4 res = float4(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +kernel void compute_main() { + degrees_d43a49(); + return; +} + diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.spvasm new file mode 100644 index 0000000000..d0ca406e51 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_d43a49 "degrees_d43a49" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_57_2957802 = OpConstant %float 57.2957802 + %14 = OpConstantComposite %v4float %float_57_2957802 %float_57_2957802 %float_57_2957802 %float_57_2957802 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_d43a49 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %degrees_d43a49 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %degrees_d43a49 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_d43a49 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.wgsl new file mode 100644 index 0000000000..5d5273450d --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/d43a49.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn degrees_d43a49() { + var res = degrees(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_d43a49(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_d43a49(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_d43a49(); +} diff --git a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.dxc.hlsl index b54ef763ca..e79a618834 100644 --- a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_degrees(vector param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_dfe8f4() { - vector res = tint_degrees((float16_t(1.0h)).xxx); + vector res = (float16_t(57.3125h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.glsl index 576497a38e..44e7b2a83f 100644 --- a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec3 tint_degrees(f16vec3 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_dfe8f4() { - f16vec3 res = tint_degrees(f16vec3(1.0hf)); + f16vec3 res = f16vec3(57.3125hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec3 tint_degrees(f16vec3 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_dfe8f4() { - f16vec3 res = tint_degrees(f16vec3(1.0hf)); + f16vec3 res = f16vec3(57.3125hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec3 tint_degrees(f16vec3 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_dfe8f4() { - f16vec3 res = tint_degrees(f16vec3(1.0hf)); + f16vec3 res = f16vec3(57.3125hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.msl index 419df21560..581a6af436 100644 --- a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half3 tint_degrees(half3 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_dfe8f4() { - half3 res = tint_degrees(half3(1.0h)); + half3 res = half3(57.3125h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.spvasm index ca76456687..449a8ea72f 100644 --- a/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/dfe8f4.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_ca8p_5 = OpConstant %half 0x1.ca8p+5 + %16 = OpConstantComposite %v3half %half_0x1_ca8p_5 %half_0x1_ca8p_5 %half_0x1_ca8p_5 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %degrees_dfe8f4 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Degrees %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %degrees_dfe8f4 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %degrees_dfe8f4 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %degrees_dfe8f4 + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_dfe8f4 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %degrees_dfe8f4 + %32 = OpLabel + %33 = OpFunctionCall %void %degrees_dfe8f4 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.dxc.hlsl index 68de11a4f2..336be91a25 100644 --- a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_degrees(vector param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_f59715() { - vector res = tint_degrees((float16_t(1.0h)).xx); + vector res = (float16_t(57.3125h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.glsl index 7a7c686429..a3e8bf9fdd 100644 --- a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec2 tint_degrees(f16vec2 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_f59715() { - f16vec2 res = tint_degrees(f16vec2(1.0hf)); + f16vec2 res = f16vec2(57.3125hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec2 tint_degrees(f16vec2 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_f59715() { - f16vec2 res = tint_degrees(f16vec2(1.0hf)); + f16vec2 res = f16vec2(57.3125hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec2 tint_degrees(f16vec2 param_0) { - return param_0 * 57.295779513082322865hf; -} - - void degrees_f59715() { - f16vec2 res = tint_degrees(f16vec2(1.0hf)); + f16vec2 res = f16vec2(57.3125hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.msl index af8aa3038f..62fd426d47 100644 --- a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half2 tint_degrees(half2 param_0) { - return param_0 * 57.295779513082322865; -} - void degrees_f59715() { - half2 res = tint_degrees(half2(1.0h)); + half2 res = half2(57.3125h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.spvasm index ca83372ca9..ba71ed336d 100644 --- a/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/degrees/f59715.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1_ca8p_5 = OpConstant %half 0x1.ca8p+5 + %16 = OpConstantComposite %v2half %half_0x1_ca8p_5 %half_0x1_ca8p_5 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %degrees_f59715 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Degrees %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %degrees_f59715 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %degrees_f59715 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %degrees_f59715 + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_f59715 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %degrees_f59715 + %32 = OpLabel + %33 = OpFunctionCall %void %degrees_f59715 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl new file mode 100644 index 0000000000..f5135de7b2 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.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 degrees(fa) -> fa +fn degrees_fafa7e() { + var res = degrees(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_fafa7e(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_fafa7e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_fafa7e(); +} diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a11be104c4 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_fafa7e(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a11be104c4 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_fafa7e(); + return; +} diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.glsl new file mode 100644 index 0000000000..4572eb3b0b --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +vec4 vertex_main() { + degrees_fafa7e(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +void fragment_main() { + degrees_fafa7e(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +void compute_main() { + degrees_fafa7e(); +} + +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/degrees/fafa7e.wgsl.expected.msl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.msl new file mode 100644 index 0000000000..770b0ab39d --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +kernel void compute_main() { + degrees_fafa7e(); + return; +} + diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.spvasm new file mode 100644 index 0000000000..e3e981003d --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_fafa7e "degrees_fafa7e" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_57_2957802 = OpConstant %float 57.2957802 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_fafa7e = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_57_2957802 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %degrees_fafa7e + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %degrees_fafa7e + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_fafa7e + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.wgsl new file mode 100644 index 0000000000..572f1d6017 --- /dev/null +++ b/test/tint/builtins/gen/literal/degrees/fafa7e.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn degrees_fafa7e() { + var res = degrees(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_fafa7e(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_fafa7e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_fafa7e(); +} diff --git a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.dxc.hlsl index d1adfed065..9fda1fb426 100644 --- a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float4 tint_radians(float4 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_09b7fc() { - float4 res = tint_radians((1.0f).xxxx); + float4 res = (0.017453292f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.fxc.hlsl index d1adfed065..9fda1fb426 100644 --- a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float4 tint_radians(float4 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_09b7fc() { - float4 res = tint_radians((1.0f).xxxx); + float4 res = (0.017453292f).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.glsl index a0c4475a17..4a6d16990d 100644 --- a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec4 tint_radians(vec4 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_09b7fc() { - vec4 res = tint_radians(vec4(1.0f)); + vec4 res = vec4(0.017453292f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec4 tint_radians(vec4 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_09b7fc() { - vec4 res = tint_radians(vec4(1.0f)); + vec4 res = vec4(0.017453292f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec4 tint_radians(vec4 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_09b7fc() { - vec4 res = tint_radians(vec4(1.0f)); + vec4 res = vec4(0.017453292f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.msl index 59ac3a3080..5b7469da73 100644 --- a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float4 tint_radians(float4 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_09b7fc() { - float4 res = tint_radians(float4(1.0f)); + float4 res = float4(0.017453292f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.spvasm index ddeea5d5e0..51235ca05f 100644 --- a/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/09b7fc.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 31 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,36 +30,36 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 - %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %14 = OpConstantComposite %v4float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 %_ptr_Function_v4float = OpTypePointer Function %v4float - %19 = OpTypeFunction %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %radians_09b7fc = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %13 = OpExtInst %v4float %14 Radians %16 - OpStore %res %13 + OpStore %res %14 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %radians_09b7fc +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %radians_09b7fc OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %void %radians_09b7fc + %26 = OpLabel + %27 = OpFunctionCall %void %radians_09b7fc OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %radians_09b7fc + %29 = OpLabel + %30 = OpFunctionCall %void %radians_09b7fc OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.dxc.hlsl index fb9a879f26..0421e6d0ce 100644 --- a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float16_t tint_radians(float16_t param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_208fd9() { - float16_t res = tint_radians(float16_t(1.0h)); + float16_t res = float16_t(0.017440796h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.glsl index a48668cb3f..efcf7aa2bd 100644 --- a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -float16_t tint_radians(float16_t param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_208fd9() { - float16_t res = tint_radians(1.0hf); + float16_t res = 0.017440796hf; } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -float16_t tint_radians(float16_t param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_208fd9() { - float16_t res = tint_radians(1.0hf); + float16_t res = 0.017440796hf; } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -float16_t tint_radians(float16_t param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_208fd9() { - float16_t res = tint_radians(1.0hf); + float16_t res = 0.017440796hf; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.msl index 72d93d68d1..93c1037338 100644 --- a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half tint_radians(half param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_208fd9() { - half res = tint_radians(1.0h); + half res = 0.017440796h; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.spvasm index e218859224..00810555b2 100644 --- a/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/208fd9.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 32 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -36,37 +35,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 +%half_0x1_1dcpn6 = OpConstant %half 0x1.1dcp-6 %_ptr_Function_half = OpTypePointer Function %half - %19 = OpConstantNull %half - %20 = OpTypeFunction %v4float + %17 = OpConstantNull %half + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %radians_208fd9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_half Function %19 - %13 = OpExtInst %half %15 Radians %half_0x1p_0 - OpStore %res %13 + %res = OpVariable %_ptr_Function_half Function %17 + OpStore %res %half_0x1_1dcpn6 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %20 - %22 = OpLabel - %23 = OpFunctionCall %void %radians_208fd9 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %radians_208fd9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %25 = OpLabel - %26 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %26 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %radians_208fd9 + %27 = OpLabel + %28 = OpFunctionCall %void %radians_208fd9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %radians_208fd9 + %30 = OpLabel + %31 = OpFunctionCall %void %radians_208fd9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl b/test/tint/builtins/gen/literal/radians/379214.wgsl new file mode 100644 index 0000000000..273ddee603 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.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 radians(vec<3, fa>) -> vec<3, fa> +fn radians_379214() { + var res = radians(vec3(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_379214(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_379214(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_379214(); +} diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..247db1d62d --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_379214() { + float3 res = (0.017453292f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_379214(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..247db1d62d --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_379214() { + float3 res = (0.017453292f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_379214(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.glsl new file mode 100644 index 0000000000..5593c1db04 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +vec4 vertex_main() { + radians_379214(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +void fragment_main() { + radians_379214(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +void compute_main() { + radians_379214(); +} + +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/radians/379214.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.msl new file mode 100644 index 0000000000..638763a97d --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_379214() { + float3 res = float3(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +kernel void compute_main() { + radians_379214(); + return; +} + diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.spvasm new file mode 100644 index 0000000000..ec9360a2a2 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_379214 "radians_379214" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v3float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_379214 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_379214 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_379214 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %radians_379214 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.wgsl new file mode 100644 index 0000000000..f0f98c8ca0 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/379214.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn radians_379214() { + var res = radians(vec3(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_379214(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_379214(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_379214(); +} diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl new file mode 100644 index 0000000000..cbb4f6d3bd --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.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 radians(vec<2, fa>) -> vec<2, fa> +fn radians_44a9f8() { + var res = radians(vec2(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_44a9f8(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_44a9f8(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_44a9f8(); +} diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cb67c5d960 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_44a9f8() { + float2 res = (0.017453292f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_44a9f8(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cb67c5d960 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_44a9f8() { + float2 res = (0.017453292f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_44a9f8(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.glsl new file mode 100644 index 0000000000..6caa601653 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +vec4 vertex_main() { + radians_44a9f8(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +void fragment_main() { + radians_44a9f8(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +void compute_main() { + radians_44a9f8(); +} + +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/radians/44a9f8.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.msl new file mode 100644 index 0000000000..fea0149da1 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_44a9f8() { + float2 res = float2(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +kernel void compute_main() { + radians_44a9f8(); + return; +} + diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.spvasm new file mode 100644 index 0000000000..4e135fcdba --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_44a9f8 "radians_44a9f8" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v2float %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_44a9f8 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_44a9f8 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_44a9f8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %radians_44a9f8 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.wgsl new file mode 100644 index 0000000000..4d6455c548 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/44a9f8.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn radians_44a9f8() { + var res = radians(vec2(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_44a9f8(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_44a9f8(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_44a9f8(); +} diff --git a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.dxc.hlsl index 3c88857501..f107b59645 100644 --- a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_radians(vector param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_44f20b() { - vector res = tint_radians((float16_t(1.0h)).xxxx); + vector res = (float16_t(0.017440796h)).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.glsl index caa4ab8cd2..ed65328450 100644 --- a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec4 tint_radians(f16vec4 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_44f20b() { - f16vec4 res = tint_radians(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.017440796hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec4 tint_radians(f16vec4 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_44f20b() { - f16vec4 res = tint_radians(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.017440796hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec4 tint_radians(f16vec4 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_44f20b() { - f16vec4 res = tint_radians(f16vec4(1.0hf)); + f16vec4 res = f16vec4(0.017440796hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.msl index 0f7b12fe36..d279cb30aa 100644 --- a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half4 tint_radians(half4 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_44f20b() { - half4 res = tint_radians(half4(1.0h)); + half4 res = half4(0.017440796h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.spvasm index 993e544f7c..7a543a4451 100644 --- a/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/44f20b.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v4half = OpTypeVector %half 4 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_1dcpn6 = OpConstant %half 0x1.1dcp-6 + %16 = OpConstantComposite %v4half %half_0x1_1dcpn6 %half_0x1_1dcpn6 %half_0x1_1dcpn6 %half_0x1_1dcpn6 %_ptr_Function_v4half = OpTypePointer Function %v4half - %21 = OpConstantNull %v4half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v4half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %radians_44f20b = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4half Function %21 - %13 = OpExtInst %v4half %16 Radians %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %radians_44f20b +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %radians_44f20b OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %radians_44f20b + %29 = OpLabel + %30 = OpFunctionCall %void %radians_44f20b OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %radians_44f20b + %32 = OpLabel + %33 = OpFunctionCall %void %radians_44f20b OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl b/test/tint/builtins/gen/literal/radians/524a91.wgsl new file mode 100644 index 0000000000..42d2fad03e --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.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 radians(vec<4, fa>) -> vec<4, fa> +fn radians_524a91() { + var res = radians(vec4(1.)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_524a91(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_524a91(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_524a91(); +} diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b3e219299f --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_524a91() { + float4 res = (0.017453292f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_524a91(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b3e219299f --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_524a91() { + float4 res = (0.017453292f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_524a91(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.glsl new file mode 100644 index 0000000000..fd1508ed2c --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +vec4 vertex_main() { + radians_524a91(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +void fragment_main() { + radians_524a91(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +void compute_main() { + radians_524a91(); +} + +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/radians/524a91.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.msl new file mode 100644 index 0000000000..fa539e01ef --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_524a91() { + float4 res = float4(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +kernel void compute_main() { + radians_524a91(); + return; +} + diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.spvasm new file mode 100644 index 0000000000..a9c1edff04 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_524a91 "radians_524a91" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_0174532924 = OpConstant %float 0.0174532924 + %14 = OpConstantComposite %v4float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_524a91 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %radians_524a91 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %radians_524a91 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %radians_524a91 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.wgsl new file mode 100644 index 0000000000..7f69a56230 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/524a91.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn radians_524a91() { + var res = radians(vec4(1.0)); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_524a91(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_524a91(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_524a91(); +} diff --git a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.dxc.hlsl index 66fd0bb9c8..08ec6b456b 100644 --- a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float2 tint_radians(float2 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_61687a() { - float2 res = tint_radians((1.0f).xx); + float2 res = (0.017453292f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.fxc.hlsl index 66fd0bb9c8..08ec6b456b 100644 --- a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float2 tint_radians(float2 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_61687a() { - float2 res = tint_radians((1.0f).xx); + float2 res = (0.017453292f).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.glsl index 0810866c4b..3ef50f35fa 100644 --- a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec2 tint_radians(vec2 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_61687a() { - vec2 res = tint_radians(vec2(1.0f)); + vec2 res = vec2(0.017453292f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec2 tint_radians(vec2 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_61687a() { - vec2 res = tint_radians(vec2(1.0f)); + vec2 res = vec2(0.017453292f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec2 tint_radians(vec2 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_61687a() { - vec2 res = tint_radians(vec2(1.0f)); + vec2 res = vec2(0.017453292f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.msl index 2ce18610d0..8d8cf5ca8d 100644 --- a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float2 tint_radians(float2 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_61687a() { - float2 res = tint_radians(float2(1.0f)); + float2 res = float2(0.017453292f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.spvasm index b9e7307a66..0dc12cf75e 100644 --- a/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/61687a.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v2float %float_1 %float_1 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v2float %float_0_0174532924 %float_0_0174532924 %_ptr_Function_v2float = OpTypePointer Function %v2float - %20 = OpConstantNull %v2float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %radians_61687a = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2float Function %20 - %13 = OpExtInst %v2float %15 Radians %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %radians_61687a +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_61687a OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %radians_61687a + %28 = OpLabel + %29 = OpFunctionCall %void %radians_61687a OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %radians_61687a + %31 = OpLabel + %32 = OpFunctionCall %void %radians_61687a OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.dxc.hlsl index 9d7e818182..5722b0ddd8 100644 --- a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.fxc.hlsl index 9d7e818182..5722b0ddd8 100644 --- a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.glsl index b279215589..ceb5f05cfc 100644 --- a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.msl index 074b46d1ae..486252d70d 100644 --- a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float tint_radians(float param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_6b0ff2() { - float res = tint_radians(1.0f); + float res = 0.017453292f; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.spvasm index 4f49a3f7e2..f105b00393 100644 --- a/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/6b0ff2.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 30 ; Schema: 0 OpCapability Shader - %14 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -31,35 +30,35 @@ %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %void = OpTypeVoid %9 = OpTypeFunction %void - %float_1 = OpConstant %float 1 +%float_0_0174532924 = OpConstant %float 0.0174532924 %_ptr_Function_float = OpTypePointer Function %float - %18 = OpTypeFunction %v4float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %radians_6b0ff2 = OpFunction %void None %9 %12 = OpLabel %res = OpVariable %_ptr_Function_float Function %8 - %13 = OpExtInst %float %14 Radians %float_1 - OpStore %res %13 + OpStore %res %float_0_0174532924 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %18 - %20 = OpLabel - %21 = OpFunctionCall %void %radians_6b0ff2 +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %radians_6b0ff2 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %23 = OpLabel - %24 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %24 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %void %radians_6b0ff2 + %25 = OpLabel + %26 = OpFunctionCall %void %radians_6b0ff2 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %radians_6b0ff2 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_6b0ff2 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.dxc.hlsl index 72427f3cde..680dffd2a1 100644 --- a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_radians(vector param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_7ea4c7() { - vector res = tint_radians((float16_t(1.0h)).xxx); + vector res = (float16_t(0.017440796h)).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.glsl index 75c124cbdd..44b377557e 100644 --- a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec3 tint_radians(f16vec3 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_7ea4c7() { - f16vec3 res = tint_radians(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.017440796hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec3 tint_radians(f16vec3 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_7ea4c7() { - f16vec3 res = tint_radians(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.017440796hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec3 tint_radians(f16vec3 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_7ea4c7() { - f16vec3 res = tint_radians(f16vec3(1.0hf)); + f16vec3 res = f16vec3(0.017440796hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.msl index a8f0e1f5de..59edb2a949 100644 --- a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half3 tint_radians(half3 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_7ea4c7() { - half3 res = tint_radians(half3(1.0h)); + half3 res = half3(0.017440796h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.spvasm index 3253f44e9e..0d5b8b8ee5 100644 --- a/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/7ea4c7.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v3half = OpTypeVector %half 3 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 +%half_0x1_1dcpn6 = OpConstant %half 0x1.1dcp-6 + %16 = OpConstantComposite %v3half %half_0x1_1dcpn6 %half_0x1_1dcpn6 %half_0x1_1dcpn6 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v3half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %radians_7ea4c7 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3half Function %21 - %13 = OpExtInst %v3half %16 Radians %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %radians_7ea4c7 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %radians_7ea4c7 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %radians_7ea4c7 + %29 = OpLabel + %30 = OpFunctionCall %void %radians_7ea4c7 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %radians_7ea4c7 + %32 = OpLabel + %33 = OpFunctionCall %void %radians_7ea4c7 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl b/test/tint/builtins/gen/literal/radians/bff231.wgsl new file mode 100644 index 0000000000..1b2cd48f90 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.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 radians(fa) -> fa +fn radians_bff231() { + var res = radians(1.); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_bff231(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_bff231(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_bff231(); +} diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cde7b14c63 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_bff231(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cde7b14c63 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_bff231(); + return; +} diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.glsl new file mode 100644 index 0000000000..a445da11e5 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_bff231() { + float res = 0.017453292f; +} + +vec4 vertex_main() { + radians_bff231(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_bff231() { + float res = 0.017453292f; +} + +void fragment_main() { + radians_bff231(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_bff231() { + float res = 0.017453292f; +} + +void compute_main() { + radians_bff231(); +} + +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/radians/bff231.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.msl new file mode 100644 index 0000000000..ddd3b6ee49 --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +kernel void compute_main() { + radians_bff231(); + return; +} + diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.spvasm new file mode 100644 index 0000000000..0a3316a88e --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_bff231 "radians_bff231" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_0174532924 = OpConstant %float 0.0174532924 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_bff231 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_0_0174532924 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %radians_bff231 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %radians_bff231 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_bff231 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.wgsl new file mode 100644 index 0000000000..c5e31e717c --- /dev/null +++ b/test/tint/builtins/gen/literal/radians/bff231.wgsl.expected.wgsl @@ -0,0 +1,19 @@ +fn radians_bff231() { + var res = radians(1.0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_bff231(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_bff231(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_bff231(); +} diff --git a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.dxc.hlsl index 3ca2a8046e..92aca968d5 100644 --- a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -float3 tint_radians(float3 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_f96258() { - float3 res = tint_radians((1.0f).xxx); + float3 res = (0.017453292f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.fxc.hlsl index 3ca2a8046e..92aca968d5 100644 --- a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.fxc.hlsl @@ -1,9 +1,5 @@ -float3 tint_radians(float3 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_f96258() { - float3 res = tint_radians((1.0f).xxx); + float3 res = (0.017453292f).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.glsl index aaab3fee08..7f15f684eb 100644 --- a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.glsl @@ -1,12 +1,7 @@ #version 310 es -vec3 tint_radians(vec3 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_f96258() { - vec3 res = tint_radians(vec3(1.0f)); + vec3 res = vec3(0.017453292f); } vec4 vertex_main() { @@ -25,13 +20,8 @@ void main() { #version 310 es precision mediump float; -vec3 tint_radians(vec3 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_f96258() { - vec3 res = tint_radians(vec3(1.0f)); + vec3 res = vec3(0.017453292f); } void fragment_main() { @@ -44,13 +34,8 @@ void main() { } #version 310 es -vec3 tint_radians(vec3 param_0) { - return param_0 * 0.017453292519943295474f; -} - - void radians_f96258() { - vec3 res = tint_radians(vec3(1.0f)); + vec3 res = vec3(0.017453292f); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.msl index cae23f490b..3ce84b49b8 100644 --- a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -float3 tint_radians(float3 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_f96258() { - float3 res = tint_radians(float3(1.0f)); + float3 res = float3(0.017453292f); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.spvasm index ef337f4f81..0178859e28 100644 --- a/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/f96258.wgsl.expected.spvasm @@ -1,10 +1,9 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 34 +; Bound: 33 ; Schema: 0 OpCapability Shader - %15 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -32,37 +31,37 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %v3float = OpTypeVector %float 3 - %float_1 = OpConstant %float 1 - %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v3float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 %_ptr_Function_v3float = OpTypePointer Function %v3float - %20 = OpConstantNull %v3float - %21 = OpTypeFunction %v4float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 %radians_f96258 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3float Function %20 - %13 = OpExtInst %v3float %15 Radians %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %radians_f96258 +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_f96258 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %29 = OpLabel - %30 = OpFunctionCall %void %radians_f96258 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_f96258 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %32 = OpLabel - %33 = OpFunctionCall %void %radians_f96258 + %31 = OpLabel + %32 = OpFunctionCall %void %radians_f96258 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.dxc.hlsl index 77ad4e46bd..4ed51a04d8 100644 --- a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.dxc.hlsl @@ -1,9 +1,5 @@ -vector tint_radians(vector param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_fbacf0() { - vector res = tint_radians((float16_t(1.0h)).xx); + vector res = (float16_t(0.017440796h)).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.glsl b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.glsl index 2d748f96fe..263666e590 100644 --- a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.glsl @@ -1,13 +1,8 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec2 tint_radians(f16vec2 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_fbacf0() { - f16vec2 res = tint_radians(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.017440796hf); } vec4 vertex_main() { @@ -27,13 +22,8 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; -f16vec2 tint_radians(f16vec2 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_fbacf0() { - f16vec2 res = tint_radians(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.017440796hf); } void fragment_main() { @@ -47,13 +37,8 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require -f16vec2 tint_radians(f16vec2 param_0) { - return param_0 * 0.017453292519943295474hf; -} - - void radians_fbacf0() { - f16vec2 res = tint_radians(f16vec2(1.0hf)); + f16vec2 res = f16vec2(0.017440796hf); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.msl b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.msl index ca066a6c70..d462d3210e 100644 --- a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.msl @@ -1,13 +1,8 @@ #include using namespace metal; - -half2 tint_radians(half2 param_0) { - return param_0 * 0.017453292519943295474; -} - void radians_fbacf0() { - half2 res = tint_radians(half2(1.0h)); + half2 res = half2(0.017440796h); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.spvasm index 3fe420d0f9..be6dede6f9 100644 --- a/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/radians/fbacf0.wgsl.expected.spvasm @@ -1,14 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 36 +; Bound: 34 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess OpCapability StorageInputOutput16 - %16 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size OpEntryPoint Fragment %fragment_main "fragment_main" @@ -37,38 +36,37 @@ %9 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 - %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0 +%half_0x1_1dcpn6 = OpConstant %half 0x1.1dcp-6 + %16 = OpConstantComposite %v2half %half_0x1_1dcpn6 %half_0x1_1dcpn6 %_ptr_Function_v2half = OpTypePointer Function %v2half - %21 = OpConstantNull %v2half - %22 = OpTypeFunction %v4float + %19 = OpConstantNull %v2half + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %radians_fbacf0 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2half Function %21 - %13 = OpExtInst %v2half %16 Radians %18 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2half Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %22 - %24 = OpLabel - %25 = OpFunctionCall %void %radians_fbacf0 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %radians_fbacf0 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %27 = OpLabel - %28 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %28 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %radians_fbacf0 + %29 = OpLabel + %30 = OpFunctionCall %void %radians_fbacf0 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %34 = OpLabel - %35 = OpFunctionCall %void %radians_fbacf0 + %32 = OpLabel + %33 = OpFunctionCall %void %radians_fbacf0 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl b/test/tint/builtins/gen/var/degrees/810467.wgsl new file mode 100644 index 0000000000..96858d01f2 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.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 degrees(vec<2, fa>) -> vec<2, fa> +fn degrees_810467() { + const arg_0 = vec2(1.); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_810467(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_810467(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_810467(); +} diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..eb0415dd4b --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_810467() { + float2 res = (57.295780182f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_810467(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..eb0415dd4b --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_810467() { + float2 res = (57.295780182f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_810467(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.glsl b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.glsl new file mode 100644 index 0000000000..cee6770316 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +vec4 vertex_main() { + degrees_810467(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +void fragment_main() { + degrees_810467(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_810467() { + vec2 res = vec2(57.295780182f); +} + +void compute_main() { + degrees_810467(); +} + +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/degrees/810467.wgsl.expected.msl b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.msl new file mode 100644 index 0000000000..26fdf6d5f2 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_810467() { + float2 res = float2(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_810467(); + 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() { + degrees_810467(); + return; +} + +kernel void compute_main() { + degrees_810467(); + return; +} + diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.spvasm b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.spvasm new file mode 100644 index 0000000000..2f16f05b7d --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_810467 "degrees_810467" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_57_2957802 = OpConstant %float 57.2957802 + %15 = OpConstantComposite %v2float %float_57_2957802 %float_57_2957802 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_810467 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_810467 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_810467 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_810467 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.wgsl b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.wgsl new file mode 100644 index 0000000000..a028b3d1c4 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/810467.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn degrees_810467() { + const arg_0 = vec2(1.0); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_810467(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_810467(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_810467(); +} diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl new file mode 100644 index 0000000000..708f7762f3 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.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 degrees(vec<3, fa>) -> vec<3, fa> +fn degrees_c0880c() { + const arg_0 = vec3(1.); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_c0880c(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_c0880c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_c0880c(); +} diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..78013a9c61 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_c0880c() { + float3 res = (57.295780182f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_c0880c(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..78013a9c61 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_c0880c() { + float3 res = (57.295780182f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_c0880c(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.glsl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.glsl new file mode 100644 index 0000000000..ad03188570 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +vec4 vertex_main() { + degrees_c0880c(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +void fragment_main() { + degrees_c0880c(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_c0880c() { + vec3 res = vec3(57.295780182f); +} + +void compute_main() { + degrees_c0880c(); +} + +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/degrees/c0880c.wgsl.expected.msl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.msl new file mode 100644 index 0000000000..4b019e90f2 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_c0880c() { + float3 res = float3(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_c0880c(); + 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() { + degrees_c0880c(); + return; +} + +kernel void compute_main() { + degrees_c0880c(); + return; +} + diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.spvasm b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.spvasm new file mode 100644 index 0000000000..7fe5c7398c --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_c0880c "degrees_c0880c" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_57_2957802 = OpConstant %float 57.2957802 + %15 = OpConstantComposite %v3float %float_57_2957802 %float_57_2957802 %float_57_2957802 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_c0880c = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %degrees_c0880c + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_c0880c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %degrees_c0880c + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.wgsl new file mode 100644 index 0000000000..0f6b91d7ac --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/c0880c.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn degrees_c0880c() { + const arg_0 = vec3(1.0); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_c0880c(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_c0880c(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_c0880c(); +} diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl new file mode 100644 index 0000000000..3184f245cb --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.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 degrees(vec<4, fa>) -> vec<4, fa> +fn degrees_d43a49() { + const arg_0 = vec4(1.); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_d43a49(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_d43a49(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_d43a49(); +} diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..0ea5685f9b --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_d43a49() { + float4 res = (57.295780182f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_d43a49(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..0ea5685f9b --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_d43a49() { + float4 res = (57.295780182f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_d43a49(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.glsl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.glsl new file mode 100644 index 0000000000..893f790649 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +vec4 vertex_main() { + degrees_d43a49(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +void fragment_main() { + degrees_d43a49(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_d43a49() { + vec4 res = vec4(57.295780182f); +} + +void compute_main() { + degrees_d43a49(); +} + +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/degrees/d43a49.wgsl.expected.msl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.msl new file mode 100644 index 0000000000..adddeb0d13 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_d43a49() { + float4 res = float4(57.295780182f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_d43a49(); + 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() { + degrees_d43a49(); + return; +} + +kernel void compute_main() { + degrees_d43a49(); + return; +} + diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.spvasm b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.spvasm new file mode 100644 index 0000000000..d0ca406e51 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_d43a49 "degrees_d43a49" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_57_2957802 = OpConstant %float 57.2957802 + %14 = OpConstantComposite %v4float %float_57_2957802 %float_57_2957802 %float_57_2957802 %float_57_2957802 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_d43a49 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %degrees_d43a49 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %degrees_d43a49 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %degrees_d43a49 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.wgsl b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.wgsl new file mode 100644 index 0000000000..0fdb2e945d --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/d43a49.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn degrees_d43a49() { + const arg_0 = vec4(1.0); + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_d43a49(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_d43a49(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_d43a49(); +} diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl new file mode 100644 index 0000000000..f1adddc3ed --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.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 degrees(fa) -> fa +fn degrees_fafa7e() { + const arg_0 = 1.; + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_fafa7e(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_fafa7e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_fafa7e(); +} diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..a11be104c4 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_fafa7e(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..a11be104c4 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + degrees_fafa7e(); + return; +} diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.glsl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.glsl new file mode 100644 index 0000000000..4572eb3b0b --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +vec4 vertex_main() { + degrees_fafa7e(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +void fragment_main() { + degrees_fafa7e(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void degrees_fafa7e() { + float res = 57.295780182f; +} + +void compute_main() { + degrees_fafa7e(); +} + +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/degrees/fafa7e.wgsl.expected.msl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.msl new file mode 100644 index 0000000000..770b0ab39d --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void degrees_fafa7e() { + float res = 57.295780182f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + degrees_fafa7e(); + 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() { + degrees_fafa7e(); + return; +} + +kernel void compute_main() { + degrees_fafa7e(); + return; +} + diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.spvasm b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.spvasm new file mode 100644 index 0000000000..e3e981003d --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %degrees_fafa7e "degrees_fafa7e" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_57_2957802 = OpConstant %float 57.2957802 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%degrees_fafa7e = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_57_2957802 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %degrees_fafa7e + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %degrees_fafa7e + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %degrees_fafa7e + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.wgsl b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.wgsl new file mode 100644 index 0000000000..1651ee1870 --- /dev/null +++ b/test/tint/builtins/gen/var/degrees/fafa7e.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn degrees_fafa7e() { + const arg_0 = 1.0; + var res = degrees(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + degrees_fafa7e(); + return vec4(); +} + +@fragment +fn fragment_main() { + degrees_fafa7e(); +} + +@compute @workgroup_size(1) +fn compute_main() { + degrees_fafa7e(); +} diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl b/test/tint/builtins/gen/var/radians/379214.wgsl new file mode 100644 index 0000000000..23569e7adf --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.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 radians(vec<3, fa>) -> vec<3, fa> +fn radians_379214() { + const arg_0 = vec3(1.); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_379214(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_379214(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_379214(); +} diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..247db1d62d --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_379214() { + float3 res = (0.017453292f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_379214(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..247db1d62d --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_379214() { + float3 res = (0.017453292f).xxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_379214(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl.expected.glsl b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.glsl new file mode 100644 index 0000000000..5593c1db04 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +vec4 vertex_main() { + radians_379214(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +void fragment_main() { + radians_379214(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_379214() { + vec3 res = vec3(0.017453292f); +} + +void compute_main() { + radians_379214(); +} + +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/radians/379214.wgsl.expected.msl b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.msl new file mode 100644 index 0000000000..638763a97d --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_379214() { + float3 res = float3(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_379214(); + 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() { + radians_379214(); + return; +} + +kernel void compute_main() { + radians_379214(); + return; +} + diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl.expected.spvasm b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.spvasm new file mode 100644 index 0000000000..ec9360a2a2 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_379214 "radians_379214" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v3float = OpTypeVector %float 3 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v3float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %18 = OpConstantNull %v3float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_379214 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_379214 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_379214 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %radians_379214 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/radians/379214.wgsl.expected.wgsl b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.wgsl new file mode 100644 index 0000000000..19821f08a0 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/379214.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn radians_379214() { + const arg_0 = vec3(1.0); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_379214(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_379214(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_379214(); +} diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl new file mode 100644 index 0000000000..4f644795ac --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.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 radians(vec<2, fa>) -> vec<2, fa> +fn radians_44a9f8() { + const arg_0 = vec2(1.); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_44a9f8(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_44a9f8(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_44a9f8(); +} diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cb67c5d960 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_44a9f8() { + float2 res = (0.017453292f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_44a9f8(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cb67c5d960 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_44a9f8() { + float2 res = (0.017453292f).xx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_44a9f8(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.glsl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.glsl new file mode 100644 index 0000000000..6caa601653 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +vec4 vertex_main() { + radians_44a9f8(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +void fragment_main() { + radians_44a9f8(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_44a9f8() { + vec2 res = vec2(0.017453292f); +} + +void compute_main() { + radians_44a9f8(); +} + +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/radians/44a9f8.wgsl.expected.msl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.msl new file mode 100644 index 0000000000..fea0149da1 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_44a9f8() { + float2 res = float2(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_44a9f8(); + 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() { + radians_44a9f8(); + return; +} + +kernel void compute_main() { + radians_44a9f8(); + return; +} + diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.spvasm b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.spvasm new file mode 100644 index 0000000000..4e135fcdba --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.spvasm @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 33 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_44a9f8 "radians_44a9f8" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void + %v2float = OpTypeVector %float 2 +%float_0_0174532924 = OpConstant %float 0.0174532924 + %15 = OpConstantComposite %v2float %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %18 = OpConstantNull %v2float + %19 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_44a9f8 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2float Function %18 + OpStore %res %15 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %19 + %21 = OpLabel + %22 = OpFunctionCall %void %radians_44a9f8 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %24 = OpLabel + %25 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %25 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_44a9f8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %31 = OpLabel + %32 = OpFunctionCall %void %radians_44a9f8 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.wgsl b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.wgsl new file mode 100644 index 0000000000..bd1268deb1 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/44a9f8.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn radians_44a9f8() { + const arg_0 = vec2(1.0); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_44a9f8(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_44a9f8(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_44a9f8(); +} diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl b/test/tint/builtins/gen/var/radians/524a91.wgsl new file mode 100644 index 0000000000..0b217c0bd7 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.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 radians(vec<4, fa>) -> vec<4, fa> +fn radians_524a91() { + const arg_0 = vec4(1.); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_524a91(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_524a91(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_524a91(); +} diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..b3e219299f --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_524a91() { + float4 res = (0.017453292f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_524a91(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..b3e219299f --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_524a91() { + float4 res = (0.017453292f).xxxx; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_524a91(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.glsl b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.glsl new file mode 100644 index 0000000000..fd1508ed2c --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +vec4 vertex_main() { + radians_524a91(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +void fragment_main() { + radians_524a91(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_524a91() { + vec4 res = vec4(0.017453292f); +} + +void compute_main() { + radians_524a91(); +} + +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/radians/524a91.wgsl.expected.msl b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.msl new file mode 100644 index 0000000000..fa539e01ef --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_524a91() { + float4 res = float4(0.017453292f); +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_524a91(); + 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() { + radians_524a91(); + return; +} + +kernel void compute_main() { + radians_524a91(); + return; +} + diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.spvasm b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.spvasm new file mode 100644 index 0000000000..a9c1edff04 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.spvasm @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_524a91 "radians_524a91" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_0174532924 = OpConstant %float 0.0174532924 + %14 = OpConstantComposite %v4float %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 %float_0_0174532924 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %17 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_524a91 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4float Function %5 + OpStore %res %14 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %17 + %19 = OpLabel + %20 = OpFunctionCall %void %radians_524a91 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %22 = OpLabel + %23 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %23 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %26 = OpLabel + %27 = OpFunctionCall %void %radians_524a91 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %radians_524a91 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.wgsl b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.wgsl new file mode 100644 index 0000000000..ac6ced279f --- /dev/null +++ b/test/tint/builtins/gen/var/radians/524a91.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn radians_524a91() { + const arg_0 = vec4(1.0); + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_524a91(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_524a91(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_524a91(); +} diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl b/test/tint/builtins/gen/var/radians/bff231.wgsl new file mode 100644 index 0000000000..a38f95f31c --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.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 radians(fa) -> fa +fn radians_bff231() { + const arg_0 = 1.; + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_bff231(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_bff231(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_bff231(); +} diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..cde7b14c63 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.dxc.hlsl @@ -0,0 +1,30 @@ +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_bff231(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..cde7b14c63 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.fxc.hlsl @@ -0,0 +1,30 @@ +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value : SV_Position; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +[numthreads(1, 1, 1)] +void compute_main() { + radians_bff231(); + return; +} diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.glsl b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.glsl new file mode 100644 index 0000000000..a445da11e5 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.glsl @@ -0,0 +1,49 @@ +#version 310 es + +void radians_bff231() { + float res = 0.017453292f; +} + +vec4 vertex_main() { + radians_bff231(); + return vec4(0.0f); +} + +void main() { + gl_PointSize = 1.0; + vec4 inner_result = vertex_main(); + gl_Position = inner_result; + gl_Position.y = -(gl_Position.y); + gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); + return; +} +#version 310 es +precision mediump float; + +void radians_bff231() { + float res = 0.017453292f; +} + +void fragment_main() { + radians_bff231(); +} + +void main() { + fragment_main(); + return; +} +#version 310 es + +void radians_bff231() { + float res = 0.017453292f; +} + +void compute_main() { + radians_bff231(); +} + +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/radians/bff231.wgsl.expected.msl b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.msl new file mode 100644 index 0000000000..ddd3b6ee49 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.msl @@ -0,0 +1,33 @@ +#include + +using namespace metal; +void radians_bff231() { + float res = 0.017453292f; +} + +struct tint_symbol { + float4 value [[position]]; +}; + +float4 vertex_main_inner() { + radians_bff231(); + 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() { + radians_bff231(); + return; +} + +kernel void compute_main() { + radians_bff231(); + return; +} + diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.spvasm b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.spvasm new file mode 100644 index 0000000000..0a3316a88e --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.spvasm @@ -0,0 +1,64 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %value "value" + OpName %vertex_point_size "vertex_point_size" + OpName %radians_bff231 "radians_bff231" + OpName %res "res" + OpName %vertex_main_inner "vertex_main_inner" + OpName %vertex_main "vertex_main" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %value BuiltIn Position + OpDecorate %vertex_point_size BuiltIn PointSize + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %value = OpVariable %_ptr_Output_v4float Output %5 +%_ptr_Output_float = OpTypePointer Output %float + %8 = OpConstantNull %float +%vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void +%float_0_0174532924 = OpConstant %float 0.0174532924 +%_ptr_Function_float = OpTypePointer Function %float + %16 = OpTypeFunction %v4float + %float_1 = OpConstant %float 1 +%radians_bff231 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_float Function %8 + OpStore %res %float_0_0174532924 + OpReturn + OpFunctionEnd +%vertex_main_inner = OpFunction %v4float None %16 + %18 = OpLabel + %19 = OpFunctionCall %void %radians_bff231 + OpReturnValue %5 + OpFunctionEnd +%vertex_main = OpFunction %void None %9 + %21 = OpLabel + %22 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %22 + OpStore %vertex_point_size %float_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %void %radians_bff231 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %9 + %28 = OpLabel + %29 = OpFunctionCall %void %radians_bff231 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.wgsl b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.wgsl new file mode 100644 index 0000000000..127e23dff2 --- /dev/null +++ b/test/tint/builtins/gen/var/radians/bff231.wgsl.expected.wgsl @@ -0,0 +1,20 @@ +fn radians_bff231() { + const arg_0 = 1.0; + var res = radians(arg_0); +} + +@vertex +fn vertex_main() -> @builtin(position) vec4 { + radians_bff231(); + return vec4(); +} + +@fragment +fn fragment_main() { + radians_bff231(); +} + +@compute @workgroup_size(1) +fn compute_main() { + radians_bff231(); +} diff --git a/test/tint/builtins/repeated_use.wgsl b/test/tint/builtins/repeated_use.wgsl index f1f1f0f5c4..f6391a3d4e 100644 --- a/test/tint/builtins/repeated_use.wgsl +++ b/test/tint/builtins/repeated_use.wgsl @@ -2,19 +2,31 @@ // same builtin overload results in single helper being generated. @compute @workgroup_size(1) fn main() { - let a = degrees(vec4()); - let b = degrees(vec4(1.)); - let c = degrees(vec4(1., 2., 3., 4.)); + let va = vec4(); + let a = degrees(va); + let vb = vec4(1.); + let b = degrees(vb); + let vc = vec4(1., 2., 3., 4.); + let c = degrees(vc); - let d = degrees(vec3()); - let e = degrees(vec3(1.)); - let f = degrees(vec3(1., 2., 3.)); + let vd = vec3(); + let d = degrees(vd); + let ve = vec3(1.); + let e = degrees(ve); + let vf = vec3(1., 2., 3.); + let f = degrees(vf); - let g = degrees(vec2()); - let h = degrees(vec2(1.)); - let i = degrees(vec2(1., 2.)); + let vg = vec2(); + let g = degrees(vg); + let vh = vec2(1.); + let h = degrees(vh); + let vi = vec2(1., 2.); + let i = degrees(vi); - let j = degrees(1.); - let k = degrees(2.); - let l = degrees(3.); + let vj = 1.; + let j = degrees(vj); + let vk = 2.; + let k = degrees(vk); + let vl = 3.; + let l = degrees(vl); } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl b/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl index bbf29d1edc..5d5323124b 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.dxc.hlsl @@ -16,17 +16,29 @@ float tint_degrees_3(float param_0) { [numthreads(1, 1, 1)] void main() { - const float4 a = tint_degrees((0.0f).xxxx); - const float4 b = tint_degrees((1.0f).xxxx); - const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - const float3 d = tint_degrees_1((0.0f).xxx); - const float3 e = tint_degrees_1((1.0f).xxx); - const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - const float2 g = tint_degrees_2((0.0f).xx); - const float2 h = tint_degrees_2((1.0f).xx); - const float2 i = tint_degrees_2(float2(1.0f, 2.0f)); - const float j = tint_degrees_3(1.0f); - const float k = tint_degrees_3(2.0f); - const float l = tint_degrees_3(3.0f); + const float4 va = (0.0f).xxxx; + const float4 a = tint_degrees(va); + const float4 vb = (1.0f).xxxx; + const float4 b = tint_degrees(vb); + const float4 vc = float4(1.0f, 2.0f, 3.0f, 4.0f); + const float4 c = tint_degrees(vc); + const float3 vd = (0.0f).xxx; + const float3 d = tint_degrees_1(vd); + const float3 ve = (1.0f).xxx; + const float3 e = tint_degrees_1(ve); + const float3 vf = float3(1.0f, 2.0f, 3.0f); + const float3 f = tint_degrees_1(vf); + const float2 vg = (0.0f).xx; + const float2 g = tint_degrees_2(vg); + const float2 vh = (1.0f).xx; + const float2 h = tint_degrees_2(vh); + const float2 vi = float2(1.0f, 2.0f); + const float2 i = tint_degrees_2(vi); + const float vj = 1.0f; + const float j = tint_degrees_3(vj); + const float vk = 2.0f; + const float k = tint_degrees_3(vk); + const float vl = 3.0f; + const float l = tint_degrees_3(vl); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl b/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl index bbf29d1edc..5d5323124b 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.fxc.hlsl @@ -16,17 +16,29 @@ float tint_degrees_3(float param_0) { [numthreads(1, 1, 1)] void main() { - const float4 a = tint_degrees((0.0f).xxxx); - const float4 b = tint_degrees((1.0f).xxxx); - const float4 c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - const float3 d = tint_degrees_1((0.0f).xxx); - const float3 e = tint_degrees_1((1.0f).xxx); - const float3 f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - const float2 g = tint_degrees_2((0.0f).xx); - const float2 h = tint_degrees_2((1.0f).xx); - const float2 i = tint_degrees_2(float2(1.0f, 2.0f)); - const float j = tint_degrees_3(1.0f); - const float k = tint_degrees_3(2.0f); - const float l = tint_degrees_3(3.0f); + const float4 va = (0.0f).xxxx; + const float4 a = tint_degrees(va); + const float4 vb = (1.0f).xxxx; + const float4 b = tint_degrees(vb); + const float4 vc = float4(1.0f, 2.0f, 3.0f, 4.0f); + const float4 c = tint_degrees(vc); + const float3 vd = (0.0f).xxx; + const float3 d = tint_degrees_1(vd); + const float3 ve = (1.0f).xxx; + const float3 e = tint_degrees_1(ve); + const float3 vf = float3(1.0f, 2.0f, 3.0f); + const float3 f = tint_degrees_1(vf); + const float2 vg = (0.0f).xx; + const float2 g = tint_degrees_2(vg); + const float2 vh = (1.0f).xx; + const float2 h = tint_degrees_2(vh); + const float2 vi = float2(1.0f, 2.0f); + const float2 i = tint_degrees_2(vi); + const float vj = 1.0f; + const float j = tint_degrees_3(vj); + const float vk = 2.0f; + const float k = tint_degrees_3(vk); + const float vl = 3.0f; + const float l = tint_degrees_3(vl); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.glsl b/test/tint/builtins/repeated_use.wgsl.expected.glsl index fdd29e0245..c40ba0461a 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.glsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.glsl @@ -18,18 +18,30 @@ float tint_degrees_3(float param_0) { void tint_symbol() { - vec4 a = tint_degrees(vec4(0.0f)); - vec4 b = tint_degrees(vec4(1.0f)); - vec4 c = tint_degrees(vec4(1.0f, 2.0f, 3.0f, 4.0f)); - vec3 d = tint_degrees_1(vec3(0.0f)); - vec3 e = tint_degrees_1(vec3(1.0f)); - vec3 f = tint_degrees_1(vec3(1.0f, 2.0f, 3.0f)); - vec2 g = tint_degrees_2(vec2(0.0f)); - vec2 h = tint_degrees_2(vec2(1.0f)); - vec2 i = tint_degrees_2(vec2(1.0f, 2.0f)); - float j = tint_degrees_3(1.0f); - float k = tint_degrees_3(2.0f); - float l = tint_degrees_3(3.0f); + vec4 va = vec4(0.0f); + vec4 a = tint_degrees(va); + vec4 vb = vec4(1.0f); + vec4 b = tint_degrees(vb); + vec4 vc = vec4(1.0f, 2.0f, 3.0f, 4.0f); + vec4 c = tint_degrees(vc); + vec3 vd = vec3(0.0f); + vec3 d = tint_degrees_1(vd); + vec3 ve = vec3(1.0f); + vec3 e = tint_degrees_1(ve); + vec3 vf = vec3(1.0f, 2.0f, 3.0f); + vec3 f = tint_degrees_1(vf); + vec2 vg = vec2(0.0f); + vec2 g = tint_degrees_2(vg); + vec2 vh = vec2(1.0f); + vec2 h = tint_degrees_2(vh); + vec2 vi = vec2(1.0f, 2.0f); + vec2 i = tint_degrees_2(vi); + float vj = 1.0f; + float j = tint_degrees_3(vj); + float vk = 2.0f; + float k = tint_degrees_3(vk); + float vl = 3.0f; + float l = tint_degrees_3(vl); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/repeated_use.wgsl.expected.msl b/test/tint/builtins/repeated_use.wgsl.expected.msl index c0ea4a3d75..03ffb6ac30 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.msl +++ b/test/tint/builtins/repeated_use.wgsl.expected.msl @@ -19,18 +19,30 @@ float tint_degrees_3(float param_0) { } kernel void tint_symbol() { - float4 const a = tint_degrees(float4(0.0f)); - float4 const b = tint_degrees(float4(1.0f)); - float4 const c = tint_degrees(float4(1.0f, 2.0f, 3.0f, 4.0f)); - float3 const d = tint_degrees_1(float3(0.0f)); - float3 const e = tint_degrees_1(float3(1.0f)); - float3 const f = tint_degrees_1(float3(1.0f, 2.0f, 3.0f)); - float2 const g = tint_degrees_2(float2(0.0f)); - float2 const h = tint_degrees_2(float2(1.0f)); - float2 const i = tint_degrees_2(float2(1.0f, 2.0f)); - float const j = tint_degrees_3(1.0f); - float const k = tint_degrees_3(2.0f); - float const l = tint_degrees_3(3.0f); + float4 const va = float4(0.0f); + float4 const a = tint_degrees(va); + float4 const vb = float4(1.0f); + float4 const b = tint_degrees(vb); + float4 const vc = float4(1.0f, 2.0f, 3.0f, 4.0f); + float4 const c = tint_degrees(vc); + float3 const vd = float3(0.0f); + float3 const d = tint_degrees_1(vd); + float3 const ve = float3(1.0f); + float3 const e = tint_degrees_1(ve); + float3 const vf = float3(1.0f, 2.0f, 3.0f); + float3 const f = tint_degrees_1(vf); + float2 const vg = float2(0.0f); + float2 const g = tint_degrees_2(vg); + float2 const vh = float2(1.0f); + float2 const h = tint_degrees_2(vh); + float2 const vi = float2(1.0f, 2.0f); + float2 const i = tint_degrees_2(vi); + float const vj = 1.0f; + float const j = tint_degrees_3(vj); + float const vk = 2.0f; + float const k = tint_degrees_3(vk); + float const vl = 3.0f; + float const l = tint_degrees_3(vl); return; } diff --git a/test/tint/builtins/repeated_use.wgsl.expected.spvasm b/test/tint/builtins/repeated_use.wgsl.expected.spvasm index 085ef9dc45..3ef304714b 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.spvasm +++ b/test/tint/builtins/repeated_use.wgsl.expected.spvasm @@ -4,7 +4,7 @@ ; Bound: 35 ; Schema: 0 OpCapability Shader - %8 = OpExtInstImport "GLSL.std.450" + %9 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -13,34 +13,34 @@ %1 = OpTypeFunction %void %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 - %9 = OpConstantNull %v4float + %7 = OpConstantNull %v4float %float_1 = OpConstant %float 1 - %12 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %11 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 %float_2 = OpConstant %float 2 %float_3 = OpConstant %float 3 %float_4 = OpConstant %float 4 - %17 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4 + %16 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4 %v3float = OpTypeVector %float 3 - %20 = OpConstantNull %v3float - %22 = OpConstantComposite %v3float %float_1 %float_1 %float_1 - %24 = OpConstantComposite %v3float %float_1 %float_2 %float_3 + %19 = OpConstantNull %v3float + %21 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %23 = OpConstantComposite %v3float %float_1 %float_2 %float_3 %v2float = OpTypeVector %float 2 - %27 = OpConstantNull %v2float - %29 = OpConstantComposite %v2float %float_1 %float_1 - %31 = OpConstantComposite %v2float %float_1 %float_2 + %26 = OpConstantNull %v2float + %28 = OpConstantComposite %v2float %float_1 %float_1 + %30 = OpConstantComposite %v2float %float_1 %float_2 %main = OpFunction %void None %1 %4 = OpLabel - %5 = OpExtInst %v4float %8 Degrees %9 - %10 = OpExtInst %v4float %8 Degrees %12 - %13 = OpExtInst %v4float %8 Degrees %17 - %18 = OpExtInst %v3float %8 Degrees %20 - %21 = OpExtInst %v3float %8 Degrees %22 - %23 = OpExtInst %v3float %8 Degrees %24 - %25 = OpExtInst %v2float %8 Degrees %27 - %28 = OpExtInst %v2float %8 Degrees %29 - %30 = OpExtInst %v2float %8 Degrees %31 - %32 = OpExtInst %float %8 Degrees %float_1 - %33 = OpExtInst %float %8 Degrees %float_2 - %34 = OpExtInst %float %8 Degrees %float_3 + %8 = OpExtInst %v4float %9 Degrees %7 + %12 = OpExtInst %v4float %9 Degrees %11 + %17 = OpExtInst %v4float %9 Degrees %16 + %20 = OpExtInst %v3float %9 Degrees %19 + %22 = OpExtInst %v3float %9 Degrees %21 + %24 = OpExtInst %v3float %9 Degrees %23 + %27 = OpExtInst %v2float %9 Degrees %26 + %29 = OpExtInst %v2float %9 Degrees %28 + %31 = OpExtInst %v2float %9 Degrees %30 + %32 = OpExtInst %float %9 Degrees %float_1 + %33 = OpExtInst %float %9 Degrees %float_2 + %34 = OpExtInst %float %9 Degrees %float_3 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/repeated_use.wgsl.expected.wgsl b/test/tint/builtins/repeated_use.wgsl.expected.wgsl index 0af3aa2bf2..d857c102d2 100644 --- a/test/tint/builtins/repeated_use.wgsl.expected.wgsl +++ b/test/tint/builtins/repeated_use.wgsl.expected.wgsl @@ -1,15 +1,27 @@ @compute @workgroup_size(1) fn main() { - let a = degrees(vec4()); - let b = degrees(vec4(1.0)); - let c = degrees(vec4(1.0, 2.0, 3.0, 4.0)); - let d = degrees(vec3()); - let e = degrees(vec3(1.0)); - let f = degrees(vec3(1.0, 2.0, 3.0)); - let g = degrees(vec2()); - let h = degrees(vec2(1.0)); - let i = degrees(vec2(1.0, 2.0)); - let j = degrees(1.0); - let k = degrees(2.0); - let l = degrees(3.0); + let va = vec4(); + let a = degrees(va); + let vb = vec4(1.0); + let b = degrees(vb); + let vc = vec4(1.0, 2.0, 3.0, 4.0); + let c = degrees(vc); + let vd = vec3(); + let d = degrees(vd); + let ve = vec3(1.0); + let e = degrees(ve); + let vf = vec3(1.0, 2.0, 3.0); + let f = degrees(vf); + let vg = vec2(); + let g = degrees(vg); + let vh = vec2(1.0); + let h = degrees(vh); + let vi = vec2(1.0, 2.0); + let i = degrees(vi); + let vj = 1.0; + let j = degrees(vj); + let vk = 2.0; + let k = degrees(vk); + let vl = 3.0; + let l = degrees(vl); }